fixes during test

This commit is contained in:
Thomas Müller 2014-06-04 15:01:36 +02:00
parent b5a145b297
commit fc1d6f4c3c
4 changed files with 32 additions and 59 deletions

View File

@ -15,35 +15,46 @@ class AdminSettingsController extends ApiController {
/**
* @param string $theme
* @param string $template
* @return type Description
* @return \OCA\Files_Sharing\Http\MailTemplateResponse
*/
public function render( $theme, $template ) {
$template = new \OCA\Files_Sharing\MailTemplate( $theme, $template );
return $template->getResponse();
try {
$template = new \OCA\Files_Sharing\MailTemplate( $theme, $template );
return $template->getResponse();
} catch (\Exception $ex) {
return new JSONResponse(array('message' => $ex->getMessage()), $ex->getCode());
}
}
/**
* @param string $theme
* @param string $template
* @param string $content
* @return array
* @return JSONResponse
*/
public function update( $theme, $template, $content ) {
$template = new \OCA\Files_Sharing\MailTemplate( $theme, $template );
$template->setContent( $content );
return new JSONResponse();
try {
$template = new \OCA\Files_Sharing\MailTemplate( $theme, $template );
$template->setContent( $content );
return new JSONResponse();
} catch (\Exception $ex) {
return new JSONResponse(array('message' => $ex->getMessage()), $ex->getCode());
}
}
/**
* @param string $theme
* @param string $template
* @return array
* @return JSONResponse
*/
public function reset( $theme, $template ) {
$template = new \OCA\Files_Sharing\MailTemplate( $theme, $template );
$template->reset();
return new JSONResponse();
try {
$template = new \OCA\Files_Sharing\MailTemplate( $theme, $template );
$template->reset();
return new JSONResponse();
} catch (\Exception $ex) {
return new JSONResponse(array('message' => $ex->getMessage()), $ex->getCode());
}
}
}

View File

@ -7,9 +7,9 @@ $(document).ready(function() {
).done(function( result ) {
$( '#mailTemplateSettings textarea' ).val(result);
}).fail(function( result ) {
alert(result);
OC.dialogs.alert(result.message, t('files_sharing', 'Could not load template'));
});
}
};
// load default template
var theme = $( '#mts-theme' ).val();
@ -41,11 +41,11 @@ $(document).ready(function() {
$.post(
OC.generateUrl('apps/files_sharing/settings/mailtemplate'),
{ theme: theme, template: template, content: content }
).done(function( result ) {
).done(function() {
var data = { status:'success', data:{message:t('files_sharing', 'Saved')} };
OC.msg.finishedSaving('#mts-msg', data);
}).fail(function( result ) {
var data = { status:'error', data:{message:t('files_sharing', 'Error')} };
}).fail(function(result) {
var data = { status: 'error', data:{message:result.responseJSON.message} };
OC.msg.finishedSaving('#mts-msg', data);
});
}
@ -55,13 +55,12 @@ $(document).ready(function() {
function() {
var theme = $( '#mts-theme' ).val();
var template = $( '#mts-template' ).val();
var content = $( '#mailTemplateSettings textarea' ).val();
OC.msg.startSaving('#mts-msg');
$.ajax({
type: "DELETE",
url: OC.generateUrl('apps/files_sharing/settings/mailtemplate'),
data: { theme: theme, template: template }
}).done(function( result ) {
}).done(function() {
var data = { status:'success', data:{message:t('files_sharing', 'Reset')} };
OC.msg.finishedSaving('#mts-msg', data);
@ -69,8 +68,8 @@ $(document).ready(function() {
var theme = $( '#mts-theme' ).val();
var template = $( '#mts-template' ).val();
loadTemplate(theme, template);
}).fail(function( result ) {
var data = { status:'error', data:{message:t('files_sharing', 'Error')} };
}).fail(function(result) {
var data = { status: 'error', data:{message:result.responseJSON.message} };
OC.msg.finishedSaving('#mts-msg', data);
});
}

View File

@ -19,7 +19,7 @@ class MailTemplate extends \OC_Template {
//determine valid theme names
$this->editableThemes = self::getEditableThemes();
//for now hardcode the valid mail template paths
//for now hard code the valid mail template paths
$this->editableTemplates = self::getEditableTemplates();
}
@ -34,6 +34,7 @@ class MailTemplate extends \OC_Template {
list($path, $template) = $this->findTemplate($this->theme, $app, $name, '');
return new MailTemplateResponse($template);
}
throw new SecurityException('Template not editable.', 403);
}
public function renderContent() {

View File

@ -1,38 +0,0 @@
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr><td>
<table cellspacing="0" cellpadding="0" border="0" width="600px">
<tr>
<td bgcolor="#1d2d44" width="20px">&nbsp;</td>
<td bgcolor="#1d2d44">
<img src="<?php print_unescaped(OC_Helper::makeURLAbsolute(image_path('', 'logo-mail.gif'))); ?>" alt="{{theme.name}}"/>
</td>
</tr>
<tr><td bgcolor="#f8f8f8" colspan="2">&nbsp;</td></tr>
<tr>
<td bgcolor="#f8f8f8" width="20px">&nbsp;</td>
<td bgcolor="#f8f8f8" style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
<?php
print_unescaped($l->t('Hey there,<br><br>just letting you know that %s shared <strong>%s</strong> with you.<br><a href="%s">View it!</a><br><br>', array($_['user_displayname'], $_['filename'], $_['link'])));
if ( isset($_['expiration']) ) {
p($l->t("The share will expire on %s.", array($_['expiration'])));
print_unescaped('<br><br>');
}
p($l->t('Cheers!'));
?>
</td>
</tr>
<tr><td bgcolor="#f8f8f8" colspan="2">&nbsp;</td></tr>
<tr>
<td bgcolor="#f8f8f8" width="20px">&nbsp;</td>
<td bgcolor="#f8f8f8" style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">--<br>
{{theme.name}} -
{{theme.slogan}}
<br><a href="{{theme.baseurl}}">{{theme.baseurl}}</a>
</td>
</tr>
<tr>
<td bgcolor="#f8f8f8" colspan="2">&nbsp;</td>
</tr>
</table>
</td></tr>
</table>