本文整理汇总了PHP中unset_all_config_for_plugin函数的典型用法代码示例。如果您正苦于以下问题:PHP unset_all_config_for_plugin函数的具体用法?PHP unset_all_config_for_plugin怎么用?PHP unset_all_config_for_plugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unset_all_config_for_plugin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: xmldb_eliscore_etl_install
/**
* Install for eliscore_etl
* @return boolean
*/
function xmldb_eliscore_etl_install()
{
global $CFG, $DB;
$dbman = $DB->get_manager();
// Run upgrade steps from old plugin
// Convert old tables to new
static $tablemap = array('etl_user_activity' => 'eliscore_etl_useractivity', 'etl_user_module_activity' => 'eliscore_etl_modactivity');
foreach ($tablemap as $oldtable => $newtable) {
$oldtableobj = new xmldb_table($oldtable);
if ($dbman->table_exists($oldtableobj)) {
$newtableobj = new xmldb_table($newtable);
$dbman->drop_table($newtableobj);
$dbman->rename_table($oldtableobj, $newtable);
}
}
// Copy any settings from old plugin
$oldconfig = get_config('eliscoreplugins_user_activity');
foreach ($oldconfig as $name => $value) {
set_config($name, $value, 'eliscore_etl');
}
unset_all_config_for_plugin('eliscoreplugins_user_activity');
// Ensure ELIS scheduled tasks is initialized.
require_once $CFG->dirroot . '/local/eliscore/lib/tasklib.php';
$DB->delete_records('local_eliscore_sched_tasks', array('plugin' => 'eliscoreplugins_user_activity'));
elis_tasks_update_definition('eliscore_etl');
return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:31,代码来源:install.php
示例2: xmldb_dhfile_log_install
function xmldb_dhfile_log_install()
{
$result = true;
unset_all_config_for_plugin('rlipfile_log');
// Ensure that scheduling is setup correctly.
rlip_scheduling_init();
return $result;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:8,代码来源:install.php
示例3: xmldb_report_participation_install
function xmldb_report_participation_install() {
global $DB;
// this is a hack which is needed for cleanup of original coursereport_participation stuff
unset_all_config_for_plugin('coursereport_participation');
capabilities_cleanup('coursereport_participation');
// update existing block page patterns
$DB->set_field('block_instances', 'pagetypepattern', 'report-participation-index', array('pagetypepattern'=>'course-report-participation-index'));
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:10,代码来源:install.php
示例4: xmldb_tool_unsuproles_install
function xmldb_tool_unsuproles_install()
{
global $CFG;
// this is a hack - this plugin used to live in admin/report/unsuproles,
// we want to remove the orphaned version info unless there is a new
// report type with the same name
if (!file_exists("{$CFG->dirroot}/report/report_unsuproles")) {
unset_all_config_for_plugin('report_unsuproles');
}
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:10,代码来源:install.php
示例5: xmldb_tool_qeupgradehelper_install
function xmldb_tool_qeupgradehelper_install()
{
global $CFG;
// this is a hack - this plugin used to live in local/qeupgradehelper,
// we want to remove the orphaned version info and capability
// unless there is a local plugin type with the same name
if (!file_exists("{$CFG->dirroot}/local/qeupgradehelper")) {
unset_all_config_for_plugin('local_qeupgradehelper');
}
}
开发者ID:ravivare,项目名称:moodle-1,代码行数:10,代码来源:install.php
示例6: xmldb_block_enrolsurvey_install
/**
* ELIS(TM): Enterprise Learning Intelligence Suite
* Copyright (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package block_enrolsurvey
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net)
*/
function xmldb_block_enrolsurvey_install()
{
global $CFG, $DB;
$result = true;
$dbman = $DB->get_manager();
// Migrate block instances.
$oldrecord = $DB->get_record('block', array('name' => 'enrol_survey'), 'id');
if (!empty($oldrecord)) {
// Convert any existing old enrol_survey block instances to enrolsurvey blocks.
$sql = "UPDATE {block_instances} SET blockname = 'enrolsurvey' WHERE blockname = 'enrol_survey'";
$DB->execute($sql);
// Delete old enrol_survey record in block table.
$DB->delete_records('block', array('id' => $oldrecord->id));
}
// Migrate old config settings.
$settings = (array) get_config('block_enrol_survey');
if (!empty($settings)) {
foreach ($settings as $name => $val) {
set_config($name, $val, 'block_enrolsurvey');
}
}
unset_all_config_for_plugin('block_enrol_survey');
// Migrate old block_enrol_survey table if it exists.
$table = new xmldb_table('block_enrol_survey_taken');
// Old pre 2.6 table.
if ($dbman->table_exists($table)) {
$newtable = new xmldb_table('block_enrolsurvey_taken');
$dbman->drop_table($newtable);
$dbman->rename_table($table, 'block_enrolsurvey_taken');
}
// Migrate capabilities.
$oldcapprefix = 'block/enrol_survey';
$newcapprefix = 'block/enrolsurvey';
$sql = 'SELECT * FROM {role_capabilities} WHERE capability LIKE ?';
$params = array($oldcapprefix . '%');
$rolecaps = $DB->get_recordset_sql($sql, $params);
foreach ($rolecaps as $rolecaprec) {
$updaterec = new stdClass();
$updaterec->id = $rolecaprec->id;
$updaterec->capability = str_replace($oldcapprefix, $newcapprefix, $rolecaprec->capability);
$DB->update_record('role_capabilities', $updaterec);
}
$sql = 'SELECT * FROM {capabilities} WHERE name LIKE ?';
$caps = $DB->get_recordset_sql($sql, $params);
foreach ($caps as $cap) {
$cap->name = str_replace($oldcapprefix, $newcapprefix, $cap->name);
$cap->component = str_replace('block_enrol_survey', 'block_enrolsurvey', $cap->component);
$DB->update_record('capabilities', $cap);
}
// Migrate language strings
$migrator = new \local_eliscore\install\migration\migrator('block_enrol_survey', 'block_enrolsurvey');
$migrator->migrate_language_strings();
return $result;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:75,代码来源:install.php
示例7: xmldb_tool_unittest_install
function xmldb_tool_unittest_install()
{
global $CFG;
// this is a hack - this plugin used to live in admin/report/unittest,
// we want to remove the orphaned version info and capability
// unless there is a new report type with the same name
if (!file_exists("{$CFG->dirroot}/report/unittest")) {
unset_all_config_for_plugin('report_unittest');
capabilities_cleanup('report_unittest');
}
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:11,代码来源:install.php
示例8: xmldb_dhexport_version1_uninstall
/**
* Uninstall hook for this export plugin
*/
function xmldb_dhexport_version1_uninstall()
{
global $DB;
$dbman = $DB->get_manager();
//remove the custom field mapping table
$mapping_table = new xmldb_table(RLIPEXPORT_VERSION1_FIELD_TABLE);
if ($dbman->table_exists($mapping_table)) {
$dbman->drop_table($mapping_table);
}
//clear config_plugins entries
unset_all_config_for_plugin('dhexport_version1');
return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:16,代码来源:uninstall.php
示例9: xmldb_dhimport_version1elis_uninstall
/**
* Uninstall hook for this import plugin
*/
function xmldb_dhimport_version1elis_uninstall()
{
global $DB;
$dbman = $DB->get_manager();
//remove the field mapping table
$mapping_table = new xmldb_table(RLIPIMPORT_VERSION1ELIS_MAPPING_TABLE);
if ($dbman->table_exists($mapping_table)) {
$dbman->drop_table($mapping_table);
}
//clear config_plugins entries
unset_all_config_for_plugin('dhimport_version1elis');
return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:16,代码来源:uninstall.php
示例10: xmldb_auth_drupalservices_upgrade
/**
* Authentication Plugin: Drupal Services Single Sign-on
*
* This module is based on work by Arsham Skrenes.
* This module will look for a Drupal cookie that represents a valid,
* authenticated session, and will use it to create an authenticated Moodle
* session for the same user. The Drupal user will be synchronized with the
* corresponding user in Moodle. If the user does not yet exist in Moodle, it
* will be created.
*
* PHP version 5
*
* @category CategoryName
* @package Drupal_Services
* @author Dave Cannon <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @link https://github.com/cannod/moodle-drupalservices
*
*/
function xmldb_auth_drupalservices_upgrade($oldversion)
{
if ($oldversion < 2014111400) {
// This module has been tracking variables using the wrong name syntax. this retroactively goes
// back and fixes them to be the proper plugin key upon upgrade
$config = get_config('auth/drupalservices');
foreach ((array) $config as $key => $value) {
set_config($key, $value, 'auth_drupalservices');
}
unset_all_config_for_plugin('auth/drupalservices');
}
upgrade_plugin_savepoint(true, 2014123000, 'auth', 'drupalservices');
}
开发者ID:kiklop74,项目名称:moodle-drupalservices,代码行数:32,代码来源:upgrade.php
示例11: xmldb_local_elisreports_install
/**
* Standard Moodle post install function defintion
* @return bool true on success, false otherwise
*/
function xmldb_local_elisreports_install()
{
global $DB;
$result = true;
$dbman = $DB->get_manager();
$table = new xmldb_table('php_report_schedule');
// Old pre 2.6 table
if ($dbman->table_exists($table)) {
$newtable = new xmldb_table('local_elisreports_schedule');
$dbman->drop_table($newtable);
$dbman->rename_table($table, 'local_elisreports_schedule');
$tables = array('local_eliscore_sched_tasks', 'elis_scheduled_tasks');
foreach ($tables as $table) {
$tableobj = new xmldb_table($table);
if ($dbman->table_exists($tableobj)) {
$tasks = $DB->get_recordset($table, array('plugin' => 'block/php_report'));
foreach ($tasks as $task) {
$task->plugin = 'local_elisreports';
$task->callfile = '/local/elisreports/runschedule.php';
$DB->update_record($table, $task);
}
}
}
}
// Migrate capabilities
$oldcapprefix = 'block/php_report';
$newcapprefix = 'local/elisreports';
$sql = 'SELECT * FROM {role_capabilities} WHERE capability LIKE ?';
$params = array($oldcapprefix . '%');
$rolecaps = $DB->get_recordset_sql($sql, $params);
foreach ($rolecaps as $rolecap) {
$rolecap->capability = str_replace($oldcapprefix, $newcapprefix, $rolecap->capability);
$DB->update_record('role_capabilities', $rolecap);
}
$sql = 'SELECT * FROM {capabilities} WHERE name LIKE ?';
$caps = $DB->get_recordset_sql($sql, $params);
foreach ($caps as $cap) {
$cap->name = str_replace($oldcapprefix, $newcapprefix, $cap->name);
$cap->component = str_replace('block_php_report', 'local_elisreports', $cap->component);
$DB->update_record('capabilities', $cap);
}
// Migrate language strings
$migrator = new \local_eliscore\install\migration\migrator('block_php_report', 'local_elisreports');
$migrator->migrate_language_strings();
// Remove the old block ...
$DB->delete_records('block', array('name' => 'php_report'));
unset_all_config_for_plugin('block_php_report');
return $result;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:53,代码来源:install.php
示例12: xmldb_dhimport_version1elis_install
/**
* Custom post-install method for the "Version 1 ELIS" Datahub import plugin
*/
function xmldb_dhimport_version1elis_install()
{
global $CFG, $DB;
$result = true;
$dbman = $DB->get_manager();
// Run upgrade steps from old plugin if applicable.
$oldversion = get_config('rlipimport_version1elis', 'version');
if ($oldversion !== false) {
if ($result && $oldversion < 2012080100) {
$table = new xmldb_table('rlipimport_version1elis_mapping');
$result = $result && !empty($table) && $dbman->table_exists($table);
if ($result) {
$dbman->rename_table($table, 'rlipimport_version1elis_map');
$result = $dbman->table_exists('rlipimport_version1elis_map');
}
// Plugin savepoint reached
upgrade_plugin_savepoint($result, 2012080100, 'rlipimport', 'version1elis');
}
}
// Migrate old rlipimport_version1elis_map if it exists.
$table = new xmldb_table('rlipimport_version1elis_map');
if ($dbman->table_exists($table)) {
$newtable = new xmldb_table('dhimport_version1elis_map');
$dbman->drop_table($newtable);
$dbman->rename_table($table, 'dhimport_version1elis_map');
}
$oldconfig = $DB->get_recordset('config_plugins', array('plugin' => 'rlipimport_version1elis'));
foreach ($oldconfig as $oldconfigrec) {
// We don't want version records.
if ($oldconfigrec->name === 'version') {
continue;
}
// Check if a setting already exists for this name, and delete if it does.
$newrec = $DB->get_record('config_plugins', array('plugin' => 'dhimport_version1elis', 'name' => $oldconfigrec->name));
if (!empty($newrec)) {
$DB->delete_records('config_plugins', array('id' => $newrec->id));
}
$updatedrec = new \stdClass();
$updatedrec->id = $oldconfigrec->id;
$updatedrec->plugin = 'dhimport_version1elis';
$DB->update_record('config_plugins', $updatedrec);
}
unset_all_config_for_plugin('rlipimport_version1elis');
return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:48,代码来源:install.php
示例13: xmldb_report_editdates_install
function xmldb_report_editdates_install()
{
global $DB;
// This is a hack to copy the permission from the old place, if they were present.
// If this report is installed into a new Moodle, we just do what it says in access.php
// and clone the permissions from moodle/site:viewreports, but if we are upgrading
// a Moodle that had the old course report plugin installed, then we get rid of the
// new cloned capabilities, and transfer the old permissions.
if ($DB->record_exists('role_capabilities', array('capability' => 'coursereport/editdates:view'))) {
$DB->delete_records('role_capabilities', array('capability' => 'report/editdates:view'));
$DB->set_field('role_capabilities', 'capability', 'report/editdates:view', array('capability' => 'coursereport/editdates:view'));
}
// This is a hack which is needed for cleanup of original coursereport_completion stuff.
unset_all_config_for_plugin('coursereport_editdates');
capabilities_cleanup('coursereport_editdates');
// Update existing block page patterns.
$DB->set_field('block_instances', 'pagetypepattern', 'report-editdates-index', array('pagetypepattern' => 'course-report-editdates-index'));
}
开发者ID:merrill-oakland,项目名称:moodle-report_editdates,代码行数:18,代码来源:install.php
示例14: xmldb_local_elisprogram_install
/**
* ELIS(TM): Enterprise Learning Intelligence Suite
* Copyright (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package local_elisprogram
* @author Remote-Learner.net Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright (C) 2008-2013 Remote Learner.net Inc http://www.remote-learner.net
*
*/
function xmldb_local_elisprogram_install()
{
global $CFG, $DB;
$elisadminblockinstalled = file_exists($CFG->dirroot . '/local/elisprogram/lib/setup.php') && $DB->record_exists('block', array('name' => 'elisadmin'));
if ($elisadminblockinstalled) {
require_once $CFG->dirroot . '/blocks/elisadmin/lib.php';
}
require_once $CFG->dirroot . '/local/elisprogram/lib/lib.php';
// Install custom context levels.
\local_eliscore\context\helper::set_custom_levels(\local_elisprogram\context\contextinfo::get_contextinfo());
\local_eliscore\context\helper::install_custom_levels();
// Initialize custom context levels.
context_helper::reset_levels();
\local_eliscore\context\helper::reset_levels();
\local_eliscore\context\helper::init_levels();
// Migrate component.
$migrator = new \local_elisprogram\install\migration\elis26();
if ($migrator->old_component_installed() === true) {
$migrator->migrate();
}
//make sure the site has exactly one curr admin block instance
//that is viewable everywhere
if ($elisadminblockinstalled) {
block_elisadmin_create_instance();
}
// make sure that the manager role can be assigned to all PM context levels
update_capabilities('local_elisprogram');
// load context levels
pm_ensure_role_assignable('manager');
pm_ensure_role_assignable('curriculumadmin');
// Migrate dataroot files
pm_migrate_certificate_files();
// These notifications are default-on.
pm_set_config('notify_addedtowaitlist_user', 1);
pm_set_config('notify_enroledfromwaitlist_user', 1);
pm_set_config('notify_incompletecourse_user', 1);
// Ensure ELIS scheduled tasks is initialized.
require_once $CFG->dirroot . '/local/eliscore/lib/tasklib.php';
elis_tasks_update_definition('local_elisprogram');
// Remove some lingering subplugins that were renamed
unset_all_config_for_plugin('usersetenrol_manual');
unset_all_config_for_plugin('usersetenrol_moodle_profile');
}
开发者ID:jamesmcq,项目名称:elis,代码行数:66,代码来源:install.php
示例15: xmldb_tool_customlang_install
function xmldb_tool_customlang_install()
{
global $CFG, $OUTPUT, $DB;
// this is a hack - this plugin used to live in admin/report/customlang,
// we want to remove the orphaned version info and capability
// unless there is a new report type with the same name
// the original tables can be dropped because they are used for caching only
if (!file_exists("{$CFG->dirroot}/report/customlang")) {
unset_all_config_for_plugin('report_customlang');
capabilities_cleanup('report_customlang');
$dbman = $DB->get_manager();
$table = new xmldb_table('report_customlang');
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
$table = new xmldb_table('report_customlang_components');
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
}
}
开发者ID:ravivare,项目名称:moodle-1,代码行数:21,代码来源:install.php
示例16: xmldb_dhimport_version1_install
function xmldb_dhimport_version1_install()
{
global $CFG, $DB;
$result = true;
$dbman = $DB->get_manager();
// Run upgrade steps from old plugin if applicable.
$oldversion = get_config('rlipimport_version1', 'version');
if ($oldversion !== false) {
if ($result && $oldversion < 2012032800) {
// Make block naming more consistent
// Will throw an exception if problem is encountered
$dbman->rename_table(new xmldb_table('block_rlip_version1_fieldmap'), 'rlipimport_version1_mapping');
}
}
// Migrate old rlipimport_version1_mapping table if it exists.
$table = new xmldb_table('rlipimport_version1_mapping');
if ($dbman->table_exists($table)) {
$newtable = new xmldb_table('dhimport_version1_mapping');
$dbman->drop_table($newtable);
$dbman->rename_table($table, 'dhimport_version1_mapping');
}
$oldconfig = $DB->get_recordset('config_plugins', array('plugin' => 'rlipimport_version1'));
foreach ($oldconfig as $oldconfigrec) {
// We don't want version records.
if ($oldconfigrec->name === 'version') {
continue;
}
// Check if a setting already exists for this name, and delete if it does.
$newrec = $DB->get_record('config_plugins', array('plugin' => 'dhimport_version1', 'name' => $oldconfigrec->name));
if (!empty($newrec)) {
$DB->delete_records('config_plugins', array('id' => $newrec->id));
}
$updatedrec = new \stdClass();
$updatedrec->id = $oldconfigrec->id;
$updatedrec->plugin = 'dhimport_version1';
$DB->update_record('config_plugins', $updatedrec);
}
unset_all_config_for_plugin('rlipimport_version1');
return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:40,代码来源:install.php
示例17: print_error
if ($needed[$delete] > 0) {
print_error('cannotdeleteneededbehaviour', 'question', $thispageurl, $behaviourname);
}
// If not yet confirmed, display a confirmation message.
if (!optional_param('confirm', '', PARAM_BOOL)) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('deletebehaviourareyousure', 'question', $behaviourname));
echo $OUTPUT->confirm(get_string('deletebehaviourareyousuremessage', 'question', $behaviourname), new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)), $thispageurl);
echo $OUTPUT->footer();
exit;
}
// Do the deletion.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('deletingbehaviour', 'question', $behaviourname));
// Delete any configuration records.
if (!unset_all_config_for_plugin('qbehaviour_' . $delete)) {
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qbehaviour_' . $delete));
}
if (($key = array_search($delete, $disabledbehaviours)) !== false) {
unset($disabledbehaviours[$key]);
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
}
$behaviourorder = array_keys($sortedbehaviours);
if (($key = array_search($delete, $behaviourorder)) !== false) {
unset($behaviourorder[$key]);
set_config('behavioursortorder', implode(',', $behaviourorder), 'question');
}
// Then the tables themselves
drop_plugin_tables($delete, get_plugin_directory('qbehaviour', $delete) . '/db/install.xml', false);
// Remove event handlers and dequeue pending events
events_uninstall('qbehaviour_' . $delete);
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:qbehaviours.php
示例18: uninstall_plugin
//.........这里部分代码省略.........
}
// clear course.modinfo for courses that used this module
$sql = "UPDATE {course}\n SET modinfo=''\n WHERE id IN (SELECT DISTINCT course\n FROM {course_modules}\n WHERE module=?)";
$DB->execute($sql, 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) {
if (!delete_context(CONTEXT_MODULE, $coursemod->id)) {
echo $OUTPUT->notification("Could not delete the context for {$strpluginname} with id = {$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);
// Perform any custom uninstall tasks
if (file_exists($CFG->dirroot . '/mod/' . $module->name . '/lib.php')) {
require_once $CFG->dirroot . '/mod/' . $module->name . '/lib.php';
$uninstallfunction = $module->name . '_uninstall';
if (function_exists($uninstallfunction)) {
debugging("{$uninstallfunction}() has been deprecated. Use the plugin's db/uninstall.php instead", DEBUG_DEVELOPER);
if (!$uninstallfunction()) {
echo $OUTPUT->notification('Encountered a problem running uninstall function for ' . $module->name . '!');
}
}
}
} else {
if ($type === 'enrol') {
// 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' => $component));
// purge participants
$DB->delete_records_select('user_enrolments', "enrolid IN (SELECT id FROM {enrol} WHERE enrol = ?)", array($name));
// purge enrol instances
$DB->delete_records('enrol', array('enrol' => $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[$name]);
$enabledenrols = array_flip($enabledenrols);
if (is_array($enabledenrols)) {
set_config('enrol_plugins_enabled', implode(',', $enabledenrols));
}
}
} else {
if ($type === 'block') {
if ($block = $DB->get_record('block', array('name' => $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));
}
}
}
}
// perform clean-up task common for all the plugin/subplugin types
// delete calendar events
$DB->delete_records('event', array('modulename' => $pluginname));
// delete all the logs
$DB->delete_records('log', array('module' => $pluginname));
// delete log_display information
$DB->delete_records('log_display', array('component' => $component));
// delete the module configuration records
unset_all_config_for_plugin($pluginname);
// delete message provider
message_provider_uninstall($component);
// delete message processor
if ($type === 'message') {
message_processor_uninstall($name);
}
// delete the plugin tables
$xmldbfilepath = $plugindirectory . '/db/install.xml';
drop_plugin_tables($component, $xmldbfilepath, false);
if ($type === 'mod' or $type === 'block') {
// non-frankenstyle table prefixes
drop_plugin_tables($name, $xmldbfilepath, false);
}
// delete the capabilities that were defined by this module
capabilities_cleanup($component);
// remove event handlers and dequeue pending events
events_uninstall($component);
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
}
开发者ID:raymondAntonio,项目名称:moodle,代码行数:101,代码来源:adminlib.php
示例19: uninstall_plugin
/**
* Automatically clean-up all plugin data and remove the plugin DB tables
*
* NOTE: do not call directly, use new /admin/plugins.php?uninstall=component instead!
*
* @param string $type The plugin type, eg. 'mod', 'qtype', 'workshopgrading' etc.
* @param string $name The plugin name, eg. 'forum', 'multichoice', 'accumulative' etc.
* @uses global $OUTPUT to produce notices and other messages
* @return void
*/
function uninstall_plugin($type, $name)
{
global $CFG, $DB, $OUTPUT;
// This may take a long time.
core_php_time_limit::raise();
// Recursively uninstall all subplugins first.
$subplugintypes = core_component::get_plugin_types_with_subplugins();
if (isset($subplugintypes[$type])) {
$base = core_component::get_plugin_directory($type, $name);
if (file_exists("{$base}/db/subplugins.php")) {
$subplugins = array();
include "{$base}/db/subplugins.php";
foreach ($subplugins as $subplugintype => $dir) {
$instances = core_component::get_plugin_list($subplugintype);
foreach ($instances as $subpluginname => $notusedpluginpath) {
uninstall_plugin($subplugintype, $subpluginname);
}
}
}
}
$component = $type . '_' . $name;
// eg. 'qtype_multichoice' or 'workshopgrading_accumulative' or 'mod_forum'
if ($type === 'mod') {
$pluginname = $name;
// eg. 'forum'
if (get_string_manager()->string_exists('modulename', $component)) {
$strpluginname = get_string('modulename', $component);
} else {
$strpluginname = $component;
}
} else {
$pluginname = $component;
if (get_string_manager()->string_exists('pluginname', $component)) {
$strpluginname = get_string('pluginname', $component);
} else {
$strpluginname = $component;
}
}
echo $OUTPUT->heading($pluginname);
// Delete all tag instances associated with this plugin.
require_once $CFG->dirroot . '/tag/lib.php';
tag_delete_instances($component);
// Custom plugin uninstall.
$plugindirectory = core_component::get_plugin_directory($type, $name);
$uninstalllib = $plugindirectory . '/db/uninstall.php';
if (file_exists($uninstalllib)) {
require_once $uninstalllib;
$uninstallfunction = 'xmldb_' . $pluginname . '_uninstall';
// eg. 'xmldb_workshop_uninstall()'
if (function_exists($uninstallfunction)) {
// Do not verify result, let plugin complain if necessary.
$uninstallfunction();
}
}
// Specific plugin type cleanup.
$plugininfo = core_plugin_manager::instance()->get_plugin_info($component);
if ($plugininfo) {
$plugininfo->uninstall_cleanup();
core_plugin_manager::reset_caches();
}
$plugininfo = null;
// perform clean-up task common for all the plugin/subplugin types
//delete the web service functions and pre-built services
require_once $CFG->dirroot . '/lib/externallib.php';
external_delete_descriptions($component);
// delete calendar events
$DB->delete_records('event', array('modulename' => $pluginname));
// Delete scheduled tasks.
$DB->delete_records('task_scheduled', array('component' => $pluginname));
// Delete Inbound Message datakeys.
$DB->delete_records_select('messageinbound_datakeys', 'handler IN (SELECT id FROM {messageinbound_handlers} WHERE component = ?)', array($pluginname));
// Delete Inbound Message handlers.
$DB->delete_records('messageinbound_handlers', array('component' => $pluginname));
// delete all the logs
$DB->delete_records('log', array('module' => $pluginname));
// delete log_display information
$DB->delete_records('log_display', array('component' => $component));
// delete the module configuration records
unset_all_config_for_plugin($component);
if ($type === 'mod') {
unset_all_config_for_plugin($pluginname);
}
// delete message provider
message_provider_uninstall($component);
// delete the plugin tables
$xmldbfilepath = $plugindirectory . '/db/install.xml';
drop_plugin_tables($component, $xmldbfilepath, false);
if ($type === 'mod' or $type === 'block') {
// non-frankenstyle table prefixes
drop_plugin_tables($name, $xmldbfilepath, false);
//.........这里部分代码省略.........
开发者ID:Alexbado,项目名称:moodle2,代码行数:101,代码来源:adminlib.php
示例20: filter_delete_all_for_filter
/**
* Delete all the data in the database relating to a filter, prior to deleting it.
*
* @global object
* @param string $filter The filter name, for example 'filter/tex' or 'mod/glossary'.
*/
function filter_delete_all_for_filter($filter)
{
global $DB;
if (substr($filter, 0, 7) == 'filter/') {
unset_all_config_for_plugin('filter_' . basename($filter));
}
$DB->delete_records('filter_active', array('filter' => $filter));
$DB->delete_records('filter_config', array('filter' => $filter));
}
开发者ID:raymondAntonio,项目名称:moodle,代码行数:15,代码来源:filterlib.php
注:本文中的unset_all_config_for_plugin函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论