本文整理汇总了PHP中update_capabilities函数的典型用法代码示例。如果您正苦于以下问题:PHP update_capabilities函数的具体用法?PHP update_capabilities怎么用?PHP update_capabilities使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_capabilities函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_block_taskchain_navigation_upgrade
function xmldb_block_taskchain_navigation_upgrade($oldversion = 0)
{
global $CFG, $DB;
$result = true;
$newversion = 2014051601;
if ($oldversion < $newversion) {
update_capabilities('block/taskchain_navigation');
upgrade_block_savepoint($result, "{$newversion}", 'taskchain_navigation');
}
return $result;
}
示例2: 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');
}
示例3: xmldb_enrol_category_install
function xmldb_enrol_category_install()
{
global $CFG, $DB;
if (!$DB->record_exists_select('role_assignments', "contextid IN (SELECT id FROM {context} WHERE contextlevel = ?)", array(CONTEXT_COURSECAT))) {
// fresh install or nobody used category enrol
return;
}
// existing sites need a way to keep category role enrols, but we do not want to encourage that on new sites
// extremely ugly hack, the sync depends on the capabilities so we unfortunately force update of caps here
// note: this is not officially supported and should not be copied elsewhere! :-(
update_capabilities('enrol_category');
$syscontext = get_context_instance(CONTEXT_SYSTEM);
$archetypes = array('student', 'teacher', 'editingteacher');
$enableplugin = false;
foreach ($archetypes as $archetype) {
$roles = get_archetype_roles($archetype);
foreach ($roles as $role) {
if (!$DB->record_exists_select('role_assignments', "roleid = ? AND contextid IN (SELECT id FROM {context} WHERE contextlevel = ?)", array($role->id, CONTEXT_COURSECAT))) {
continue;
}
assign_capability('enrol/category:synchronised', CAP_ALLOW, $role->id, $syscontext->id, true);
$levels = get_role_contextlevels($role->id);
$levels[] = CONTEXT_COURSECAT;
set_role_contextlevels($role->id, $levels);
$enableplugin = true;
}
}
if (!$enableplugin) {
return;
}
// enable this plugin
$enabledplugins = explode(',', $CFG->enrol_plugins_enabled);
$enabledplugins[] = 'category';
$enabledplugins = array_unique($enabledplugins);
set_config('enrol_plugins_enabled', implode(',', $enabledplugins));
// brute force course resync, this may take a while
require_once "{$CFG->dirroot}/enrol/category/locallib.php";
enrol_category_sync_full();
}
示例4: main_upgrade
$status = main_upgrade($CFG->version);
}
/// If succesful and exists launch the new main upgrade (XMLDB), called xmldb_main_upgrade
if ($status && function_exists('xmldb_main_upgrade')) {
$status = xmldb_main_upgrade($CFG->version);
}
$db->debug = false;
/// If successful, continue upgrading roles and setting everything properly
if ($status) {
if (empty($CFG->rolesactive)) {
/// Groups upgrade is now in core above.
// Upgrade to the roles system.
moodle_install_roles();
set_config('rolesactive', 1);
} else {
if (!update_capabilities()) {
error('Had trouble upgrading the core capabilities for the Roles System');
}
}
// update core events
events_update_definition();
require_once $CFG->libdir . '/statslib.php';
if (!stats_upgrade_for_roles_wrapper()) {
notify('Couldn\'t upgrade the stats tables to use the new roles system');
}
if (set_config("version", $version)) {
remove_dir($CFG->dataroot . '/cache', true);
// flush cache
notify($strdatabasesuccess, "green");
print_continue("upgradesettings.php");
print_footer('none');
示例5: upgrade_core
/**
* Upgrade moodle core
* @param float $version target version
* @param bool $verbose
* @return void, may throw exception
*/
function upgrade_core($version, $verbose) {
global $CFG;
raise_memory_limit(MEMORY_EXTRA);
require_once($CFG->libdir.'/db/upgrade.php'); // Defines upgrades
try {
// Reset caches before any output
purge_all_caches();
// Upgrade current language pack if we can
upgrade_language_pack();
print_upgrade_part_start('moodle', false, $verbose);
// one time special local migration pre 2.0 upgrade script
if ($CFG->version < 2007101600) {
$pre20upgradefile = "$CFG->dirroot/local/upgrade_pre20.php";
if (file_exists($pre20upgradefile)) {
set_time_limit(0);
require($pre20upgradefile);
// reset upgrade timeout to default
upgrade_set_timeout();
}
}
$result = xmldb_main_upgrade($CFG->version);
if ($version > $CFG->version) {
// store version if not already there
upgrade_main_savepoint($result, $version, false);
}
// perform all other component upgrade routines
update_capabilities('moodle');
log_update_descriptions('moodle');
external_update_descriptions('moodle');
events_update_definition('moodle');
message_update_providers('moodle');
// Reset caches again, just to be sure
purge_all_caches();
// Clean up contexts - more and more stuff depends on existence of paths and contexts
context_helper::cleanup_instances();
context_helper::create_instances(null, false);
context_helper::build_all_paths(false);
$syscontext = context_system::instance();
$syscontext->mark_dirty();
print_upgrade_part_end('moodle', false, $verbose);
} catch (Exception $ex) {
upgrade_handle_exception($ex);
}
}
示例6: upgrade_local_dbs
/**
* This function checks to see whether local database customisations are up-to-date
* by comparing $CFG->local_version to the variable $local_version defined in
* local/version.php. If not, it looks for a function called 'xmldb_local_upgrade'
* in a file called 'local/db/upgrade.php', and if it's there calls it with the
* appropiate $oldversion parameter. Then it updates $CFG->local_version.
* On success it prints a continue link. On failure it prints an error.
*
* @uses $CFG
* @uses $db to do something really evil with the debug setting that should probably be eliminated. TODO!
* @param string $continueto a URL passed to print_continue() if the local upgrades succeed.
*/
function upgrade_local_dbs($continueto)
{
global $CFG, $db;
$path = '/local';
$pat = 'local';
$status = true;
$changed = false;
$firstloop = true;
while (is_dir($CFG->dirroot . $path)) {
// if we don't have code version or a db upgrade file, check lower
if (!file_exists($CFG->dirroot . "{$path}/version.php") || !file_exists($CFG->dirroot . "{$path}/db/upgrade.php")) {
$path .= '/local';
$pat .= 'local';
continue;
}
require_once $CFG->dirroot . "{$path}/version.php";
// Get code versions
$cfgvarname = "{$pat}_version";
if (empty($CFG->{$cfgvarname})) {
// normally we'd install, but just replay all the upgrades.
$CFG->{$cfgvarname} = 0;
}
$localversionvar = "{$pat}_version";
// echo "($localversionvar) ".$$localversionvar." > ($cfgvarname) ".$CFG->{$cfgvarname}."<br/>";
if (${$localversionvar} > $CFG->{$cfgvarname}) {
// something upgrades!
upgrade_log_start();
/// Capabilities
/// do this first *instead of* last , so that the installer has the chance to locally assign caps
if (!update_capabilities($pat)) {
error('Could not set up the capabilities for ' . $pat . '!');
}
if ($firstloop) {
$strdatabaseupgrades = get_string('databaseupgrades');
print_header($strdatabaseupgrades, $strdatabaseupgrades, build_navigation(array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript());
$firstloop = false;
}
$changed = true;
require_once $CFG->dirroot . "{$path}/db/upgrade.php";
$db->debug = true;
$upgradefunc = "xmldb_{$pat}_upgrade";
if ($upgradefunc($CFG->{$cfgvarname})) {
$db->debug = false;
if (set_config($localversionvar, ${$localversionvar})) {
notify(get_string('databasesuccess'), 'notifysuccess');
notify(get_string('databaseupgradelocal', '', $path . ' >> ' . ${$localversionvar}), 'notifysuccess');
} else {
$status = false;
error('Upgrade of local database customisations failed in $path! (Could not update version in config table)');
}
} else {
$db->debug = false;
error("Upgrade failed! See {$path}/version.php");
}
if (!events_update_definition($pat)) {
error('Could not set up the events definitions for ' . $pat . '!');
}
upgrade_log_finish();
} else {
if (${$localversionvar} < $CFG->{$cfgvarname}) {
notify("WARNING!!! The local version you are using in {$path} is OLDER than the version that made these databases!");
}
}
$path .= '/local';
$pat .= 'local';
}
if ($changed) {
print_continue($continueto);
print_footer('none');
exit;
}
}
示例7: upgrade_blocks_plugins
//.........这里部分代码省略.........
$newupgrade_function = 'xmldb_block_' . $block->name . '_upgrade';
/// First, the old function if exists
$oldupgrade_status = true;
if ($oldupgrade && function_exists($oldupgrade_function)) {
$db->debug = true;
$oldupgrade_status = $oldupgrade_function($currblock->version, $block);
} else {
if ($oldupgrade) {
notify('Upgrade function ' . $oldupgrade_function . ' was not available in ' . $fullblock . '/db/' . $CFG->dbtype . '.php');
}
}
/// Then, the new function if exists and the old one was ok
$newupgrade_status = true;
if ($newupgrade && function_exists($newupgrade_function) && $oldupgrade_status) {
$db->debug = true;
$newupgrade_status = $newupgrade_function($currblock->version, $block);
} else {
if ($newupgrade) {
notify('Upgrade function ' . $newupgrade_function . ' was not available in ' . $fullblock . '/db/upgrade.php');
}
}
$db->debug = false;
/// Now analyze upgrade results
if ($oldupgrade_status && $newupgrade_status) {
// No upgrading failed
// Set the block cron on upgrade
$block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0;
// OK so far, now update the block record
$block->id = $currblock->id;
if (!update_record('block', $block)) {
error('Could not update block ' . $block->name . ' record in block table!');
}
$component = 'block/' . $block->name;
if (!update_capabilities($component)) {
error('Could not update ' . $block->name . ' capabilities!');
}
events_update_definition($component);
notify(get_string('blocksuccess', '', $blocktitle), 'notifysuccess');
} else {
notify('Upgrading block ' . $block->name . ' from ' . $currblock->version . ' to ' . $block->version . ' FAILED!');
}
echo '<hr />';
} else {
upgrade_log_start();
error('Version mismatch: block ' . $block->name . ' can\'t downgrade ' . $currblock->version . ' -> ' . $block->version . '!');
}
}
} else {
// block not installed yet, so install it
// If it allows multiples, start with it enabled
if ($blockobj->instance_allow_multiple()) {
$block->multiple = 1;
}
// Set the block cron on install
$block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0;
// [pj] Normally this would be inline in the if, but we need to
// check for NULL (necessary for 4.0.5 <= PHP < 4.2.0)
$conflictblock = array_search($blocktitle, $blocktitles);
if ($conflictblock !== false && $conflictblock !== NULL) {
// Duplicate block titles are not allowed, they confuse people
// AND PHP's associative arrays ;)
error('<strong>Naming conflict</strong>: block <strong>' . $block->name . '</strong> has the same title with an existing block, <strong>' . $conflictblock . '</strong>!');
}
if (empty($updated_blocks)) {
$strblocksetup = get_string('blocksetup');
print_header($strblocksetup, $strblocksetup, build_navigation(array(array('name' => $strblocksetup, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, ' ', ' ');
示例8: test_get_users_by_capability
function test_get_users_by_capability()
{
global $CFG;
$tablenames = array('capabilities', 'context', 'role', 'role_capabilities', 'role_allow_assign', 'role_allow_override', 'role_assignments', 'role_context_levels', 'user', 'groups_members', 'cache_flags', 'events_handlers', 'user_lastaccess', 'course');
$this->create_test_tables($tablenames, 'lib');
accesslib_clear_all_caches_for_unit_testing();
$this->switch_to_test_db();
$this->switch_to_test_cfg();
$course = new stdClass();
$course->category = 0;
$this->testdb->insert_record('course', $course);
$syscontext = get_system_context(false);
/// Install the roles system.
$coursecreatorrole = create_role(get_string('coursecreators'), 'coursecreator', get_string('coursecreatorsdescription'), 'coursecreator');
$editteacherrole = create_role(get_string('defaultcourseteacher'), 'editingteacher', get_string('defaultcourseteacherdescription'), 'editingteacher');
$noneditteacherrole = create_role(get_string('noneditingteacher'), 'teacher', get_string('noneditingteacherdescription'), 'teacher');
$studentrole = create_role(get_string('defaultcoursestudent'), 'student', get_string('defaultcoursestudentdescription'), 'student');
$guestrole = create_role(get_string('guest'), 'guest', get_string('guestdescription'), 'guest');
$userrole = create_role(get_string('authenticateduser'), 'user', get_string('authenticateduserdescription'), 'user');
/// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles
update_capabilities('moodle');
update_capabilities('mod_forum');
update_capabilities('mod_quiz');
// Create some nested contexts. instanceid does not matter for this. Just
// ensure we don't violate any unique keys by using an unlikely number.
// We will fix paths in a second.
$contexts = $this->load_test_data('context', array('contextlevel', 'instanceid', 'path', 'depth'), array(1 => array(40, 666, '', 2), 2 => array(50, 666, '', 3), 3 => array(70, 666, '', 4)));
$contexts[0] = $syscontext;
$contexts[1]->path = $contexts[0]->path . '/' . $contexts[1]->id;
$this->testdb->set_field('context', 'path', $contexts[1]->path, array('id' => $contexts[1]->id));
$contexts[2]->path = $contexts[1]->path . '/' . $contexts[2]->id;
$this->testdb->set_field('context', 'path', $contexts[2]->path, array('id' => $contexts[2]->id));
$contexts[3]->path = $contexts[2]->path . '/' . $contexts[3]->id;
$this->testdb->set_field('context', 'path', $contexts[3]->path, array('id' => $contexts[3]->id));
// Now make some test users.
$users = $this->load_test_data('user', array('username', 'confirmed', 'deleted'), array('a' => array('a', 1, 0), 'cc' => array('cc', 1, 0), 't1' => array('t1', 1, 0), 's1' => array('s1', 1, 0), 's2' => array('s2', 1, 0), 'del' => array('del', 1, 1), 'unc' => array('unc', 0, 0)));
// Get some of the standard roles.
$creator = $this->testdb->get_record('role', array('shortname' => 'coursecreator'));
$teacher = $this->testdb->get_record('role', array('shortname' => 'editingteacher'));
$student = $this->testdb->get_record('role', array('shortname' => 'student'));
$authuser = $this->testdb->get_record('role', array('shortname' => 'user'));
// And some role assignments.
$ras = $this->load_test_data('role_assignments', array('userid', 'roleid', 'contextid'), array('cc' => array($users['cc']->id, $creator->id, $contexts[1]->id), 't1' => array($users['t1']->id, $teacher->id, $contexts[2]->id), 's1' => array($users['s1']->id, $student->id, $contexts[2]->id), 's2' => array($users['s2']->id, $student->id, $contexts[2]->id)));
// And make user a into admin
$CFG->siteadmins = $users['a']->id;
$CFG->defaultuserroleid = $userrole;
// And some group memebership.
$gms = $this->load_test_data('groups_members', array('userid', 'groupid'), array(array($users['t1']->id, 666), array($users['s1']->id, 666), array($users['s2']->id, 667)));
// Test some simple cases - check that looking in coruse and module contextlevel gives the same answer.
foreach (array(2, 3) as $conindex) {
$results = get_users_by_capability($contexts[$conindex], 'mod/forum:replypost');
// note: admin accounts are never returned, so no admin return here
$this->assert(new ArraysHaveSameValuesExpectation(array($users['t1']->id, $users['s1']->id, $users['s2']->id)), array_map(create_function('$o', 'return $o->id;'), $results));
// Paging.
$firstuser = reset($results);
$this->assertEqual(array($firstuser->id => $firstuser), get_users_by_capability($contexts[$conindex], 'mod/forum:replypost', '', '', 0, 1));
$seconduser = next($results);
$this->assertEqual(array($seconduser->id => $seconduser), get_users_by_capability($contexts[$conindex], 'mod/forum:replypost', '', '', 1, 1));
// $doanything = false (ignored now)
$this->assert(new ArraysHaveSameValuesExpectation(array($users['t1']->id, $users['s1']->id, $users['s2']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[$conindex], 'mod/forum:replypost', '', '', '', '', '', '', false)));
// group
$this->assert(new ArraysHaveSameValuesExpectation(array($users['t1']->id, $users['s1']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[$conindex], 'mod/forum:replypost', '', '', '', '', 666)));
// exceptions
$this->assert(new ArraysHaveSameValuesExpectation(array($users['s1']->id, $users['s2']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[$conindex], 'mod/forum:replypost', '', '', '', '', '', array($users['t1']->id))));
$this->assert(new ArraysHaveSameValuesExpectation(array($users['s1']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[$conindex], 'mod/forum:replypost', '', '', '', '', 666, array($users['t1']->id))));
// $useviewallgroups
$this->assert(new ArraysHaveSameValuesExpectation(array($users['t1']->id, $users['s2']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[$conindex], 'mod/forum:replypost', '', '', '', '', 667, '', false, false, true)));
// More than one capability.
$this->assert(new ArraysHaveSameValuesExpectation(array($users['s1']->id, $users['s2']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[$conindex], array('mod/quiz:attempt', 'mod/quiz:reviewmyattempts'))));
}
// For reference: get_users_by_capability argument order:
// $context, $capability, $fields='', $sort='', $limitfrom='', $limitnum='',
// $groups='', $exceptions='', $doanything=true, $view=false, $useviewallgroups=false
// Now add some role overrides.
$rcs = $this->load_test_data('role_capabilities', array('capability', 'roleid', 'contextid', 'permission'), array(array('mod/forum:replypost', $student->id, $contexts[1]->id, CAP_PREVENT), array('mod/forum:replypost', $student->id, $contexts[3]->id, CAP_ALLOW), array('mod/quiz:attempt', $student->id, $contexts[2]->id, CAP_PREVENT), array('mod/forum:startdiscussion', $student->id, $contexts[1]->id, CAP_PROHIBIT), array('mod/forum:startdiscussion', $student->id, $contexts[3]->id, CAP_ALLOW), array('mod/forum:viewrating', $authuser->id, $contexts[1]->id, CAP_PROHIBIT), array('mod/forum:createattachment', $authuser->id, $contexts[3]->id, CAP_PREVENT)));
// Now test the overridden cases.
// Students prevented at category level, with and without doanything.
$this->assert(new ArraysHaveSameValuesExpectation(array($users['t1']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[2], 'mod/forum:replypost')));
$this->assert(new ArraysHaveSameValuesExpectation(array($users['t1']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[2], 'mod/forum:replypost', '', '', '', '', '', '', false)));
// Students prevented at category level, but re-allowed at module level, with and without doanything.
$this->assert(new ArraysHaveSameValuesExpectation(array($users['t1']->id, $users['s1']->id, $users['s2']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[3], 'mod/forum:replypost', '', '', '', '', '', '', false)));
$this->assert(new ArraysHaveSameValuesExpectation(array($users['t1']->id, $users['s1']->id, $users['s2']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[3], 'mod/forum:replypost')));
// Students prohibited at category level, re-allowed at module level should have no effect.
$this->assert(new ArraysHaveSameValuesExpectation(array($users['t1']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[2], 'mod/forum:startdiscussion')));
$this->assert(new ArraysHaveSameValuesExpectation(array($users['t1']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[3], 'mod/forum:startdiscussion')));
// Prevent on logged-in user should be overridden by student allow.
$this->assert(new ArraysHaveSameValuesExpectation(array($users['t1']->id, $users['s1']->id, $users['s2']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[3], 'mod/forum:createattachment')));
// Prohibit on logged-in user should trump student/teacher allow.
$this->assert(new ArraysHaveSameValuesExpectation(array()), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[3], 'mod/forum:viewrating')));
// More than one capability, where students have one, but not the other.
$this->assert(new ArraysHaveSameValuesExpectation(array($users['s1']->id, $users['s2']->id)), array_map(create_function('$o', 'return $o->id;'), get_users_by_capability($contexts[3], array('mod/quiz:attempt', 'mod/quiz:reviewmyattempts'), '', '', '', '', '', '', false)));
}
示例9: xmldb_main_install
//.........这里部分代码省略.........
/// Create guest record - do not assign any role, guest user get's the default guest role automatically on the fly
$guest = new stdClass();
$guest->auth = 'manual';
$guest->username = 'guest';
$guest->password = hash_internal_user_password('guest');
$guest->firstname = get_string('guestuser');
$guest->lastname = ' ';
$guest->email = 'root@localhost';
$guest->description = get_string('guestuserinfo');
$guest->mnethostid = $CFG->mnet_localhost_id;
$guest->confirmed = 1;
$guest->lang = $CFG->lang;
$guest->timemodified = time();
$guest->id = $DB->insert_record('user', $guest);
if ($guest->id != 1) {
echo $OUTPUT->notification('Unexpected id generated for the Guest account. Your database configuration or clustering setup may not be fully supported', 'notifyproblem');
}
// Store guest id
set_config('siteguest', $guest->id);
/// Now create admin user
$admin = new stdClass();
$admin->auth = 'manual';
$admin->firstname = get_string('admin');
$admin->lastname = get_string('user');
$admin->username = 'admin';
$admin->password = 'adminsetuppending';
$admin->email = '';
$admin->confirmed = 1;
$admin->mnethostid = $CFG->mnet_localhost_id;
$admin->lang = $CFG->lang;
$admin->maildisplay = 1;
$admin->timemodified = time();
$admin->lastip = CLI_SCRIPT ? '0.0.0.0' : getremoteaddr();
// installation hijacking prevention
$admin->id = $DB->insert_record('user', $admin);
if ($admin->id != 2) {
echo $OUTPUT->notification('Unexpected id generated for the Admin account. Your database configuration or clustering setup may not be fully supported', 'notifyproblem');
}
if ($admin->id != $guest->id + 1) {
echo $OUTPUT->notification('Nonconsecutive id generated for the Admin account. Your database configuration or clustering setup may not be fully supported.', 'notifyproblem');
}
/// Store list of admins
set_config('siteadmins', $admin->id);
/// Install the roles system.
$managerrole = create_role(get_string('manager', 'role'), 'manager', get_string('managerdescription', 'role'), 'manager');
$coursecreatorrole = create_role(get_string('coursecreators'), 'coursecreator', get_string('coursecreatorsdescription'), 'coursecreator');
$editteacherrole = create_role(get_string('defaultcourseteacher'), 'editingteacher', get_string('defaultcourseteacherdescription'), 'editingteacher');
$noneditteacherrole = create_role(get_string('noneditingteacher'), 'teacher', get_string('noneditingteacherdescription'), 'teacher');
$studentrole = create_role(get_string('defaultcoursestudent'), 'student', get_string('defaultcoursestudentdescription'), 'student');
$guestrole = create_role(get_string('guest'), 'guest', get_string('guestdescription'), 'guest');
$userrole = create_role(get_string('authenticateduser'), 'user', get_string('authenticateduserdescription'), 'user');
$frontpagerole = create_role(get_string('frontpageuser', 'role'), 'frontpage', get_string('frontpageuserdescription', 'role'), 'frontpage');
/// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles
update_capabilities('moodle');
/// Default allow assign
$defaultallowassigns = array(array($managerrole, $managerrole), array($managerrole, $coursecreatorrole), array($managerrole, $editteacherrole), array($managerrole, $noneditteacherrole), array($managerrole, $studentrole), array($editteacherrole, $noneditteacherrole), array($editteacherrole, $studentrole));
foreach ($defaultallowassigns as $allow) {
list($fromroleid, $toroleid) = $allow;
allow_assign($fromroleid, $toroleid);
}
/// Default allow override
$defaultallowoverrides = array(array($managerrole, $managerrole), array($managerrole, $coursecreatorrole), array($managerrole, $editteacherrole), array($managerrole, $noneditteacherrole), array($managerrole, $studentrole), array($managerrole, $guestrole), array($managerrole, $userrole), array($managerrole, $frontpagerole), array($editteacherrole, $noneditteacherrole), array($editteacherrole, $studentrole), array($editteacherrole, $guestrole));
foreach ($defaultallowoverrides as $allow) {
list($fromroleid, $toroleid) = $allow;
allow_override($fromroleid, $toroleid);
// There is a rant about this in MDL-15841.
}
/// Default allow switch.
$defaultallowswitch = array(array($managerrole, $editteacherrole), array($managerrole, $noneditteacherrole), array($managerrole, $studentrole), array($managerrole, $guestrole), array($editteacherrole, $noneditteacherrole), array($editteacherrole, $studentrole), array($editteacherrole, $guestrole), array($noneditteacherrole, $studentrole), array($noneditteacherrole, $guestrole));
foreach ($defaultallowswitch as $allow) {
list($fromroleid, $toroleid) = $allow;
allow_switch($fromroleid, $toroleid);
}
/// Set up the context levels where you can assign each role.
set_role_contextlevels($managerrole, get_default_contextlevels('manager'));
set_role_contextlevels($coursecreatorrole, get_default_contextlevels('coursecreator'));
set_role_contextlevels($editteacherrole, get_default_contextlevels('editingteacher'));
set_role_contextlevels($noneditteacherrole, get_default_contextlevels('teacher'));
set_role_contextlevels($studentrole, get_default_contextlevels('student'));
set_role_contextlevels($guestrole, get_default_contextlevels('guest'));
set_role_contextlevels($userrole, get_default_contextlevels('user'));
// Init themes
set_config('themerev', 1);
// Install licenses
require_once $CFG->libdir . '/licenselib.php';
license_manager::install_licenses();
/// Add two lines of data into this new table
$mypage = new stdClass();
$mypage->userid = NULL;
$mypage->name = '__default';
$mypage->private = 0;
$mypage->sortorder = 0;
if (!$DB->record_exists('my_pages', array('userid' => NULL, 'private' => 0))) {
$DB->insert_record('my_pages', $mypage);
}
$mypage->private = 1;
if (!$DB->record_exists('my_pages', array('userid' => NULL, 'private' => 1))) {
$DB->insert_record('my_pages', $mypage);
}
}
示例10: test_everything_in_accesslib
/**
* A small functional test of accesslib functions and classes.
*/
public function test_everything_in_accesslib()
{
global $USER, $SITE, $CFG, $DB, $ACCESSLIB_PRIVATE;
// First of all finalize the session, we must not carry over any of this mess to the next page via SESSION!!!
session_get_instance()->write_close();
// hack - this is going to take very long time
set_time_limit(3600);
// Get rid of current user that would not work anyway,
// do NOT even think about using $this->switch_global_user_id()!
if (!isset($this->accesslibprevuser)) {
$this->accesslibprevuser = clone $USER;
$USER = new stdClass();
$USER->id = 0;
}
// Backup $SITE global
if (!isset($this->accesslibprevsite)) {
$this->accesslibprevsite = $SITE;
}
// Switch DB, if it somehow fails or you specified wrong unittest prefix it will nuke real data, you have been warned!
$this->switch_to_test_db();
// Let's switch the CFG
$prevcfg = clone $CFG;
$this->switch_to_test_cfg();
$CFG->config_php_settings = $prevcfg->config_php_settings;
$CFG->noemailever = true;
$CFG->admin = $prevcfg->admin;
$CFG->lang = 'en';
$CFG->tempdir = $prevcfg->tempdir;
$CFG->cachedir = $prevcfg->cachedir;
$CFG->directorypermissions = $prevcfg->directorypermissions;
$CFG->filepermissions = $prevcfg->filepermissions;
// Reset all caches
accesslib_clear_all_caches_for_unit_testing();
// Add some core tables - this is known to break constantly because we keep adding dependencies...
$tablenames = array('config', 'config_plugins', 'modules', 'course', 'course_modules', 'course_sections', 'course_categories', 'mnet_host', 'mnet_application', 'capabilities', 'context', 'context_temp', 'role', 'role_capabilities', 'role_allow_switch', 'license', 'my_pages', 'block', 'block_instances', 'block_positions', 'role_allow_assign', 'role_allow_override', 'role_assignments', 'role_context_levels', 'enrol', 'user_enrolments', 'filter_active', 'filter_config', 'comments', 'user', 'groups_members', 'cache_flags', 'events_handlers', 'user_lastaccess', 'rating', 'files', 'role_names', 'user_preferences');
$this->create_test_tables($tablenames, 'lib');
// Create all core default records and default settings
require_once "{$CFG->libdir}/db/install.php";
xmldb_main_install();
// installs the capabilities too
// Fake mod_page install
$tablenames = array('page');
$this->create_test_tables($tablenames, 'mod/page');
$module = new stdClass();
require $CFG->dirroot . '/mod/page/version.php';
$module->name = 'page';
$pagemoduleid = $DB->insert_record('modules', $module);
update_capabilities('mod_page');
// Fake block_online_users install
$plugin = new stdClass();
$plugin->version = NULL;
$plugin->cron = 0;
include $CFG->dirroot . '/blocks/online_users/version.php';
$plugin->name = 'online_users';
$onlineusersblockid = $DB->insert_record('block', $plugin);
update_capabilities('block_online_users');
// Finish roles setup
set_config('defaultfrontpageroleid', $DB->get_field('role', 'id', array('archetype' => 'frontpage')));
set_config('defaultuserroleid', $DB->get_field('role', 'id', array('archetype' => 'user')));
set_config('notloggedinroleid', $DB->get_field('role', 'id', array('archetype' => 'guest')));
set_config('rolesactive', 1);
// Init manual enrol
set_config('status', ENROL_INSTANCE_ENABLED, 'enrol_manual');
set_config('defaultperiod', 0, 'enrol_manual');
$manualenrol = enrol_get_plugin('manual');
// Fill the site with some real data
$testcategories = array();
$testcourses = array();
$testpages = array();
$testblocks = array();
$allroles = $DB->get_records_menu('role', array(), 'id', 'archetype, id');
$systemcontext = context_system::instance();
$frontpagecontext = context_course::instance(SITEID);
// Add block to system context
$bi = new stdClass();
$bi->blockname = 'online_users';
$bi->parentcontextid = $systemcontext->id;
$bi->showinsubcontexts = 1;
$bi->pagetypepattern = '';
$bi->subpagepattern = '';
$bi->defaultregion = '';
$bi->defaultweight = 0;
$bi->configdata = '';
$biid = $DB->insert_record('block_instances', $bi);
context_block::instance($biid);
$testblocks[] = $biid;
// Some users
$testusers = array();
for ($i = 0; $i < 20; $i++) {
$user = new stdClass();
$user->auth = 'manual';
$user->firstname = 'user' . $i;
$user->lastname = 'user' . $i;
$user->username = 'user' . $i;
$user->password = 'doesnotexist';
$user->email = "user{$i}@example.com";
$user->confirmed = 1;
//.........这里部分代码省略.........
示例11: upgrade_local_db
/**
* This function checks to see whether local database customisations are up-to-date
* by comparing $CFG->local_version to the variable $local_version defined in
* local/version.php. If not, it looks for a function called 'xmldb_local_upgrade'
* in a file called 'local/db/upgrade.php', and if it's there calls it with the
* appropiate $oldversion parameter. Then it updates $CFG->local_version.
*
* @uses $CFG
*/
function upgrade_local_db($startcallback, $endcallback)
{
global $CFG, $DB;
// if we don't have code version, just return false
if (!file_exists($CFG->dirroot . '/local/version.php')) {
return;
}
$local_version = null;
require $CFG->dirroot . '/local/version.php';
// Get code versions
if (empty($CFG->local_version)) {
// install
$startcallback('local', true);
if (file_exists($CFG->dirroot . '/local/db/install.php')) {
require_once $CFG->dirroot . '/local/db/install.php';
xmldb_local_install();
}
set_config('local_version', $local_version);
/// Install various components
events_update_definition('local');
update_capabilities('local');
message_update_providers('local');
$endcallback('local', true);
} else {
if ($local_version > $CFG->local_version) {
// upgrade!
$startcallback('local', false);
if (file_exists($CFG->dirroot . '/local/db/upgrade.php')) {
require_once $CFG->dirroot . '/local/db/upgrade.php';
xmldb_local_upgrade($CFG->local_version);
}
set_config('local_version', $local_version);
/// Upgrade various components
events_update_definition('local');
update_capabilities('local');
message_update_providers('local');
$endcallback('local', false);
} else {
if ($local_version < $CFG->local_version) {
throw new downgrade_exception('local', $CFG->local_version, $local_version);
}
}
}
}
示例12: xmldb_main_install
//.........这里部分代码省略.........
$mnethost->ip_address = $_SERVER['SERVER_ADDR'];
}
$mnetid = $DB->insert_record('mnet_host', $mnethost);
set_config('mnet_localhost_id', $mnetid);
// Initial insert of mnet applications info
$mnet_app = new object();
$mnet_app->name = 'moodle';
$mnet_app->display_name = 'Moodle';
$mnet_app->xmlrpc_server_url = '/mnet/xmlrpc/server.php';
$mnet_app->sso_land_url = '/auth/mnet/land.php';
$mnet_app->sso_jump_url = '/auth/mnet/land.php';
$DB->insert_record('mnet_application', $mnet_app);
$mnet_app = new object();
$mnet_app->name = 'mahara';
$mnet_app->display_name = 'Mahara';
$mnet_app->xmlrpc_server_url = '/api/xmlrpc/server.php';
$mnet_app->sso_land_url = '/auth/xmlrpc/land.php';
$mnet_app->sso_jump_url = '/auth/xmlrpc/jump.php';
$DB->insert_record('mnet_application', $mnet_app);
/// insert log entries - replaces statements section in install.xml
update_log_display_entry('user', 'view', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('course', 'user report', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('course', 'view', 'course', 'fullname');
update_log_display_entry('course', 'update', 'course', 'fullname');
update_log_display_entry('course', 'enrol', 'course', 'fullname');
update_log_display_entry('course', 'unenrol', 'course', 'fullname');
update_log_display_entry('course', 'report log', 'course', 'fullname');
update_log_display_entry('course', 'report live', 'course', 'fullname');
update_log_display_entry('course', 'report outline', 'course', 'fullname');
update_log_display_entry('course', 'report participation', 'course', 'fullname');
update_log_display_entry('course', 'report stats', 'course', 'fullname');
update_log_display_entry('message', 'write', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('message', 'read', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('message', 'add contact', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('message', 'remove contact', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('message', 'block contact', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('message', 'unblock contact', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('group', 'view', 'groups', 'name');
/// Create guest record
$guest = new object();
$guest->auth = 'manual';
$guest->username = 'guest';
$guest->password = hash_internal_user_password('guest');
$guest->firstname = get_string('guestuser');
$guest->lastname = ' ';
$guest->email = 'root@localhost';
$guest->description = get_string('guestuserinfo');
$guest->mnethostid = $CFG->mnet_localhost_id;
$guest->confirmed = 1;
$guest->lang = $CFG->lang;
$guest->timemodified = time();
$guest->id = $DB->insert_record('user', $guest);
/// Now create admin user
$admin = new object();
$admin->auth = 'manual';
$admin->firstname = get_string('admin');
$admin->lastname = get_string('user');
$admin->username = 'admin';
$admin->password = 'adminsetuppending';
$admin->email = '';
$admin->confirmed = 1;
$admin->mnethostid = $CFG->mnet_localhost_id;
$admin->lang = $CFG->lang;
$admin->maildisplay = 1;
$admin->timemodified = time();
$admin->lastip = CLI_SCRIPT ? '0.0.0.0' : getremoteaddr();
// installation hijacking prevention
$admin->id = $DB->insert_record('user', $admin);
/// Install the roles system.
$adminrole = create_role(get_string('administrator'), 'admin', get_string('administratordescription'), 'moodle/legacy:admin');
$coursecreatorrole = create_role(get_string('coursecreators'), 'coursecreator', get_string('coursecreatorsdescription'), 'moodle/legacy:coursecreator');
$editteacherrole = create_role(get_string('defaultcourseteacher'), 'editingteacher', get_string('defaultcourseteacherdescription'), 'moodle/legacy:editingteacher');
$noneditteacherrole = create_role(get_string('noneditingteacher'), 'teacher', get_string('noneditingteacherdescription'), 'moodle/legacy:teacher');
$studentrole = create_role(get_string('defaultcoursestudent'), 'student', get_string('defaultcoursestudentdescription'), 'moodle/legacy:student');
$guestrole = create_role(get_string('guest'), 'guest', get_string('guestdescription'), 'moodle/legacy:guest');
$userrole = create_role(get_string('authenticateduser'), 'user', get_string('authenticateduserdescription'), 'moodle/legacy:user');
/// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles
assign_capability('moodle/site:doanything', CAP_ALLOW, $adminrole, $syscontext->id);
update_capabilities('moodle');
/// assign default roles
role_assign($guestrole, $guest->id, 0, $syscontext->id);
role_assign($adminrole, $admin->id, 0, $syscontext->id);
/// Default allow assign/override/switch.
$defaultallows = array($coursecreatorrole => $noneditteacherrole, $coursecreatorrole => $editteacherrole, $coursecreatorrole => $studentrole, $coursecreatorrole => $guestrole, $editteacherrole => $noneditteacherrole, $editteacherrole => $studentrole, $editteacherrole => $guestrole);
foreach ($defaultallows as $fromroleid => $toroleid) {
allow_assign($fromroleid, $toroleid);
allow_override($fromroleid, $toroleid);
// There is a rant about this in MDL-15841.
allow_switch($fromroleid, $toroleid);
}
allow_switch($noneditteacherrole, $studentrole);
/// Set up the context levels where you can assign each role.
set_role_contextlevels($adminrole, get_default_contextlevels('admin'));
set_role_contextlevels($coursecreatorrole, get_default_contextlevels('coursecreator'));
set_role_contextlevels($editteacherrole, get_default_contextlevels('editingteacher'));
set_role_contextlevels($noneditteacherrole, get_default_contextlevels('teacher'));
set_role_contextlevels($studentrole, get_default_contextlevels('student'));
set_role_contextlevels($guestrole, get_default_contextlevels('guest'));
set_role_contextlevels($userrole, get_default_contextlevels('user'));
}
示例13: upgrade_core
/**
* Upgrade moodle core
* @param float $version target version
* @param bool $verbose
* @return void, may throw exception
*/
function upgrade_core($version, $verbose)
{
global $CFG;
raise_memory_limit(MEMORY_EXTRA);
require_once $CFG->libdir . '/db/upgrade.php';
// Defines upgrades
try {
// Reset caches before any output.
cache_helper::purge_all(true);
purge_all_caches();
// Upgrade current language pack if we can
upgrade_language_pack();
print_upgrade_part_start('moodle', false, $verbose);
// Pre-upgrade scripts for local hack workarounds.
$preupgradefile = "{$CFG->dirroot}/local/preupgrade.php";
if (file_exists($preupgradefile)) {
core_php_time_limit::raise();
require $preupgradefile;
// Reset upgrade timeout to default.
upgrade_set_timeout();
}
$result = xmldb_main_upgrade($CFG->version);
if ($version > $CFG->version) {
// store version if not already there
upgrade_main_savepoint($result, $version, false);
}
// perform all other component upgrade routines
update_capabilities('moodle');
log_update_descriptions('moodle');
external_update_descriptions('moodle');
events_update_definition('moodle');
message_update_providers('moodle');
// Update core definitions.
cache_helper::update_definitions(true);
// Purge caches again, just to be sure we arn't holding onto old stuff now.
cache_helper::purge_all(true);
purge_all_caches();
// Clean up contexts - more and more stuff depends on existence of paths and contexts
context_helper::cleanup_instances();
context_helper::create_instances(null, false);
context_helper::build_all_paths(false);
$syscontext = context_system::instance();
$syscontext->mark_dirty();
print_upgrade_part_end('moodle', false, $verbose);
} catch (Exception $ex) {
upgrade_handle_exception($ex);
}
}
示例14: upgrade_core
/**
* Upgrade moodle core
* @param float $version target version
* @param bool $verbose
* @return void, may throw exception
*/
function upgrade_core($version, $verbose)
{
global $CFG;
raise_memory_limit(MEMORY_EXTRA);
require_once $CFG->libdir . '/db/upgrade.php';
// Defines upgrades
try {
// Reset caches before any output
purge_all_caches();
// Disable the use of cache stores here. We will reset the factory after we've performed the installation.
// This ensures that we don't permanently cache anything during installation.
cache_factory::disable_stores();
// Upgrade current language pack if we can
upgrade_language_pack();
print_upgrade_part_start('moodle', false, $verbose);
// one time special local migration pre 2.0 upgrade script
if ($CFG->version < 2007101600) {
$pre20upgradefile = "{$CFG->dirroot}/local/upgrade_pre20.php";
if (file_exists($pre20upgradefile)) {
set_time_limit(0);
require $pre20upgradefile;
// reset upgrade timeout to default
upgrade_set_timeout();
}
}
$result = xmldb_main_upgrade($CFG->version);
if ($version > $CFG->version) {
// store version if not already there
upgrade_main_savepoint($result, $version, false);
}
// perform all other component upgrade routines
update_capabilities('moodle');
log_update_descriptions('moodle');
external_update_descriptions('moodle');
events_update_definition('moodle');
message_update_providers('moodle');
// Update core definitions.
cache_helper::update_definitions(true);
// Reset the cache, this returns it to a normal operation state.
cache_factory::reset();
// Purge caches again, just to be sure we arn't holding onto old stuff now.
purge_all_caches();
// Clean up contexts - more and more stuff depends on existence of paths and contexts
context_helper::cleanup_instances();
context_helper::create_instances(null, false);
context_helper::build_all_paths(false);
$syscontext = context_system::instance();
$syscontext->mark_dirty();
print_upgrade_part_end('moodle', false, $verbose);
} catch (Exception $ex) {
upgrade_handle_exception($ex);
}
}
示例15: vmoodle_upgrade_subplugins_modules
/**
* Find and check all submodules and load them up or upgrade them if necessary
*
* @global object
* @global object
*/
function vmoodle_upgrade_subplugins_modules($startcallback, $endcallback, $verbose = true)
{
global $CFG, $DB;
include $CFG->dirroot . '/local/vmoodle/db/subplugins.php';
foreach ($subplugins as $type => $subpluginpath) {
$plugindirs = glob($CFG->dirroot . '/' . $subpluginpath . '/*');
foreach ($plugindirs as $dir) {
$plug = basename($dir);
$fullplug = $dir;
if ($plug === 'CVS') {
// Someone has unzipped the template, ignore it.
continue;
}
if ($plug === 'NEWMODULE') {
// Someone has unzipped the template, ignore it.
continue;
}
// Reset time so that it works when installing a large number of plugins.
set_time_limit(600);
$component = clean_param($type . '_' . $plug, PARAM_COMPONENT);
// standardised plugin name
// Check plugin dir is valid name.
if (empty($component)) {
throw new plugin_defective_exception($type . '_' . $plug, 'Invalid plugin directory name.');
}
if (!is_readable($fullplug . '/version.php')) {
continue;
}
$plugin = new stdClass();
require $fullplug . '/version.php';
// Defines $plugin with version etc.
// If plugin tells us it's full name we may check the location.
if (isset($plugin->component)) {
if ($plugin->component !== $component) {
throw new plugin_defective_exception($component, 'Plugin installed in wrong folder.');
}
}
if (empty($plugin->version)) {
throw new plugin_defective_exception($component, 'Missing version value in version.php');
}
$plugin->name = $plug;
$plugin->fullname = $component;
if (!empty($plugin->requires)) {
if ($plugin->requires > $CFG->version) {
throw new upgrade_requires_exception($component, $plugin->version, $CFG->version, $plugin->requires);
} else {
if ($plugin->requires < 2010000000) {
throw new plugin_defective_exception($component, 'Plugin is not compatible with Moodle 2.x or later.');
}
}
}
// Try to recover from interrupted install.php if needed.
if (file_exists($fullplug . '/db/install.php')) {
if (get_config($plugin->fullname, 'installrunning')) {
require_once $fullplug . '/db/install.php';
$recover_install_function = 'xmldb_' . $plugin->fullname . '_install_recovery';
if (function_exists($recover_install_function)) {
$startcallback($component, true, $verbose);
$recover_install_function();
unset_config('installrunning', $plugin->fullname);
update_capabilities($component);
log_update_descriptions($component);
external_update_descriptions($component);
events_update_definition($component);
message_update_providers($component);
if ($type === 'message') {
message_update_processors($plug);
}
vmoodle_upgrade_plugin_mnet_functions($component, $fullplug);
// Fix wrongly twicked paths.
if ($rpc_shifted_defines = $DB->get_records_select('mnet_rpc', " xmlrpcpath LIKE 'vmoodleadminset' ", array())) {
foreach ($rpc_shifted_defines as $rpc) {
$rpc->xmlrpcpath = str_replace('vmoocleadminset', 'local/vmoodle/plugins');
$DB->update_record('mnet_rpc', $rpc);
}
}
$endcallback($component, true, $verbose);
}
}
}
$installedversion = get_config($plugin->fullname, 'version');
if (empty($installedversion)) {
// New installation.
$startcallback($component, true, $verbose);
// Install tables if defined.
if (file_exists($fullplug . '/db/install.xml')) {
$DB->get_manager()->install_from_xmldb_file($fullplug . '/db/install.xml');
}
// Store version.
upgrade_plugin_savepoint(true, $plugin->version, $type, $plug, false);
// Execute post install file.
if (file_exists($fullplug . '/db/install.php')) {
require_once $fullplug . '/db/install.php';
set_config('installrunning', 1, $plugin->fullname);
//.........这里部分代码省略.........