Skip to content

Commit

Permalink
MDL-42078 multiple uninstall improvements and cleanup
Browse files Browse the repository at this point in the history
Includes:
* update checker refactored to \core\update\ namespace
* plugininfo classes refactored to \core\plugininfo\ namespace
* plugin_manager renamed to core_plugin_manager
* redirect back to original page after plugin uninstall
* fixed assign subplugin uninstall
* move assign subplugins under the assignment in admin tree
* fixed plugininfo for all question related plugin types
* auth uninstall support
* added missing block dependencies
* added theme uninstall
* subplugin types are following the plugin on plugin overview page
* several performance improvements in plugin manager
* new warnigns when plugininfo are outdated or missing
* multiple fixes and other improvements
  • Loading branch information
skodak committed Oct 7, 2013
1 parent 56cc9b3 commit e87214b
Show file tree
Hide file tree
Showing 105 changed files with 7,034 additions and 4,987 deletions.
5 changes: 2 additions & 3 deletions admin/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
require_once($CFG->libdir.'/pluginlib.php');

require_login();
require_capability('moodle/site:config', context_system::instance());
Expand Down Expand Up @@ -53,7 +52,7 @@
set_config('registerauth', '');
}
\core\session\manager::gc(); // Remove stale sessions.
plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
break;

case 'enable':
Expand All @@ -64,7 +63,7 @@
set_config('auth', implode(',', $authsenabled));
}
\core\session\manager::gc(); // Remove stale sessions.
plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
break;

case 'down':
Expand Down
23 changes: 11 additions & 12 deletions admin/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
require_once($CFG->libdir.'/pluginlib.php');

admin_externalpage_setup('manageblocks');

Expand Down Expand Up @@ -37,7 +36,7 @@
print_error('blockdoesnotexist', 'error');
}
$DB->set_field('block', 'visible', '0', array('id'=>$block->id)); // Hide block
plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
admin_get_root(true, false); // settings not required - only pages
}

Expand All @@ -46,7 +45,7 @@
print_error('blockdoesnotexist', 'error');
}
$DB->set_field('block', 'visible', '1', array('id'=>$block->id)); // Show block
plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
admin_get_root(true, false); // settings not required - only pages
}

Expand Down Expand Up @@ -97,8 +96,8 @@

$table = new flexible_table('admin-blocks-compatible');

$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'uninstall', 'settings'));
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $struninstall, $strsettings));
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'settings', 'uninstall'));
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strsettings, $struninstall));
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
$table->set_attribute('class', 'admintable blockstable generaltable');
$table->set_attribute('id', 'compatibleblockstable');
Expand Down Expand Up @@ -141,7 +140,7 @@
}
}

if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('block_'.$blockname)) {
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$blockname, 'manage')) {
$uninstall = html_writer::link($uninstallurl, $struninstall);
} else {
$uninstall = '';
Expand Down Expand Up @@ -184,7 +183,7 @@
} else {
$visible = '<a href="blocks.php?show='.$blockid.'&amp;sesskey='.sesskey().'" title="'.$strshow.'">'.
'<img src="'.$OUTPUT->pix_url('t/show') . '" class="iconsmall" alt="'.$strshow.'" /></a>';
$class = ' class="dimmed_text"'; // Leading space required!
$class = 'dimmed_text';
}

if ($dbversion == $plugin->version) {
Expand All @@ -205,15 +204,15 @@
}

$row = array(
'<span'.$class.'>'.$strblockname.'</span>',
$strblockname,
$blocklist,
'<span'.$class.'>'.$version.'</span>',
$version,
$visible,
$undeletable,
$settings,
$uninstall,
$settings
);
$table->add_data($row);
$table->add_data($row, $class);
}

$table->print_html();
Expand All @@ -232,7 +231,7 @@
$table->setup();

foreach ($incompatible as $block) {
if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('block_'.$block->name)) {
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$block->name, 'manage')) {
$uninstall = html_writer::link($uninstallurl, $struninstall);
} else {
$uninstall = '';
Expand Down
3 changes: 1 addition & 2 deletions admin/cli/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -753,9 +753,8 @@
}

// Test plugin dependencies.
require_once($CFG->libdir . '/pluginlib.php');
$failed = array();
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
cli_error(get_string('pluginschecktodo', 'admin'));
}
Expand Down
3 changes: 1 addition & 2 deletions admin/cli/install_database.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,8 @@
}

// Test plugin dependencies.
require_once($CFG->libdir . '/pluginlib.php');
$failed = array();
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
cli_error(get_string('pluginschecktodo', 'admin'));
}
Expand Down
3 changes: 1 addition & 2 deletions admin/cli/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
require_once($CFG->libdir.'/clilib.php'); // cli only functions
require_once($CFG->libdir.'/environmentlib.php');
require_once($CFG->libdir.'/pluginlib.php');

// now get cli options
list($options, $unrecognized) = cli_get_params(
Expand Down Expand Up @@ -117,7 +116,7 @@

// Test plugin dependencies.
$failed = array();
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
cli_error(get_string('pluginschecktodo', 'admin'));
}
Expand Down
7 changes: 3 additions & 4 deletions admin/courseformats.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/pluginlib.php');

$action = required_param('action', PARAM_ALPHANUMEXT);
$formatname = required_param('format', PARAM_PLUGIN);
Expand All @@ -39,7 +38,7 @@

$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));

$formatplugins = plugin_manager::instance()->get_plugins_of_type('format');
$formatplugins = core_plugin_manager::instance()->get_plugins_of_type('format');
$sortorder = array_flip(array_keys($formatplugins));

if (!isset($formatplugins[$formatname])) {
Expand All @@ -53,13 +52,13 @@
print_error('cannotdisableformat', 'error', $return);
}
set_config('disabled', 1, 'format_'. $formatname);
plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
}
break;
case 'enable':
if (!$formatplugins[$formatname]->is_enabled()) {
unset_config('disabled', 'format_'. $formatname);
plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
}
break;
case 'up':
Expand Down
3 changes: 1 addition & 2 deletions admin/editors.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
require_once($CFG->libdir.'/pluginlib.php');

$action = required_param('action', PARAM_ALPHANUMEXT);
$editor = required_param('editor', PARAM_PLUGIN);
Expand Down Expand Up @@ -94,7 +93,7 @@
}

set_config('texteditors', implode(',', $active_editors));
plugin_manager::reset_caches();
core_plugin_manager::reset_caches();

if ($return) {
redirect ($returnurl);
Expand Down
7 changes: 3 additions & 4 deletions admin/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/pluginlib.php');

$action = required_param('action', PARAM_ALPHANUMEXT);
$enrol = required_param('enrol', PARAM_PLUGIN);
Expand All @@ -51,7 +50,7 @@
case 'disable':
unset($enabled[$enrol]);
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
$syscontext->mark_dirty(); // resets all enrol caches
break;

Expand All @@ -62,7 +61,7 @@
$enabled = array_keys($enabled);
$enabled[] = $enrol;
set_config('enrol_plugins_enabled', implode(',', $enabled));
plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
$syscontext->mark_dirty(); // resets all enrol caches
break;

Expand Down Expand Up @@ -122,7 +121,7 @@

echo $OUTPUT->notification(get_string('success'), 'notifysuccess');

if (!$return = plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol)) {
if (!$return = core_plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol, 'manage')) {
$return = new moodle_url('/admin/plugins.php');
}
echo $OUTPUT->continue_button($return);
Expand Down
9 changes: 4 additions & 5 deletions admin/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/pluginlib.php');

$action = optional_param('action', '', PARAM_ALPHANUMEXT);
$filterpath = optional_param('filterpath', '', PARAM_SAFEDIR);
Expand Down Expand Up @@ -104,7 +103,7 @@

// Reset caches and return
if ($action) {
plugin_manager::reset_caches();
core_plugin_manager::reset_caches();
reset_text_filters_cache();
redirect($returnurl);
}
Expand Down Expand Up @@ -137,7 +136,7 @@

$table = new html_table();
$table->head = array(get_string('filter'), get_string('isactive', 'filters'),
get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('delete'));
get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('uninstallplugin', 'core_admin'));
$table->colclasses = array ('leftalign', 'leftalign', 'centeralign', 'leftalign', 'leftalign', 'leftalign');
$table->attributes['class'] = 'admintable generaltable';
$table->id = 'filterssetting';
Expand Down Expand Up @@ -180,7 +179,7 @@

function filters_action_url($filterpath, $action) {
if ($action === 'delete') {
return new moodle_url('/admin/plugins.php', array('sesskey'=>sesskey(), 'uninstall'=>'filter_'.$filterpath));
return core_plugin_manager::instance()->get_uninstall_url('filter_'.$filterpath, 'manage');
}
return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
}
Expand Down Expand Up @@ -233,7 +232,7 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
}

// Delete
$row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
$row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('uninstallplugin', 'core_admin') . '</a>';

return $row;
}
32 changes: 20 additions & 12 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@

require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
require_once($CFG->libdir.'/pluginlib.php'); // available updates notifications

$id = optional_param('id', '', PARAM_TEXT);
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
Expand Down Expand Up @@ -196,7 +195,7 @@

// check plugin dependencies
$failed = array();
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
$PAGE->navbar->add(get_string('pluginscheck', 'admin'));
$PAGE->set_title($strinstallation);
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
Expand Down Expand Up @@ -323,7 +322,7 @@

// check plugin dependencies first
$failed = array();
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
die();
}
Expand All @@ -332,12 +331,12 @@
if ($fetchupdates) {
// no sesskey support guaranteed here
if (empty($CFG->disableupdatenotifications)) {
available_update_checker::instance()->fetch();
\core\update\checker::instance()->fetch();
}
redirect($reloadurl);
}

$deployer = available_update_deployer::instance();
$deployer = \core\update\deployer::instance();
if ($deployer->enabled()) {
$deployer->initialize($reloadurl, $reloadurl);

Expand All @@ -348,7 +347,7 @@
}
}

echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
$version, $showallplugins, $reloadurl,
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)));
die();
Expand Down Expand Up @@ -386,13 +385,13 @@

if ($fetchupdates) {
// no sesskey support guaranteed here
available_update_checker::instance()->fetch();
\core\update\checker::instance()->fetch();
redirect($PAGE->url);
}

$output = $PAGE->get_renderer('core', 'admin');

$deployer = available_update_deployer::instance();
$deployer = \core\update\deployer::instance();
if ($deployer->enabled()) {
$deployer->initialize($PAGE->url, $PAGE->url);

Expand All @@ -405,14 +404,14 @@

// check plugin dependencies first
$failed = array();
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
echo $output->unsatisfied_dependencies_page($version, $failed, $PAGE->url);
die();
}
unset($failed);

// dependencies check passed, let's rock!
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
$version, $showallplugins,
new moodle_url($PAGE->url),
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1)));
Expand Down Expand Up @@ -514,6 +513,15 @@
redirect('upgradesettings.php');
}

// Return to original page that started the plugin uninstallation if necessary.
if (isset($SESSION->pluginuninstallreturn)) {
$return = $SESSION->pluginuninstallreturn;
unset($SESSION->pluginuninstallreturn);
if ($return) {
redirect($return);
}
}

// Everything should now be set up, and the user is an admin

// Print default admin page with notifications.
Expand All @@ -525,13 +533,13 @@
$maintenancemode = !empty($CFG->maintenance_enabled);

// Available updates for Moodle core
$updateschecker = available_update_checker::instance();
$updateschecker = \core\update\checker::instance();
$availableupdates = array();
$availableupdates['core'] = $updateschecker->get_update_info('core',
array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));

// Available updates for contributed plugins
$pluginman = plugin_manager::instance();
$pluginman = core_plugin_manager::instance();
foreach ($pluginman->get_plugins() as $plugintype => $plugintypeinstances) {
foreach ($plugintypeinstances as $pluginname => $plugininfo) {
if (!empty($plugininfo->availableupdates)) {
Expand Down
Loading

0 comments on commit e87214b

Please sign in to comment.