Skip to content

Commit

Permalink
MDL-30786 fix overview status of standard plugins to be deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Dec 23, 2011
1 parent 929c26c commit 96ebc91
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions lang/en/plugin.php
Expand Up @@ -50,6 +50,7 @@
$string['sourceext'] = 'Extension';
$string['sourcestd'] = 'Standard';
$string['status'] = 'Status';
$string['status_delete'] = 'To be deleted';
$string['status_downgrade'] = 'Higher version already installed!';
$string['status_missing'] = 'Missing from disk!';
$string['status_new'] = 'To be installed';
Expand Down
34 changes: 33 additions & 1 deletion lib/pluginlib.php
Expand Up @@ -47,6 +47,8 @@ class plugin_manager {
const PLUGIN_STATUS_NEW = 'new';
/** the plugin is about to be upgraded */
const PLUGIN_STATUS_UPGRADE = 'upgrade';
/** the standard plugin is about to be deleted */
const PLUGIN_STATUS_DELETE = 'delete';
/** the version at the disk is lower than the one already installed */
const PLUGIN_STATUS_DOWNGRADE = 'downgrade';
/** the plugin is installed but missing from disk */
Expand Down Expand Up @@ -289,9 +291,32 @@ public function all_plugins_ok($moodleversion) {
return true;
}

/**
* Defines a list of all plugins that were originally shipped in the standard Moodle distribution,
* but are not anymore and are deleted during upgrades.
*
* The main purpose of this list is to hide missing plugins during upgrade.
*
* @param string $type plugin type
* @param string $name plugin name
* @return bool
*/
public static function is_deleted_standard_plugin($type, $name) {
static $plugins = array(
'block' => array('admin', 'admin_tree', 'loancalc', 'search'),
'filter' => array('mod_data', 'mod_glossary'),
);

if (!isset($plugins[$type])) {
return false;
}
return in_array($name, $plugins[$type]);
}

/**
* Defines a white list of all plugins shipped in the standard Moodle distribution
*
* @param string $type
* @return false|array array of standard plugins or false if the type is unknown
*/
public static function standard_plugins_list($type) {
Expand Down Expand Up @@ -809,6 +834,9 @@ public function init_is_standard() {
$standard = array_flip($standard);
if (isset($standard[$this->name])) {
$this->source = plugin_manager::PLUGIN_SOURCE_STANDARD;
} else if (!is_null($this->versiondb) and is_null($this->versiondisk)
and plugin_manager::is_deleted_standard_plugin($this->type, $this->name)) {
$this->source = plugin_manager::PLUGIN_SOURCE_STANDARD; // to be deleted
} else {
$this->source = plugin_manager::PLUGIN_SOURCE_EXTENSION;
}
Expand All @@ -834,7 +862,11 @@ public function get_status() {
return plugin_manager::PLUGIN_STATUS_NEW;

} else if (!is_null($this->versiondb) and is_null($this->versiondisk)) {
return plugin_manager::PLUGIN_STATUS_MISSING;
if (plugin_manager::is_deleted_standard_plugin($this->type, $this->name)) {
return plugin_manager::PLUGIN_STATUS_DELETE;
} else {
return plugin_manager::PLUGIN_STATUS_MISSING;
}

} else if ((string)$this->versiondb === (string)$this->versiondisk) {
return plugin_manager::PLUGIN_STATUS_UPTODATE;
Expand Down
1 change: 1 addition & 0 deletions theme/base/style/admin.css
Expand Up @@ -190,6 +190,7 @@
#page-admin-index #plugins-check .status-missing .status {background-color:#ffd3d9;}
#page-admin-index #plugins-check .status-new .status {background-color:#e7f1c3;}
#page-admin-index #plugins-check .status-nodb .status {color:#999;}
#page-admin-index #plugins-check .status-delete .status {background-color:#d2ebff;}
#page-admin-index #plugins-check .status-upgrade .status {background-color:#d2ebff;}
#page-admin-index #plugins-check .status-uptodate .status {color:#999;}
#page-admin-index #plugins-check .requires ul {font-size:0.7em;margin:0;}
Expand Down

0 comments on commit 96ebc91

Please sign in to comment.