本文整理匯總了PHP中core_date::get_list_of_timezones方法的典型用法代碼示例。如果您正苦於以下問題:PHP core_date::get_list_of_timezones方法的具體用法?PHP core_date::get_list_of_timezones怎麽用?PHP core_date::get_list_of_timezones使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core_date
的用法示例。
在下文中一共展示了core_date::get_list_of_timezones方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: definition
//.........這裏部分代碼省略.........
unset($teacherroles);
}
}
// default values
$mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'tool_uploaduser'));
$mform->addElement('text', 'username', get_string('uuusernametemplate', 'tool_uploaduser'), 'size="20"');
$mform->setType('username', PARAM_RAW);
// No cleaning here. The process verifies it later.
$mform->addRule('username', get_string('requiredtemplate', 'tool_uploaduser'), 'required', null, 'client');
$mform->disabledIf('username', 'uutype', 'eq', UU_USER_ADD_UPDATE);
$mform->disabledIf('username', 'uutype', 'eq', UU_USER_UPDATE);
$mform->setForceLtr('username');
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
$mform->setType('email', PARAM_RAW);
// No cleaning here. The process verifies it later.
$mform->disabledIf('email', 'uutype', 'eq', UU_USER_ADD_UPDATE);
$mform->disabledIf('email', 'uutype', 'eq', UU_USER_UPDATE);
$mform->setForceLtr('email');
// only enabled and known to work plugins
$choices = uu_supported_auths();
$mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $choices);
$mform->setDefault('auth', 'manual');
// manual is a sensible backwards compatible default
$mform->addHelpButton('auth', 'chooseauthmethod', 'auth');
$mform->setAdvanced('auth');
$choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', core_user::get_property_default('maildisplay'));
$choices = array(0 => get_string('textformat'), 1 => get_string('htmlformat'));
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
$mform->setDefault('mailformat', core_user::get_property_default('mailformat'));
$mform->setAdvanced('mailformat');
$choices = array(0 => get_string('emaildigestoff'), 1 => get_string('emaildigestcomplete'), 2 => get_string('emaildigestsubjects'));
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
$mform->setDefault('maildigest', core_user::get_property_default('maildigest'));
$mform->setAdvanced('maildigest');
$choices = array(1 => get_string('autosubscribeyes'), 0 => get_string('autosubscribeno'));
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', core_user::get_property_default('autosubscribe'));
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="25"');
$mform->setType('city', PARAM_TEXT);
if (empty($CFG->defaultcity)) {
$mform->setDefault('city', $templateuser->city);
} else {
$mform->setDefault('city', core_user::get_property_default('city'));
}
$choices = get_string_manager()->get_list_of_countries();
$choices = array('' => get_string('selectacountry') . '...') + $choices;
$mform->addElement('select', 'country', get_string('selectacountry'), $choices);
if (empty($CFG->country)) {
$mform->setDefault('country', $templateuser->country);
} else {
$mform->setDefault('country', core_user::get_property_default('country'));
}
$mform->setAdvanced('country');
$choices = core_date::get_list_of_timezones($templateuser->timezone, true);
$mform->addElement('select', 'timezone', get_string('timezone'), $choices);
$mform->setDefault('timezone', $templateuser->timezone);
$mform->setAdvanced('timezone');
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
$mform->setDefault('lang', $templateuser->lang);
$mform->setAdvanced('lang');
$editoroptions = array('maxfiles' => 0, 'maxbytes' => 0, 'trusttext' => false, 'forcehttps' => false);
$mform->addElement('editor', 'description', get_string('userdescription'), null, $editoroptions);
$mform->setType('description', PARAM_CLEANHTML);
$mform->addHelpButton('description', 'userdescription');
$mform->setAdvanced('description');
$mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
$mform->setType('url', PARAM_URL);
$mform->setAdvanced('url');
$mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="255" size="25"');
$mform->setType('idnumber', PARAM_NOTAGS);
$mform->setForceLtr('idnumber');
$mform->addElement('text', 'institution', get_string('institution'), 'maxlength="255" size="25"');
$mform->setType('institution', PARAM_TEXT);
$mform->setDefault('institution', $templateuser->institution);
$mform->addElement('text', 'department', get_string('department'), 'maxlength="255" size="25"');
$mform->setType('department', PARAM_TEXT);
$mform->setDefault('department', $templateuser->department);
$mform->addElement('text', 'phone1', get_string('phone1'), 'maxlength="20" size="25"');
$mform->setType('phone1', PARAM_NOTAGS);
$mform->setAdvanced('phone1');
$mform->setForceLtr('phone1');
$mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"');
$mform->setType('phone2', PARAM_NOTAGS);
$mform->setAdvanced('phone2');
$mform->setForceLtr('phone2');
$mform->addElement('text', 'address', get_string('address'), 'maxlength="255" size="25"');
$mform->setType('address', PARAM_TEXT);
$mform->setAdvanced('address');
// Next the profile defaults
profile_definition($mform);
// hidden fields
$mform->addElement('hidden', 'iid');
$mform->setType('iid', PARAM_INT);
$mform->addElement('hidden', 'previewrows');
$mform->setType('previewrows', PARAM_INT);
$this->add_action_buttons(true, get_string('uploadusers', 'tool_uploaduser'));
$this->set_data($data);
}
示例2: load_choices
/**
* Lazy load timezone options.
* @return bool true if loaded, false if error
*/
public function load_choices()
{
global $CFG;
if (is_array($this->choices)) {
return true;
}
$current = isset($CFG->forcetimezone) ? $CFG->forcetimezone : null;
$this->choices = core_date::get_list_of_timezones($current, true);
$this->choices['99'] = new lang_string('timezonenotforced', 'core_admin');
return true;
}
示例3: useredit_shared_definition
/**
* Powerful function that is used by edit and editadvanced to add common form elements/rules/etc.
*
* @param moodleform $mform
* @param array $editoroptions
* @param array $filemanageroptions
* @param stdClass $user
*/
function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions, $user)
{
global $CFG, $USER, $DB;
if ($user->id > 0) {
useredit_load_preferences($user, false);
}
$strrequired = get_string('required');
$stringman = get_string_manager();
// Add the necessary names.
foreach (useredit_get_required_name_fields() as $fullname) {
$mform->addElement('text', $fullname, get_string($fullname), 'maxlength="100" size="30"');
if ($stringman->string_exists('missing' . $fullname, 'core')) {
$strmissingfield = get_string('missing' . $fullname, 'core');
} else {
$strmissingfield = $strrequired;
}
$mform->addRule($fullname, $strmissingfield, 'required', null, 'client');
$mform->setType($fullname, PARAM_NOTAGS);
}
$enabledusernamefields = useredit_get_enabled_name_fields();
// Add the enabled additional name fields.
foreach ($enabledusernamefields as $addname) {
$mform->addElement('text', $addname, get_string($addname), 'maxlength="100" size="30"');
$mform->setType($addname, PARAM_NOTAGS);
}
// Do not show email field if change confirmation is pending.
if ($user->id > 0 and !empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) {
$notice = get_string('emailchangepending', 'auth', $user);
$notice .= '<br /><a href="edit.php?cancelemailchange=1&id=' . $user->id . '">' . get_string('emailchangecancel', 'auth') . '</a>';
$mform->addElement('static', 'emailpending', get_string('email'), $notice);
} else {
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
$mform->addRule('email', $strrequired, 'required', null, 'client');
$mform->setType('email', PARAM_RAW_TRIMMED);
}
$choices = array();
$choices['0'] = get_string('emaildisplayno');
$choices['1'] = get_string('emaildisplayyes');
$choices['2'] = get_string('emaildisplaycourse');
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', core_user::get_property_default('maildisplay'));
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
$mform->setType('city', PARAM_TEXT);
if (!empty($CFG->defaultcity)) {
$mform->setDefault('city', $CFG->defaultcity);
}
$choices = get_string_manager()->get_list_of_countries();
$choices = array('' => get_string('selectacountry') . '...') + $choices;
$mform->addElement('select', 'country', get_string('selectacountry'), $choices);
if (!empty($CFG->country)) {
$mform->setDefault('country', core_user::get_property_default('country'));
}
if (isset($CFG->forcetimezone) and $CFG->forcetimezone != 99) {
$choices = core_date::get_list_of_timezones($CFG->forcetimezone);
$mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]);
$mform->addElement('hidden', 'timezone');
$mform->setType('timezone', core_user::get_property_type('timezone'));
} else {
$choices = core_date::get_list_of_timezones($user->timezone, true);
$mform->addElement('select', 'timezone', get_string('timezone'), $choices);
}
if (!empty($CFG->allowuserthemes)) {
$choices = array();
$choices[''] = get_string('default');
$themes = get_list_of_themes();
foreach ($themes as $key => $theme) {
if (empty($theme->hidefromselector)) {
$choices[$key] = get_string('pluginname', 'theme_' . $theme->name);
}
}
$mform->addElement('select', 'theme', get_string('preferredtheme'), $choices);
}
$mform->addElement('editor', 'description_editor', get_string('userdescription'), null, $editoroptions);
$mform->setType('description_editor', PARAM_CLEANHTML);
$mform->addHelpButton('description_editor', 'userdescription');
if (empty($USER->newadminuser)) {
$mform->addElement('header', 'moodle_picture', get_string('pictureofuser'));
$mform->setExpanded('moodle_picture', true);
if (!empty($CFG->enablegravatar)) {
$mform->addElement('html', html_writer::tag('p', get_string('gravatarenabled')));
}
$mform->addElement('static', 'currentpicture', get_string('currentpicture'));
$mform->addElement('checkbox', 'deletepicture', get_string('delete'));
$mform->setDefault('deletepicture', 0);
$mform->addElement('filemanager', 'imagefile', get_string('newpicture'), '', $filemanageroptions);
$mform->addHelpButton('imagefile', 'newpicture');
$mform->addElement('text', 'imagealt', get_string('imagealt'), 'maxlength="100" size="30"');
$mform->setType('imagealt', PARAM_TEXT);
}
// Display user name fields that are not currenlty enabled here if there are any.
$disabledusernamefields = useredit_get_disabled_name_fields($enabledusernamefields);
if (count($disabledusernamefields) > 0) {
//.........這裏部分代碼省略.........
示例4: test_get_user_timezone_object
public function test_get_user_timezone_object()
{
global $CFG, $USER;
$this->resetAfterTest();
$this->setTimezone('Pacific/Auckland');
$CFG->forcetimezone = '99';
$zones = core_date::get_list_of_timezones();
foreach ($zones as $zone) {
$USER->timezone = $zone;
$tz = core_date::get_user_timezone_object();
$this->assertInstanceOf('DateTimeZone', $tz);
$this->assertSame($zone, $tz->getName());
}
}
示例5: get_list_of_timezones
/**
* Returns a list of timezones in the current language.
* @deprecated since Moodle 2.9
* @return array
*/
function get_list_of_timezones()
{
debugging('get_list_of_timezones() is deprecated, use core_date::get_list_of_timezones() instead', DEBUG_DEVELOPER);
return core_date::get_list_of_timezones();
}
示例6: defined
*/
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('enrol_lti_settings', '', get_string('pluginname_desc', 'enrol_lti')));
if (!is_enabled_auth('lti')) {
$notify = new \core\output\notification(get_string('authltimustbeenabled', 'enrol_lti'), \core\output\notification::NOTIFY_WARNING);
$settings->add(new admin_setting_heading('enrol_lti_enable_auth_lti', '', $OUTPUT->render($notify)));
}
if (empty($CFG->allowframembedding)) {
$notify = new \core\output\notification(get_string('allowframeembedding', 'enrol_lti'), \core\output\notification::NOTIFY_WARNING);
$settings->add(new admin_setting_heading('enrol_lti_enable_embedding', '', $OUTPUT->render($notify)));
}
$settings->add(new admin_setting_heading('enrol_lti_user_default_values', get_string('userdefaultvalues', 'enrol_lti'), ''));
$choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
$maildisplay = isset($CFG->defaultpreference_maildisplay) ? $CFG->defaultpreference_maildisplay : 2;
$settings->add(new admin_setting_configselect('enrol_lti/emaildisplay', get_string('emaildisplay'), '', $maildisplay, $choices));
$city = '';
if (!empty($CFG->defaultcity)) {
$city = $CFG->defaultcity;
}
$settings->add(new admin_setting_configtext('enrol_lti/city', get_string('city'), '', $city));
$country = '';
if (!empty($CFG->country)) {
$country = $CFG->country;
}
$countries = array('' => get_string('selectacountry') . '...') + get_string_manager()->get_list_of_countries();
$settings->add(new admin_setting_configselect('enrol_lti/country', get_string('selectacountry'), '', $country, $countries));
$settings->add(new admin_setting_configselect('enrol_lti/timezone', get_string('timezone'), '', 99, core_date::get_list_of_timezones(null, true)));
$settings->add(new admin_setting_configselect('enrol_lti/lang', get_string('preferredlanguage'), '', $CFG->lang, get_string_manager()->get_list_of_translations()));
$settings->add(new admin_setting_configtext('enrol_lti/institution', get_string('institution'), '', ''));
}
示例7: definition
public function definition()
{
global $USER, $CFG, $COURSE;
$mform =& $this->_form;
$templateuser = $USER;
$context = $this->_customdata['context'];
$mform->addElement('header', 'settingsheader', get_string('toolsettings', 'local_ltiprovider'));
$tools = array();
$tools[$context->id] = get_string('course');
$modinfo = get_fast_modinfo($this->_customdata['courseid']);
$mods = $modinfo->get_cms();
foreach ($mods as $mod) {
$tools[$mod->context->id] = format_string($mod->name);
}
$mform->addElement('select', 'contextid', get_string('tooltobeprovide', 'local_ltiprovider'), $tools);
$mform->setDefault('contextid', $context->id);
$mform->addElement('checkbox', 'sendgrades', null, get_string('sendgrades', 'local_ltiprovider'));
$mform->setDefault('sendgrades', 1);
$mform->addElement('checkbox', 'requirecompletion', null, get_string('requirecompletion', 'local_ltiprovider'));
$mform->setDefault('requirecompletion', 0);
$mform->disabledIf('requirecompletion', 'sendgrades');
$mform->addElement('checkbox', 'forcenavigation', null, get_string('forcenavigation', 'local_ltiprovider'));
$mform->setDefault('forcenavigation', 1);
$mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'local_ltiprovider'), array('optional' => true, 'defaultunit' => 86400));
$mform->setDefault('enrolperiod', 0);
$mform->addHelpButton('enrolperiod', 'enrolperiod', 'local_ltiprovider');
$mform->addElement('date_selector', 'enrolstartdate', get_string('enrolstartdate', 'local_ltiprovider'), array('optional' => true));
$mform->setDefault('enrolstartdate', 0);
$mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'local_ltiprovider');
$mform->addElement('date_selector', 'enrolenddate', get_string('enrolenddate', 'local_ltiprovider'), array('optional' => true));
$mform->setDefault('enrolenddate', 0);
$mform->addHelpButton('enrolenddate', 'enrolenddate', 'local_ltiprovider');
$mform->addElement('text', 'maxenrolled', get_string('maxenrolled', 'local_ltiprovider'));
$mform->setDefault('maxenrolled', 0);
$mform->addHelpButton('maxenrolled', 'maxenrolled', 'local_ltiprovider');
$mform->setType('maxenrolled', PARAM_INT);
$assignableroles = get_assignable_roles($context);
$mform->addElement('checkbox', 'enrolinst', null, get_string('enrolinst', 'local_ltiprovider'));
$mform->setDefault('enrolinst', 1);
$mform->addHelpButton('enrolinst', 'enrolinst', 'local_ltiprovider');
$mform->setAdvanced('enrolinst');
$mform->addElement('checkbox', 'enrollearn', null, get_string('enrollearn', 'local_ltiprovider'));
$mform->setDefault('enrollearn', 1);
$mform->addHelpButton('enrollearn', 'enrollearn', 'local_ltiprovider');
$mform->setAdvanced('enrollearn');
$mform->addElement('select', 'croleinst', get_string('courseroleinstructor', 'local_ltiprovider'), $assignableroles);
$mform->setDefault('croleinst', '3');
$mform->setAdvanced('croleinst');
$mform->addElement('select', 'crolelearn', get_string('courserolelearner', 'local_ltiprovider'), $assignableroles);
$mform->setDefault('crolelearn', '5');
$mform->setAdvanced('crolelearn');
$mform->addElement('select', 'aroleinst', get_string('activityroleinstructor', 'local_ltiprovider'), $assignableroles);
$mform->disabledIf('aroleinst', 'contextid', 'eq', $context->id);
$mform->setDefault('aroleinst', '3');
$mform->setAdvanced('aroleinst');
$mform->addElement('select', 'arolelearn', get_string('activityrolelearner', 'local_ltiprovider'), $assignableroles);
$mform->disabledIf('arolelearn', 'contextid', 'eq', $context->id);
$mform->setDefault('arolelearn', '5');
$mform->setAdvanced('arolelearn');
$mform->addElement('header', 'remotesystem', get_string('remotesystem', 'local_ltiprovider'));
$mform->addElement('text', 'secret', get_string('secret', 'local_ltiprovider'), 'maxlength="64" size="25"');
$mform->setType('secret', PARAM_MULTILANG);
$mform->setDefault('secret', md5(uniqid(rand(), 1)));
$mform->addRule('secret', get_string('required'), 'required');
$choices = core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('remoteencoding', 'local_ltiprovider'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$mform->addElement('header', 'defaultheader', get_string('userdefaultvalues', 'local_ltiprovider'));
$choices = array(0 => get_string('never'), 1 => get_string('always'));
$mform->addElement('select', 'userprofileupdate', get_string('userprofileupdate', 'local_ltiprovider'), $choices);
$userprofileupdate = get_config('local_ltiprovider', 'userprofileupdate');
if ($userprofileupdate != -1) {
$mform->setDefault('userprofileupdate', $userprofileupdate);
$mform->freeze('userprofileupdate');
} else {
$mform->setDefault('userprofileupdate', 1);
}
$choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', 2);
$mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
$mform->setType('city', PARAM_MULTILANG);
if (empty($CFG->defaultcity)) {
$mform->setDefault('city', $templateuser->city);
} else {
$mform->setDefault('city', $CFG->defaultcity);
}
$mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
if (empty($CFG->country)) {
$mform->setDefault('country', $templateuser->country);
} else {
$mform->setDefault('country', $CFG->country);
}
$mform->setAdvanced('country');
$choices = core_date::get_list_of_timezones();
$choices['99'] = get_string('serverlocaltime');
$mform->addElement('select', 'timezone', get_string('timezone'), $choices);
$mform->setDefault('timezone', $templateuser->timezone);
$mform->setAdvanced('timezone');
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
//.........這裏部分代碼省略.........
示例8: edit_instance_form
/**
* Add elements to the edit instance form.
*
* @param stdClass $instance
* @param MoodleQuickForm $mform
* @param context $context
* @return bool
*/
public function edit_instance_form($instance, MoodleQuickForm $mform, $context)
{
global $DB;
$nameattribs = array('size' => '20', 'maxlength' => '255');
$mform->addElement('text', 'name', get_string('custominstancename', 'enrol'), $nameattribs);
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'server');
$tools = array();
$tools[$context->id] = get_string('course');
$modinfo = get_fast_modinfo($instance->courseid);
$mods = $modinfo->get_cms();
foreach ($mods as $mod) {
$tools[$mod->context->id] = format_string($mod->name);
}
$mform->addElement('select', 'contextid', get_string('tooltobeprovided', 'enrol_lti'), $tools);
$mform->setDefault('contextid', $context->id);
$mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_lti'), array('optional' => true, 'defaultunit' => DAYSECS));
$mform->setDefault('enrolperiod', 0);
$mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_lti');
$mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_lti'), array('optional' => true));
$mform->setDefault('enrolstartdate', 0);
$mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_lti');
$mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_lti'), array('optional' => true));
$mform->setDefault('enrolenddate', 0);
$mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_lti');
$mform->addElement('text', 'maxenrolled', get_string('maxenrolled', 'enrol_lti'));
$mform->setDefault('maxenrolled', 0);
$mform->addHelpButton('maxenrolled', 'maxenrolled', 'enrol_lti');
$mform->setType('maxenrolled', PARAM_INT);
$assignableroles = get_assignable_roles($context);
$mform->addElement('select', 'roleinstructor', get_string('roleinstructor', 'enrol_lti'), $assignableroles);
$mform->setDefault('roleinstructor', '3');
$mform->addHelpButton('roleinstructor', 'roleinstructor', 'enrol_lti');
$mform->addElement('select', 'rolelearner', get_string('rolelearner', 'enrol_lti'), $assignableroles);
$mform->setDefault('rolelearner', '5');
$mform->addHelpButton('rolelearner', 'rolelearner', 'enrol_lti');
$mform->addElement('header', 'remotesystem', get_string('remotesystem', 'enrol_lti'));
$mform->addElement('text', 'secret', get_string('secret', 'enrol_lti'), 'maxlength="64" size="25"');
$mform->setType('secret', PARAM_ALPHANUM);
$mform->setDefault('secret', random_string(32));
$mform->addHelpButton('secret', 'secret', 'enrol_lti');
$mform->addRule('secret', get_string('required'), 'required');
$mform->addElement('selectyesno', 'gradesync', get_string('gradesync', 'enrol_lti'));
$mform->setDefault('gradesync', 1);
$mform->addHelpButton('gradesync', 'gradesync', 'enrol_lti');
$mform->addElement('selectyesno', 'gradesynccompletion', get_string('requirecompletion', 'enrol_lti'));
$mform->setDefault('gradesynccompletion', 0);
$mform->disabledIf('gradesynccompletion', 'gradesync', 0);
$mform->addElement('selectyesno', 'membersync', get_string('membersync', 'enrol_lti'));
$mform->setDefault('membersync', 1);
$mform->addHelpButton('membersync', 'membersync', 'enrol_lti');
$options = array();
$options[\enrol_lti\helper::MEMBER_SYNC_ENROL_AND_UNENROL] = get_string('membersyncmodeenrolandunenrol', 'enrol_lti');
$options[\enrol_lti\helper::MEMBER_SYNC_ENROL_NEW] = get_string('membersyncmodeenrolnew', 'enrol_lti');
$options[\enrol_lti\helper::MEMBER_SYNC_UNENROL_MISSING] = get_string('membersyncmodeunenrolmissing', 'enrol_lti');
$mform->addElement('select', 'membersyncmode', get_string('membersyncmode', 'enrol_lti'), $options);
$mform->setDefault('membersyncmode', \enrol_lti\helper::MEMBER_SYNC_ENROL_AND_UNENROL);
$mform->addHelpButton('membersyncmode', 'membersyncmode', 'enrol_lti');
$mform->disabledIf('membersyncmode', 'membersync', 0);
$mform->addElement('header', 'defaultheader', get_string('userdefaultvalues', 'enrol_lti'));
$emaildisplay = get_config('enrol_lti', 'emaildisplay');
$choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', $emaildisplay);
$city = get_config('enrol_lti', 'city');
$mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
$mform->setType('city', PARAM_TEXT);
$mform->setDefault('city', $city);
$country = get_config('enrol_lti', 'country');
$countries = array('' => get_string('selectacountry') . '...') + get_string_manager()->get_list_of_countries();
$mform->addElement('select', 'country', get_string('selectacountry'), $countries);
$mform->setDefault('country', $country);
$mform->setAdvanced('country');
$timezone = get_config('enrol_lti', 'timezone');
$choices = core_date::get_list_of_timezones(null, true);
$mform->addElement('select', 'timezone', get_string('timezone'), $choices);
$mform->setDefault('timezone', $timezone);
$mform->setAdvanced('timezone');
$lang = get_config('enrol_lti', 'lang');
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
$mform->setDefault('lang', $lang);
$mform->setAdvanced('lang');
$institution = get_config('enrol_lti', 'institution');
$mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
$mform->setType('institution', core_user::get_property_type('institution'));
$mform->setDefault('institution', $institution);
$mform->setAdvanced('institution');
// Check if we are editing an instance.
if (!empty($instance->id)) {
// Get the details from the enrol_lti_tools table.
$ltitool = $DB->get_record('enrol_lti_tools', array('enrolid' => $instance->id), '*', MUST_EXIST);
$mform->addElement('hidden', 'toolid');
//.........這裏部分代碼省略.........
示例9: require_login
$PAGE->set_context(context_system::instance());
require_login();
require_capability('moodle/site:config', context_system::instance());
$strtimezone = get_string("timezone");
$strsavechanges = get_string("savechanges");
$strusers = get_string("users");
$strall = get_string("all");
$PAGE->set_title($strtimezone);
$PAGE->set_heading($strtimezone);
$PAGE->navbar->add($strtimezone);
echo $OUTPUT->header();
echo $OUTPUT->heading("");
if (data_submitted() and !empty($zone) and confirm_sesskey()) {
echo "<center>";
$DB->execute("UPDATE {user} SET timezone = ?", array($zone));
echo "</center>";
$USER->timezone = $zone;
$current = $zone;
echo $OUTPUT->notification('Timezone of all users changed', 'notifysuccess');
} else {
$current = 99;
}
require_once $CFG->dirroot . '/calendar/lib.php';
$timezones = core_date::get_list_of_timezones(null, true);
echo '<center><form action="timezone.php" method="post">';
echo html_writer::label($strusers . ' (' . $strall . '): ', 'menuzone');
echo html_writer::select($timezones, "zone", $current);
echo "<input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . "\" />";
echo '<input type="submit" value="' . s($strsavechanges) . '" />';
echo "</form></center>";
echo $OUTPUT->footer();
示例10: fill_properties_cache
/**
* Definition of user profile fields and the expected parameter type for data validation.
*
* array(
* 'property_name' => array( // The user property to be checked. Should match the field on the user table.
* 'null' => NULL_ALLOWED, // Defaults to NULL_NOT_ALLOWED. Takes NULL_NOT_ALLOWED or NULL_ALLOWED.
* 'type' => PARAM_TYPE, // Expected parameter type of the user field.
* 'choices' => array(1, 2..) // An array of accepted values of the user field.
* 'default' => $CFG->setting // An default value for the field.
* )
* )
*
* The fields choices and default are optional.
*
* @return void
*/
protected static function fill_properties_cache()
{
global $CFG;
if (self::$propertiescache !== null) {
return;
}
// Array of user fields properties and expected parameters.
// Every new field on the user table should be added here otherwise it won't be validated.
$fields = array();
$fields['id'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['auth'] = array('type' => PARAM_AUTH, 'null' => NULL_NOT_ALLOWED);
$fields['confirmed'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
$fields['policyagreed'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
$fields['deleted'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
$fields['suspended'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
$fields['mnethostid'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['username'] = array('type' => PARAM_USERNAME, 'null' => NULL_NOT_ALLOWED);
$fields['password'] = array('type' => PARAM_RAW, 'null' => NULL_NOT_ALLOWED);
$fields['idnumber'] = array('type' => PARAM_RAW, 'null' => NULL_NOT_ALLOWED);
$fields['firstname'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
$fields['lastname'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
$fields['surname'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
$fields['email'] = array('type' => PARAM_RAW_TRIMMED, 'null' => NULL_NOT_ALLOWED);
$fields['emailstop'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['icq'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
$fields['skype'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
$fields['aim'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
$fields['yahoo'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
$fields['msn'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
$fields['phone1'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
$fields['phone2'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
$fields['institution'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED);
$fields['department'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED);
$fields['address'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED);
$fields['city'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultcity);
$fields['country'] = array('type' => PARAM_ALPHA, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->country, 'choices' => array_merge(array('' => ''), get_string_manager()->get_list_of_countries(true, true)));
$fields['lang'] = array('type' => PARAM_LANG, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->lang, 'choices' => array_merge(array('' => ''), get_string_manager()->get_list_of_translations(false)));
$fields['calendartype'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->calendartype, 'choices' => array_merge(array('' => ''), \core_calendar\type_factory::get_list_of_calendar_types()));
$fields['theme'] = array('type' => PARAM_THEME, 'null' => NULL_NOT_ALLOWED, 'default' => theme_config::DEFAULT_THEME, 'choices' => array_merge(array('' => ''), get_list_of_themes()));
$fields['timezone'] = array('type' => PARAM_TIMEZONE, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->timezone, 'choices' => core_date::get_list_of_timezones(null, true));
$fields['firstaccess'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['lastaccess'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['lastlogin'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['currentlogin'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['lastip'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
$fields['secret'] = array('type' => PARAM_RAW, 'null' => NULL_NOT_ALLOWED);
$fields['picture'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['url'] = array('type' => PARAM_URL, 'null' => NULL_NOT_ALLOWED);
$fields['description'] = array('type' => PARAM_RAW, 'null' => NULL_ALLOWED);
$fields['descriptionformat'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['mailformat'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_mailformat);
$fields['maildigest'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_maildigest);
$fields['maildisplay'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_maildisplay);
$fields['autosubscribe'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_autosubscribe);
$fields['trackforums'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_trackforums);
$fields['timecreated'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['timemodified'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['trustbitmask'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
$fields['imagealt'] = array('type' => PARAM_TEXT, 'null' => NULL_ALLOWED);
$fields['lastnamephonetic'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
$fields['firstnamephonetic'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
$fields['middlename'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
$fields['alternatename'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
self::$propertiescache = $fields;
}