当前位置: 首页>>代码示例>>PHP>>正文


PHP core_user::get_property_default方法代码示例

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


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

示例1: definition

 /**
  * Define the form.
  */
 public function definition()
 {
     global $CFG, $COURSE;
     $mform = $this->_form;
     $choices = array();
     $choices['0'] = get_string('emaildigestoff');
     $choices['1'] = get_string('emaildigestcomplete');
     $choices['2'] = get_string('emaildigestsubjects');
     $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
     $mform->setDefault('maildigest', core_user::get_property_default('maildigest'));
     $mform->addHelpButton('maildigest', 'emaildigest');
     $choices = array();
     $choices['1'] = get_string('autosubscribeyes');
     $choices['0'] = get_string('autosubscribeno');
     $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
     $mform->setDefault('autosubscribe', core_user::get_property_default('autosubscribe'));
     if (!empty($CFG->forum_trackreadposts)) {
         $choices = array();
         $choices['0'] = get_string('trackforumsno');
         $choices['1'] = get_string('trackforumsyes');
         $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
         $mform->setDefault('trackforums', core_user::get_property_default('trackforums'));
     }
     // Add some extra hidden fields.
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'course', $COURSE->id);
     $mform->setType('course', PARAM_INT);
     $this->add_action_buttons(true, get_string('savechanges'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:33,代码来源:forum_form.php

示例2: definition_after_data

 /**
  * Extend the form definition after the data has been parsed.
  */
 public function definition_after_data()
 {
     global $CFG, $DB, $OUTPUT;
     $mform = $this->_form;
     // If language does not exist, use site default lang.
     if ($langsel = $mform->getElementValue('lang')) {
         $lang = reset($langsel);
         // Check lang exists.
         if (!get_string_manager()->translation_exists($lang, false)) {
             $langel =& $mform->getElement('lang');
             $langel->setValue(core_user::get_property_default('lang'));
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:17,代码来源:language_form.php

示例3: definition


//.........这里部分代码省略.........
             foreach ($teacherroles as $role) {
                 if (isset($choices[$role->id])) {
                     $mform->setDefault('uulegacy3', $role->id);
                     break;
                 }
             }
             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());
开发者ID:janeklb,项目名称:moodle,代码行数:67,代码来源:user_form.php

示例4: 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&amp;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) {
//.........这里部分代码省略.........
开发者ID:gabrielrosset,项目名称:moodle,代码行数:101,代码来源:editlib.php

示例5: test_get_property_default

 /**
  * Test get_property_default().
  *
  *
  * @expectedException        coding_exception
  * @expectedExceptionMessage Invalid property requested, or the property does not has a default value.
  */
 public function test_get_property_default()
 {
     global $CFG;
     $this->resetAfterTest();
     $country = core_user::get_property_default('country');
     $this->assertEquals($CFG->country, $country);
     set_config('country', 'AU');
     core_user::reset_caches();
     $country = core_user::get_property_default('country');
     $this->assertEquals($CFG->country, $country);
     $lang = core_user::get_property_default('lang');
     $this->assertEquals($CFG->lang, $lang);
     set_config('lang', 'en');
     $lang = core_user::get_property_default('lang');
     $this->assertEquals($CFG->lang, $lang);
     $this->setTimezone('Europe/London', 'Pacific/Auckland');
     core_user::reset_caches();
     $timezone = core_user::get_property_default('timezone');
     $this->assertEquals('Europe/London', $timezone);
     $this->setTimezone('99', 'Pacific/Auckland');
     core_user::reset_caches();
     $timezone = core_user::get_property_default('timezone');
     $this->assertEquals('Pacific/Auckland', $timezone);
     core_user::get_property_default('firstname');
 }
开发者ID:evltuma,项目名称:moodle,代码行数:32,代码来源:user_test.php

示例6: create_users_parameters

 /**
  * Returns description of method parameters
  *
  * @return external_function_parameters
  * @since Moodle 2.2
  */
 public static function create_users_parameters()
 {
     global $CFG;
     return new external_function_parameters(array('users' => new external_multiple_structure(new external_single_structure(array('username' => new external_value(core_user::get_property_type('username'), 'Username policy is defined in Moodle security config.'), 'password' => new external_value(core_user::get_property_type('password'), 'Plain text password consisting of any characters', VALUE_OPTIONAL), 'createpassword' => new external_value(PARAM_BOOL, 'True if password should be created and mailed to user.', VALUE_OPTIONAL), 'firstname' => new external_value(core_user::get_property_type('firstname'), 'The first name(s) of the user'), 'lastname' => new external_value(core_user::get_property_type('lastname'), 'The family name of the user'), 'email' => new external_value(core_user::get_property_type('email'), 'A valid and unique email address'), 'auth' => new external_value(core_user::get_property_type('auth'), 'Auth plugins include manual, ldap, imap, etc', VALUE_DEFAULT, 'manual', core_user::get_property_null('auth')), 'idnumber' => new external_value(core_user::get_property_type('idnumber'), 'An arbitrary ID code number perhaps from the institution', VALUE_DEFAULT, ''), 'lang' => new external_value(core_user::get_property_type('lang'), 'Language code such as "en", must exist on server', VALUE_DEFAULT, core_user::get_property_default('lang'), core_user::get_property_null('lang')), 'calendartype' => new external_value(core_user::get_property_type('calendartype'), 'Calendar type such as "gregorian", must exist on server', VALUE_DEFAULT, $CFG->calendartype, VALUE_OPTIONAL), 'theme' => new external_value(core_user::get_property_type('theme'), 'Theme name such as "standard", must exist on server', VALUE_OPTIONAL), 'timezone' => new external_value(core_user::get_property_type('timezone'), 'Timezone code such as Australia/Perth, or 99 for default', VALUE_OPTIONAL), 'mailformat' => new external_value(core_user::get_property_type('mailformat'), 'Mail format code is 0 for plain text, 1 for HTML etc', VALUE_OPTIONAL), 'description' => new external_value(core_user::get_property_type('description'), 'User profile description, no HTML', VALUE_OPTIONAL), 'city' => new external_value(core_user::get_property_type('city'), 'Home city of the user', VALUE_OPTIONAL), 'country' => new external_value(core_user::get_property_type('country'), 'Home country code of the user, such as AU or CZ', VALUE_OPTIONAL), 'firstnamephonetic' => new external_value(core_user::get_property_type('firstnamephonetic'), 'The first name(s) phonetically of the user', VALUE_OPTIONAL), 'lastnamephonetic' => new external_value(core_user::get_property_type('lastnamephonetic'), 'The family name phonetically of the user', VALUE_OPTIONAL), 'middlename' => new external_value(core_user::get_property_type('middlename'), 'The middle name of the user', VALUE_OPTIONAL), 'alternatename' => new external_value(core_user::get_property_type('alternatename'), 'The alternate name of the user', VALUE_OPTIONAL), 'preferences' => new external_multiple_structure(new external_single_structure(array('type' => new external_value(PARAM_ALPHANUMEXT, 'The name of the preference'), 'value' => new external_value(PARAM_RAW, 'The value of the preference'))), 'User preferences', VALUE_OPTIONAL), 'customfields' => new external_multiple_structure(new external_single_structure(array('type' => new external_value(PARAM_ALPHANUMEXT, 'The name of the custom field'), 'value' => new external_value(PARAM_RAW, 'The value of the custom field'))), 'User custom fields (also known as user profil fields)', VALUE_OPTIONAL))))));
 }
开发者ID:sirromas,项目名称:lms,代码行数:11,代码来源:externallib.php

示例7: test_get_property_default

 /**
  * Test get_property_default().
  */
 public function test_get_property_default()
 {
     global $CFG;
     $this->resetAfterTest();
     $country = core_user::get_property_default('country');
     $this->assertEquals($CFG->country, $country);
     set_config('country', 'AU');
     core_user::reset_caches();
     $country = core_user::get_property_default('country');
     $this->assertEquals($CFG->country, $country);
     $lang = core_user::get_property_default('lang');
     $this->assertEquals($CFG->lang, $lang);
     set_config('lang', 'en');
     $lang = core_user::get_property_default('lang');
     $this->assertEquals($CFG->lang, $lang);
     $this->setTimezone('Europe/London', 'Pacific/Auckland');
     core_user::reset_caches();
     $timezone = core_user::get_property_default('timezone');
     $this->assertEquals('Europe/London', $timezone);
     $this->setTimezone('99', 'Pacific/Auckland');
     core_user::reset_caches();
     $timezone = core_user::get_property_default('timezone');
     $this->assertEquals('Pacific/Auckland', $timezone);
     $this->setExpectedException('coding_exception', 'Invalid property requested, or the property does not has a default value.');
     core_user::get_property_default('firstname');
 }
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:29,代码来源:user_test.php

示例8: user_create_user

/**
 * Creates a user
 *
 * @throws moodle_exception
 * @param stdClass $user user to create
 * @param bool $updatepassword if true, authentication plugin will update password.
 * @param bool $triggerevent set false if user_created event should not be triggred.
 *             This will not affect user_password_updated event triggering.
 * @return int id of the newly created user
 */
function user_create_user($user, $updatepassword = true, $triggerevent = true)
{
    global $DB;
    // Set the timecreate field to the current time.
    if (!is_object($user)) {
        $user = (object) $user;
    }
    // Check username.
    if ($user->username !== core_text::strtolower($user->username)) {
        throw new moodle_exception('usernamelowercase');
    } else {
        if ($user->username !== core_user::clean_field($user->username, 'username')) {
            throw new moodle_exception('invalidusername');
        }
    }
    // Save the password in a temp value for later.
    if ($updatepassword && isset($user->password)) {
        // Check password toward the password policy.
        if (!check_password_policy($user->password, $errmsg)) {
            throw new moodle_exception($errmsg);
        }
        $userpassword = $user->password;
        unset($user->password);
    }
    // Apply default values for user preferences that are stored in users table.
    if (!isset($user->calendartype)) {
        $user->calendartype = core_user::get_property_default('calendartype');
    }
    if (!isset($user->maildisplay)) {
        $user->maildisplay = core_user::get_property_default('maildisplay');
    }
    if (!isset($user->mailformat)) {
        $user->mailformat = core_user::get_property_default('mailformat');
    }
    if (!isset($user->maildigest)) {
        $user->maildigest = core_user::get_property_default('maildigest');
    }
    if (!isset($user->autosubscribe)) {
        $user->autosubscribe = core_user::get_property_default('autosubscribe');
    }
    if (!isset($user->trackforums)) {
        $user->trackforums = core_user::get_property_default('trackforums');
    }
    if (!isset($user->lang)) {
        $user->lang = core_user::get_property_default('lang');
    }
    $user->timecreated = time();
    $user->timemodified = $user->timecreated;
    // Validate user data object.
    $uservalidation = core_user::validate($user);
    if ($uservalidation !== true) {
        foreach ($uservalidation as $field => $message) {
            debugging("The property '{$field}' has invalid data and has been cleaned.", DEBUG_DEVELOPER);
            $user->{$field} = core_user::clean_field($user->{$field}, $field);
        }
    }
    // Insert the user into the database.
    $newuserid = $DB->insert_record('user', $user);
    // Create USER context for this user.
    $usercontext = context_user::instance($newuserid);
    // Update user password if necessary.
    if (isset($userpassword)) {
        // Get full database user row, in case auth is default.
        $newuser = $DB->get_record('user', array('id' => $newuserid));
        $authplugin = get_auth_plugin($newuser->auth);
        $authplugin->user_update_password($newuser, $userpassword);
    }
    // Trigger event If required.
    if ($triggerevent) {
        \core\event\user_created::create_from_userid($newuserid)->trigger();
    }
    return $newuserid;
}
开发者ID:dg711,项目名称:moodle,代码行数:83,代码来源:lib.php

示例9: optional_param

$courseid = optional_param('course', SITEID, PARAM_INT);
// Course id (defaults to Site).
$PAGE->set_url('/user/language.php', array('id' => $userid, 'course' => $courseid));
list($user, $course) = useredit_setup_preference_page($userid, $courseid);
// Create form.
$languageform = new user_edit_language_form(null, array('userid' => $user->id));
$languageform->set_data($user);
$redirect = new moodle_url("/user/preferences.php", array('userid' => $user->id));
if ($languageform->is_cancelled()) {
    redirect($redirect);
} else {
    if ($data = $languageform->get_data()) {
        $lang = $data->lang;
        // If the specified language does not exist, use the site default.
        if (!get_string_manager()->translation_exists($lang, false)) {
            $lang = core_user::get_property_default('lang');
        }
        $user->lang = $lang;
        // Update user with new language.
        user_update_user($user, false, false);
        // Trigger event.
        \core\event\user_updated::create_from_userid($user->id)->trigger();
        if ($USER->id == $user->id) {
            $USER->lang = $lang;
        }
        redirect($redirect);
    }
}
// Display page header.
$streditmylanguage = get_string('preferredlanguage');
$userfullname = fullname($user, true);
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:language.php


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