diff --git a/modules/system/controllers/Updates.php b/modules/system/controllers/Updates.php
index bfb14e21b..c5f6a5945 100644
--- a/modules/system/controllers/Updates.php
+++ b/modules/system/controllers/Updates.php
@@ -735,28 +735,6 @@ class Updates extends Controller
}
}
- /**
- * Rollback and remove plugins from the system.
- * @return void
- */
- public function onRemovePlugins()
- {
- if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
-
- foreach ($checkedIds as $objectId) {
- if (!$object = PluginVersion::find($objectId)) {
- continue;
- }
-
- PluginManager::instance()->deletePlugin($object->code);
- }
-
- Flash::success(Lang::get('system::lang.plugins.remove_success'));
- }
-
- return $this->listRefresh('manage');
- }
-
/**
* Rollback and remove a single plugin from the system.
* @return void
@@ -764,9 +742,7 @@ class Updates extends Controller
public function onRemovePlugin()
{
if ($pluginCode = post('code')) {
-
PluginManager::instance()->deletePlugin($pluginCode);
-
Flash::success(Lang::get('system::lang.plugins.remove_success'));
}
@@ -774,114 +750,67 @@ class Updates extends Controller
}
/**
- * Rebuilds plugin database migrations.
+ * Perform a bulk action on the provided plugins
* @return void
*/
- public function onRefreshPlugins()
- {
- if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
-
- foreach ($checkedIds as $objectId) {
- if (!$object = PluginVersion::find($objectId)) {
- continue;
- }
-
- PluginManager::instance()->refreshPlugin($object->code);
- }
-
- Flash::success(Lang::get('system::lang.plugins.refresh_success'));
- }
-
- return $this->listRefresh('manage');
- }
-
public function onBulkAction()
{
- if (($bulkAction = post('action')) && ($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
-
+ if (($bulkAction = post('action')) &&
+ ($checkedIds = post('checked')) &&
+ is_array($checkedIds) &&
+ count($checkedIds)
+ ) {
$manager = PluginManager::instance();
foreach ($checkedIds as $pluginId) {
-
if (!$plugin = PluginVersion::find($pluginId)) {
continue;
}
+ $savePlugin = true;
switch ($bulkAction) {
+ // Enables plugin's updates.
case 'freeze':
$plugin->is_frozen = 1;
- Flash::success(Lang::get('system::lang.plugins.freeze_success'));
break;
+ // Disables plugin's updates.
case 'unfreeze':
$plugin->is_frozen = 0;
- Flash::success(Lang::get('system::lang.plugins.unfreeze_success'));
break;
+ // Disables plugin on the system.
case 'disable':
$plugin->is_disabled = 1;
$manager->disablePlugin($plugin->code, true);
- Flash::success(Lang::get('system::lang.plugins.disable_success'));
break;
+ // Enables plugin on the system.
case 'enable':
$plugin->is_disabled = 0;
$manager->enablePlugin($plugin->code, true);
- Flash::success(Lang::get('system::lang.plugins.enable_success'));
+ break;
+
+ // Rebuilds plugin database migrations.
+ case 'refresh':
+ $savePlugin = false;
+ $manager->refreshPlugin($plugin->code);
+ break;
+
+ // Rollback and remove plugins from the system.
+ case 'remove':
+ $savePlugin = false;
+ $manager->deletePlugin($plugin->code);
break;
}
- $plugin->save();
-
+ if ($savePlugin) {
+ $plugin->save();
+ }
}
-
- }
-
- return $this->listRefresh('manage');
- }
-
- public function onToggleFreeze()
- {
- $plugin = PluginVersion::find(post('plugin_id'));
-
- $freeze = post('freeze_' . $plugin->id);
-
- $plugin->is_frozen = $freeze;
- $plugin->save();
-
- if($freeze) {
- Flash::success(Lang::get('system::lang.plugins.freeze_success'));
- } else {
- Flash::success(Lang::get('system::lang.plugins.unfreeze_success'));
- }
-
- return $this->listRefresh('manage');
- }
-
- public function onToggleDisable()
- {
- $manager = PluginManager::instance();
- $plugin = PluginVersion::find(post('plugin_id'));
-
- $disable = post('disable_' . $plugin->id);
-
- if ($disable) {
- $manager->disablePlugin($plugin->code, true);
- }
- else {
- $manager->enablePlugin($plugin->code, true);
- }
-
- $plugin->is_disabled = $disable;
- $plugin->save();
-
- if ($disable) {
- Flash::success(Lang::get('system::lang.plugins.disable_success'));
- }
- else{
- Flash::success(Lang::get('system::lang.plugins.enable_success'));
}
+ Flash::success(Lang::get("system::lang.plugins.{$bulkAction}_success"));
return $this->listRefresh('manage');
}
diff --git a/modules/system/controllers/updates/_is_disabled.htm b/modules/system/controllers/updates/_is_disabled.htm
deleted file mode 100644
index 3dcdaa1cc..000000000
--- a/modules/system/controllers/updates/_is_disabled.htm
+++ /dev/null
@@ -1,15 +0,0 @@
-
diff --git a/modules/system/controllers/updates/_is_enabled.htm b/modules/system/controllers/updates/_is_enabled.htm
new file mode 100644
index 000000000..72e4d90f6
--- /dev/null
+++ b/modules/system/controllers/updates/_is_enabled.htm
@@ -0,0 +1,18 @@
+is_disabled ? 'enable' : 'disable'; ?>
+
diff --git a/modules/system/controllers/updates/_is_frozen.htm b/modules/system/controllers/updates/_is_frozen.htm
deleted file mode 100644
index 25b53148b..000000000
--- a/modules/system/controllers/updates/_is_frozen.htm
+++ /dev/null
@@ -1,15 +0,0 @@
-
diff --git a/modules/system/controllers/updates/_is_unfrozen.htm b/modules/system/controllers/updates/_is_unfrozen.htm
new file mode 100644
index 000000000..9f5a88d2a
--- /dev/null
+++ b/modules/system/controllers/updates/_is_unfrozen.htm
@@ -0,0 +1,18 @@
+is_frozen ? 'unfreeze' : 'freeze'; ?>
+
diff --git a/modules/system/controllers/updates/_list_manage_toolbar.htm b/modules/system/controllers/updates/_list_manage_toolbar.htm
index c763c5d27..6940b07aa 100644
--- a/modules/system/controllers/updates/_list_manage_toolbar.htm
+++ b/modules/system/controllers/updates/_list_manage_toolbar.htm
@@ -76,8 +76,8 @@