diff --git a/administrator/components/com_admin/sql/updates/mysql/3.7.0-2016-12-01.sql b/administrator/components/com_admin/sql/updates/mysql/3.7.0-2016-12-01.sql new file mode 100644 index 0000000000000..20a8d6a8ba9d0 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/3.7.0-2016-12-01.sql @@ -0,0 +1,2 @@ +-- Enable all the protected plugin extensions so they don't eternally disabled. +UPDATE `#__extensions` SET `enabled` = 1 WHERE `type` = 'plugin' AND `protected` = 1; diff --git a/administrator/components/com_admin/sql/updates/postgresql/3.7.0-2016-12-01.sql b/administrator/components/com_admin/sql/updates/postgresql/3.7.0-2016-12-01.sql new file mode 100644 index 0000000000000..132f15d140756 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/3.7.0-2016-12-01.sql @@ -0,0 +1,2 @@ +-- Enable all the protected plugin extensions so they don't eternally disabled. +UPDATE "#__extensions" SET "enabled" = 1 WHERE "type" = 'plugin' AND "protected" = 1; diff --git a/administrator/components/com_admin/sql/updates/sqlazure/3.7.0-2016-12-01.sql b/administrator/components/com_admin/sql/updates/sqlazure/3.7.0-2016-12-01.sql new file mode 100644 index 0000000000000..0ebb6f982c672 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/sqlazure/3.7.0-2016-12-01.sql @@ -0,0 +1,2 @@ +-- Enable all the protected plugin extensions so they don't eternally disabled. +UPDATE [#__extensions] SET [enabled] = 1 WHERE [type] = 'plugin' AND [protected] = 1; diff --git a/administrator/components/com_plugins/models/plugin.php b/administrator/components/com_plugins/models/plugin.php index 691a536afc90d..07c517103ba67 100644 --- a/administrator/components/com_plugins/models/plugin.php +++ b/administrator/components/com_plugins/models/plugin.php @@ -97,6 +97,16 @@ public function getForm($data = array(), $loadData = true) return false; } + // Disable enabled form field based on protected state. + if ($item && $item->protected) + { + // Disable fields for display. + $form->setFieldAttribute('enabled', 'disabled', 'true'); + + // Disable fields while saving. + $form->setFieldAttribute('enabled', 'filter', 'unset'); + } + // Modify the form based on access controls. if (!$this->canEditState((object) $data)) { @@ -367,4 +377,39 @@ protected function cleanCache($group = null, $client_id = 0) parent::cleanCache('com_plugins', 0); parent::cleanCache('com_plugins', 1); } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since __DEPLOY_VERSION__ + */ + public function publish(&$pks, $value = 1) + { + $table = $this->getTable(); + $pks = (array) $pks; + + // Default menu item existence checks. + foreach ($pks as $i => $pk) + { + // Check if plugin is protected. + if ($table->load($pk) && $table->protected) + { + JError::raiseWarning(500, JText::_('COM_PLUGINS_ERROR_PROTECTED')); + unset($pks[$i]); + continue; + } + } + + if ($pks === array()) + { + return false; + } + + return parent::publish($pks, $value); + } } diff --git a/administrator/components/com_plugins/models/plugins.php b/administrator/components/com_plugins/models/plugins.php index 3e2634eadee37..c24eae3ed1042 100644 --- a/administrator/components/com_plugins/models/plugins.php +++ b/administrator/components/com_plugins/models/plugins.php @@ -222,10 +222,10 @@ protected function getListQuery() $this->getState( 'list.select', 'a.extension_id , a.name, a.element, a.folder, a.checked_out, a.checked_out_time,' . - ' a.enabled, a.access, a.ordering' + ' a.enabled, a.protected, a.access, a.ordering' ) ) - ->from($db->quoteName('#__extensions') . ' AS a') + ->from($db->quoteName('#__extensions', 'a')) ->where($db->quoteName('type') . ' = ' . $db->quote('plugin')); // Join over the users for the checked out user. diff --git a/administrator/components/com_plugins/views/plugins/tmpl/default.php b/administrator/components/com_plugins/views/plugins/tmpl/default.php index 7833a007abe95..dfe9e22833631 100644 --- a/administrator/components/com_plugins/views/plugins/tmpl/default.php +++ b/administrator/components/com_plugins/views/plugins/tmpl/default.php @@ -110,7 +110,11 @@ extension_id); ?> - enabled, $i, 'plugins.', $canChange); ?> + protected) : ?> + + + enabled, $i, 'plugins.', $canChange); ?> + checked_out) : ?> diff --git a/administrator/language/en-GB/en-GB.com_plugins.ini b/administrator/language/en-GB/en-GB.com_plugins.ini index d26b4ccd8b1d5..267ca0cae4dcf 100644 --- a/administrator/language/en-GB/en-GB.com_plugins.ini +++ b/administrator/language/en-GB/en-GB.com_plugins.ini @@ -9,6 +9,7 @@ COM_PLUGINS_BASIC_FIELDSET_LABEL="Basic" COM_PLUGINS_CONFIGURATION="Plugin: Options" COM_PLUGINS_ELEMENT_HEADING="Element" COM_PLUGINS_ERROR_FILE_NOT_FOUND="The file %s could not be found." +COM_PLUGINS_ERROR_PROTECTED="A protected plugin cannot be enabled or disabled." COM_PLUGINS_FIELD_ELEMENT_DESC="Plugin main file name." COM_PLUGINS_FIELD_ELEMENT_LABEL="Plugin File" COM_PLUGINS_FIELD_ENABLED_DESC="The enabled status of this plugin." diff --git a/administrator/templates/hathor/html/com_plugins/plugins/default.php b/administrator/templates/hathor/html/com_plugins/plugins/default.php index 497aa98423231..7db18d62c7425 100644 --- a/administrator/templates/hathor/html/com_plugins/plugins/default.php +++ b/administrator/templates/hathor/html/com_plugins/plugins/default.php @@ -125,7 +125,11 @@ - enabled, $i, 'plugins.', $canChange); ?> + protected) : ?> + + + enabled, $i, 'plugins.', $canChange); ?> +