Skip to content
Snippets Groups Projects
Commit 1a4465f4 authored by Christopher Schäpers's avatar Christopher Schäpers
Browse files

Improve app-management

- Better error messages

- Translate untranslated strings

Basically picks non-app-dependency related stuff from #4017
parent 057d7aa1
Branches
No related tags found
No related merge requests found
......@@ -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"));
}
}
......
......@@ -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()) ));
}
......@@ -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'));
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'));
}
else {
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'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment