diff options
Diffstat (limited to 'settings')
-rw-r--r-- | settings/ajax/enableapp.php | 12 | ||||
-rw-r--r-- | settings/js/apps.js | 18 |
2 files changed, 19 insertions, 11 deletions
diff --git a/settings/ajax/enableapp.php b/settings/ajax/enableapp.php index ab84aee5166..735794360b3 100644 --- a/settings/ajax/enableapp.php +++ b/settings/ajax/enableapp.php @@ -3,10 +3,10 @@ OC_JSON::checkAdminUser(); OCP\JSON::callCheck(); -$appid = OC_App::enable(OC_App::cleanAppId($_POST['appid'])); -if($appid !== false) { - OC_JSON::success(array('data' => array('appid' => $appid))); -} else { - $l = OC_L10N::get('settings'); - OC_JSON::error(array("data" => array( "message" => $l->t("Could not enable app. ") ))); +try { + OC_App::enable(OC_App::cleanAppId($_POST['appid'])); + OC_JSON::success(); +} catch (Exception $e) { + OC_Log::write('core', $e->getMessage(), OC_Log::ERROR); + OC_JSON::error(array("data" => array("message" => $e->getMessage()) )); } diff --git a/settings/js/apps.js b/settings/js/apps.js index 2ff3f0536d4..6c835a59997 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -61,7 +61,11 @@ OC.Settings.Apps = OC.Settings.Apps || { if(active) { $.post(OC.filePath('settings','ajax','disableapp.php'),{appid:appid},function(result) { if(!result || result.status !== 'success') { - OC.dialogs.alert('Error while disabling app', t('core', 'Error')); + if (result.data && result.data.message) { + OC.dialogs.alert(result.data.message, t('core', 'Error')); + } else { + OC.dialogs.alert(t('settings', 'Error while disabling app'), t('core', 'Error')); + } } else { element.data('active',false); @@ -73,16 +77,20 @@ OC.Settings.Apps = OC.Settings.Apps || { } else { $.post(OC.filePath('settings','ajax','enableapp.php'),{appid:appid},function(result) { if(!result || result.status !== 'success') { - OC.dialogs.alert('Error while enabling app', t('core', 'Error')); - } - else { + if (result.data && result.data.message) { + OC.dialogs.alert(result.data.message, t('core', 'Error')); + } else { + OC.dialogs.alert(t('settings', 'Error while enabling app'), t('core', 'Error')); + } + element.val(t('settings','Enable')); + } else { OC.Settings.Apps.addNavigation(appid); element.data('active',true); element.val(t('settings','Disable')); } },'json') .fail(function() { - OC.dialogs.alert('Error while enabling app', t('core', 'Error')); + OC.dialogs.alert(t('settings', 'Error while enabling app'), t('core', 'Error')); element.data('active',false); OC.Settings.Apps.removeNavigation(appid); element.val(t('settings','Enable')); |