本文整理汇总了PHP中print_password_policy函数的典型用法代码示例。如果您正苦于以下问题:PHP print_password_policy函数的具体用法?PHP print_password_policy怎么用?PHP print_password_policy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_password_policy函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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'));
}
示例2: definition
/**
* Define the set password form.
*/
public function definition()
{
global $USER, $CFG;
// Prepare a string showing whether the site wants login password autocompletion to be available to user.
if (empty($CFG->loginpasswordautocomplete)) {
$autocomplete = 'autocomplete="on"';
} else {
$autocomplete = '';
}
$mform = $this->_form;
$mform->setDisableShortforms(true);
$mform->addElement('header', 'setpassword', get_string('setpassword'), '');
// Include the username in the form so browsers will recognise that a password is being set.
$mform->addElement('text', 'username', '', 'style="display: none;" ' . $autocomplete);
$mform->setType('username', PARAM_RAW);
// Token gives authority to change password.
$mform->addElement('hidden', 'token', '');
$mform->setType('token', PARAM_ALPHANUM);
// Visible elements.
$mform->addElement('static', 'username2', get_string('username'));
if (!empty($CFG->passwordpolicy)) {
$mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
}
$mform->addElement('password', 'password', get_string('newpassword'), $autocomplete);
$mform->addRule('password', get_string('required'), 'required', null, 'client');
$mform->setType('password', PARAM_RAW);
$strpasswordagain = get_string('newpassword') . ' (' . get_string('again') . ')';
$mform->addElement('password', 'password2', $strpasswordagain, $autocomplete);
$mform->addRule('password2', get_string('required'), 'required', null, 'client');
$mform->setType('password2', PARAM_RAW);
$this->add_action_buttons(true);
}
示例3: definition
function definition()
{
global $USER, $CFG;
$mform =& $this->_form;
$mform->addElement('header', '', get_string('changepassword'), '');
// visible elements
$mform->addElement('static', 'username', get_string('username'), $USER->username);
if (!empty($CFG->passwordpolicy)) {
$passwordpolicy = print_password_policy();
$mform->addElement('html', $passwordpolicy);
}
$mform->addElement('password', 'password', get_string('oldpassword'));
$mform->addRule('password', get_string('required'), 'required', null, 'client');
$mform->setType('password', PARAM_RAW);
$mform->addElement('password', 'newpassword1', get_string('newpassword'));
$mform->addRule('newpassword1', get_string('required'), 'required', null, 'client');
$mform->setType('newpassword1', PARAM_RAW);
$mform->addElement('password', 'newpassword2', get_string('newpassword') . ' (' . get_String('again') . ')');
$mform->addRule('newpassword2', get_string('required'), 'required', null, 'client');
$mform->setType('newpassword2', PARAM_RAW);
// hidden optional params
$mform->addElement('hidden', 'id', 0);
$mform->setType('id', PARAM_INT);
// buttons
if (get_user_preferences('auth_forcepasswordchange')) {
$this->add_action_buttons(false);
} else {
$this->add_action_buttons(true);
}
}
示例4: definition
function definition()
{
global $USER, $CFG, $COURSE;
$mform =& $this->_form;
$editoroptions = null;
$filemanageroptions = null;
$userid = $USER->id;
if (is_array($this->_customdata)) {
if (array_key_exists('editoroptions', $this->_customdata)) {
$editoroptions = $this->_customdata['editoroptions'];
}
if (array_key_exists('filemanageroptions', $this->_customdata)) {
$filemanageroptions = $this->_customdata['filemanageroptions'];
}
if (array_key_exists('userid', $this->_customdata)) {
$userid = $this->_customdata['userid'];
}
}
//Accessibility: "Required" is bad legend text.
$strgeneral = get_string('general');
$strrequired = get_string('required');
/// 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);
/// Print the required moodle fields first
$mform->addElement('header', 'moodle', $strgeneral);
$mform->addElement('text', 'username', get_string('username'), 'size="20"');
$mform->addRule('username', $strrequired, 'required', null, 'client');
$mform->setType('username', PARAM_RAW);
$auths = get_plugin_list('auth');
$auth_options = array();
foreach ($auths as $auth => $unused) {
$auth_options[$auth] = get_string('pluginname', "auth_{$auth}");
}
$mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $auth_options);
$mform->addHelpButton('auth', 'chooseauthmethod', 'auth');
$mform->addElement('advcheckbox', 'suspended', get_string('suspended', 'auth'));
$mform->addHelpButton('suspended', 'suspended', 'auth');
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('advcheckbox', 'preference_auth_forcepasswordchange', get_string('forcepasswordchange'));
$mform->addHelpButton('preference_auth_forcepasswordchange', 'forcepasswordchange');
/// shared fields
useredit_shared_definition($mform, $editoroptions, $filemanageroptions);
/// Next the customisable profile fields
profile_definition($mform, $userid);
if ($userid == -1) {
$btnstring = get_string('createuser');
} else {
$btnstring = get_string('updatemyprofile');
}
$this->add_action_buttons(false, $btnstring);
}
示例5: definition
function definition()
{
global $CFG;
$mform = $this->_form;
// This 'dummy' element has two purposes:
// - To force open the Moodle Forms invisible fieldset outside of any table on the form (corrupts display otherwise)
// - To let us inform the user that there are validation errors without them having to scroll down further
$mform->addElement('static', 'form_errors');
$mform->addElement('header', 'emailandpassword', get_string('emailandpassword', 'local_obu_application'), '');
$mform->addElement('static', 'preregistered', get_string('preregistered', 'local_obu_application'));
$mform->addElement('text', 'email', get_string('email'), 'size="25" maxlength="100"');
$mform->setType('email', PARAM_RAW_TRIMMED);
$mform->addRule('email', get_string('missingemail'), 'required', null, 'server');
$mform->addElement('text', 'username', get_string('confirm_email', 'local_obu_application'), 'size="25" maxlength="100"');
$mform->setType('username', PARAM_RAW_TRIMMED);
$mform->addRule('username', get_string('missingemail'), 'required', null, 'server');
if (!empty($CFG->passwordpolicy)) {
$mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
}
$mform->addElement('passwordunmask', 'password', get_string('password'), 'size="12" maxlength="32"');
$mform->setType('password', PARAM_RAW);
$mform->addRule('password', get_string('missingpassword'), 'required', null, 'server');
$mform->addElement('header', 'contactdetails', get_string('contactdetails', 'local_obu_application'), '');
$mform->addElement('text', 'title', get_string('title', 'local_obu_application'), 'size="10" maxlength="10"');
$mform->setType('title', PARAM_TEXT);
$mform->addRule('title', null, 'required', null, 'server');
$mform->addElement('text', 'firstname', get_string('firstname'), 'size="30" maxlength="100"');
$mform->setType('firstname', PARAM_TEXT);
$mform->addRule('firstname', null, 'required', null, 'server');
$mform->addElement('text', 'lastname', get_string('lastname'), 'size="30" maxlength="100"');
$mform->setType('lastname', PARAM_TEXT);
$mform->addRule('lastname', null, 'required', null, 'server');
$mform->addElement('text', 'phone1', get_string('phone', 'local_obu_application'), 'size="20" maxlength="20"');
$mform->setType('phone1', PARAM_TEXT);
$mform->addRule('phone1', null, 'required', null, 'server');
// Use reCAPTCHA if it's setup
if (!empty($CFG->recaptchapublickey) && !empty($CFG->recaptchaprivatekey)) {
$mform->addElement('recaptcha', 'recaptcha_element', get_string('recaptcha', 'auth'), array('https' => $CFG->loginhttps));
$mform->addHelpButton('recaptcha_element', 'recaptcha', 'auth');
}
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('register', 'local_obu_application'));
}
示例6: definition
function definition()
{
global $USER, $CFG, $COURSE;
$mform =& $this->_form;
$this->set_upload_manager(new upload_manager('imagefile', false, false, null, false, 0, true, true, false));
//Accessibility: "Required" is bad legend text.
$strgeneral = get_string('general');
$strrequired = get_string('required');
/// 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);
/// Print the required moodle fields first
$mform->addElement('header', 'moodle', $strgeneral);
$mform->addElement('text', 'username', get_string('username'), 'size="20"');
$mform->addRule('username', $strrequired, 'required', null, 'client');
$mform->setType('username', PARAM_RAW);
$modules = get_list_of_plugins('auth');
$auth_options = array();
foreach ($modules as $module) {
$auth_options[$module] = auth_get_plugin_title($module);
}
$mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $auth_options);
$mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod', 'auth')));
$mform->setAdvanced('auth');
if (!empty($CFG->passwordpolicy)) {
$mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
}
$mform->addElement('passwordunmask', 'newpassword', get_string('newpassword'), 'size="20"');
$mform->setHelpButton('newpassword', array('newpassword', get_string('leavetokeep')));
$mform->setType('newpassword', PARAM_RAW);
$mform->addElement('advcheckbox', 'preference_auth_forcepasswordchange', get_string('forcepasswordchange'));
$mform->setHelpButton('preference_auth_forcepasswordchange', array('forcepasswordchange', get_string('forcepasswordchange')));
/// shared fields
useredit_shared_definition($mform);
$mform->addElement('header', 'f1integration', get_string('f1integration'));
$mform->addElement('text', 'f1householdid', get_string('f1householdid'));
$mform->setType('f1householdid', PARAM_INT);
$mform->addElement('text', 'f1individualid', get_string('f1individualid'));
$mform->setType('f1individualid', PARAM_INT);
/// Next the customisable profile fields
profile_definition($mform);
$this->add_action_buttons(false, get_string('updatemyprofile'));
}
示例7: definition
function definition()
{
global $USER, $CFG;
$mform = $this->_form;
$mform->setDisableShortforms(true);
$mform->addElement('header', 'changepassword', get_string('changepassword'), '');
// visible elements
$mform->addElement('static', 'username', get_string('username'), $USER->username);
$policies = array();
if (!empty($CFG->passwordpolicy)) {
$policies[] = print_password_policy();
}
if (!empty($CFG->passwordreuselimit) and $CFG->passwordreuselimit > 0) {
$policies[] = get_string('informminpasswordreuselimit', 'auth', $CFG->passwordreuselimit);
}
if ($policies) {
$mform->addElement('static', 'passwordpolicyinfo', '', implode('<br />', $policies));
}
$mform->addElement('password', 'password', get_string('oldpassword'));
$mform->addRule('password', get_string('required'), 'required', null, 'client');
$mform->setType('password', PARAM_RAW);
$mform->addElement('password', 'newpassword1', get_string('newpassword'));
$mform->addRule('newpassword1', get_string('required'), 'required', null, 'client');
$mform->setType('newpassword1', PARAM_RAW);
$mform->addElement('password', 'newpassword2', get_string('newpassword') . ' (' . get_String('again') . ')');
$mform->addRule('newpassword2', get_string('required'), 'required', null, 'client');
$mform->setType('newpassword2', PARAM_RAW);
if (empty($CFG->passwordchangetokendeletion) and !empty(webservice::get_active_tokens($USER->id))) {
$mform->addElement('advcheckbox', 'signoutofotherservices', get_string('signoutofotherservices'));
$mform->addHelpButton('signoutofotherservices', 'signoutofotherservices');
$mform->setDefault('signoutofotherservices', 1);
}
// hidden optional params
$mform->addElement('hidden', 'id', 0);
$mform->setType('id', PARAM_INT);
// buttons
if (get_user_preferences('auth_forcepasswordchange')) {
$this->add_action_buttons(false);
} else {
$this->add_action_buttons(true);
}
}
示例8: test_get_signup_settings
public function test_get_signup_settings()
{
global $CFG;
$CFG->defaultcity = 'Bcn';
$CFG->country = 'ES';
$CFG->sitepolicy = 'https://moodle.org';
$result = auth_email_external::get_signup_settings();
$result = external_api::clean_returnvalue(auth_email_external::get_signup_settings_returns(), $result);
// Check expected data.
$this->assertEquals(array('firstname', 'lastname'), $result['namefields']);
$this->assertEquals($CFG->defaultcity, $result['defaultcity']);
$this->assertEquals($CFG->country, $result['country']);
$this->assertEquals($CFG->sitepolicy, $result['sitepolicy']);
$this->assertEquals(print_password_policy(), $result['passwordpolicy']);
$this->assertNotContains('recaptchachallengehash', $result);
$this->assertNotContains('recaptchachallengeimage', $result);
$this->assertCount(2, $result['profilefields']);
$this->assertEquals('text', $result['profilefields'][0]['datatype']);
$this->assertEquals('textarea', $result['profilefields'][1]['datatype']);
}
示例9: 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;
}
示例10: definition
function definition()
{
global $USER, $CFG;
$mform = $this->_form;
$mform->addElement('header', '', 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', '', get_string('supplyinfo'), '');
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="25"');
$mform->setType('email', PARAM_NOTAGS);
$mform->addRule('email', get_string('missingemail'), 'required', null, 'server');
$mform->addElement('text', 'email2', get_string('emailagain'), 'maxlength="100" size="25"');
$mform->setType('email2', PARAM_NOTAGS);
$mform->addRule('email2', get_string('missingemail'), 'required', null, 'server');
$nameordercheck = new stdClass();
$nameordercheck->firstname = 'a';
$nameordercheck->lastname = 'b';
if (fullname($nameordercheck) == 'b a') {
// See MDL-4325
$mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
$mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
} else {
$mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
$mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
}
$mform->setType('firstname', PARAM_TEXT);
$mform->addRule('firstname', get_string('missingfirstname'), 'required', null, 'server');
$mform->setType('lastname', PARAM_TEXT);
$mform->addRule('lastname', get_string('missinglastname'), 'required', null, 'server');
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="20"');
$mform->setType('city', PARAM_TEXT);
$mform->addRule('city', get_string('missingcity'), 'required', null, 'server');
$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);
$mform->addRule('country', get_string('missingcountry'), 'required', null, 'server');
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('recaptcha', 'auth'), array('https' => $CFG->loginhttps));
$mform->addHelpButton('recaptcha_element', 'recaptcha', 'auth');
}
profile_signup_fields($mform);
if (!empty($CFG->sitepolicy)) {
$mform->addElement('header', '', get_string('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'));
}
示例11: definition
/**
* Define the form.
*/
public function definition()
{
global $USER, $CFG, $COURSE;
$mform = $this->_form;
$editoroptions = null;
$filemanageroptions = null;
if (!is_array($this->_customdata)) {
throw new coding_exception('invalid custom data for user_edit_form');
}
$editoroptions = $this->_customdata['editoroptions'];
$filemanageroptions = $this->_customdata['filemanageroptions'];
$user = $this->_customdata['user'];
$userid = $user->id;
// Accessibility: "Required" is bad legend text.
$strgeneral = get_string('general');
$strrequired = get_string('required');
// 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);
// Print the required moodle fields first.
$mform->addElement('header', 'moodle', $strgeneral);
$mform->addElement('text', 'username', get_string('username'), 'size="20"');
$mform->addRule('username', $strrequired, 'required', null, 'client');
$mform->setType('username', PARAM_RAW);
$auths = core_component::get_plugin_list('auth');
$enabled = get_string('pluginenabled', 'core_plugin');
$disabled = get_string('plugindisabled', 'core_plugin');
$authoptions = array($enabled => array(), $disabled => array());
$cannotchangepass = array();
foreach ($auths as $auth => $unused) {
$authinst = get_auth_plugin($auth);
$passwordurl = $authinst->change_password_url();
if (!($authinst->can_change_password() && empty($passwordurl))) {
if ($userid < 1 and $authinst->is_internal()) {
// This is unlikely but we can not create account without password
// when plugin uses passwords, we need to set it initially at least.
} else {
$cannotchangepass[] = $auth;
}
}
if (is_enabled_auth($auth)) {
$authoptions[$enabled][$auth] = get_string('pluginname', "auth_{$auth}");
} else {
$authoptions[$disabled][$auth] = get_string('pluginname', "auth_{$auth}");
}
}
$mform->addElement('selectgroups', 'auth', get_string('chooseauthmethod', 'auth'), $authoptions);
$mform->addHelpButton('auth', 'chooseauthmethod', 'auth');
$mform->addElement('advcheckbox', 'suspended', get_string('suspended', 'auth'));
$mform->addHelpButton('suspended', 'suspended', 'auth');
$mform->addElement('checkbox', 'createpassword', get_string('createpassword', 'auth'));
$mform->disabledIf('createpassword', 'auth', 'in', $cannotchangepass);
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->disabledIf('newpassword', 'createpassword', 'checked');
$mform->disabledIf('newpassword', 'auth', 'in', $cannotchangepass);
$mform->addElement('advcheckbox', 'preference_auth_forcepasswordchange', get_string('forcepasswordchange'));
$mform->addHelpButton('preference_auth_forcepasswordchange', 'forcepasswordchange');
$mform->disabledIf('preference_auth_forcepasswordchange', 'createpassword', 'checked');
// Shared fields.
useredit_shared_definition($mform, $editoroptions, $filemanageroptions, $user);
// Next the customisable profile fields.
profile_definition($mform, $userid);
if ($userid == -1) {
$btnstring = get_string('createuser');
} else {
$btnstring = get_string('updatemyprofile');
}
$this->add_action_buttons(false, $btnstring);
$this->set_data($user);
}
示例12: 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;
}
}
//.........这里部分代码省略.........
示例13: definition
function definition() {
global $USER, $CFG, $DB, $PAGE;
global $myuser;
$costcenter = new costcenter();
$mform = $this->_form;
$positions=new positions();
$id = $this->_customdata['id'];
$editoroptions = $this->_customdata['editoroptions'];
$filemanageroptions = $this->_customdata['filemanageroptions'];
$admin = $this->_customdata['admin'];
$mform->addElement('header', 'moodle', get_string('generaldetails', 'local_users'));
if (!$admin) {
$mform->addElement('date_selector', 'dateofapplication', get_string('joiningdate', 'local_users'));
}
if (is_siteadmin($USER->id)) {
$costcenters = $DB->get_records('local_costcenter', array('visible' => 1));
$Position =$DB->get_records('local_positions',array('visible'=>1));
} else {
$costcenters = $costcenter->get_assignedcostcenters();
}
$parents = $costcenter->get_costcenter_parent($costcenters, '', $top = true, $all = false);
$position =$positions->get_positions_parent($Position,'', $top=true, $all = false);
$count = count($costcenters);
$mform->addElement('hidden', 'count', $count);
$mform->setType('count', PARAM_INT);
if ($id > 0) {
$mform->addElement('static', 'costcenter_name', get_string('costcenterid', 'local_costcenter'));
//$mform->addElement('static', 'role_name', get_string('role', 'local_users'));
} else {
if ($count == 1) {
//registrar is assigned to only one costcenter, display as static
foreach ($costcenters as $scl) {
$key = $scl->id;
$value = $scl->fullname;
}
$mform->addElement('static', 'costcenters', get_string('costcenterid', 'local_costcenter'), $value);
$mform->addElement('hidden', 'costcenterid', $key);
$mform->setType('costcenterid', PARAM_INT);
} else {
$costcenters = $mform->addElement('select', 'costcenterid', get_string('select', 'local_costcenter'), $parents);
$mform->addHelpButton('costcenterid', 'assigncostcenter', 'local_costcenter');
$mform->addRule('costcenterid', get_string('required'), 'required', null, 'client');
}
// $systemroles = $myuser->systemroles_custom();
// $mform->addElement('select', 'roleid', get_string('selectrole', 'local_users'), $systemroles);
// $mform->addHelpButton('roleid', 'assignrole', 'local_users');
// $mform->addRule('roleid', get_string('required'), 'required', null, 'client');
}
$mform->addElement('text', 'username', get_string('username', 'local_users'));
$mform->addRule('username', get_string('required'), 'required', null, 'client');
$mform->setType('username', PARAM_RAW);
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);
if ($id < 0)
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
$mform->addElement('header', 'moodle', get_string('personaldetails', 'local_users'));
$mform->addElement('text', 'firstname', get_string('firstname', 'local_users'));
$mform->addRule('firstname', get_string('required'), 'required', null, 'client');
$mform->setType('firstname', PARAM_RAW);
$mform->addElement('text', 'middlename', get_string('middlename', 'local_users'));
$mform->setType('middlename', PARAM_RAW);
$mform->addElement('text', 'lastname', get_string('lastname', 'local_users'));
$mform->addRule('lastname', get_string('required'), 'required', null, 'client');
$mform->setType('lastname', PARAM_RAW);
//$costcenters = $mform->addElement('select', 'position', get_string('select', 'local_positions'), $position);
//$mform->addHelpButton('position', 'assignpositions', 'local_positions');
//$mform->addRule('position', get_string('required'), 'required', null, 'client');
$radioarray = array();
$radioarray[] = & $mform->createElement('radio', 'gender', '', get_string('male', 'local_users'), 'M');
$radioarray[] = & $mform->createElement('radio', 'gender', '', get_string('female', 'local_users'), 'F');
$mform->addGroup($radioarray, 'gender', 'Gender', array(' '), false);
$mform->setDefault('gender', 'Male');
//if (!$admin) {
// $mform->addElement('date_selector', 'dob', get_string('dob', 'local_users'));
// $mform->addHelpButton('dob', 'dateofbirth', 'local_users');
//}
/************************************code by sreekanth**********************************************/
$mform->addElement('header', 'otherdetails', get_string('otherdetails', 'local_users'));
$mform->addElement('text', 'designation', get_string('designation', 'local_users'));
$mform->setType('designation', PARAM_RAW);
$mform->addElement('text', 'level', get_string('level', 'local_users'));
$mform->setType('level', PARAM_RAW);
//.........这里部分代码省略.........
示例14: definition
function definition() {
global $USER, $CFG, $DB, $PAGE;
global $hierarchy, $myuser;
$mform = $this->_form;
$id = $this->_customdata['id'];
$editoroptions = $this->_customdata['editoroptions'];
$filemanageroptions = $this->_customdata['filemanageroptions'];
$admin = $this->_customdata['admin'];
$mform->addElement('header', 'moodle', get_string('generaldetails', 'local_users'));
if (!$admin) {
$mform->addElement('date_selector', 'dateofapplication', get_string('joiningdate', 'local_users'));
}
if (is_siteadmin($USER->id)) {
$school = $DB->get_records('local_school', array('visible' => 1));
} else {
$school = $hierarchy->get_assignedschools();
}
$parents = $hierarchy->get_school_parent($school, '', $top = true, $all = false);
$count = count($school);
$mform->addElement('hidden', 'count', $count);
$mform->setType('count', PARAM_INT);
if ($id > 0) {
$mform->addElement('static', 'school_name', get_string('schoolid', 'local_collegestructure'));
// $mform->addElement('static', 'role_name', get_string('role', 'local_users'));
} else {
if ($count == 1) {
//registrar is assigned to only one school, display as static
foreach ($school as $scl) {
$key = $scl->id;
$value = $scl->fullname;
}
$mform->addElement('static', 'schools', get_string('schoolid', 'local_collegestructure'), $value);
$mform->addElement('hidden', 'schoolid', $key);
$mform->setType('schoolid', PARAM_INT);
} else {
$school = $mform->addElement('select', 'schoolid', get_string('select', 'local_collegestructure'), $parents);
$mform->addHelpButton('schoolid', 'assignschool', 'local_collegestructure');
$mform->addRule('schoolid', get_string('required'), 'required', null, 'client');
}
}
$systemroles = $myuser->systemroles_custom();
$mform->addElement('select', 'roleid', get_string('selectrole', 'local_users'), $systemroles);
$mform->addHelpButton('roleid', 'assignrole', 'local_users');
$mform->addRule('roleid', get_string('required'), 'required', null, 'client');
$mform->addElement('text', 'username', get_string('username', 'local_users'));
$mform->addRule('username', get_string('required'), 'required', null, 'client');
$mform->setType('username', PARAM_RAW);
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);
if ($id < 0)
$mform->addRule('newpassword', get_string('required'), 'required', null, 'client');
$mform->addElement('header', 'moodle', get_string('personaldetails', 'local_users'));
$mform->addElement('text', 'firstname', get_string('firstname', 'local_admission'));
$mform->addRule('firstname', get_string('required'), 'required', null, 'client');
$mform->setType('firstname', PARAM_RAW);
$mform->addElement('text', 'middlename', get_string('middlename', 'local_admission'));
$mform->setType('middlename', PARAM_RAW);
$mform->addElement('text', 'lastname', get_string('lastname', 'local_admission'));
$mform->addRule('lastname', get_string('required'), 'required', null, 'client');
$mform->setType('lastname', PARAM_RAW);
$radioarray = array();
$radioarray[] = & $mform->createElement('radio', 'gender', '', get_string('male', 'local_admission'), 'Male');
$radioarray[] = & $mform->createElement('radio', 'gender', '', get_string('female', 'local_admission'), 'Female');
$mform->addGroup($radioarray, 'gender', 'Gender', array(' '), false);
$mform->setDefault('gender', 'Male');
if (!$admin) {
$mform->addElement('date_selector', 'dob', get_string('dob', 'local_admission'));
$mform->addHelpButton('dob', 'dateofbirth', 'local_users');
}
$mform->addElement('header', 'moodle', get_string('contactdetails', 'local_users'));
$mform->addElement('text', 'phone1', get_string('phone', 'local_admission'));
$mform->addRule('phone1', get_string('required'), 'required', null, 'client');
$mform->addRule('phone1', get_string('numeric', 'local_admission'), 'numeric', null, 'client');
$mform->addRule('phone1', get_string('phoneminimum', 'local_admission'), 'minlength', 10, 'client');
$mform->addRule('phone1', get_string('phonemaximum', 'local_admission'), 'maxlength', 15, 'client');
$mform->setType('phone1', PARAM_RAW);
$mform->addElement('text', 'email', get_string('email', 'local_admission'));
$mform->addRule('email', get_string('required'), 'required', null, 'client');
$mform->addRule('email', get_string('emailerror', 'local_admission'), 'email', null, 'client');
$mform->setType('email', PARAM_RAW);
$mform->addElement('text', 'city', get_string('city'));
$mform->addRule('city', get_string('required'), 'required', null, 'client');
$mform->setType('city', PARAM_RAW);
//.........这里部分代码省略.........