Make disableapp.php accept arrays
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
parent
da67264a23
commit
732c92e93a
|
@ -370,9 +370,9 @@ class AppSettingsController extends Controller {
|
||||||
if($app['id'] === $identifier) {
|
if($app['id'] === $identifier) {
|
||||||
if($newCategory) {
|
if($newCategory) {
|
||||||
$app['newCategory'] = true;
|
$app['newCategory'] = true;
|
||||||
$app['bundleId'] = $bundle->getIdentifier();
|
|
||||||
$app['categoryName'] = $bundle->getName();
|
$app['categoryName'] = $bundle->getName();
|
||||||
}
|
}
|
||||||
|
$app['bundleId'] = $bundle->getIdentifier();
|
||||||
$newCategory = false;
|
$newCategory = false;
|
||||||
$apps[] = $app;
|
$apps[] = $app;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -36,8 +36,9 @@ if (!array_key_exists('appid', $_POST)) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$appId = (string)$_POST['appid'];
|
$appIds = (array)$_POST['appid'];
|
||||||
|
foreach($appIds as $appId) {
|
||||||
$appId = OC_App::cleanAppId($appId);
|
$appId = OC_App::cleanAppId($appId);
|
||||||
|
|
||||||
OC_App::disable($appId);
|
OC_App::disable($appId);
|
||||||
|
}
|
||||||
OC_JSON::success();
|
OC_JSON::success();
|
||||||
|
|
|
@ -313,53 +313,94 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bundles = OC.Settings.Apps.State.currentCategoryElements;
|
var apps = OC.Settings.Apps.State.currentCategoryElements;
|
||||||
bundles.forEach(function(bundle) {
|
var appsToEnable = [];
|
||||||
if(bundle['id'] === bundleId) {
|
apps.forEach(function(app) {
|
||||||
OC.Settings.Apps.enableApp(bundle['apps'], active, element, groups);
|
if(app['bundleId'] === bundleId) {
|
||||||
|
if(app['active'] === false) {
|
||||||
|
appsToEnable.push(app['id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
OC.Settings.Apps.enableApp(appsToEnable, false, groups);
|
||||||
},
|
},
|
||||||
|
|
||||||
enableApp:function(appId, active, element, groups) {
|
/**
|
||||||
|
* @param {string[]} appId
|
||||||
|
* @param {boolean} active
|
||||||
|
* @param {array} groups
|
||||||
|
*/
|
||||||
|
enableApp:function(appId, active, groups) {
|
||||||
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
||||||
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.enableApp, this, appId, active, element, groups));
|
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.enableApp, this, appId, active, groups));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var elements = [];
|
||||||
|
appId.forEach(function(appId) {
|
||||||
|
elements.push($('#app-'+appId+' .enable'));
|
||||||
|
});
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
appId.forEach(function(appId) {
|
||||||
OC.Settings.Apps.hideErrorMessage(appId);
|
OC.Settings.Apps.hideErrorMessage(appId);
|
||||||
|
});
|
||||||
groups = groups || [];
|
groups = groups || [];
|
||||||
var appItem = $('div#app-'+appId+'');
|
var appItems = [];
|
||||||
|
appId.forEach(function(appId) {
|
||||||
|
appItems.push($('div#app-'+appId+''));
|
||||||
|
});
|
||||||
|
|
||||||
if(active && !groups.length) {
|
if(active && !groups.length) {
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.val(t('settings','Disabling app …'));
|
element.val(t('settings','Disabling app …'));
|
||||||
|
});
|
||||||
$.post(OC.filePath('settings','ajax','disableapp.php'),{appid:appId},function(result) {
|
$.post(OC.filePath('settings','ajax','disableapp.php'),{appid:appId},function(result) {
|
||||||
if(!result || result.status !== 'success') {
|
if(!result || result.status !== 'success') {
|
||||||
if (result.data && result.data.message) {
|
if (result.data && result.data.message) {
|
||||||
OC.Settings.Apps.showErrorMessage(appId, result.data.message);
|
OC.Settings.Apps.showErrorMessage(appId, result.data.message);
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.data('errormsg', result.data.message);
|
appItem.data('errormsg', result.data.message);
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while disabling app'));
|
OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while disabling app'));
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.data('errormsg', t('settings', 'Error while disabling app'));
|
appItem.data('errormsg', t('settings', 'Error while disabling app'));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.val(t('settings','Disable'));
|
element.val(t('settings','Disable'));
|
||||||
|
});
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.addClass('appwarning');
|
appItem.addClass('appwarning');
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
OC.Settings.Apps.rebuildNavigation();
|
OC.Settings.Apps.rebuildNavigation();
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.data('active', false);
|
appItem.data('active', false);
|
||||||
appItem.data('groups', '');
|
appItem.data('groups', '');
|
||||||
|
});
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.data('active', false);
|
element.data('active', false);
|
||||||
|
});
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.removeClass('active');
|
appItem.removeClass('active');
|
||||||
|
});
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.val(t('settings', 'Enable'));
|
element.val(t('settings', 'Enable'));
|
||||||
element.parent().find(".groups-enable").hide();
|
element.parent().find(".groups-enable").hide();
|
||||||
element.parent().find('#group_select').hide().val(null);
|
element.parent().find('#group_select').hide().val(null);
|
||||||
|
});
|
||||||
OC.Settings.Apps.State.apps[appId].active = false;
|
OC.Settings.Apps.State.apps[appId].active = false;
|
||||||
}
|
}
|
||||||
},'json');
|
},'json');
|
||||||
} else {
|
} else {
|
||||||
// TODO: display message to admin to not refresh the page!
|
// TODO: display message to admin to not refresh the page!
|
||||||
// TODO: lock UI to prevent further operations
|
// TODO: lock UI to prevent further operations
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.val(t('settings', 'Enabling app …'));
|
element.val(t('settings', 'Enabling app …'));
|
||||||
|
});
|
||||||
|
|
||||||
var appIdArray = [];
|
var appIdArray = [];
|
||||||
if( typeof appId === 'string' ) {
|
if( typeof appId === 'string' ) {
|
||||||
|
@ -371,13 +412,21 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
if(!result || result.status !== 'success') {
|
if(!result || result.status !== 'success') {
|
||||||
if (result.data && result.data.message) {
|
if (result.data && result.data.message) {
|
||||||
OC.Settings.Apps.showErrorMessage(appId, result.data.message);
|
OC.Settings.Apps.showErrorMessage(appId, result.data.message);
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.data('errormsg', result.data.message);
|
appItem.data('errormsg', result.data.message);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while enabling app'));
|
OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while enabling app'));
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.data('errormsg', t('settings', 'Error while disabling app'));
|
appItem.data('errormsg', t('settings', 'Error while disabling app'));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.val(t('settings', 'Enable'));
|
element.val(t('settings', 'Enable'));
|
||||||
|
});
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.addClass('appwarning');
|
appItem.addClass('appwarning');
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
self._checkServerHealth().done(function() {
|
self._checkServerHealth().done(function() {
|
||||||
if (result.data.update_required) {
|
if (result.data.update_required) {
|
||||||
|
@ -389,24 +438,40 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
}
|
}
|
||||||
|
|
||||||
OC.Settings.Apps.rebuildNavigation();
|
OC.Settings.Apps.rebuildNavigation();
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.data('active', true);
|
appItem.data('active', true);
|
||||||
|
});
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.data('active', true);
|
element.data('active', true);
|
||||||
|
});
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.addClass('active');
|
appItem.addClass('active');
|
||||||
|
});
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.val(t('settings', 'Disable'));
|
element.val(t('settings', 'Disable'));
|
||||||
|
});
|
||||||
var app = OC.Settings.Apps.State.apps[appId];
|
var app = OC.Settings.Apps.State.apps[appId];
|
||||||
app.active = true;
|
app.active = true;
|
||||||
|
|
||||||
if (OC.Settings.Apps.isType(app, 'filesystem') || OC.Settings.Apps.isType(app, 'prelogin') ||
|
if (OC.Settings.Apps.isType(app, 'filesystem') || OC.Settings.Apps.isType(app, 'prelogin') ||
|
||||||
OC.Settings.Apps.isType(app, 'authentication') || OC.Settings.Apps.isType(app, 'logging')) {
|
OC.Settings.Apps.isType(app, 'authentication') || OC.Settings.Apps.isType(app, 'logging')) {
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.parent().find(".groups-enable").prop('checked', true);
|
element.parent().find(".groups-enable").prop('checked', true);
|
||||||
element.parent().find(".groups-enable").hide();
|
element.parent().find(".groups-enable").hide();
|
||||||
element.parent().find('#group_select').hide().val(null);
|
element.parent().find('#group_select').hide().val(null);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.parent().find("#groups-enable").show();
|
element.parent().find("#groups-enable").show();
|
||||||
|
});
|
||||||
if (groups) {
|
if (groups) {
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.data('groups', JSON.stringify(groups));
|
appItem.data('groups', JSON.stringify(groups));
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.data('groups', '');
|
appItem.data('groups', '');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
|
@ -416,27 +481,41 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
appId,
|
appId,
|
||||||
t('settings', 'Error: this app cannot be enabled because it makes the server unstable')
|
t('settings', 'Error: this app cannot be enabled because it makes the server unstable')
|
||||||
);
|
);
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.data('errormsg', t('settings', 'Error while enabling app'));
|
appItem.data('errormsg', t('settings', 'Error while enabling app'));
|
||||||
|
});
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.val(t('settings', 'Enable'));
|
element.val(t('settings', 'Enable'));
|
||||||
|
});
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.addClass('appwarning');
|
appItem.addClass('appwarning');
|
||||||
|
});
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
OC.Settings.Apps.showErrorMessage(
|
OC.Settings.Apps.showErrorMessage(
|
||||||
appId,
|
appId,
|
||||||
t('settings', 'Error: could not disable broken app')
|
t('settings', 'Error: could not disable broken app')
|
||||||
);
|
);
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.data('errormsg', t('settings', 'Error while disabling broken app'));
|
appItem.data('errormsg', t('settings', 'Error while disabling broken app'));
|
||||||
|
});
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.val(t('settings', 'Enable'));
|
element.val(t('settings', 'Enable'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},'json')
|
},'json')
|
||||||
.fail(function() {
|
.fail(function() {
|
||||||
OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while enabling app'));
|
OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while enabling app'));
|
||||||
|
appItems.forEach(function(appItem) {
|
||||||
appItem.data('errormsg', t('settings', 'Error while enabling app'));
|
appItem.data('errormsg', t('settings', 'Error while enabling app'));
|
||||||
appItem.data('active', false);
|
appItem.data('active', false);
|
||||||
appItem.addClass('appwarning');
|
appItem.addClass('appwarning');
|
||||||
|
});
|
||||||
|
elements.forEach(function(element) {
|
||||||
element.val(t('settings', 'Enable'));
|
element.val(t('settings', 'Enable'));
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -799,14 +878,16 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
|
|
||||||
$(document).on('click', '#apps-list input.enable', function () {
|
$(document).on('click', '#apps-list input.enable', function () {
|
||||||
var appId = $(this).data('appid');
|
var appId = $(this).data('appid');
|
||||||
|
var bundleId = $(this).data('bundleid');
|
||||||
var element = $(this);
|
var element = $(this);
|
||||||
var active = $(this).data('active');
|
var active = $(this).data('active');
|
||||||
|
|
||||||
var category = $('#app-navigation').attr('data-category');
|
var category = $('#app-navigation').attr('data-category');
|
||||||
if(category === 'app-bundles') {
|
if(bundleId) {
|
||||||
OC.Settings.Apps.enableAppBundle(appId, active, element);
|
OC.Settings.Apps.enableAppBundle(bundleId, active, element);
|
||||||
|
element.val(t('settings', 'Enable all'));
|
||||||
} else {
|
} else {
|
||||||
OC.Settings.Apps.enableApp(appId, active, element);
|
OC.Settings.Apps.enableApp([appId], active);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -835,7 +916,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
|
|
||||||
var appId = element.data('appid');
|
var appId = element.data('appid');
|
||||||
if (appId) {
|
if (appId) {
|
||||||
OC.Settings.Apps.enableApp(appId, false, element, groups);
|
OC.Settings.Apps.enableApp([appId], false, groups);
|
||||||
OC.Settings.Apps.State.apps[appId].groups = groups;
|
OC.Settings.Apps.State.apps[appId].groups = groups;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue