本文整理汇总了PHP中drop_plugin_tables函数的典型用法代码示例。如果您正苦于以下问题:PHP drop_plugin_tables函数的具体用法?PHP drop_plugin_tables怎么用?PHP drop_plugin_tables使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drop_plugin_tables函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: unset
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);
$a = new stdClass();
$a->behaviour = $behaviourname;
$a->directory = get_plugin_directory('qbehaviour', $delete);
echo $OUTPUT->box(get_string('qbehaviourdeletefiles', 'question', $a), 'generalbox', 'notice');
echo $OUTPUT->continue_button($thispageurl);
echo $OUTPUT->footer();
exit;
}
// End of process actions ==================================================
// Print the page heading.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('manageqbehaviours', 'admin'));
// Set up the table.
示例3: moodle_url
echo $OUTPUT->heading(get_string('deleteqtypeareyousure', 'question', $qtypename));
echo $OUTPUT->confirm(get_string('deleteqtypeareyousuremessage', 'question', $qtypename), 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('deletingqtype', 'question', $qtypename));
// Delete any configuration records.
if (!unset_all_config_for_plugin('qtype_' . $delete)) {
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete));
}
unset_config($delete . '_disabled', 'question');
unset_config($delete . '_sortorder', 'question');
// Then the tables themselves
drop_plugin_tables($delete, $qtypes[$delete]->plugin_dir() . '/db/install.xml', false);
// Remove event handlers and dequeue pending events
events_uninstall('qtype_' . $delete);
$a = new stdClass();
$a->qtype = $qtypename;
$a->directory = $qtypes[$delete]->plugin_dir();
echo $OUTPUT->box(get_string('qtypedeletefiles', 'question', $a), 'generalbox', 'notice');
echo $OUTPUT->continue_button($thispageurl);
echo $OUTPUT->footer();
exit;
}
// End of process actions ==================================================
// Print the page heading.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('manageqtypes', 'admin'));
// Set up the table.
示例4: 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);
//.........这里部分代码省略.........
示例5: print_heading
print_heading(get_string('deleteqtypeareyousure', 'admin', $qtypename));
notice_yesno(get_string('deleteqtypeareyousuremessage', 'admin', $qtypename), admin_url('qtypes.php?delete=' . $delete . '&confirm=1&sesskey=' . sesskey()), admin_url('qtypes.php'), NULL, NULL, 'post', 'get');
admin_externalpage_print_footer();
exit;
}
// Do the deletion.
admin_externalpage_print_header();
print_heading(get_string('deletingqtype', 'admin', $qtypename));
// Delete any configuration records.
if (!unset_all_config_for_plugin('qtype_' . $delete)) {
notify(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete));
}
unset_config($delete . '_disabled', 'question');
unset_config($delete . '_sortorder', 'question');
// Then the tables themselves
drop_plugin_tables($delete, $QTYPES[$delete]->plugin_dir() . '/db/install.xml', false);
// Remove event handlers and dequeue pending events
events_uninstall('qtype/' . $delete);
$a->qtype = $qtypename;
$a->directory = $QTYPES[$delete]->plugin_dir();
print_box(get_string('qtypedeletefiles', 'admin', $a), 'generalbox', 'notice');
print_continue(admin_url('qtypes.php'));
admin_externalpage_print_footer();
exit;
}
// End of process actions ==================================================
/// Print the page heading.
admin_externalpage_print_header();
print_heading(get_string('manageqtypes', 'admin'));
/// Set up the table.
$table = new flexible_table('qtypeadmintable');
示例6: grade_uninstalled_module
if (!$DB->delete_records("log_display", array("module" => $module->name))) {
echo $OUTPUT->notification("Error occurred while deleting all {$strmodulename} records in log_display table");
}
// And the module entry itself
if (!$DB->delete_records("modules", array("name" => $module->name))) {
echo $OUTPUT->notification("Error occurred while deleting the {$strmodulename} record from modules table");
}
// And the module configuration records
if (!unset_all_config_for_plugin($module->name)) {
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', $strmodulename));
}
// cleanup the gradebook
require_once $CFG->libdir . '/gradelib.php';
grade_uninstalled_module($module->name);
// Then the tables themselves
drop_plugin_tables($module->name, "{$CFG->dirroot}/mod/{$module->name}/db/install.xml", false);
// Delete the capabilities that were defined by this module
capabilities_cleanup('mod/' . $module->name);
// remove entent handlers and dequeue pending events
events_uninstall('mod/' . $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)) {
if (!$uninstallfunction()) {
echo $OUTPUT->notification('Encountered a problem running uninstall function for ' . $module->name . '!');
}
}
}
$a->module = $strmodulename;
示例7: array
$blockobject->before_delete();
//only if we can create instance, block might have been already removed
}
}
// First delete instances and then block
$instances = $DB->get_records('block_instances', array('blockname' => $block->name));
if (!empty($instances)) {
foreach ($instances as $instance) {
blocks_delete_instance($instance);
}
}
// Delete block
$DB->delete_records('block', array('id' => $block->id));
drop_plugin_tables($block->name, "{$CFG->dirroot}/blocks/{$block->name}/db/install.xml", false);
// old obsoleted table names
drop_plugin_tables('block_' . $block->name, "{$CFG->dirroot}/blocks/{$block->name}/db/install.xml", false);
// Delete the capabilities that were defined by this block
capabilities_cleanup('block/' . $block->name);
// Remove event handlers and dequeue pending events
events_uninstall('block/' . $block->name);
$a->block = $strblockname;
$a->directory = $CFG->dirroot . '/blocks/' . $block->name;
notice(get_string('blockdeletefiles', '', $a), 'blocks.php');
}
}
echo $OUTPUT->header();
echo $OUTPUT->heading($strmanageblocks);
/// Main display starts here
/// Get and sort the existing blocks
if (!($blocks = $DB->get_records('block', array(), 'name ASC'))) {
print_error('noblocks', 'error');
示例8: delete_plugin
/**
* Delete the database and files associated with this plugin.
*
* @param string $plugin - The type of the plugin to delete
* @return string the name of the next page to display
*/
public function delete_plugin($plugin) {
global $CFG, $DB, $OUTPUT;
$confirm = optional_param('confirm', null, PARAM_BOOL);
if ($confirm) {
// Delete any configuration records.
if (!unset_all_config_for_plugin('assignsubmission_' . $plugin)) {
$this->error = $OUTPUT->notification(get_string('errordeletingconfig', 'admin', $this->subtype . '_' . $plugin));
}
// Should be covered by the previous function - but just in case
unset_config('disabled', $this->subtype . '_' . $plugin);
unset_config('sortorder', $this->subtype . '_' . $plugin);
// delete the plugin specific config settings
$DB->delete_records('assign_plugin_config', array('plugin'=>$plugin, 'subtype'=>$this->subtype));
// Then the tables themselves
drop_plugin_tables($this->subtype . '_' . $plugin, $CFG->dirroot . '/mod/assign/' . $this->subtype . '/' .$plugin. '/db/install.xml', false);
// Remove event handlers and dequeue pending events
events_uninstall($this->subtype . '_' . $plugin);
// the page to display
return 'plugindeleted';
} else {
// the page to display
return 'confirmdelete';
}
}
示例9: vmoodle_uninstall_plugin
/**
* Automatically clean-up all plugin data and remove the plugin DB tables
*
* @param string $type The subplugin type, eg. 'vmoodleadminset' etc.
* @param string $name The subplugin name, eg. 'example', 'generic', etc.
* @uses global $OUTPUT to produce notices and other messages
* @return void
*/
function vmoodle_uninstall_plugin($type, $name, $plugindirectory)
{
global $CFG, $DB, $OUTPUT;
// This may take a long time.
@set_time_limit(0);
$component = $type . '_' . $name;
// eg. 'qtype_multichoice' or 'workshopgrading_accumulative' or 'mod_forum'
$pluginname = $component;
if (get_string_manager()->string_exists('pluginname', $component)) {
$strpluginname = get_string('pluginname', $component);
} else {
$strpluginname = $component;
}
echo $OUTPUT->heading($pluginname);
$uninstalllib = $plugindirectory . '/db/uninstall.php';
if (file_exists($uninstalllib)) {
require_once $uninstalllib;
$uninstallfunction = 'xmldb_' . $pluginname . '_uninstall';
// eg. 'xmldb_workshop_uninstall()'
if (function_exists($uninstallfunction)) {
if (!$uninstallfunction()) {
echo $OUTPUT->notification('Encountered a problem running uninstall function for ' . $pluginname);
}
}
}
// 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 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);
// 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');
}