Skip to content

Commit

Permalink
Merge branch 'MDL-45619_m27' of git://github.com/sbourget/moodle into…
Browse files Browse the repository at this point in the history
… MOODLE_27_STABLE
  • Loading branch information
David Monllao committed Mar 25, 2015
2 parents 7a95447 + f1a1e58 commit bcecb03
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
18 changes: 14 additions & 4 deletions admin/repository.php
Expand Up @@ -264,6 +264,7 @@ function repository_action_url($repository) {
$strshow = get_string('on', 'repository');
$strhide = get_string('off', 'repository');
$strdelete = get_string('disabled', 'repository');
$struninstall = get_string('uninstallplugin', 'core_admin');

$actionchoicesforexisting = array(
'show' => $strshow,
Expand All @@ -286,9 +287,9 @@ function repository_action_url($repository) {

// Table to list plug-ins
$table = new html_table();
$table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr);
$table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr, $struninstall);

$table->colclasses = array('leftalign', 'centeralign', 'centeralign', 'centeralign', 'centeralign');
$table->colclasses = array('leftalign', 'centeralign', 'centeralign', 'centeralign', 'centeralign', 'centeralign');
$table->id = 'repositoriessetting';
$table->data = array();
$table->attributes['class'] = 'admintable generaltable';
Expand Down Expand Up @@ -384,7 +385,12 @@ function repository_action_url($repository) {

$updowncount++;

$table->data[] = array($i->get_readablename(), $OUTPUT->render($select), $updown, $settings);
$uninstall = '';
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('repository_' . $typename, 'manage')) {
$uninstall = html_writer::link($uninstallurl, $struninstall);
}

$table->data[] = array($i->get_readablename(), $OUTPUT->render($select), $updown, $settings, $uninstall);

if (!in_array($typename, $alreadyplugins)) {
$alreadyplugins[] = $typename;
Expand All @@ -400,7 +406,11 @@ function repository_action_url($repository) {
if (!in_array($plugin, $alreadyplugins)) {
$select = new single_select(repository_action_url($plugin, 'repos'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . basename($plugin));
$select->set_label(get_string('action'), array('class' => 'accesshide'));
$table->data[] = array(get_string('pluginname', 'repository_'.$plugin), $OUTPUT->render($select), '', '');
$uninstall = '';
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('repository_' . $plugin, 'manage')) {
$uninstall = html_writer::link($uninstallurl, $struninstall);
}
$table->data[] = array(get_string('pluginname', 'repository_'.$plugin), $OUTPUT->render($select), '', '', $uninstall);
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions lib/classes/plugininfo/repository.php
Expand Up @@ -67,4 +67,34 @@ public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $h
public static function get_manage_url() {
return new moodle_url('/admin/repository.php');
}

/**
* Defines if there should be a way to uninstall the plugin via the administration UI.
* @return boolean
*/
public function is_uninstall_allowed() {
if ($this->name === 'upload' || $this->name === 'coursefiles' || $this->name === 'user') {
return false;
} else {
return true;
}
}

/**
* Pre-uninstall hook.
* This is intended for disabling of plugin, some DB table purging, etc.
* Converts all linked files to standard files when repository is removed
* and cleans up all records in the DB for that repository.
*/
public function uninstall_cleanup() {
global $CFG;
require_once($CFG->dirroot.'/repository/lib.php');

$repo = \repository::get_type_by_typename($this->name);
if ($repo) {
$repo->delete(true);
}

parent::uninstall_cleanup();
}
}

0 comments on commit bcecb03

Please sign in to comment.