本文整理汇总了PHP中license_manager::install_licenses方法的典型用法代码示例。如果您正苦于以下问题:PHP license_manager::install_licenses方法的具体用法?PHP license_manager::install_licenses怎么用?PHP license_manager::install_licenses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类license_manager
的用法示例。
在下文中一共展示了license_manager::install_licenses方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_main_install
//.........这里部分代码省略.........
$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);
// Make sure user context exists
context_user::instance($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);
// Make sure user context exists
context_user::instance($admin->id);
// Install the roles system.
$managerrole = create_role('', 'manager', '', 'manager');
$coursecreatorrole = create_role('', 'coursecreator', '', 'coursecreator');
$editteacherrole = create_role('', 'editingteacher', '', 'editingteacher');
$noneditteacherrole = create_role('', 'teacher', '', 'teacher');
$studentrole = create_role('', 'student', '', 'student');
$guestrole = create_role('', 'guest', '', 'guest');
$userrole = create_role('', 'user', '', 'user');
$frontpagerole = create_role('', 'frontpage', '', 'frontpage');
// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles
update_capabilities('moodle');
// Default allow role matrices.
foreach ($DB->get_records('role') as $role) {
foreach (array('assign', 'override', 'switch') as $type) {
$function = 'allow_' . $type;
$allows = get_default_role_archetype_allows($type, $role->archetype);
foreach ($allows as $allowid) {
$function($role->id, $allowid);
}
}
}
// 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 theme and JS revisions
set_config('themerev', time());
set_config('jsrev', time());
// No admin setting for this any more, GD is now required, remove in Moodle 2.6.
set_config('gdversion', 2);
// Install licenses
require_once $CFG->libdir . '/licenselib.php';
license_manager::install_licenses();
// Init profile pages defaults
if ($DB->record_exists('my_pages', array())) {
throw new moodle_exception('generalexceptionmessage', 'error', '', 'Can not create default profile pages, records already exist.');
}
$mypage = new stdClass();
$mypage->userid = NULL;
$mypage->name = '__default';
$mypage->private = 0;
$mypage->sortorder = 0;
$DB->insert_record('my_pages', $mypage);
$mypage->private = 1;
$DB->insert_record('my_pages', $mypage);
// Set a sensible default sort order for the most-used question types.
set_config('multichoice_sortorder', 1, 'question');
set_config('truefalse_sortorder', 2, 'question');
set_config('match_sortorder', 3, 'question');
set_config('shortanswer_sortorder', 4, 'question');
set_config('numerical_sortorder', 5, 'question');
set_config('essay_sortorder', 6, 'question');
}
示例2: 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);
}
}