summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkondou <kondou@ts.unde.re>2013-08-06 17:19:18 +0200
committerkondou <kondou@ts.unde.re>2013-08-06 17:19:18 +0200
commit1a4465f41d3fe334f42782545e3130a19796e590 (patch)
treeb3e5fbd743dd22ea3255e96593735791a59b11a1
parent057d7aa108f9b24c12b97f5f78008eb17a6d3bee (diff)
downloadnextcloud-server-1a4465f41d3fe334f42782545e3130a19796e590.tar.gz
nextcloud-server-1a4465f41d3fe334f42782545e3130a19796e590.zip
Improve app-management
- Better error messages - Translate untranslated strings Basically picks non-app-dependency related stuff from #4017
-rw-r--r--lib/app.php9
-rw-r--r--settings/ajax/enableapp.php11
-rw-r--r--settings/js/apps.js18
3 files changed, 23 insertions, 15 deletions
diff --git a/lib/app.php b/lib/app.php
index 2437896157a..1ff18c799cb 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -210,7 +210,8 @@ class OC_App{
/**
* @brief enables an app
* @param mixed $app app
- * @return bool
+ * @throws \Exception
+ * @return void
*
* This function set an app as enabled in appconfig.
*/
@@ -228,6 +229,7 @@ class OC_App{
}
}
}
+ $l = OC_L10N::get('core');
if($app!==false) {
// check if the app is compatible with this version of ownCloud
$info=OC_App::getAppInfo($app);
@@ -237,16 +239,15 @@ class OC_App{
'App "'.$info['name'].'" can\'t be installed because it is'
.' not compatible with this version of ownCloud',
OC_Log::ERROR);
- return false;
+ throw new \Exception($l->t("App can't be installed because it is not compatible with this version of ownCloud."));
}else{
OC_Appconfig::setValue( $app, 'enabled', 'yes' );
if(isset($appdata['id'])) {
OC_Appconfig::setValue( $app, 'ocsid', $appdata['id'] );
}
- return true;
}
}else{
- return false;
+ throw new \Exception($l->t("No app name specified"));
}
}
diff --git a/settings/ajax/enableapp.php b/settings/ajax/enableapp.php
index ab84aee5166..0784736a655 100644
--- a/settings/ajax/enableapp.php
+++ b/settings/ajax/enableapp.php
@@ -3,10 +3,9 @@
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_JSON::error(array("data" => array("message" => $e->getMessage()) ));
}
diff --git a/settings/js/apps.js b/settings/js/apps.js
index 0540d9b1c58..6b32686a693 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'));