/**
  * Define the setting for a datetime custom field.
  *
  * @param moodleform $form the user form
  */
 public function define_form_specific($form)
 {
     // Get the current calendar in use - see MDL-18375.
     $calendartype = \core_calendar\type_factory::get_calendar_instance();
     // Create variables to store start and end.
     list($year, $month, $day) = explode('_', date('Y_m_d'));
     $currentdate = $calendartype->convert_from_gregorian($year, $month, $day);
     $currentyear = $currentdate['year'];
     $arryears = $calendartype->get_years();
     // Add elements.
     $form->addElement('select', 'param1', get_string('startyear', 'profilefield_datetime'), $arryears);
     $form->setType('param1', PARAM_INT);
     $form->setDefault('param1', $currentyear);
     $form->addElement('select', 'param2', get_string('endyear', 'profilefield_datetime'), $arryears);
     $form->setType('param2', PARAM_INT);
     $form->setDefault('param2', $currentyear);
     $form->addElement('checkbox', 'param3', get_string('wanttime', 'profilefield_datetime'));
     $form->setType('param3', PARAM_INT);
     $form->addElement('hidden', 'startday', '1');
     $form->setType('startday', PARAM_INT);
     $form->addElement('hidden', 'startmonth', '1');
     $form->setType('startmonth', PARAM_INT);
     $form->addElement('hidden', 'startyear', '1');
     $form->setType('startyear', PARAM_INT);
     $form->addElement('hidden', 'endday', '1');
     $form->setType('endday', PARAM_INT);
     $form->addElement('hidden', 'endmonth', '1');
     $form->setType('endmonth', PARAM_INT);
     $form->addElement('hidden', 'endyear', '1');
     $form->setType('endyear', PARAM_INT);
     $form->addElement('hidden', 'defaultdata', '0');
     $form->setType('defaultdata', PARAM_INT);
 }
Exemple #2
0
 /**
  * Adds elements to the form for creating/editing this type of profile field.
  * @param moodleform $form
  */
 public function define_form_specific($form)
 {
     // Param 1 for menu type contains the options.
     $form->addElement('textarea', 'param1', get_string('profilemenuoptions', 'admin'), array('rows' => 6, 'cols' => 40));
     $form->setType('param1', PARAM_TEXT);
     // Default data.
     $form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
     $form->setType('defaultdata', PARAM_TEXT);
 }
 /**
  * Form definition.
  *
  * @param moodleform $mform Moodle form.
  * @return void
  */
 protected function specific_definition($mform)
 {
     $mform->addElement('header', 'confighdr', get_string('configheader', 'block_xp'));
     $mform->addElement('text', 'config_title', get_string('configtitle', 'block_xp'));
     $mform->setDefault('config_title', get_string('levelup', 'block_xp'));
     $mform->setType('config_title', PARAM_TEXT);
     $mform->addElement('textarea', 'config_description', get_string('configdescription', 'block_xp'));
     $mform->setDefault('config_description', get_string('participatetolevelup', 'block_xp'));
     $mform->setType('config_description', PARAM_TEXT);
 }
 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform Moodle forms object
  * @param stdClass $data not used
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_date', get_string('enable'));
     $mform->addElement('date_selector', 'criteria_date_value', get_string('afterspecifieddate', 'completion'));
     // If instance of criteria exists
     if ($this->id) {
         $mform->setDefault('criteria_date', 1);
         $mform->setDefault('criteria_date_value', $this->timeend);
     } else {
         $mform->setDefault('criteria_date_value', time() + 3600 * 24);
     }
 }
 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform Moodle forms object
  * @param stdClass $data not used
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_duration', get_string('enable'));
     $thresholdmenu = array();
     for ($i = 1; $i <= 30; $i++) {
         $seconds = $i * 86400;
         $thresholdmenu[$seconds] = get_string('numdays', '', $i);
     }
     $mform->addElement('select', 'criteria_duration_days', get_string('daysafterenrolment', 'completion'), $thresholdmenu);
     if ($this->id) {
         $mform->setDefault('criteria_duration', 1);
         $mform->setDefault('criteria_duration_days', $this->enrolperiod);
     }
 }
 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform Moodle forms object
  * @param stdClass $data Form data
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_unenrol', get_string('completiononunenrolment', 'completion'));
     if ($this->id) {
         $mform->setDefault('criteria_unenrol', 1);
     }
 }
 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform  Moodle forms object
  * @param stdClass $data details of various modules
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_activity[' . $data->id . ']', ucfirst(self::get_mod_name($data->module)) . ' - ' . $data->name);
     if ($this->id) {
         $mform->setDefault('criteria_activity[' . $data->id . ']', 1);
     }
 }
Exemple #8
0
 /**
  * Add elements for creating/editing a textarea profile field.
  * @param moodleform $form
  */
 public function define_form_specific($form)
 {
     // Default data.
     $form->addElement('editor', 'defaultdata', get_string('profiledefaultdata', 'admin'));
     $form->setType('defaultdata', PARAM_RAW);
     // We have to trust person with capability to edit this default description.
 }
Exemple #9
0
 /**
  * Adds elements for this field type to the edit form.
  * @param moodleform $mform
  */
 public function edit_field_add($mform)
 {
     // Create the form field.
     $mform->addElement('editor', $this->inputname, format_string($this->field->name), null, null);
     $mform->setType($this->inputname, PARAM_RAW);
     // We MUST clean this before display!
 }
 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform  Moodle forms object
  * @param stdClass $data Form data
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_self', get_string('enable'));
     if ($this->id) {
         $mform->setDefault('criteria_self', 1);
     }
 }
 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform Moodle forms object
  * @param stdClass $data used to set default values of the form
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_role[' . $data->id . ']', $this->get_title($data));
     if ($this->id) {
         $mform->setDefault('criteria_role[' . $data->id . ']', 1);
     }
 }
 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform  Moodle forms object
  * @param stdClass $data details of various modules
  */
 public function config_form_display(&$mform, $data = null)
 {
     $modnames = get_module_types_names();
     $mform->addElement('checkbox', 'criteria_activity[' . $data->id . ']', $modnames[self::get_mod_name($data->module)] . ' - ' . format_string($data->name));
     if ($this->id) {
         $mform->setDefault('criteria_activity[' . $data->id . ']', 1);
     }
 }
Exemple #13
0
 /**
  * Adds controls specific to this filter in the form.
  * @param moodleform $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $choices = array('' => get_string('anyvalue', 'filters')) + $this->_options;
     $mform->addElement('select', $this->_name, $this->_label, $choices);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name);
     }
 }
Exemple #14
0
 /**
  * Prints out the form snippet for the part of creating or
  * editing a profile field specific to the current data type
  *
  * @param moodleform $form reference to moodleform for adding elements.
  */
 function define_form_specific(&$form)
 {
     //Add elements, set defualt value and define type of data
     $form->addElement('radio', 'defaultdata', get_string('mystring', 'profilefield_myprofilefield'));
     $form->setDefault('defaultdata', 1);
     // defaults to 'yes'
     $form->setType('defaultdata', PARAM_BOOL);
 }
Exemple #15
0
 /**
  * Add elements for creating/editing a checkbox profile field.
  *
  * @param moodleform $form
  */
 public function define_form_specific($form)
 {
     // Select whether or not this should be checked by default.
     $form->addElement('selectyesno', 'defaultdata', get_string('profiledefaultchecked', 'admin'));
     $form->setDefault('defaultdata', 0);
     // Defaults to 'no'.
     $form->setType('defaultdata', PARAM_BOOL);
 }
Exemple #16
0
 /**
  * Add fields for editing a text profile field.
  * @param moodleform $mform
  */
 public function edit_field_add($mform)
 {
     $size = $this->field->param1;
     $maxlength = $this->field->param2;
     $fieldtype = $this->field->param3 == 1 ? 'password' : 'text';
     // Create the form field.
     $mform->addElement($fieldtype, $this->inputname, format_string($this->field->name), 'maxlength="' . $maxlength . '" size="' . $size . '" ');
     $mform->setType($this->inputname, PARAM_TEXT);
 }
Exemple #17
0
 /**
  * Add elements for editing the profile field value.
  * @param moodleform $mform
  */
 public function edit_field_add($mform)
 {
     // Create the form field.
     $checkbox = $mform->addElement('advcheckbox', $this->inputname, format_string($this->field->name));
     if ($this->data == '1') {
         $checkbox->setChecked(true);
     }
     $mform->setType($this->inputname, PARAM_BOOL);
     if ($this->is_required() and !has_capability('moodle/user:update', context_system::instance())) {
         $mform->addRule($this->inputname, get_string('required'), 'nonzero', null, 'client');
     }
 }
 /**
  * Adds controls specific to this filter in the form.
  * @param moodleform $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs[] = $mform->createElement('select', $this->_name . '_rl', null, $this->get_roles());
     $objs[] = $mform->createElement('select', $this->_name . '_ct', null, $this->get_course_categories());
     $objs[] = $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->setType($this->_name, PARAM_TEXT);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
Exemple #19
0
 /**
  * Add elements for creating/editing a text profile field.
  * @param moodleform $form
  */
 public function define_form_specific($form)
 {
     // Default data.
     $form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
     $form->setType('defaultdata', PARAM_TEXT);
     // Param 1 for text type is the size of the field.
     $form->addElement('text', 'param1', get_string('profilefieldsize', 'admin'), 'size="6"');
     $form->setDefault('param1', 30);
     $form->setType('param1', PARAM_INT);
     // Param 2 for text type is the maxlength of the field.
     $form->addElement('text', 'param2', get_string('profilefieldmaxlength', 'admin'), 'size="6"');
     $form->setDefault('param2', 2048);
     $form->setType('param2', PARAM_INT);
     // Param 3 for text type detemines if this is a password field or not.
     $form->addElement('selectyesno', 'param3', get_string('profilefieldispassword', 'admin'));
     $form->setDefault('param3', 0);
     // Defaults to 'no'.
     $form->setType('param3', PARAM_INT);
     // Param 4 for text type contains a link.
     $form->addElement('text', 'param4', get_string('profilefieldlink', 'admin'));
     $form->setType('param4', PARAM_URL);
     $form->addHelpButton('param4', 'profilefieldlink', 'admin');
     // Param 5 for text type contains link target.
     $targetoptions = array('' => get_string('linktargetnone', 'editor'), '_blank' => get_string('linktargetblank', 'editor'), '_self' => get_string('linktargetself', 'editor'), '_top' => get_string('linktargettop', 'editor'));
     $form->addElement('select', 'param5', get_string('profilefieldlinktarget', 'admin'), $targetoptions);
     $form->setType('param5', PARAM_RAW);
 }
Exemple #20
0
 /**
  * Adds controls specific to this filter in the form.
  *
  * @param moodleform $mform a MoodleQuickForm object in which element will be added
  */
 public function setupForm(&$mform)
 {
     $mform->addElement('checkbox', $this->_name, $this->_label, '');
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name);
     }
     // Check if disable if options are set. if yes then set rules.
     if (!empty($this->disableelements) && is_array($this->disableelements)) {
         foreach ($this->disableelements as $disableelement) {
             $mform->disabledIf($disableelement, $this->_name, 'checked');
         }
     }
 }
Exemple #21
0
 /**
  * Handles editing datetime fields.
  *
  * @param moodleform $mform
  */
 public function edit_field_add($mform)
 {
     // Get the current calendar in use - see MDL-18375.
     $calendartype = \core_calendar\type_factory::get_calendar_instance();
     // Check if the field is required.
     if ($this->field->required) {
         $optional = false;
     } else {
         $optional = true;
     }
     // Convert the year stored in the DB as gregorian to that used by the calendar type.
     $startdate = $calendartype->convert_from_gregorian($this->field->param1, 1, 1);
     $stopdate = $calendartype->convert_from_gregorian($this->field->param2, 1, 1);
     $attributes = array('startyear' => $startdate['year'], 'stopyear' => $stopdate['year'], 'optional' => $optional);
     // Check if they wanted to include time as well.
     if (!empty($this->field->param3)) {
         $mform->addElement('date_time_selector', $this->inputname, format_string($this->field->name), $attributes);
     } else {
         $mform->addElement('date_selector', $this->inputname, format_string($this->field->name), $attributes);
     }
     $mform->setType($this->inputname, PARAM_INT);
     $mform->setDefault($this->inputname, time());
 }
 /**
  * Adds controls specific to this filter in the form.
  * @param moodleform $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs[] = $mform->createElement('select', $this->_name . '_op', null, $this->get_operators());
     $objs[] = $mform->createElement('select', $this->_name, null, $this->_options);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 0);
     if (!is_null($this->_default)) {
         $mform->setDefault($this->_name, $this->_default);
     }
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
 /**
  * Adds controls specific to this filter in the form.
  *
  * @param moodleform $mform a MoodleQuickForm object in which element will be added
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs[] = $mform->createElement('checkbox', $this->_name, null, '');
     $grp = $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
     // Check if disable if options are set. if yes then set rules.
     if (!empty($this->disableelements) && is_array($this->disableelements)) {
         foreach ($this->disableelements as $disableelement) {
             $mform->disabledIf($disableelement, $this->_name, 'checked');
         }
     }
 }
 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform Moodle forms object
  * @param stdClass $data not used
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_duration', get_string('enable'));
     // Populate the duration length drop down.
     $thresholdmenu = array(86400 => get_string('secondstotime86400', 'core'), 172800 => get_string('secondstotime172800', 'core'), 259200 => get_string('secondstotime259200', 'core'), 345600 => get_string('secondstotime345600', 'core'), 432000 => get_string('secondstotime432000', 'core'), 518400 => get_string('secondstotime518400', 'core'), 518400 => get_string('secondstotime518400', 'core'));
     // Append strings for 7 - 30 days (step by 1 day).
     for ($i = 7; $i <= 30; $i++) {
         $seconds = $i * DAYSECS;
         $thresholdmenu[$seconds] = get_string('numdays', 'core', $i);
     }
     // Append strings for 40 - 180 days (step by 10 days).
     for ($i = 40; $i <= 180; $i = $i + 10) {
         $seconds = $i * DAYSECS;
         $thresholdmenu[$seconds] = get_string('numdays', 'core', $i);
     }
     // Append string for 1 year.
     $thresholdmenu[365 * DAYSECS] = get_string('numdays', 'core', 365);
     $mform->addElement('select', 'criteria_duration_days', get_string('enrolmentdurationlength', 'core_completion'), $thresholdmenu);
     $mform->disabledIf('criteria_duration_days', 'criteria_duration');
     if ($this->id) {
         $mform->setDefault('criteria_duration', 1);
         $mform->setDefault('criteria_duration_days', $this->enrolperiod);
     }
 }
Exemple #25
0
 /**
  * Adds controls specific to this filter in the form.
  * @param moodleform $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs['limiter'] = $mform->createElement('select', $this->_name . '_op', null, $this->get_operators());
     $objs['limiter']->setLabel(get_string('limiterfor', 'filters', $this->_label));
     $objs['country'] = $mform->createElement('select', $this->_name, null, $this->_options);
     $objs['country']->setLabel(get_string('valuefor', 'filters', $this->_label));
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 0);
     if (!is_null($this->_default)) {
         $mform->setDefault($this->_name, $this->_default);
     }
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
Exemple #26
0
 /**
  * Prints out the form snippet for the part of creating or editing a profile field common to all data types.
  *
  * @param moodleform $form instance of the moodleform class
  */
 public function define_form_common(&$form)
 {
     $strrequired = get_string('required');
     $form->addElement('text', 'shortname', get_string('profileshortname', 'admin'), 'maxlength="100" size="25"');
     $form->addRule('shortname', $strrequired, 'required', null, 'client');
     $form->setType('shortname', PARAM_ALPHANUM);
     $form->addElement('text', 'name', get_string('profilename', 'admin'), 'size="50"');
     $form->addRule('name', $strrequired, 'required', null, 'client');
     $form->setType('name', PARAM_TEXT);
     $form->addElement('editor', 'description', get_string('profiledescription', 'admin'), null, null);
     $form->addElement('selectyesno', 'required', get_string('profilerequired', 'admin'));
     $form->addElement('selectyesno', 'locked', get_string('profilelocked', 'admin'));
     $form->addElement('selectyesno', 'forceunique', get_string('profileforceunique', 'admin'));
     $form->addElement('selectyesno', 'signup', get_string('profilesignup', 'admin'));
     $choices = array();
     $choices[PROFILE_VISIBLE_NONE] = get_string('profilevisiblenone', 'admin');
     $choices[PROFILE_VISIBLE_PRIVATE] = get_string('profilevisibleprivate', 'admin');
     $choices[PROFILE_VISIBLE_ALL] = get_string('profilevisibleall', 'admin');
     $form->addElement('select', 'visible', get_string('profilevisible', 'admin'), $choices);
     $form->addHelpButton('visible', 'profilevisible', 'admin');
     $form->setDefault('visible', PROFILE_VISIBLE_ALL);
     $choices = profile_list_categories();
     $form->addElement('select', 'categoryid', get_string('profilecategory', 'admin'), $choices);
 }
Exemple #27
0
/**
 * Adds code snippet to a moodle form object for custom profile fields that
 * should appear on the signup page
 * @param moodleform $mform moodle form object
 */
function profile_signup_fields($mform)
{
    if ($fields = profile_get_signup_fields()) {
        foreach ($fields as $field) {
            // Check if we change the categories.
            if (!isset($currentcat) || $currentcat != $field->categoryid) {
                $currentcat = $field->categoryid;
                $mform->addElement('header', 'category_' . $field->categoryid, format_string($field->categoryname));
            }
            $field->object->edit_field($mform);
        }
    }
}
Exemple #28
0
/**
 * Implementation of the function for printing the form elements that control
 * whether the course reset functionality affects the assignment.
 * @param moodleform $mform form passed by reference
 */
function assign_reset_course_form_definition(&$mform) {
    $mform->addElement('header', 'assignheader', get_string('modulenameplural', 'assign'));
    $mform->addElement('advcheckbox', 'reset_assign_submissions', get_string('deleteallsubmissions','assign'));
}
Exemple #29
0
/**
 * Adds code snippet to a moodle form object for custom profile fields that
 * should appear on the signup page
 * @param moodleform $mform moodle form object
 */
function profile_signup_fields($mform)
{
    global $CFG, $DB;
    // Only retrieve required custom fields (with category information)
    // results are sort by categories, then by fields.
    $sql = "SELECT uf.id as fieldid, ic.id as categoryid, ic.name as categoryname, uf.datatype\n                FROM {user_info_field} uf\n                JOIN {user_info_category} ic\n                ON uf.categoryid = ic.id AND uf.signup = 1 AND uf.visible<>0\n                ORDER BY ic.sortorder ASC, uf.sortorder ASC";
    if ($fields = $DB->get_records_sql($sql)) {
        foreach ($fields as $field) {
            // Check if we change the categories.
            if (!isset($currentcat) || $currentcat != $field->categoryid) {
                $currentcat = $field->categoryid;
                $mform->addElement('header', 'category_' . $field->categoryid, format_string($field->categoryname));
            }
            require_once $CFG->dirroot . '/user/profile/field/' . $field->datatype . '/field.class.php';
            $newfield = 'profile_field_' . $field->datatype;
            $formfield = new $newfield($field->fieldid);
            $formfield->edit_field($mform);
        }
    }
}
Exemple #30
0
/**
 * 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) {
        $mform->addElement('header', 'moodle_additional_names', get_string('additionalnames'));
        foreach ($disabledusernamefields as $allname) {
            $mform->addElement('text', $allname, get_string($allname), 'maxlength="100" size="30"');
            $mform->setType($allname, PARAM_NOTAGS);
        }
    }
    if (core_tag_tag::is_enabled('core', 'user') and empty($USER->newadminuser)) {
        $mform->addElement('header', 'moodle_interests', get_string('interests'));
        $mform->addElement('tags', 'interests', get_string('interestslist'), array('itemtype' => 'user', 'component' => 'core'));
        $mform->addHelpButton('interests', 'interestslist');
    }
    // Moodle optional fields.
    $mform->addElement('header', 'moodle_optional', get_string('optional', 'form'));
    $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
    $mform->setType('url', core_user::get_property_type('url'));
    $mform->addElement('text', 'icq', get_string('icqnumber'), 'maxlength="15" size="25"');
    $mform->setType('icq', core_user::get_property_type('icq'));
    $mform->setForceLtr('icq');
    $mform->addElement('text', 'skype', get_string('skypeid'), 'maxlength="50" size="25"');
    $mform->setType('skype', core_user::get_property_type('skype'));
    $mform->setForceLtr('skype');
    $mform->addElement('text', 'aim', get_string('aimid'), 'maxlength="50" size="25"');
    $mform->setType('aim', core_user::get_property_type('aim'));
    $mform->setForceLtr('aim');
    $mform->addElement('text', 'yahoo', get_string('yahooid'), 'maxlength="50" size="25"');
    $mform->setType('yahoo', core_user::get_property_type('yahoo'));
    $mform->setForceLtr('yahoo');
    $mform->addElement('text', 'msn', get_string('msnid'), 'maxlength="50" size="25"');
    $mform->setType('msn', core_user::get_property_type('msn'));
    $mform->setForceLtr('msn');
    $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="255" size="25"');
    $mform->setType('idnumber', core_user::get_property_type('idnumber'));
    $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="255" size="25"');
    $mform->setType('institution', core_user::get_property_type('institution'));
    $mform->addElement('text', 'department', get_string('department'), 'maxlength="255" size="25"');
    $mform->setType('department', core_user::get_property_type('department'));
    $mform->addElement('text', 'phone1', get_string('phone1'), 'maxlength="20" size="25"');
    $mform->setType('phone1', core_user::get_property_type('phone1'));
    $mform->setForceLtr('phone1');
    $mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"');
    $mform->setType('phone2', core_user::get_property_type('phone2'));
    $mform->setForceLtr('phone2');
    $mform->addElement('text', 'address', get_string('address'), 'maxlength="255" size="25"');
    $mform->setType('address', core_user::get_property_type('address'));
}