• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP core_plugin_manager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中core_plugin_manager的典型用法代码示例。如果您正苦于以下问题:PHP core_plugin_manager类的具体用法?PHP core_plugin_manager怎么用?PHP core_plugin_manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了core_plugin_manager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: reset_all_data


//.........这里部分代码省略.........
     if ($detectchanges === true) {
         if ($resetdb) {
             $warnings[] = 'Warning: unexpected database modification, resetting DB state';
         }
         $oldcfg = self::get_global_backup('CFG');
         $oldsite = self::get_global_backup('SITE');
         foreach ($CFG as $k => $v) {
             if (!property_exists($oldcfg, $k)) {
                 $warnings[] = 'Warning: unexpected new $CFG->' . $k . ' value';
             } else {
                 if ($oldcfg->{$k} !== $CFG->{$k}) {
                     $warnings[] = 'Warning: unexpected change of $CFG->' . $k . ' value';
                 }
             }
             unset($oldcfg->{$k});
         }
         if ($oldcfg) {
             foreach ($oldcfg as $k => $v) {
                 $warnings[] = 'Warning: unexpected removal of $CFG->' . $k;
             }
         }
         if ($USER->id != 0) {
             $warnings[] = 'Warning: unexpected change of $USER';
         }
         if ($COURSE->id != $oldsite->id) {
             $warnings[] = 'Warning: unexpected change of $COURSE';
         }
     }
     if (ini_get('max_execution_time') != 0) {
         // This is special warning for all resets because we do not want any
         // libraries to mess with timeouts unintentionally.
         // Our PHPUnit integration is not supposed to change it either.
         if ($detectchanges !== false) {
             $warnings[] = 'Warning: max_execution_time was changed to ' . ini_get('max_execution_time');
         }
         set_time_limit(0);
     }
     // restore original globals
     $_SERVER = self::get_global_backup('_SERVER');
     $CFG = self::get_global_backup('CFG');
     $SITE = self::get_global_backup('SITE');
     $_GET = array();
     $_POST = array();
     $_FILES = array();
     $_REQUEST = array();
     $COURSE = $SITE;
     // reinitialise following globals
     $OUTPUT = new bootstrap_renderer();
     $PAGE = new moodle_page();
     $FULLME = null;
     $ME = null;
     $SCRIPT = null;
     // Empty sessison and set fresh new not-logged-in user.
     \core\session\manager::init_empty_session();
     // reset all static caches
     \core\event\manager::phpunit_reset();
     accesslib_clear_all_caches(true);
     get_string_manager()->reset_caches(true);
     reset_text_filters_cache(true);
     events_get_handlers('reset');
     core_text::reset_caches();
     get_message_processors(false, true);
     filter_manager::reset_caches();
     // Reset internal users.
     core_user::reset_internal_users();
     //TODO MDL-25290: add more resets here and probably refactor them to new core function
     // Reset course and module caches.
     if (class_exists('format_base')) {
         // If file containing class is not loaded, there is no cache there anyway.
         format_base::reset_course_cache(0);
     }
     get_fast_modinfo(0, 0, true);
     // Reset other singletons.
     if (class_exists('core_plugin_manager')) {
         core_plugin_manager::reset_caches(true);
     }
     if (class_exists('\\core\\update\\checker')) {
         \core\update\checker::reset_caches(true);
     }
     if (class_exists('\\core\\update\\deployer')) {
         \core\update\deployer::reset_caches(true);
     }
     // purge dataroot directory
     self::reset_dataroot();
     // restore original config once more in case resetting of caches changed CFG
     $CFG = self::get_global_backup('CFG');
     // inform data generator
     self::get_data_generator()->reset();
     // fix PHP settings
     error_reporting($CFG->debug);
     // verify db writes just in case something goes wrong in reset
     if (self::$lastdbwrites != $DB->perf_get_writes()) {
         error_log('Unexpected DB writes in phpunit_util::reset_all_data()');
         self::$lastdbwrites = $DB->perf_get_writes();
     }
     if ($warnings) {
         $warnings = implode("\n", $warnings);
         trigger_error($warnings, E_USER_WARNING);
     }
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:util.php


示例2: definition

 protected function definition()
 {
     global $CFG, $OUTPUT;
     $mform =& $this->_form;
     $indicators = $this->_customdata['indicators'];
     $mform->addElement('hidden', 'id', $this->_customdata['id']);
     $mform->setType('id', PARAM_INT);
     // TODO: general course-level report settings.
     $mform->addElement('header', 'general', get_string('pluginname', 'report_engagement'));
     $mform->addElement('header', 'weightings', get_string('weighting', 'report_engagement'));
     $mform->addElement('static', 'weightings_desc', get_string('indicator', 'report_engagement'));
     $mform->addHelpButton('weightings_desc', 'indicator', 'report_engagement');
     foreach ($indicators as $name => $path) {
         $grouparray = array();
         $grouparray[] =& $mform->createElement('text', "weighting_{$name}", '', array('size' => 3));
         $grouparray[] =& $mform->createElement('static', '', '', '%');
         $mform->addGroup($grouparray, "weight_group_{$name}", get_string('pluginname', "engagementindicator_{$name}"), ' ', false);
         $mform->addHelpButton("weight_group_{$name}", 'pluginname', "engagementindicator_{$name}");
         $mform->setType("weighting_{$name}", PARAM_FLOAT);
     }
     $pluginman = core_plugin_manager::instance();
     $instances = get_plugin_list('engagementindicator');
     foreach ($indicators as $name => $path) {
         $plugin = $pluginman->get_plugin_info('engagementindicator_' . $name);
         $file = "{$CFG->dirroot}/mod/engagement/indicator/{$name}/thresholds_form.php";
         if (file_exists($file) && $plugin->is_enabled()) {
             require_once $file;
             $class = "engagementindicator_{$name}_thresholds_form";
             $subform = new $class();
             $mform->addElement('header', 'general', get_string('pluginname', "engagementindicator_{$name}"));
             $subform->definition_inner($mform);
         }
     }
     $this->add_action_buttons();
 }
开发者ID:netspotau,项目名称:moodle-report_engagement,代码行数:35,代码来源:edit_form.php


示例3: __construct

 /**
  * Constructor.
  * @throws            Command_Exception.
  */
 public function __construct()
 {
     global $DB, $STANDARD_PLUGIN_TYPES;
     // Getting command description.
     $cmd_name = vmoodle_get_string('cmdpluginsetupname', 'vmoodleadminset_plugins');
     $cmd_desc = vmoodle_get_string('cmdpluginsetupdesc', 'vmoodleadminset_plugins');
     $pm = \core_plugin_manager::instance();
     $allplugins = $pm->get_plugins();
     $pluginlist = array();
     foreach ($allplugins as $type => $plugins) {
         foreach ($plugins as $p) {
             if (array_key_exists($type, $STANDARD_PLUGIN_TYPES)) {
                 $pluginlist[$type . '/' . $p->name] = $STANDARD_PLUGIN_TYPES[$type] . ' : ' . $p->displayname;
             }
         }
     }
     asort($pluginlist, SORT_STRING);
     $plugin_param = new Command_Parameter('plugin', 'enum', vmoodle_get_string('pluginparamdesc', 'vmoodleadminset_plugins'), null, $pluginlist);
     $states = array();
     $states['enable'] = vmoodle_get_string('enable', 'vmoodleadminset_plugins');
     $states['disable'] = vmoodle_get_string('disable', 'vmoodleadminset_plugins');
     $state_param = new Command_Parameter('state', 'enum', vmoodle_get_string('pluginstateparamdesc', 'vmoodleadminset_plugins'), null, $states);
     // Creating command.
     parent::__construct($cmd_name, $cmd_desc, array($plugin_param, $state_param));
 }
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:29,代码来源:Command_Plugin_Set_State.php


示例4: enable_plugin

 /**
  * Creates a new instance of the portfolio plugin
  *
  * @param string $name name of the instance
  * @param stdClass $data config data for the instance
  * @return portfolio_plugin_base
  */
 protected function enable_plugin($name = 'Instance name', $data = null)
 {
     $data = $data ?: new stdClass();
     $instance = portfolio_static_function($this->pluginname, 'create_instance', $this->pluginname, $name, $data);
     core_plugin_manager::reset_caches();
     return $instance;
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:14,代码来源:plugin_test.php


示例5: get_filter_options

 /**
  * Retrieve the list of available filter options.
  *
  * @return  array                   An array whose keys are the valid options
  *                                  And whose values are the values to display
  */
 public static function get_filter_options()
 {
     $manager = \core_plugin_manager::instance();
     $themes = $manager->get_installed_plugins('theme');
     $options = [];
     foreach (array_keys($themes) as $themename) {
         try {
             $theme = \theme_config::load($themename);
         } catch (Exception $e) {
             // Bad theme, just skip it for now.
             continue;
         }
         if ($themename !== $theme->name) {
             // Obsoleted or broken theme, just skip for now.
             continue;
         }
         if ($theme->hidefromselector) {
             // The theme doesn't want to be shown in the theme selector and as theme
             // designer mode is switched off we will respect that decision.
             continue;
         }
         $options[$theme->name] = get_string('pluginname', "theme_{$theme->name}");
     }
     return $options;
 }
开发者ID:dg711,项目名称:moodle,代码行数:31,代码来源:theme.php


示例6: get_plugins

 /**
  * Gathers and returns the information about all plugins of the given type,
  * either on disk or previously installed.
  *
  * @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)
 {
     $return = array();
     $plugins = $pluginman->get_installed_plugins($type);
     foreach ($plugins as $name => $version) {
         $plugin = new $typeclass();
         $plugin->type = $type;
         $plugin->typerootdir = $typerootdir;
         $plugin->name = $name;
         $plugin->rootdir = null;
         $plugin->displayname = $name;
         $plugin->versiondb = $version;
         $plugin->pluginman = $pluginman;
         $plugin->init_is_standard();
         $return[$name] = $plugin;
     }
     return $return;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:28,代码来源:orphaned.php


示例7: execute

 public function execute()
 {
     $manager = \core_plugin_manager::instance();
     $types = $manager->get_plugin_types();
     ksort($types);
     foreach ($types as $type => $directory) {
         echo $type . "," . $directory . "\n";
     }
 }
开发者ID:dariogs,项目名称:moosh,代码行数:9,代码来源:InfoPlugins.php


示例8: definition

 public function definition()
 {
     $mform = $this->_form;
     /** @var \core\task\scheduled_task $task */
     $task = $this->_customdata;
     $plugininfo = core_plugin_manager::instance()->get_plugin_info($task->get_component());
     $plugindisabled = $plugininfo && $plugininfo->is_enabled() === false && !$task->get_run_if_component_disabled();
     $lastrun = $task->get_last_run_time() ? userdate($task->get_last_run_time()) : get_string('never');
     $nextrun = $task->get_next_run_time();
     if ($plugindisabled) {
         $nextrun = get_string('plugindisabled', 'tool_task');
     } else {
         if ($task->get_disabled()) {
             $nextrun = get_string('taskdisabled', 'tool_task');
         } else {
             if ($nextrun > time()) {
                 $nextrun = userdate($nextrun);
             } else {
                 $nextrun = get_string('asap', 'tool_task');
             }
         }
     }
     $mform->addElement('static', 'lastrun', get_string('lastruntime', 'tool_task'), $lastrun);
     $mform->addElement('static', 'nextrun', get_string('nextruntime', 'tool_task'), $nextrun);
     $mform->addElement('text', 'minute', get_string('taskscheduleminute', 'tool_task'));
     $mform->setType('minute', PARAM_RAW);
     $mform->addHelpButton('minute', 'taskscheduleminute', 'tool_task');
     $mform->addElement('text', 'hour', get_string('taskschedulehour', 'tool_task'));
     $mform->setType('hour', PARAM_RAW);
     $mform->addHelpButton('hour', 'taskschedulehour', 'tool_task');
     $mform->addElement('text', 'day', get_string('taskscheduleday', 'tool_task'));
     $mform->setType('day', PARAM_RAW);
     $mform->addHelpButton('day', 'taskscheduleday', 'tool_task');
     $mform->addElement('text', 'month', get_string('taskschedulemonth', 'tool_task'));
     $mform->setType('month', PARAM_RAW);
     $mform->addHelpButton('month', 'taskschedulemonth', 'tool_task');
     $mform->addElement('text', 'dayofweek', get_string('taskscheduledayofweek', 'tool_task'));
     $mform->setType('dayofweek', PARAM_RAW);
     $mform->addHelpButton('dayofweek', 'taskscheduledayofweek', 'tool_task');
     $mform->addElement('advcheckbox', 'disabled', get_string('disabled', 'tool_task'));
     $mform->addHelpButton('disabled', 'disabled', 'tool_task');
     $mform->addElement('advcheckbox', 'resettodefaults', get_string('resettasktodefaults', 'tool_task'));
     $mform->addHelpButton('resettodefaults', 'resettasktodefaults', 'tool_task');
     $mform->disabledIf('minute', 'resettodefaults', 'checked');
     $mform->disabledIf('hour', 'resettodefaults', 'checked');
     $mform->disabledIf('day', 'resettodefaults', 'checked');
     $mform->disabledIf('dayofweek', 'resettodefaults', 'checked');
     $mform->disabledIf('month', 'resettodefaults', 'checked');
     $mform->disabledIf('disabled', 'resettodefaults', 'checked');
     $mform->addElement('hidden', 'task', get_class($task));
     $mform->setType('task', PARAM_RAW);
     $mform->addElement('hidden', 'action', 'edit');
     $mform->setType('action', PARAM_ALPHANUMEXT);
     $this->add_action_buttons(true, get_string('savechanges'));
     // Do not use defaults for existing values, the set_data() is the correct way.
     $this->set_data(\core\task\manager::record_from_scheduled_task($task));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:57,代码来源:edit_scheduled_task_form.php


示例9: test_plugin_info

 /**
  * Tests the plugininfo class is present and working.
  */
 public function test_plugin_info()
 {
     // This code will throw debugging information if the plugininfo class
     // is missing. Unfortunately it doesn't actually cause the test to
     // fail, but it's obvious when running test at least.
     $pluginmanager = core_plugin_manager::instance();
     $list = $pluginmanager->get_enabled_plugins('availability');
     $this->assertEquals(array('completion', 'date', 'grade', 'group', 'grouping', 'profile'), array_keys($list));
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:12,代码来源:component_test.php


示例10: create_target

 /**
  * Returns a target object, given a name.
  */
 public static function create_target($name, $identifier = '')
 {
     // Sanity check.
     $pluginman = \core_plugin_manager::instance();
     $plugins = $pluginman->get_plugins_of_type('cattarget');
     if (!isset($plugins[$name]) || $plugins[$name]->is_enabled() === false) {
         throw new \moodle_exception("Invalid target.");
     }
     $target = "\\cattarget_{$name}\\{$name}";
     return new $target($identifier);
 }
开发者ID:unikent,项目名称:moodle-tool_cat,代码行数:14,代码来源:target.php


示例11: create_rule

 /**
  * Return a rule object, given a name.
  */
 public static function create_rule($name, $config = null)
 {
     // Sanity check.
     $pluginman = \core_plugin_manager::instance();
     $plugins = $pluginman->get_plugins_of_type('catrule');
     if (!isset($plugins[$name]) || $plugins[$name]->is_enabled() === false) {
         throw new \moodle_exception("Invalid rule.");
     }
     $ruletype = "\\catrule_{$name}\\{$name}";
     return new $ruletype($config);
 }
开发者ID:unikent,项目名称:moodle-tool_cat,代码行数:14,代码来源:rule.php


示例12: create_activity

 /**
  * Return a activity object, given a name.
  */
 public static function create_activity($name, $data = '')
 {
     // Sanity check.
     $pluginman = \core_plugin_manager::instance();
     $plugins = $pluginman->get_plugins_of_type('catactivity');
     if (!isset($plugins[$name]) || $plugins[$name]->is_enabled() === false) {
         throw new \moodle_exception("Invalid activity.");
     }
     $activity = "\\catactivity_{$name}\\{$name}";
     return new $activity($data);
 }
开发者ID:unikent,项目名称:moodle-tool_cat,代码行数:14,代码来源:activity.php


示例13: scheduled_tasks_table

 /**
  * This function will render one beautiful table with all the scheduled tasks.
  *
  * @param \core\task\scheduled_task[] $tasks - list of all scheduled tasks.
  * @return string HTML to output.
  */
 public function scheduled_tasks_table($tasks)
 {
     global $CFG;
     $table = new html_table();
     $table->head = array(get_string('name'), get_string('component', 'tool_task'), get_string('edit'), get_string('lastruntime', 'tool_task'), get_string('nextruntime', 'tool_task'), get_string('taskscheduleminute', 'tool_task'), get_string('taskschedulehour', 'tool_task'), get_string('taskscheduleday', 'tool_task'), get_string('taskscheduledayofweek', 'tool_task'), get_string('taskschedulemonth', 'tool_task'), get_string('faildelay', 'tool_task'), get_string('default', 'tool_task'));
     $table->attributes['class'] = 'admintable generaltable';
     $data = array();
     $yes = get_string('yes');
     $no = get_string('no');
     $never = get_string('never');
     $asap = get_string('asap', 'tool_task');
     $disabled = get_string('disabled', 'tool_task');
     foreach ($tasks as $task) {
         $customised = $task->is_customised() ? $no : $yes;
         $lastrun = $task->get_last_run_time() ? userdate($task->get_last_run_time()) : $never;
         $nextrun = $task->get_next_run_time();
         if ($task->get_disabled()) {
             $nextrun = $disabled;
         } else {
             if ($nextrun > time()) {
                 $nextrun = userdate($nextrun);
             } else {
                 $nextrun = $asap;
             }
         }
         if (empty($CFG->preventscheduledtaskchanges)) {
             $configureurl = new moodle_url('/admin/tool/task/scheduledtasks.php', array('action' => 'edit', 'task' => get_class($task)));
             $editlink = $this->action_icon($configureurl, new pix_icon('t/edit', get_string('edittaskschedule', 'tool_task', $task->get_name())));
         } else {
             $editlink = $this->render(new pix_icon('t/locked', get_string('scheduledtaskchangesdisabled', 'tool_task')));
         }
         $namecell = new html_table_cell($task->get_name() . "\n" . html_writer::tag('span', '\\' . get_class($task), array('class' => 'task-class')));
         $namecell->header = true;
         $component = $task->get_component();
         list($type, $plugin) = core_component::normalize_component($component);
         if ($type === 'core') {
             $componentcell = new html_table_cell(get_string('corecomponent', 'tool_task'));
         } else {
             if ($plugininfo = core_plugin_manager::instance()->get_plugin_info($component)) {
                 $plugininfo->init_display_name();
                 $componentcell = new html_table_cell($plugininfo->displayname);
             } else {
                 $componentcell = new html_table_cell($component);
             }
         }
         $row = new html_table_row(array($namecell, $componentcell, new html_table_cell($editlink), new html_table_cell($lastrun), new html_table_cell($nextrun), new html_table_cell($task->get_minute()), new html_table_cell($task->get_hour()), new html_table_cell($task->get_day()), new html_table_cell($task->get_day_of_week()), new html_table_cell($task->get_month()), new html_table_cell($task->get_fail_delay()), new html_table_cell($customised)));
         if ($task->get_disabled()) {
             $row->attributes['class'] = 'disabled';
         }
         $data[] = $row;
     }
     $table->data = $data;
     return html_writer::table($table);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:60,代码来源:renderer.php


示例14: get_instantiable_plugins

 /**
  * Finds all plugins the user can instantiate in the context. The result may include missing plugins.
  * Calls {@link \mod_dataform\plugininfo\dataformview::is_instantiable()}.
  * Returns an associative list $pluginname => $pluginname, or null if no plugin is instantiable.
  *
  * @param context $context Either course or dataform (module) context.
  * @return array|null
  */
 public static function get_instantiable_plugins($context)
 {
     $return = array();
     if (!($plugins = \core_plugin_manager::instance()->get_plugins_of_type('dataformview'))) {
         return null;
     }
     foreach ($plugins as $name => $plugin) {
         if ($plugin->is_instantiable($context)) {
             $return[$name] = $name;
         }
     }
     return $return;
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:21,代码来源:dataformview.php


示例15: get_supported_activities

 /**
  * Return a list of datatypes this target supports.
  *
  * @return array An array of valid datatypes.
  */
 public function get_supported_activities()
 {
     $pluginman = \core_plugin_manager::instance();
     $plugins = $pluginman->get_plugins_of_type('catactivity');
     $rules = array();
     foreach ($plugins as $plugin) {
         if ($plugin->is_enabled() === false) {
             continue;
         }
         $rules[] = $plugin->name;
     }
     return $rules;
 }
开发者ID:unikent,项目名称:moodle-tool_cat,代码行数:18,代码来源:activity.php


示例16: create_datatype

 /**
  * Return a datatype object, given a name.
  */
 public static function create_datatype($name, $data = '')
 {
     // Sanity check.
     $pluginman = \core_plugin_manager::instance();
     $plugins = $pluginman->get_plugins_of_type('catdatatype');
     if (!isset($plugins[$name]) || $plugins[$name]->is_enabled() === false) {
         throw new \moodle_exception("Invalid datatype.");
     }
     $datatype = "\\catdatatype_{$name}\\{$name}";
     $datatype = new $datatype($data);
     $datatype->name = $name;
     return $datatype;
 }
开发者ID:unikent,项目名称:moodle-tool_cat,代码行数:16,代码来源:datatype.php


示例17: get_rules

 /**
  * Get a list of valid rules.
  *
  * @return array [string]
  * @throws \invalid_parameter_exception
  */
 public static function get_rules()
 {
     $pluginman = \core_plugin_manager::instance();
     $plugins = $pluginman->get_plugins_of_type('catrule');
     $rules = array();
     foreach ($plugins as $plugin) {
         if ($plugin->is_enabled() === false) {
             continue;
         }
         $rules[$plugin->name] = get_string('prettyname', "{$plugin->type}_{$plugin->name}");
     }
     return $rules;
 }
开发者ID:unikent,项目名称:moodle-tool_cat,代码行数:19,代码来源:external.php


示例18: get_services

 public static function get_services($plugin)
 {
     $services = array();
     $pluginmanager = \core_plugin_manager::instance();
     $plugininfo = $pluginmanager->get_plugin_info($plugin);
     if (is_null($plugininfo)) {
         return;
     }
     $defsfile = $plugininfo->rootdir . '/db/local_nagios.php';
     if (!file_exists($defsfile)) {
         return;
     }
     include $defsfile;
     return $services;
 }
开发者ID:pauln,项目名称:local_nagios,代码行数:15,代码来源:service.php


示例19: get_enabled_plugins

 public static function get_enabled_plugins()
 {
     global $DB;
     // Get all available plugins.
     $plugins = \core_plugin_manager::instance()->get_installed_plugins('availability');
     if (!$plugins) {
         return array();
     }
     // Check they are enabled using get_config (which is cached and hopefully fast).
     $enabled = array();
     foreach ($plugins as $plugin => $version) {
         $disabled = get_config('availability_' . $plugin, 'disabled');
         if (empty($disabled)) {
             $enabled[$plugin] = $plugin;
         }
     }
     return $enabled;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:18,代码来源:availability.php


示例20: xmldb_tool_usertours_install

/**
 * Perform the post-install procedures.
 */
function xmldb_tool_usertours_install()
{
    global $DB;
    $localplugin = core_plugin_manager::instance()->get_plugin_info('local_usertours');
    if ($localplugin) {
        // If the old local plugin was previously installed, copy over the data from the old tables.
        // The 'comment' field was renamed to 'description' in:
        // * 3.0 version 2015111604
        // * 3.1 version 2016052303
        // We need to attempt to fetch comment for these older versions.
        $hasdescription = $localplugin->versiondb < 2016052301 && $localplugin->versiondb >= 2015111604;
        $hasdescription = $hasdescription || $localplugin->versiondb > 2016052303;
        $tours = $DB->get_recordset('usertours_tours');
        $mapping = [];
        foreach ($tours as $tour) {
            if (!$hasdescription) {
                if (property_exists($tour, 'comment')) {
                    $tour->description = $tour->comment;
                    unset($tour->comment);
                } else {
                    $tour->description = '';
                }
            }
            $mapping[$tour->id] = $DB->insert_record('tool_usertours_tours', $tour);
        }
        $tours->close();
        $steps = $DB->get_recordset('usertours_steps');
        foreach ($steps as $step) {
            if (!isset($mapping[$step->tourid])) {
                // Skip this one. It has somehow become orphaned.
                continue;
            }
            $step->tourid = $mapping[$step->tourid];
            $DB->insert_record('tool_usertours_steps', $step);
        }
        $steps->close();
        // Delete the old records.
        $DB->delete_records('usertours_steps', null);
        $DB->delete_records('usertours_tours', null);
    }
    // Update the tours shipped with Moodle.
    manager::update_shipped_tours();
}
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:46,代码来源:install.php



注:本文中的core_plugin_manager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP core_renderer类代码示例发布时间:2022-05-23
下一篇:
PHP core_php_time_limit类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap