本文整理汇总了PHP中useredit_get_required_name_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP useredit_get_required_name_fields函数的具体用法?PHP useredit_get_required_name_fields怎么用?PHP useredit_get_required_name_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了useredit_get_required_name_fields函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: definition
function definition()
{
global $USER, $CFG;
$mform = $this->_form;
$mform->addElement('header', 'createuserandpass', get_string('createuserandpass'), '');
$mform->addElement('text', 'username', get_string('username'), 'maxlength="100" size="12"');
$mform->setType('username', PARAM_NOTAGS);
$mform->addRule('username', get_string('missingusername'), 'required', null, 'server');
if (!empty($CFG->passwordpolicy)) {
$mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
}
$mform->addElement('passwordunmask', 'password', get_string('password'), 'maxlength="32" size="12"');
$mform->setType('password', PARAM_RAW);
$mform->addRule('password', get_string('missingpassword'), 'required', null, 'server');
$mform->addElement('header', 'supplyinfo', get_string('supplyinfo'), '');
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="25"');
$mform->setType('email', PARAM_RAW_TRIMMED);
$mform->addRule('email', get_string('missingemail'), 'required', null, 'server');
$mform->addElement('text', 'email2', get_string('emailagain'), 'maxlength="100" size="25"');
$mform->setType('email2', PARAM_RAW_TRIMMED);
$mform->addRule('email2', get_string('missingemail'), 'required', null, 'server');
$namefields = useredit_get_required_name_fields();
foreach ($namefields as $field) {
$mform->addElement('text', $field, get_string($field), 'maxlength="100" size="30"');
$mform->setType($field, PARAM_TEXT);
$stringid = 'missing' . $field;
if (!get_string_manager()->string_exists($stringid, 'moodle')) {
$stringid = 'required';
}
$mform->addRule($field, get_string($stringid), 'required', null, 'server');
}
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="20"');
$mform->setType('city', PARAM_TEXT);
if (!empty($CFG->defaultcity)) {
$mform->setDefault('city', $CFG->defaultcity);
}
$country = get_string_manager()->get_list_of_countries();
$default_country[''] = get_string('selectacountry');
$country = array_merge($default_country, $country);
$mform->addElement('select', 'country', get_string('country'), $country);
if (!empty($CFG->country)) {
$mform->setDefault('country', $CFG->country);
} else {
$mform->setDefault('country', '');
}
if ($this->signup_captcha_enabled()) {
$mform->addElement('recaptcha', 'recaptcha_element', get_string('security_question', 'auth'), array('https' => $CFG->loginhttps));
$mform->addHelpButton('recaptcha_element', 'recaptcha', 'auth');
}
profile_signup_fields($mform);
if (!empty($CFG->sitepolicy)) {
$mform->addElement('header', 'policyagreement', get_string('policyagreement'), '');
$mform->setExpanded('policyagreement');
$mform->addElement('static', 'policylink', '', '<a href="' . $CFG->sitepolicy . '" onclick="this.target=\'_blank\'">' . get_String('policyagreementclick') . '</a>');
$mform->addElement('checkbox', 'policyagreed', get_string('policyaccept'));
$mform->addRule('policyagreed', get_string('policyagree'), 'required', null, 'server');
}
// buttons
$this->add_action_buttons(true, get_string('createaccount'));
}
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:60,代码来源:signup_form.php
示例2: test_useredit_get_required_name_fields
/**
* Test that the required fields are returned in the correct order.
*/
function test_useredit_get_required_name_fields()
{
global $CFG;
// Back up config settings for restore later.
$originalcfg = new stdClass();
$originalcfg->fullnamedisplay = $CFG->fullnamedisplay;
$CFG->fullnamedisplay = 'language';
$expectedresult = array(5 => 'firstname', 21 => 'lastname');
$this->assertEquals(useredit_get_required_name_fields(), $expectedresult);
$CFG->fullnamedisplay = 'firstname';
$expectedresult = array(5 => 'firstname', 21 => 'lastname');
$this->assertEquals(useredit_get_required_name_fields(), $expectedresult);
$CFG->fullnamedisplay = 'lastname firstname';
$expectedresult = array('lastname', 9 => 'firstname');
$this->assertEquals(useredit_get_required_name_fields(), $expectedresult);
$CFG->fullnamedisplay = 'firstnamephonetic lastnamephonetic';
$expectedresult = array(5 => 'firstname', 21 => 'lastname');
$this->assertEquals(useredit_get_required_name_fields(), $expectedresult);
// Tidy up after we finish testing.
$CFG->fullnamedisplay = $originalcfg->fullnamedisplay;
}
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:24,代码来源:editlib_test.php
示例3: get_signup_settings
/**
* Get the signup required settings and profile fields.
*
* @return array settings and possible warnings
* @since Moodle 3.2
* @throws moodle_exception
*/
public static function get_signup_settings()
{
global $CFG, $PAGE;
$context = context_system::instance();
// We need this to make work the format text functions.
$PAGE->set_context($context);
self::check_signup_enabled();
$result = array();
$result['namefields'] = useredit_get_required_name_fields();
if (!empty($CFG->passwordpolicy)) {
$result['passwordpolicy'] = print_password_policy();
}
if (!empty($CFG->sitepolicy)) {
$result['sitepolicy'] = $CFG->sitepolicy;
}
if (!empty($CFG->defaultcity)) {
$result['defaultcity'] = $CFG->defaultcity;
}
if (!empty($CFG->country)) {
$result['country'] = $CFG->country;
}
if ($fields = profile_get_signup_fields()) {
$result['profilefields'] = array();
foreach ($fields as $field) {
$fielddata = $field->object->get_field_config_for_external();
$fielddata['categoryname'] = external_format_string($field->categoryname, $context->id);
$fielddata['name'] = external_format_string($fielddata['name'], $context->id);
list($fielddata['defaultdata'], $fielddata['defaultdataformat']) = external_format_text($fielddata['defaultdata'], $fielddata['defaultdataformat'], $context->id);
$result['profilefields'][] = $fielddata;
}
}
if (signup_captcha_enabled()) {
require_once $CFG->libdir . '/recaptchalib.php';
// We return the public key, maybe we want to use the javascript api to get the image.
$result['recaptchapublickey'] = $CFG->recaptchapublickey;
list($result['recaptchachallengehash'], $result['recaptchachallengeimage'], $result['recaptchachallengejs']) = recaptcha_get_challenge_hash_and_urls(RECAPTCHA_API_SECURE_SERVER, $CFG->recaptchapublickey);
}
$result['warnings'] = array();
return $result;
}
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:47,代码来源:external.php
示例4: validation
/**
* Server side validation.
*/
function validation($data, $files)
{
$errors = parent::validation($data, $files);
$columns = $this->_customdata['columns'];
$optype = $data['uutype'];
// detect if password column needed in file
if (!in_array('password', $columns)) {
switch ($optype) {
case UU_USER_UPDATE:
if (!empty($data['uupasswordold'])) {
$errors['uupasswordold'] = get_string('missingfield', 'error', 'password');
}
break;
case UU_USER_ADD_UPDATE:
if (empty($data['uupasswordnew'])) {
$errors['uupasswordnew'] = get_string('missingfield', 'error', 'password');
}
if (!empty($data['uupasswordold'])) {
$errors['uupasswordold'] = get_string('missingfield', 'error', 'password');
}
break;
case UU_USER_ADDNEW:
if (empty($data['uupasswordnew'])) {
$errors['uupasswordnew'] = get_string('missingfield', 'error', 'password');
}
break;
case UU_USER_ADDINC:
if (empty($data['uupasswordnew'])) {
$errors['uupasswordnew'] = get_string('missingfield', 'error', 'password');
}
break;
}
}
// look for other required data
if ($optype != UU_USER_UPDATE) {
$requiredusernames = useredit_get_required_name_fields();
$missing = array();
foreach ($requiredusernames as $requiredusername) {
if (!in_array($requiredusername, $columns)) {
$missing[] = get_string('missingfield', 'error', $requiredusername);
}
}
if ($missing) {
$errors['uutype'] = implode('<br />', $missing);
}
if (!in_array('email', $columns) and empty($data['email'])) {
$errors['email'] = get_string('requiredtemplate', 'tool_uploaduser');
}
}
return $errors;
}
开发者ID:janeklb,项目名称:moodle,代码行数:54,代码来源:user_form.php
示例5: 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) {
//.........这里部分代码省略.........
开发者ID:gabrielrosset,项目名称:moodle,代码行数:101,代码来源:editlib.php
示例6: useredit_shared_definition
function useredit_shared_definition(&$mform, $editoroptions = null, $filemanageroptions = null)
{
global $CFG, $USER, $DB;
$user = $DB->get_record('user', array('id' => $USER->id));
useredit_load_preferences($user, false);
$strrequired = get_string('required');
// Add the necessary names.
foreach (useredit_get_required_name_fields() as $fullname) {
$mform->addElement('text', $fullname, get_string($fullname), 'maxlength="100" size="30"');
$mform->addRule($fullname, $strrequired, '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 (!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_EMAIL);
}
$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', 2);
$choices = array();
$choices['0'] = get_string('textformat');
$choices['1'] = get_string('htmlformat');
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
$mform->setDefault('mailformat', 1);
if (!empty($CFG->allowusermailcharset)) {
$choices = array();
$charsets = get_list_of_charsets();
if (!empty($CFG->sitemailcharset)) {
$choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
} else {
$choices['0'] = get_string('site') . ' (UTF-8)';
}
$choices = array_merge($choices, $charsets);
$mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
}
$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', 0);
$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', 1);
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', 0);
}
$editors = editors_get_enabled();
if (count($editors) > 1) {
$choices = array('' => get_string('defaulteditor'));
$firsteditor = '';
foreach (array_keys($editors) as $editor) {
if (!$firsteditor) {
$firsteditor = $editor;
}
$choices[$editor] = get_string('pluginname', 'editor_' . $editor);
}
$mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
$mform->setDefault('preference_htmleditor', '');
} else {
// Empty string means use the first chosen text editor.
$mform->addElement('hidden', 'preference_htmleditor');
$mform->setDefault('preference_htmleditor', '');
$mform->setType('preference_htmleditor', PARAM_PLUGIN);
}
$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', $CFG->country);
}
$choices = get_list_of_timezones();
$choices['99'] = get_string('serverlocaltime');
//.........这里部分代码省略.........
开发者ID:helenagarcia90,项目名称:moodle,代码行数:101,代码来源:editlib.php
示例7: definition_after_data
function definition_after_data()
{
$mform = $this->_form;
$mform->applyFilter('username', 'trim');
// Trim required name fields.
foreach (useredit_get_required_name_fields() as $field) {
$mform->applyFilter($field, 'trim');
}
}
开发者ID:dg711,项目名称:moodle,代码行数:9,代码来源:signup_form.php
示例8: redirect
$PAGE->set_url('/login/signup.php');
$PAGE->set_context(context_system::instance());
$mform_signup = $authplugin->signup_form();
if ($mform_signup->is_cancelled()) {
redirect(get_login_url());
} else {
if ($user = $mform_signup->get_data()) {
$user->confirmed = 0;
$user->lang = current_language();
$user->firstaccess = time();
$user->timecreated = time();
$user->mnethostid = $CFG->mnet_localhost_id;
$user->secret = random_string(15);
$user->auth = $CFG->registerauth;
// Initialize alternate name fields to empty strings.
$namefields = array_diff(get_all_user_name_fields(), useredit_get_required_name_fields());
foreach ($namefields as $namefield) {
$user->{$namefield} = '';
}
$authplugin->user_signup($user, true);
// prints notice and link to login/index.php
exit;
//never reached
}
}
// make sure we really are on the https page when https login required
$PAGE->verify_https_required();
$newaccount = get_string('newaccount');
$login = get_string('login');
$PAGE->navbar->add($login);
$PAGE->navbar->add($newaccount);
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:31,代码来源:signup.php
示例9: definition_after_data
/**
* Extend the form definition after data has been parsed.
*/
public function definition_after_data()
{
global $USER, $CFG, $DB, $OUTPUT;
$mform = $this->_form;
// Trim required name fields.
foreach (useredit_get_required_name_fields() as $field) {
$mform->applyFilter($field, 'trim');
}
if ($userid = $mform->getElementValue('id')) {
$user = $DB->get_record('user', array('id' => $userid));
} else {
$user = false;
}
// User can not change own auth method.
if ($userid == $USER->id) {
$mform->hardFreeze('auth');
$mform->hardFreeze('preference_auth_forcepasswordchange');
}
// Admin must choose some password and supply correct email.
if (!empty($USER->newadminuser)) {
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
if ($mform->elementExists('suspended')) {
$mform->removeElement('suspended');
}
}
// Require password for new users.
if ($userid > 0) {
if ($mform->elementExists('createpassword')) {
$mform->removeElement('createpassword');
}
}
if ($user and is_mnet_remote_user($user)) {
// Only local accounts can be suspended.
if ($mform->elementExists('suspended')) {
$mform->removeElement('suspended');
}
}
if ($user and ($user->id == $USER->id or is_siteadmin($user))) {
// Prevent self and admin mess ups.
if ($mform->elementExists('suspended')) {
$mform->hardFreeze('suspended');
}
}
// Print picture.
if (empty($USER->newadminuser)) {
if ($user) {
$context = context_user::instance($user->id, MUST_EXIST);
$fs = get_file_storage();
$hasuploadedpicture = $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.jpg');
if (!empty($user->picture) && $hasuploadedpicture) {
$imagevalue = $OUTPUT->user_picture($user, array('courseid' => SITEID, 'size' => 64));
} else {
$imagevalue = get_string('none');
}
} else {
$imagevalue = get_string('none');
}
$imageelement = $mform->getElement('currentpicture');
$imageelement->setValue($imagevalue);
if ($user && $mform->elementExists('deletepicture') && !$hasuploadedpicture) {
$mform->removeElement('deletepicture');
}
}
// Next the customisable profile fields.
profile_definition_after_data($mform, $userid);
}
开发者ID:rushi963,项目名称:moodle,代码行数:69,代码来源:editadvanced_form.php
示例10: definition
public function definition()
{
global $CFG, $DB;
$mform =& $this->_form;
// Then show the fields about where this block appears.
$mform->addElement('header', 'header', get_string('companyuser', 'block_iomad_company_admin'));
$mform->addElement('hidden', 'companyid', $this->selectedcompany);
$mform->setType('companyid', PARAM_INT);
// Code added by sumit
$mform->addElement('hidden', 'returnurl', $this->returnurl);
$mform->setType('returnurl', PARAM_LOCALURL);
// end of code
/* copied from /user/editlib.php */
$strrequired = get_string('required');
$mform->addElement('hidden', 'id', $this->userid);
$mform->setType('id', PARAM_INT);
// Deal with the name order sorting and required fields.
$necessarynames = useredit_get_required_name_fields();
foreach ($necessarynames as $necessaryname) {
$mform->addElement('text', $necessaryname, get_string($necessaryname), 'maxlength="100" size="30"');
$mform->addRule($necessaryname, $strrequired, 'required', null, 'client');
$mform->setType($necessaryname, PARAM_NOTAGS);
}
// Do not show email field if change confirmation is pending.
if (!empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) {
$notice = get_string('auth_emailchangepending', 'auth_email', $user);
$notice .= '<br /><a href="edit.php?cancelemailchange=1&id=' . $user->id . '">' . get_string('auth_emailchangecancel', 'auth_email') . '</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_EMAIL);
}
/* GWL : Add Field for Username while edit the user */
$mform->addElement('text', 'username', get_string('phone'), 'size="20"');
// GWL : Change get_string('username') to 'phone'
$mform->addRule('username', $strrequired, 'required', null, 'client');
$mform->setType('username', PARAM_RAW);
/* GWL : Add Field for Username while edit the user */
/* /copied from /user/editlib.php */
$mform->addElement('static', 'blankline', '', '');
if (!empty($CFG->passwordpolicy)) {
$mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
}
$mform->addElement('passwordunmask', 'newpassword', get_string('newpassword'), 'size="20"');
$mform->addHelpButton('newpassword', 'newpassword');
$mform->setType('newpassword', PARAM_RAW);
$mform->addElement('static', 'generatepassword', '', get_string('leavepasswordemptytogenerate', 'block_iomad_company_admin'));
$mform->addElement('advcheckbox', 'preference_auth_forcepasswordchange', get_string('forcepasswordchange'));
$mform->addHelpButton('preference_auth_forcepasswordchange', 'forcepasswordchange');
// $mform->setDefault('preference_auth_forcepasswordchange', 1);
$mform->addElement('selectyesno', 'sendnewpasswordemails', get_string('sendnewpasswordemails', 'block_iomad_company_admin'));
$mform->setDefault('sendnewpasswordemails', 1);
$mform->disabledIf('sendnewpasswordemails', 'newpassword', 'eq', '');
// Deal with company optional fields.
$mform->addElement('header', 'category_id', format_string(get_string('companyprofilefields', 'block_iomad_company_admin')));
// Department drop down.
// $mform->addElement('select', 'userdepartment', get_string('department', 'block_iomad_company_admin'), $this->subhierarchieslist, $this->userdepartment);
// Add in company/department manager checkboxes.
$departmentlist = company_department::get_department_list($this->selectedcompany);
$titlelist = company_title::get_title_list($this->selectedcompany);
if ($departmentlist) {
$mform->addElement('select', 'userdepartment', get_string('department', 'block_iomad_company_admin'), $departmentlist);
}
if ($titlelist) {
$mform->addElement('select', 'usertitle', get_string('title', 'local_manage_company_dept_title'), $titlelist);
}
$managerarray = array();
if (iomad::has_capability('block/iomad_company_admin:assign_department_manager', context_system::instance())) {
$managerarray['0'] = get_string('user', 'block_iomad_company_admin');
$managerarray['2'] = get_string('regionlocationmanager', 'block_iomad_company_admin');
}
if (iomad::has_capability('block/iomad_company_admin:assign_company_manager', context_system::instance())) {
if (empty($managearray)) {
$managerarray['0'] = get_string('user', 'block_iomad_company_admin');
}
$managerarray['1'] = get_string('companymanager', 'block_iomad_company_admin');
$managerarray['3'] = get_string('companyinstructor', 'block_iomad_company_admin');
//GWL : Add Instructor
}
if (!empty($managerarray)) {
$mform->addElement('select', 'managertype', get_string('managertype', 'block_iomad_company_admin'), $managerarray, 0);
$mform->addHelpButton('managertype', 'managertype', 'block_iomad_company_admin');
} else {
$mform->addElement('hidden', 'managertype', 0);
}
// get region list
$regionslistobj = company::get_all_regions($this->selectedcompany);
$regionlist = array('' => get_string('regionnotselect', 'block_iomad_company_admin'));
foreach ($regionslistobj as $region) {
$regionlist[$region->id] = $region->name;
}
// Code added by sumit display region and location drop downs list
$locationlist = array('' => get_string('choose'));
if (!empty($this->regionid)) {
$locationlistarr = company::get_all_locations($this->regionid);
foreach ($locationlistarr as $location) {
$locationlist[$location->id] = $location->name;
}
}
//.........这里部分代码省略.........
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:company_editadvanced_form.php
示例11: 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;
$userid = $mform->getElementValue('id');
// Trim required name fields.
foreach (useredit_get_required_name_fields() as $field) {
$mform->applyFilter($field, 'trim');
}
if ($user = $DB->get_record('user', array('id' => $userid))) {
// Remove description.
if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !$DB->record_exists('role_assignments', array('userid' => $userid))) {
$mform->removeElement('description_editor');
}
// Print picture.
$context = context_user::instance($user->id, MUST_EXIST);
$fs = get_file_storage();
$hasuploadedpicture = $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.jpg');
if (!empty($user->picture) && $hasuploadedpicture) {
$imagevalue = $OUTPUT->user_picture($user, array('courseid' => SITEID, 'size' => 64));
} else {
$imagevalue = get_string('none');
}
$imageelement = $mform->getElement('currentpicture');
$imageelement->setValue($imagevalue);
if ($mform->elementExists('deletepicture') && !$hasuploadedpicture) {
$mform->removeElement('deletepicture');
}
// Disable fields that are locked by auth plugins.
$fields = get_user_fieldnames();
$authplugin = get_auth_plugin($user->auth);
$customfields = $authplugin->get_custom_user_profile_fields();
$customfieldsdata = profile_user_record($userid, false);
$fields = array_merge($fields, $customfields);
foreach ($fields as $field) {
if ($field === 'description') {
// Hard coded hack for description field. See MDL-37704 for details.
$formfield = 'description_editor';
} else {
$formfield = $field;
}
if (!$mform->elementExists($formfield)) {
continue;
}
// Get the original value for the field.
if (in_array($field, $customfields)) {
$key = str_replace('profile_field_', '', $field);
$value = isset($customfieldsdata->{$key}) ? $customfieldsdata->{$key} : '';
} else {
$value = $user->{$field};
}
$configvariable = 'field_lock_' . $field;
if (isset($authplugin->config->{$configvariable})) {
if ($authplugin->config->{$configvariable} === 'locked') {
$mform->hardFreeze($formfield);
$mform->setConstant($formfield, $value);
} else {
if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $value != '') {
$mform->hardFreeze($formfield);
$mform->setConstant($formfield, $value);
}
}
}
}
// Next the customisable profile fields.
profile_definition_after_data($mform, $user->id);
} else {
profile_definition_after_data($mform, 0);
}
}
开发者ID:evltuma,项目名称:moodle,代码行数:73,代码来源:edit_form.php
示例12: signup_setup_new_user
/**
* Add the missing fields to a user that is going to be created
*
* @param stdClass $user the new user object
* @return stdClass the user filled
* @since Moodle 3.2
*/
function signup_setup_new_user($user)
{
global $CFG;
$user->confirmed = 0;
$user->lang = current_language();
$user->firstaccess = 0;
$user->timecreated = time();
$user->mnethostid = $CFG->mnet_localhost_id;
$user->secret = random_string(15);
$user->auth = $CFG->registerauth;
// Initialize alternate name fields to empty strings.
$namefields = array_diff(get_all_user_name_fields(), useredit_get_required_name_fields());
foreach ($namefields as $namefield) {
$user->{$namefield} = '';
}
return $user;
}
开发者ID:janeklb,项目名称:moodle,代码行数:24,代码来源:authlib.php
示例13: signup_user
function signup_user($user)
{
global $CFG;
$authplugin = get_auth_plugin($CFG->registerauth);
$namefields = array_diff(get_all_user_name_fields(), useredit_get_required_name_fields());
foreach ($namefields as $namefield) {
$user->{$namefield} = '';
}
try {
$authplugin->user_signup($user, false);
$this->update_users_data($user);
echo "User {$user->username} has been imported";
echo "<br>-------------------------------------------------------<br>";
} catch (Exception $e) {
echo 'Error occured: ', $e->getMessage(), "\n";
}
}
开发者ID:sirromas,项目名称:medical,代码行数:17,代码来源:Import.php
注:本文中的useredit_get_required_name_fields函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论