/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { global $DB; // Do the opposite of db/install.php scripts - deregister the report. $DB->delete_records('offlinequiz_reports', array('name' => $this->name)); parent::uninstall_cleanup(); }
/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { global $DB; $DB->set_field('course', 'theme', '', array('theme' => $this->name)); $DB->set_field('course_categories', 'theme', '', array('theme' => $this->name)); $DB->set_field('user', 'theme', '', array('theme' => $this->name)); $DB->set_field('mnet_host', 'theme', '', array('theme' => $this->name)); if (get_config('core', 'thememobile') === $this->name) { unset_config('thememobile'); } if (get_config('core', 'themetablet') === $this->name) { unset_config('themetablet'); } if (get_config('core', 'themelegacy') === $this->name) { unset_config('themelegacy'); } $themelist = get_config('core', 'themelist'); if (!empty($themelist)) { $themes = explode(',', $themelist); $key = array_search($this->name, $themes); if ($key !== false) { unset($themes[$key]); set_config('themelist', implode(',', $themes)); } } parent::uninstall_cleanup(); }
public function uninstall_cleanup() { $enabled = get_config('tool_log', 'enabled_stores'); if ($enabled) { $enabled = array_flip(explode(',', $enabled)); unset($enabled['logstore_' . $this->name]); $enabled = array_flip($enabled); set_config('enabled_stores', implode(',', $enabled), 'tool_log'); } parent::uninstall_cleanup(); }
/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { global $DB; $DB->set_field('course', 'theme', '', array('theme' => $this->name)); $DB->set_field('course_categories', 'theme', '', array('theme' => $this->name)); $DB->set_field('user', 'theme', '', array('theme' => $this->name)); $DB->set_field('mnet_host', 'theme', '', array('theme' => $this->name)); unset_config('thememobile'); unset_config('themetablet'); unset_config('themelegacy'); parent::uninstall_cleanup(); }
/** * Gathers and returns the information about all plugins of the given type * * @param string $type the name of the plugintype, eg. mod, auth or workshopform * @param string $typerootdir full path to the location of the plugin dir * @param string $typeclass the name of the actually called class * @param core_plugin_manager $pluginman the plugin manager calling this method * @return array of plugintype classes, indexed by the plugin name */ public static function get_plugins($type, $typerootdir, $typeclass, $pluginman) { global $CFG; $formats = parent::get_plugins($type, $typerootdir, $typeclass, $pluginman); if (!empty($CFG->dataformat_plugins_sortorder)) { $order = explode(',', $CFG->dataformat_plugins_sortorder); $order = array_merge(array_intersect($order, array_keys($formats)), array_diff(array_keys($formats), $order)); } else { $order = array_keys($formats); } $sortedformats = array(); foreach ($order as $formatname) { $sortedformats[$formatname] = $formats[$formatname]; } return $sortedformats; }
/** * Pre-uninstall hook. * This is intended for disabling of plugin, some DB table purging, etc. */ public function uninstall_cleanup() { global $DB; // Get all instances of this portfolio. $count = $DB->count_records('portfolio_instance', array('plugin' => $this->name)); if ($count > 0) { // This portfolio is in use, get the it's ID. $rec = $DB->get_record('portfolio_instance', array('plugin' => $this->name)); // Remove all records from portfolio_instance_config. $DB->delete_records('portfolio_instance_config', array('instance' => $rec->id)); // Remove all records from portfolio_instance_user. $DB->delete_records('portfolio_instance_user', array('instance' => $rec->id)); // Remove all records from portfolio_log. $DB->delete_records('portfolio_log', array('portfolio' => $rec->id)); // Remove all records from portfolio_tempdata. $DB->delete_records('portfolio_tempdata', array('instance' => $rec->id)); // Remove the record from the portfolio_instance table. $DB->delete_records('portfolio_instance', array('id' => $rec->id)); } parent::uninstall_cleanup(); }
/** * Formats the information that needs to go in the 'Requires' column. * @param \core\plugininfo\base $plugin the plugin we are rendering the row for. * @param core_plugin_manager $pluginman provides data on all the plugins. * @param string $version * @return string HTML code */ protected function required_column(\core\plugininfo\base $plugin, core_plugin_manager $pluginman, $version) { $requires = array(); if (!empty($plugin->versionrequires)) { if ($plugin->versionrequires <= $version) { $class = 'requires-ok'; } else { $class = 'requires-failed'; } $requires[] = html_writer::tag('li', get_string('moodleversion', 'core_plugin', $plugin->versionrequires), array('class' => $class)); } foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) { $otherplugin = $pluginman->get_plugin_info($component); $actions = array(); if (is_null($otherplugin)) { // The required plugin is not installed. $class = 'requires-failed requires-missing'; $installurl = new moodle_url('https://moodle.org/plugins/view.php', array('plugin' => $component)); $uploadurl = new moodle_url('/admin/tool/installaddon/'); $actions[] = html_writer::link($installurl, get_string('dependencyinstall', 'core_plugin')); $actions[] = html_writer::link($uploadurl, get_string('dependencyupload', 'core_plugin')); } else { if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) { // The required plugin is installed but needs to be updated. $class = 'requires-failed requires-outdated'; if (!$otherplugin->is_standard()) { $updateurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'fetchupdates' => 1)); $actions[] = html_writer::link($updateurl, get_string('checkforupdates', 'core_plugin')); } } else { // Already installed plugin with sufficient version. $class = 'requires-ok'; } } if ($requiredversion != ANY_VERSION) { $str = 'otherpluginversion'; } else { $str = 'otherplugin'; } $requires[] = html_writer::tag('li', html_writer::div(get_string($str, 'core_plugin', array('component' => $component, 'version' => $requiredversion)), 'component') . html_writer::div(implode(' | ', $actions), 'actions'), array('class' => $class)); } if (!$requires) { return ''; } return html_writer::tag('ul', implode("\n", $requires)); }
/** * Pre-uninstall hook. * @private */ public function uninstall_cleanup() { global $DB; $DB->delete_records('sepl_plugin_config', array('plugin' => $this->name, 'subtype' => 'seplsubmission')); parent::uninstall_cleanup(); }
/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { global $DB, $CFG; if ($block = $DB->get_record('block', array('name' => $this->name))) { // Inform block it's about to be deleted. if (file_exists("{$CFG->dirroot}/blocks/{$block->name}/block_{$block->name}.php")) { $blockobject = block_instance($block->name); if ($blockobject) { $blockobject->before_delete(); // Only if we can create instance, block might have been already removed. } } // First delete instances and related contexts. $instances = $DB->get_records('block_instances', array('blockname' => $block->name)); foreach ($instances as $instance) { blocks_delete_instance($instance); } // Delete block. $DB->delete_records('block', array('id' => $block->id)); } parent::uninstall_cleanup(); }
/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { global $DB, $CFG; if (!($module = $DB->get_record('modules', array('name' => $this->name)))) { parent::uninstall_cleanup(); return; } // Delete all the relevant instances from all course sections. if ($coursemods = $DB->get_records('course_modules', array('module' => $module->id))) { foreach ($coursemods as $coursemod) { // Do not verify results, there is not much we can do anyway. delete_mod_from_section($coursemod->id, $coursemod->section); } } // Increment course.cacherev for courses that used this module. // This will force cache rebuilding on the next request. increment_revision_number('course', 'cacherev', "id IN (SELECT DISTINCT course\n FROM {course_modules}\n WHERE module=?)", array($module->id)); // Delete all the course module records. $DB->delete_records('course_modules', array('module' => $module->id)); // Delete module contexts. if ($coursemods) { foreach ($coursemods as $coursemod) { \context_helper::delete_instance(CONTEXT_MODULE, $coursemod->id); } } // Delete the module entry itself. $DB->delete_records('modules', array('name' => $module->name)); // Cleanup the gradebook. require_once $CFG->libdir . '/gradelib.php'; grade_uninstalled_module($module->name); // Do not look for legacy $module->name . '_uninstall any more, // they should have migrated to db/uninstall.php by now. parent::uninstall_cleanup(); }
/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { global $DB; if (($defaultformat = get_config('moodlecourse', 'format')) && $defaultformat !== $this->name) { $courses = $DB->get_records('course', array('format' => $this->name), 'id'); $data = (object) array('id' => null, 'format' => $defaultformat); foreach ($courses as $record) { $data->id = $record->id; update_course($data); } } $DB->delete_records('course_format_options', array('format' => $this->name)); parent::uninstall_cleanup(); }
/** * Helper method that implements common uninstall prerequisites * * @param \core\plugininfo\base $pluginfo * @return bool */ protected function common_uninstall_check(\core\plugininfo\base $pluginfo) { if (!$pluginfo->is_uninstall_allowed()) { // The plugin's plugininfo class declares it should not be uninstalled. return false; } if ($pluginfo->get_status() === static::PLUGIN_STATUS_NEW) { // The plugin is not installed. It should be either installed or removed from the disk. // Relying on this temporary state may be tricky. return false; } if (method_exists($pluginfo, 'get_uninstall_url') and is_null($pluginfo->get_uninstall_url())) { // Backwards compatibility. debugging('\\core\\plugininfo\\base subclasses should use is_uninstall_allowed() instead of returning null in get_uninstall_url()', DEBUG_DEVELOPER); return false; } return true; }
/** * Pre-uninstall hook. * @private */ public function uninstall_cleanup() { global $DB; $DB->delete_records('assign_plugin_config', array('plugin' => $this->name, 'subtype' => 'assignfeedback')); parent::uninstall_cleanup(); }
/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { global $DB, $CFG; $DB->delete_records('filter_active', array('filter' => $this->name)); $DB->delete_records('filter_config', array('filter' => $this->name)); if (empty($CFG->filterall)) { $stringfilters = array(); } else { if (!empty($CFG->stringfilters)) { $stringfilters = explode(',', $CFG->stringfilters); $stringfilters = array_combine($stringfilters, $stringfilters); } else { $stringfilters = array(); } } unset($stringfilters[$this->name]); set_config('stringfilters', implode(',', $stringfilters)); set_config('filterall', !empty($stringfilters)); parent::uninstall_cleanup(); }
/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { global $CFG; require_once $CFG->libdir . '/messagelib.php'; message_processor_uninstall($this->name); parent::uninstall_cleanup(); }
/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { // Delete any question configuration records mentioning this plugin. unset_config($this->name . '_disabled', 'question'); unset_config($this->name . '_sortorder', 'question'); parent::uninstall_cleanup(); }
/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { global $CFG; if (!empty($CFG->auth)) { $auths = explode(',', $CFG->auth); $auths = array_unique($auths); } else { $auths = array(); } if (($key = array_search($this->name, $auths)) !== false) { unset($auths[$key]); set_config('auth', implode(',', $auths)); } if (!empty($CFG->registerauth) and $CFG->registerauth === $this->name) { unset_config('registerauth'); } parent::uninstall_cleanup(); }
/** * Pre-uninstall hook. * @private */ public function uninstall_cleanup() { global $DB; parent::uninstall_cleanup(); }
/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { if ($disabledbehaviours = get_config('question', 'disabledbehaviours')) { $disabledbehaviours = explode(',', $disabledbehaviours); $disabledbehaviours = array_unique($disabledbehaviours); } else { $disabledbehaviours = array(); } if (($key = array_search($this->name, $disabledbehaviours)) !== false) { unset($disabledbehaviours[$key]); set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question'); } if ($behaviourorder = get_config('question', 'behavioursortorder')) { $behaviourorder = explode(',', $behaviourorder); $behaviourorder = array_unique($behaviourorder); } else { $behaviourorder = array(); } if (($key = array_search($this->name, $behaviourorder)) !== false) { unset($behaviourorder[$key]); set_config('behavioursortorder', implode(',', $behaviourorder), 'question'); } parent::uninstall_cleanup(); }
public function uninstall_cleanup() { $enabled = get_config('mod_dataform', 'enabled_dataformview'); if ($enabled) { $enabled = array_flip(explode(',', $enabled)); unset($enabled[$this->name]); $enabled = array_flip($enabled); set_config('enabled_dataformview', implode(',', $enabled), 'mod_dataform'); } parent::uninstall_cleanup(); }
/** * Formats the information that needs to go in the 'Requires' column. * @param \core\plugininfo\base $plugin the plugin we are rendering the row for. * @param core_plugin_manager $pluginman provides data on all the plugins. * @param string $version * @return string HTML code */ protected function required_column(\core\plugininfo\base $plugin, core_plugin_manager $pluginman, $version) { $requires = array(); if (!empty($plugin->versionrequires)) { if ($plugin->versionrequires <= $version) { $class = 'requires-ok'; } else { $class = 'requires-failed'; } $requires[] = html_writer::tag('li', get_string('moodleversion', 'core_plugin', $plugin->versionrequires), array('class' => $class)); } foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) { $ok = true; $otherplugin = $pluginman->get_plugin_info($component); if (is_null($otherplugin)) { $ok = false; } else { if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) { $ok = false; } } if ($ok) { $class = 'requires-ok'; } else { $class = 'requires-failed'; } if ($requiredversion != ANY_VERSION) { $str = 'otherpluginversion'; } else { $str = 'otherplugin'; } $componenturl = new moodle_url('https://moodle.org/plugins/view.php?plugin=' . $component); $componenturl = html_writer::tag('a', $component, array('href' => $componenturl->out())); $requires[] = html_writer::tag('li', get_string($str, 'core_plugin', array('component' => $componenturl, 'version' => $requiredversion)), array('class' => $class)); } if (!$requires) { return ''; } return html_writer::tag('ul', implode("\n", $requires)); }
/** * 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(); }
/** * Pre-uninstall hook. * * This is intended for disabling of plugin, some DB table purging, etc. * * NOTE: to be called from uninstall_plugin() only. * @private */ public function uninstall_cleanup() { global $DB, $CFG; // NOTE: this is a bit brute force way - it will not trigger events and hooks properly. // Nuke all role assignments. role_unassign_all(array('component' => 'enrol_' . $this->name)); // Purge participants. $DB->delete_records_select('user_enrolments', "enrolid IN (SELECT id FROM {enrol} WHERE enrol = ?)", array($this->name)); // Purge enrol instances. $DB->delete_records('enrol', array('enrol' => $this->name)); // Tweak enrol settings. if (!empty($CFG->enrol_plugins_enabled)) { $enabledenrols = explode(',', $CFG->enrol_plugins_enabled); $enabledenrols = array_unique($enabledenrols); $enabledenrols = array_flip($enabledenrols); unset($enabledenrols[$this->name]); $enabledenrols = array_flip($enabledenrols); if (is_array($enabledenrols)) { set_config('enrol_plugins_enabled', implode(',', $enabledenrols)); } } parent::uninstall_cleanup(); }
/** * Display a page to confirm the plugin uninstallation. * * @param core_plugin_manager $pluginman * @param \core\plugininfo\base $pluginfo * @param moodle_url $continueurl URL to continue after confirmation * @param moodle_url $cancelurl URL to to go if cancelled * @return string */ public function plugin_uninstall_confirm_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo, moodle_url $continueurl, moodle_url $cancelurl) { $output = ''; $pluginname = $pluginman->plugin_name($pluginfo->component); $confirm = '<p>' . get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)) . '</p>'; if ($extraconfirm = $pluginfo->get_uninstall_extra_warning()) { $confirm .= $extraconfirm; } $output .= $this->output->header(); $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname))); $output .= $this->output->confirm($confirm, $continueurl, $cancelurl); $output .= $this->output->footer(); return $output; }
/** * Pre-uninstall hook. */ public function uninstall_cleanup() { global $CFG; if (!empty($CFG->antiviruses)) { $antiviruses = explode(',', $CFG->antiviruses); $antiviruses = array_unique($antiviruses); } else { $antiviruses = array(); } if (($key = array_search($this->name, $antiviruses)) !== false) { unset($antiviruses[$key]); set_config('antiviruses', implode(',', $antiviruses)); } parent::uninstall_cleanup(); }