summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-06-04 15:01:36 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-06-04 15:01:36 +0200
commitfc1d6f4c3cd2882c22d71c060c8ffef8c4a44b7e (patch)
tree925ca5dd9262e58d4e106a0c40d2d3da868ea730 /apps/files_sharing
parentb5a145b297ee933dc4c9d7e016a57feba91bf8ac (diff)
downloadnextcloud-server-fc1d6f4c3cd2882c22d71c060c8ffef8c4a44b7e.tar.gz
nextcloud-server-fc1d6f4c3cd2882c22d71c060c8ffef8c4a44b7e.zip
fixes during test
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/controller/adminsettingscontroller.php33
-rw-r--r--apps/files_sharing/js/settings-admin.js17
-rw-r--r--apps/files_sharing/lib/mailtemplate.php3
3 files changed, 32 insertions, 21 deletions
diff --git a/apps/files_sharing/controller/adminsettingscontroller.php b/apps/files_sharing/controller/adminsettingscontroller.php
index 7125641617d..fed3147a99c 100644
--- a/apps/files_sharing/controller/adminsettingscontroller.php
+++ b/apps/files_sharing/controller/adminsettingscontroller.php
@@ -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());
+ }
}
}
diff --git a/apps/files_sharing/js/settings-admin.js b/apps/files_sharing/js/settings-admin.js
index 0362af0232b..fa9b236ea98 100644
--- a/apps/files_sharing/js/settings-admin.js
+++ b/apps/files_sharing/js/settings-admin.js
@@ -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);
});
}
diff --git a/apps/files_sharing/lib/mailtemplate.php b/apps/files_sharing/lib/mailtemplate.php
index cb08b534d6f..ca1b0234ccf 100644
--- a/apps/files_sharing/lib/mailtemplate.php
+++ b/apps/files_sharing/lib/mailtemplate.php
@@ -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() {