function definition() { global $CFG, $COURSE; $mform =& $this->_form; //Accessibility: "Required" is bad legend text. $strgeneral = get_string('general'); $strrequired = get_string('required'); /// Add some extra hidden fields $mform->addElement('hidden', 'id'); $mform->addElement('hidden', 'course', $COURSE->id); /// Print the required moodle fields first $mform->addElement('header', 'moodle', $strgeneral); /// shared fields useredit_shared_definition($mform); /// extra settigs $mform->addRule('description', $strrequired, 'required', null, 'client'); if (!empty($CFG->gdversion) and !empty($CFG->disableuserimages)) { $mform->removeElement('deletepicture'); $mform->removeElement('imagefile'); $mform->removeElement('imagealt'); } /// Next the customisable profile fields profile_definition($mform); $this->add_action_buttons(false, get_string('updatemyprofile')); }
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->addElement('hidden', 'course', $COURSE->id); /// 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] = get_string("auth_{$module}" . "title", "auth"); } $mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $auth_options); $mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod', 'auth'))); $mform->setAdvanced('auth'); $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); /// Next the customisable profile fields profile_definition($mform); $this->add_action_buttons(false, get_string('updatemyprofile')); }
function definition() { global $CFG, $COURSE; $mform =& $this->_form; if (is_array($this->_customdata) && array_key_exists('editoroptions', $this->_customdata)) { $editoroptions = $this->_customdata['editoroptions']; } else { $editoroptions = null; } //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); /// shared fields useredit_shared_definition($mform, $editoroptions); /// extra settigs if (!empty($CFG->gdversion) and !empty($CFG->disableuserimages)) { $mform->removeElement('deletepicture'); $mform->removeElement('imagefile'); $mform->removeElement('imagealt'); } /// Next the customisable profile fields profile_definition($mform); $this->add_action_buttons(false, get_string('updatemyprofile')); }
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); }
/** * Define the form. */ public function definition () { global $CFG, $COURSE, $USER; $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; if (empty($user->country)) { // We must unset the value here so $CFG->country can be used as default one. unset($user->country); } // 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); // Shared fields. useredit_shared_definition($mform, $editoroptions, $filemanageroptions, $user); // Extra settigs. if (!empty($CFG->disableuserimages)) { $mform->removeElement('deletepicture'); $mform->removeElement('imagefile'); $mform->removeElement('imagealt'); } // Next the customisable profile fields. profile_definition($mform, $userid); $this->add_action_buttons(false, get_string('updatemyprofile')); $this->set_data($user); }
function definition() { global $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); /** * ******************************************************* * TEOSSO auth patch to give the CPM profile link for users * should be added after the 'header' element and before * useredit_shared_definition($mform); */ // add link to joump to CPM user profile editing global $USER; if ($USER->auth == 'teosso') { $profilestr = get_string('profile', 'auth_teosso'); $teosso_config = get_config('auth/teosso'); $link = "<a href=\"" . $teosso_config->cpm_edit_url . "\" target=\"_blank\">" . $profilestr . "</a>"; $mform->addElement('static', 'jump_to_cpm', get_string('profileedit', 'auth_teosso'), $link); } /// shared fields useredit_shared_definition($mform); /// extra settigs $mform->addRule('description', $strrequired, 'required', null, 'client'); if (!empty($CFG->gdversion) and !empty($CFG->disableuserimages)) { $mform->removeElement('deletepicture'); $mform->removeElement('imagefile'); $mform->removeElement('imagealt'); } /// Next the customisable profile fields profile_definition($mform); $this->add_action_buttons(false, get_string('updatemyprofile')); }
/** * Define the form. */ public function definition() { global $CFG, $COURSE, $USER; $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); // Shared fields. useredit_shared_definition($mform, $editoroptions, $filemanageroptions); // Extra settigs. if (!empty($CFG->disableuserimages)) { $mform->removeElement('deletepicture'); $mform->removeElement('imagefile'); $mform->removeElement('imagealt'); } // Next the customisable profile fields. profile_definition($mform, $userid); $this->add_action_buttons(false, get_string('updatemyprofile')); }
function definition() { global $CFG, $USER; $mform = $this->_form; $columns = $this->_customdata['columns']; $data = $this->_customdata['data']; // I am the template user, why should it be the administrator? we have roles now, other ppl may use this script ;-) $templateuser = $USER; // upload settings and file $mform->addElement('header', 'settingsheader', get_string('settings')); $choices = array(UU_USER_ADDNEW => get_string('uuoptype_addnew', 'tool_uploaduser'), UU_USER_ADDINC => get_string('uuoptype_addinc', 'tool_uploaduser'), UU_USER_ADD_UPDATE => get_string('uuoptype_addupdate', 'tool_uploaduser'), UU_USER_UPDATE => get_string('uuoptype_update', 'tool_uploaduser')); $mform->addElement('select', 'uutype', get_string('uuoptype', 'tool_uploaduser'), $choices); $choices = array(0 => get_string('infilefield', 'auth'), 1 => get_string('createpasswordifneeded', 'auth')); $mform->addElement('select', 'uupasswordnew', get_string('uupasswordnew', 'tool_uploaduser'), $choices); $mform->setDefault('uupasswordnew', 1); $mform->disabledIf('uupasswordnew', 'uutype', 'eq', UU_USER_UPDATE); $choices = array(UU_UPDATE_NOCHANGES => get_string('nochanges', 'tool_uploaduser'), UU_UPDATE_FILEOVERRIDE => get_string('uuupdatefromfile', 'tool_uploaduser'), UU_UPDATE_ALLOVERRIDE => get_string('uuupdateall', 'tool_uploaduser'), UU_UPDATE_MISSING => get_string('uuupdatemissing', 'tool_uploaduser')); $mform->addElement('select', 'uuupdatetype', get_string('uuupdatetype', 'tool_uploaduser'), $choices); $mform->setDefault('uuupdatetype', UU_UPDATE_NOCHANGES); $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_USER_ADDNEW); $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_USER_ADDINC); $choices = array(0 => get_string('nochanges', 'tool_uploaduser'), 1 => get_string('update')); $mform->addElement('select', 'uupasswordold', get_string('uupasswordold', 'tool_uploaduser'), $choices); $mform->setDefault('uupasswordold', 0); $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_USER_ADDNEW); $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_USER_ADDINC); $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 0); $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 3); $choices = array(UU_PWRESET_WEAK => get_string('usersweakpassword', 'tool_uploaduser'), UU_PWRESET_NONE => get_string('none'), UU_PWRESET_ALL => get_string('all')); if (empty($CFG->passwordpolicy)) { unset($choices[UU_PWRESET_WEAK]); } $mform->addElement('select', 'uuforcepasswordchange', get_string('forcepasswordchange', 'core'), $choices); $mform->addElement('selectyesno', 'uuallowrenames', get_string('allowrenames', 'tool_uploaduser')); $mform->setDefault('uuallowrenames', 0); $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_USER_ADDNEW); $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_USER_ADDINC); $mform->addElement('selectyesno', 'uuallowdeletes', get_string('allowdeletes', 'tool_uploaduser')); $mform->setDefault('uuallowdeletes', 0); $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_USER_ADDNEW); $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_USER_ADDINC); $mform->addElement('selectyesno', 'uuallowsuspends', get_string('allowsuspends', 'tool_uploaduser')); $mform->setDefault('uuallowsuspends', 1); $mform->disabledIf('uuallowsuspends', 'uutype', 'eq', UU_USER_ADDNEW); $mform->disabledIf('uuallowsuspends', 'uutype', 'eq', UU_USER_ADDINC); if (!empty($CFG->allowaccountssameemail)) { $mform->addElement('selectyesno', 'uunoemailduplicates', get_string('uunoemailduplicates', 'tool_uploaduser')); $mform->setDefault('uunoemailduplicates', 1); } else { $mform->addElement('hidden', 'uunoemailduplicates', 1); } $mform->setType('uunoemailduplicates', PARAM_BOOL); $mform->addElement('selectyesno', 'uustandardusernames', get_string('uustandardusernames', 'tool_uploaduser')); $mform->setDefault('uustandardusernames', 1); $choices = array(UU_BULK_NONE => get_string('no'), UU_BULK_NEW => get_string('uubulknew', 'tool_uploaduser'), UU_BULK_UPDATED => get_string('uubulkupdated', 'tool_uploaduser'), UU_BULK_ALL => get_string('uubulkall', 'tool_uploaduser')); $mform->addElement('select', 'uubulk', get_string('uubulk', 'tool_uploaduser'), $choices); $mform->setDefault('uubulk', 0); // roles selection $showroles = false; foreach ($columns as $column) { if (preg_match('/^type\\d+$/', $column)) { $showroles = true; break; } } if ($showroles) { $mform->addElement('header', 'rolesheader', get_string('roles')); $choices = uu_allowed_roles(true); $mform->addElement('select', 'uulegacy1', get_string('uulegacy1role', 'tool_uploaduser'), $choices); if ($studentroles = get_archetype_roles('student')) { foreach ($studentroles as $role) { if (isset($choices[$role->id])) { $mform->setDefault('uulegacy1', $role->id); break; } } unset($studentroles); } $mform->addElement('select', 'uulegacy2', get_string('uulegacy2role', 'tool_uploaduser'), $choices); if ($editteacherroles = get_archetype_roles('editingteacher')) { foreach ($editteacherroles as $role) { if (isset($choices[$role->id])) { $mform->setDefault('uulegacy2', $role->id); break; } } unset($editteacherroles); } $mform->addElement('select', 'uulegacy3', get_string('uulegacy3role', 'tool_uploaduser'), $choices); if ($teacherroles = get_archetype_roles('teacher')) { foreach ($teacherroles as $role) { if (isset($choices[$role->id])) { $mform->setDefault('uulegacy3', $role->id); break; } } unset($teacherroles); } } // default values $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'tool_uploaduser')); $mform->addElement('text', 'username', get_string('uuusernametemplate', 'tool_uploaduser'), 'size="20"'); $mform->setType('username', PARAM_RAW); // No cleaning here. The process verifies it later. $mform->addRule('username', get_string('requiredtemplate', 'tool_uploaduser'), 'required', null, 'client'); $mform->disabledIf('username', 'uutype', 'eq', UU_USER_ADD_UPDATE); $mform->disabledIf('username', 'uutype', 'eq', UU_USER_UPDATE); $mform->setForceLtr('username'); $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"'); $mform->setType('email', PARAM_RAW); // No cleaning here. The process verifies it later. $mform->disabledIf('email', 'uutype', 'eq', UU_USER_ADD_UPDATE); $mform->disabledIf('email', 'uutype', 'eq', UU_USER_UPDATE); $mform->setForceLtr('email'); // only enabled and known to work plugins $choices = uu_supported_auths(); $mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $choices); $mform->setDefault('auth', 'manual'); // manual is a sensible backwards compatible default $mform->addHelpButton('auth', 'chooseauthmethod', 'auth'); $mform->setAdvanced('auth'); $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse')); $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices); $mform->setDefault('maildisplay', core_user::get_property_default('maildisplay')); $choices = array(0 => get_string('textformat'), 1 => get_string('htmlformat')); $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices); $mform->setDefault('mailformat', core_user::get_property_default('mailformat')); $mform->setAdvanced('mailformat'); $choices = array(0 => get_string('emaildigestoff'), 1 => get_string('emaildigestcomplete'), 2 => get_string('emaildigestsubjects')); $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices); $mform->setDefault('maildigest', core_user::get_property_default('maildigest')); $mform->setAdvanced('maildigest'); $choices = array(1 => get_string('autosubscribeyes'), 0 => get_string('autosubscribeno')); $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices); $mform->setDefault('autosubscribe', core_user::get_property_default('autosubscribe')); $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="25"'); $mform->setType('city', PARAM_TEXT); if (empty($CFG->defaultcity)) { $mform->setDefault('city', $templateuser->city); } else { $mform->setDefault('city', core_user::get_property_default('city')); } $choices = get_string_manager()->get_list_of_countries(); $choices = array('' => get_string('selectacountry') . '...') + $choices; $mform->addElement('select', 'country', get_string('selectacountry'), $choices); if (empty($CFG->country)) { $mform->setDefault('country', $templateuser->country); } else { $mform->setDefault('country', core_user::get_property_default('country')); } $mform->setAdvanced('country'); $choices = core_date::get_list_of_timezones($templateuser->timezone, true); $mform->addElement('select', 'timezone', get_string('timezone'), $choices); $mform->setDefault('timezone', $templateuser->timezone); $mform->setAdvanced('timezone'); $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations()); $mform->setDefault('lang', $templateuser->lang); $mform->setAdvanced('lang'); $editoroptions = array('maxfiles' => 0, 'maxbytes' => 0, 'trusttext' => false, 'forcehttps' => false); $mform->addElement('editor', 'description', get_string('userdescription'), null, $editoroptions); $mform->setType('description', PARAM_CLEANHTML); $mform->addHelpButton('description', 'userdescription'); $mform->setAdvanced('description'); $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"'); $mform->setType('url', PARAM_URL); $mform->setAdvanced('url'); $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="255" size="25"'); $mform->setType('idnumber', PARAM_NOTAGS); $mform->setForceLtr('idnumber'); $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="255" size="25"'); $mform->setType('institution', PARAM_TEXT); $mform->setDefault('institution', $templateuser->institution); $mform->addElement('text', 'department', get_string('department'), 'maxlength="255" size="25"'); $mform->setType('department', PARAM_TEXT); $mform->setDefault('department', $templateuser->department); $mform->addElement('text', 'phone1', get_string('phone1'), 'maxlength="20" size="25"'); $mform->setType('phone1', PARAM_NOTAGS); $mform->setAdvanced('phone1'); $mform->setForceLtr('phone1'); $mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"'); $mform->setType('phone2', PARAM_NOTAGS); $mform->setAdvanced('phone2'); $mform->setForceLtr('phone2'); $mform->addElement('text', 'address', get_string('address'), 'maxlength="255" size="25"'); $mform->setType('address', PARAM_TEXT); $mform->setAdvanced('address'); // Next the profile defaults profile_definition($mform); // hidden fields $mform->addElement('hidden', 'iid'); $mform->setType('iid', PARAM_INT); $mform->addElement('hidden', 'previewrows'); $mform->setType('previewrows', PARAM_INT); $this->add_action_buttons(true, get_string('uploadusers', 'tool_uploaduser')); $this->set_data($data); }
function definition() { global $CFG, $USER; //no editors here - we need proper empty fields $CFG->htmleditor = null; $mform =& $this->_form; $columns =& $this->_customdata; // I am the template user, why should it be the administrator? we have roles now, other ppl may use this script ;-) $templateuser = $USER; // upload settings and file $mform->addElement('header', 'settingsheader', get_string('settings')); $choices = array(UU_ADDNEW => get_string('uuoptype_addnew', 'admin'), UU_ADDINC => get_string('uuoptype_addinc', 'admin'), UU_ADD_UPDATE => get_string('uuoptype_addupdate', 'admin'), UU_UPDATE => get_string('uuoptype_update', 'admin')); $mform->addElement('select', 'uutype', get_string('uuoptype', 'admin'), $choices); $choices = array(0 => get_string('infilefield', 'auth'), 1 => get_string('createpasswordifneeded', 'auth')); $mform->addElement('select', 'uupasswordnew', get_string('uupasswordnew', 'admin'), $choices); $mform->setDefault('uupasswordnew', 0); $mform->disabledIf('uupasswordnew', 'uutype', 'eq', UU_UPDATE); $choices = array(0 => get_string('nochanges', 'admin'), 1 => get_string('uuupdatefromfile', 'admin'), 2 => get_string('uuupdateall', 'admin'), 3 => get_string('uuupdatemissing', 'admin')); $mform->addElement('select', 'uuupdatetype', get_string('uuupdatetype', 'admin'), $choices); $mform->setDefault('uuupdatetype', 0); $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_ADDINC); $choices = array(0 => get_string('nochanges', 'admin'), 1 => get_string('update')); $mform->addElement('select', 'uupasswordold', get_string('uupasswordold', 'admin'), $choices); $mform->setDefault('uupasswordold', 0); $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_ADDINC); $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 0); $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 3); $mform->addElement('selectyesno', 'uuallowrenames', get_string('allowrenames', 'admin')); $mform->setDefault('uuallowrenames', 0); $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDINC); $mform->addElement('selectyesno', 'uuallowdeletes', get_string('allowdeletes', 'admin')); $mform->setDefault('uuallowdeletes', 0); $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDINC); $mform->addElement('selectyesno', 'uunoemailduplicates', get_string('uunoemailduplicates', 'admin')); $mform->setDefault('uunoemailduplicates', 0); $choices = array(0 => get_string('no'), 1 => get_string('uubulknew', 'admin'), 2 => get_string('uubulkupdated', 'admin'), 3 => get_string('uubulkall', 'admin')); $mform->addElement('select', 'uubulk', get_string('uubulk', 'admin'), $choices); $mform->setDefault('uubulk', 0); // roles selection $showroles = false; foreach ($columns as $column) { if (preg_match('/^type\\d+$/', $column)) { $showroles = true; break; } } if ($showroles) { $mform->addElement('header', 'rolesheader', get_string('roles')); $choices = uu_allowed_roles(true); $choices[0] = get_string('uucoursedefaultrole', 'admin'); $mform->addElement('select', 'uulegacy1', get_string('uulegacy1role', 'admin'), $choices); $mform->setDefault('uulegacy1', 0); unset($choices[0]); $mform->addElement('select', 'uulegacy2', get_string('uulegacy2role', 'admin'), $choices); if ($editteacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW)) { $editteacherrole = array_shift($editteacherroles); /// Take the first one $mform->setDefault('uulegacy2', $editteacherrole->id); unset($editteacherroles); } else { $mform->setDefault('uulegacy2', $CFG->defaultcourseroleid); } $mform->addElement('select', 'uulegacy3', get_string('uulegacy3role', 'admin'), $choices); if ($teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) { $teacherrole = array_shift($teacherroles); /// Take the first one $mform->setDefault('uulegacy3', $teacherrole->id); unset($teacherroles); } else { $mform->setDefault('uulegacy3', $CFG->defaultcourseroleid); } } // default values $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'admin')); $mform->addElement('text', 'username', get_string('username'), 'size="20"'); $mform->addRule('username', get_string('requiredtemplate', 'admin'), 'required', null, 'client'); // only enabled and known to work plugins $choices = uu_allowed_auths(); $mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $choices); $mform->setDefault('auth', 'manual'); // manual is a sensible backwards compatible default $mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod', 'auth'))); $mform->setAdvanced('auth'); $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"'); $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse')); $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices); $mform->setDefault('maildisplay', 2); $choices = array(0 => get_string('emailenable'), 1 => get_string('emaildisable')); $mform->addElement('select', 'emailstop', get_string('emailactive'), $choices); $choices = array(0 => get_string('textformat'), 1 => get_string('htmlformat')); $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices); $mform->setDefault('mailformat', 1); $mform->setAdvanced('mailformat'); $choices = array(0 => get_string('autosubscribeyes'), 1 => get_string('autosubscribeno')); $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices); $mform->setDefault('autosubscribe', 1); if ($CFG->htmleditor) { $choices = array(0 => get_string('texteditor'), 1 => get_string('htmleditor')); $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices); $mform->setDefault('htmleditor', 1); } else { $mform->addElement('static', 'htmleditor', get_string('textediting'), get_string('texteditor')); } $mform->setAdvanced('htmleditor'); if (empty($CFG->enableajax)) { $mform->addElement('static', 'ajax', get_string('ajaxuse'), get_string('ajaxno')); } else { $choices = array(0 => get_string('ajaxno'), 1 => get_string('ajaxyes')); $mform->addElement('select', 'ajax', get_string('ajaxuse'), $choices); $mform->setDefault('ajax', 1); } $mform->setAdvanced('ajax'); $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"'); $mform->setType('city', PARAM_MULTILANG); $mform->setDefault('city', $templateuser->city); $mform->addElement('select', 'country', get_string('selectacountry'), get_list_of_countries()); $mform->setDefault('country', $templateuser->country); $mform->setAdvanced('country'); $choices = get_list_of_timezones(); $choices['99'] = get_string('serverlocaltime'); $mform->addElement('select', 'timezone', get_string('timezone'), $choices); $mform->setDefault('timezone', $templateuser->timezone); $mform->setAdvanced('timezone'); $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_list_of_languages()); $mform->setDefault('lang', $templateuser->lang); $mform->setAdvanced('lang'); $mform->addElement('htmleditor', 'description', get_string('userdescription')); $mform->setType('description', PARAM_CLEAN); $mform->setHelpButton('description', array('text', get_string('helptext'))); $mform->setAdvanced('description'); $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"'); $mform->setAdvanced('url'); $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="64" size="25"'); $mform->setType('idnumber', PARAM_CLEAN); $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"'); $mform->setType('institution', PARAM_MULTILANG); $mform->setDefault('institution', $templateuser->institution); $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"'); $mform->setType('department', PARAM_MULTILANG); $mform->setDefault('department', $templateuser->department); $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"'); $mform->setType('phone1', PARAM_CLEAN); $mform->setAdvanced('phone1'); $mform->addElement('text', 'phone2', get_string('phone'), 'maxlength="20" size="25"'); $mform->setType('phone2', PARAM_CLEAN); $mform->setAdvanced('phone2'); $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"'); $mform->setType('address', PARAM_MULTILANG); $mform->setAdvanced('address'); /// Next the profile defaults profile_definition($mform); // hidden fields $mform->addElement('hidden', 'iid'); $mform->setType('iid', PARAM_INT); $mform->addElement('hidden', 'previewrows'); $mform->setType('previewrows', PARAM_INT); $mform->addElement('hidden', 'readcount'); $mform->setType('readcount', PARAM_INT); $this->add_action_buttons(true, get_string('uploadusers')); }
public function definition() { global $CFG, $USER, $SESSION; $mform =& $this->_form; $columns =& $this->_customdata; // I am the template user, why should it be the administrator? we have roles now, other ppl may use this script ;-). $templateuser = $USER; // Upload settings and file. $mform->addElement('header', 'settingsheader', get_string('settings')); $mform->addElement('static', 'uutypelabel', get_string('uuoptype', 'tool_uploaduser')); $choices = array(0 => get_string('infilefield', 'auth'), 1 => get_string('createpasswordifneeded', 'auth')); $mform->addElement('select', 'uupasswordnew', get_string('uupasswordnew', 'tool_uploaduser'), $choices); $mform->setDefault('uupasswordnew', 1); $mform->disabledIf('uupasswordnew', 'uutype', 'eq', UU_UPDATE); $mform->addElement('selectyesno', 'sendnewpasswordemails', get_string('sendnewpasswordemails', 'block_iomad_company_admin')); $mform->setDefault('sendnewpasswordemails', 1); $choices = array(0 => get_string('nochanges', 'tool_uploaduser'), 1 => get_string('uuupdatefromfile', 'tool_uploaduser'), 2 => get_string('uuupdateall', 'tool_uploaduser'), 3 => get_string('uuupdatemissing', 'tool_uploaduser')); $mform->addElement('select', 'uuupdatetype', get_string('uuupdatetype', 'tool_uploaduser'), $choices); $mform->setDefault('uuupdatetype', 0); $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_ADDINC); $choices = array(0 => get_string('nochanges', 'tool_uploaduser'), 1 => get_string('update')); $mform->addElement('select', 'uupasswordold', get_string('uupasswordold', 'tool_uploaduser'), $choices); $mform->setDefault('uupasswordold', 0); $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_ADDINC); $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 0); $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 3); $mform->addElement('selectyesno', 'uuallowrenames', get_string('allowrenames', 'tool_uploaduser')); $mform->setDefault('uuallowrenames', 0); $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDINC); $mform->addElement('selectyesno', 'uuallowdeletes', get_string('allowdeletes', 'tool_uploaduser')); $mform->setDefault('uuallowdeletes', 0); $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDINC); $mform->addElement('selectyesno', 'uunoemailduplicates', get_string('uunoemailduplicates', 'tool_uploaduser')); $mform->setDefault('uunoemailduplicates', 1); $choices = array(0 => get_string('no'), 1 => get_string('uubulknew', 'tool_uploaduser'), 2 => get_string('uubulkupdated', 'tool_uploaduser'), 3 => get_string('uubulkall', 'tool_uploaduser')); $mform->addElement('select', 'uubulk', get_string('uubulk', 'tool_uploaduser'), $choices); $mform->setDefault('uubulk', 0); // Roles selection. $showroles = false; foreach ($columns as $column) { if (preg_match('/^type\\d+$/', $column)) { $showroles = true; break; } } if ($showroles) { $mform->addElement('header', 'rolesheader', get_string('roles')); $choices = uu_allowed_roles(true); $mform->addElement('select', 'uulegacy1', get_string('uulegacy1role', 'tool_uploaduser'), $choices); if ($studentroles = get_archetype_roles('student')) { foreach ($studentroles as $role) { if (isset($choices[$role->id])) { $mform->setDefault('uulegacy1', $role->id); break; } } unset($studentroles); } $mform->addElement('select', 'uulegacy2', get_string('uulegacy2role', 'tool_uploaduser'), $choices); if ($editteacherroles = get_archetype_roles('editingteacher')) { foreach ($editteacherroles as $role) { if (isset($choices[$role->id])) { $mform->setDefault('uulegacy2', $role->id); break; } } unset($editteacherroles); } $mform->addElement('select', 'uulegacy3', get_string('uulegacy3role', 'tool_uploaduser'), $choices); if ($teacherroles = get_archetype_roles('teacher')) { foreach ($teacherroles as $role) { if (isset($choices[$role->id])) { $mform->setDefault('uulegacy3', $role->id); break; } } unset($teacherroles); } } // Next the profile defaults. profile_definition($mform); // Remove the company profile field from the form (this was added by the call to profile_definition // above but we don't want the user to edit this here). // Hidden fields. $mform->addElement('hidden', 'iid'); $mform->setType('iid', PARAM_INT); $mform->addElement('hidden', 'auth'); $mform->setDefault('auth', ''); $mform->setType('auth', PARAM_TEXT); $mform->addElement('hidden', 'previewrows'); $mform->setType('previewrows', PARAM_INT); $mform->addElement('hidden', 'readcount'); $mform->setType('readcount', PARAM_INT); $mform->addElement('hidden', 'uutype'); $mform->setType('uutype', PARAM_INT); $mform->addElement('hidden', 'companyid', $this->selectedcompany); $mform->setType('companyid', PARAM_INT); }
/** * 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); }
function definition() { global $USER, $CFG, $DB; $mform = $this->_form; $course = $this->_customdata['course']; // this contains the data of this form $category = $this->_customdata['category']; $editoroptions = $this->_customdata['editoroptions']; $returnto = $this->_customdata['returnto']; $systemcontext = get_context_instance(CONTEXT_SYSTEM); $categorycontext = get_context_instance(CONTEXT_COURSECAT, $category->id); if (!empty($course->id)) { $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); $context = $coursecontext; } else { $coursecontext = null; $context = $categorycontext; } $courseconfig = get_config('moodlecourse'); $this->course = $course; $this->context = $context; /// form definition with new course defaults //-------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('hidden', 'returnto', null); $mform->setType('returnto', PARAM_ALPHANUM); $mform->setConstant('returnto', $returnto); // verify permissions to change course category or keep current if (empty($course->id)) { if (has_capability('moodle/course:create', $categorycontext)) { $displaylist = array(); $parentlist = array(); make_categories_list($displaylist, $parentlist, 'moodle/course:create'); $mform->addElement('select', 'category', get_string('category'), $displaylist); $mform->addHelpButton('category', 'category'); $mform->setDefault('category', $category->id); } else { $mform->addElement('hidden', 'category', null); $mform->setType('category', PARAM_INT); $mform->setConstant('category', $category->id); } } else { if (has_capability('moodle/course:changecategory', $coursecontext)) { $displaylist = array(); $parentlist = array(); make_categories_list($displaylist, $parentlist, 'moodle/course:create'); if (!isset($displaylist[$course->category])) { //always keep current $displaylist[$course->category] = format_string($DB->get_field('course_categories', 'name', array('id' => $course->category))); } $mform->addElement('select', 'category', get_string('category'), $displaylist); $mform->addHelpButton('category', 'category'); } else { //keep current $mform->addElement('hidden', 'category', null); $mform->setType('category', PARAM_INT); $mform->setConstant('category', $course->category); } } $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"'); $mform->addHelpButton('fullname', 'fullnamecourse'); $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client'); $mform->setType('fullname', PARAM_MULTILANG); if (!empty($course->id) and !has_capability('moodle/course:changefullname', $coursecontext)) { $mform->hardFreeze('fullname'); $mform->setConstant('fullname', $course->fullname); } $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"'); $mform->addHelpButton('shortname', 'shortnamecourse'); $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client'); $mform->setType('shortname', PARAM_MULTILANG); if (!empty($course->id) and !has_capability('moodle/course:changeshortname', $coursecontext)) { $mform->hardFreeze('shortname'); $mform->setConstant('shortname', $course->shortname); } $mform->addElement('text', 'idnumber', get_string('idnumbercourse'), 'maxlength="100" size="10"'); $mform->addHelpButton('idnumber', 'idnumbercourse'); $mform->setType('idnumber', PARAM_RAW); if (!empty($course->id) and !has_capability('moodle/course:changeidnumber', $coursecontext)) { $mform->hardFreeze('idnumber'); $mform->setConstants('idnumber', $course->idnumber); } $mform->addElement('editor', 'summary_editor', get_string('coursesummary'), null, $editoroptions); $mform->addHelpButton('summary_editor', 'coursesummary'); $mform->setType('summary_editor', PARAM_RAW); if (!empty($course->id) and !has_capability('moodle/course:changesummary', $coursecontext)) { $mform->hardFreeze('summary_editor'); } $courseformats = get_plugin_list('format'); $formcourseformats = array(); foreach ($courseformats as $courseformat => $formatdir) { $formcourseformats[$courseformat] = get_string('pluginname', "format_{$courseformat}"); } $mform->addElement('select', 'format', get_string('format'), $formcourseformats); $mform->addHelpButton('format', 'format'); $mform->setDefault('format', $courseconfig->format); $mform->addElement('select', 'coursedisplay', get_string('coursedisplay'), array(COURSE_DISPLAY_SINGLEPAGE => get_string('coursedisplay_single'), COURSE_DISPLAY_MULTIPAGE => get_string('coursedisplay_multi'))); $mform->addHelpButton('coursedisplay', 'coursedisplay'); $mform->setDefault('coursedisplay', COURSE_DISPLAY_SINGLEPAGE); for ($i = 0; $i <= $courseconfig->maxsections; $i++) { $sectionmenu[$i] = "{$i}"; } $mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu); $mform->setDefault('numsections', $courseconfig->numsections); $mform->addElement('date_selector', 'startdate', get_string('startdate')); $mform->addHelpButton('startdate', 'startdate'); $mform->setDefault('startdate', time() + 3600 * 24); $choices = array(); $choices['0'] = get_string('hiddensectionscollapsed'); $choices['1'] = get_string('hiddensectionsinvisible'); $mform->addElement('select', 'hiddensections', get_string('hiddensections'), $choices); $mform->addHelpButton('hiddensections', 'hiddensections'); $mform->setDefault('hiddensections', $courseconfig->hiddensections); $options = range(0, 10); $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options); $mform->addHelpButton('newsitems', 'newsitemsnumber'); $mform->setDefault('newsitems', $courseconfig->newsitems); $mform->addElement('selectyesno', 'showgrades', get_string('showgrades')); $mform->addHelpButton('showgrades', 'showgrades'); $mform->setDefault('showgrades', $courseconfig->showgrades); $mform->addElement('selectyesno', 'showreports', get_string('showreports')); $mform->addHelpButton('showreports', 'showreports'); $mform->setDefault('showreports', $courseconfig->showreports); $choices = get_max_upload_sizes($CFG->maxbytes); $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices); $mform->addHelpButton('maxbytes', 'maximumupload'); $mform->setDefault('maxbytes', $courseconfig->maxbytes); if (!empty($course->legacyfiles) or !empty($CFG->legacyfilesinnewcourses)) { if (empty($course->legacyfiles)) { //0 or missing means no legacy files ever used in this course - new course or nobody turned on legacy files yet $choices = array('0' => get_string('no'), '2' => get_string('yes')); } else { $choices = array('1' => get_string('no'), '2' => get_string('yes')); } $mform->addElement('select', 'legacyfiles', get_string('courselegacyfiles'), $choices); $mform->addHelpButton('legacyfiles', 'courselegacyfiles'); if (!isset($courseconfig->legacyfiles)) { // in case this was not initialised properly due to switching of $CFG->legacyfilesinnewcourses $courseconfig->legacyfiles = 0; } $mform->setDefault('legacyfiles', $courseconfig->legacyfiles); } if (!empty($CFG->allowcoursethemes)) { $themeobjects = get_list_of_themes(); $themes = array(); $themes[''] = get_string('forceno'); foreach ($themeobjects as $key => $theme) { if (empty($theme->hidefromselector)) { $themes[$key] = get_string('pluginname', 'theme_' . $theme->name); } } $mform->addElement('select', 'theme', get_string('forcetheme'), $themes); } //-------------------------------------------------------------------------------- enrol_course_edit_form($mform, $course, $context); //-------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('groups', 'group')); $choices = array(); $choices[NOGROUPS] = get_string('groupsnone', 'group'); $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group'); $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group'); $mform->addElement('select', 'groupmode', get_string('groupmode', 'group'), $choices); $mform->addHelpButton('groupmode', 'groupmode', 'group'); $mform->setDefault('groupmode', $courseconfig->groupmode); $choices = array(); $choices['0'] = get_string('no'); $choices['1'] = get_string('yes'); $mform->addElement('select', 'groupmodeforce', get_string('groupmodeforce', 'group'), $choices); $mform->addHelpButton('groupmodeforce', 'groupmodeforce', 'group'); $mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce); //default groupings selector $options = array(); $options[0] = get_string('none'); $mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options); //-------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('availability')); $choices = array(); $choices['0'] = get_string('courseavailablenot'); $choices['1'] = get_string('courseavailable'); $mform->addElement('select', 'visible', get_string('availability'), $choices); $mform->addHelpButton('visible', 'availability'); $mform->setDefault('visible', $courseconfig->visible); if (!has_capability('moodle/course:visibility', $context)) { $mform->hardFreeze('visible'); if (!empty($course->id)) { $mform->setConstant('visible', $course->visible); } else { $mform->setConstant('visible', $category->visible); } } //-------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('language')); $languages = array(); $languages[''] = get_string('forceno'); $languages += get_string_manager()->get_list_of_translations(); $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages); $mform->setDefault('lang', $courseconfig->lang); //-------------------------------------------------------------------------------- if (completion_info::is_enabled_for_site()) { $mform->addElement('header', '', get_string('progress', 'completion')); $mform->addElement('select', 'enablecompletion', get_string('completion', 'completion'), array(0 => get_string('completiondisabled', 'completion'), 1 => get_string('completionenabled', 'completion'))); $mform->setDefault('enablecompletion', $courseconfig->enablecompletion); $mform->addElement('checkbox', 'completionstartonenrol', get_string('completionstartonenrol', 'completion')); $mform->setDefault('completionstartonenrol', $courseconfig->completionstartonenrol); $mform->disabledIf('completionstartonenrol', 'enablecompletion', 'eq', 0); } else { $mform->addElement('hidden', 'enablecompletion'); $mform->setType('enablecompletion', PARAM_INT); $mform->setDefault('enablecompletion', 0); $mform->addElement('hidden', 'completionstartonenrol'); $mform->setType('completionstartonenrol', PARAM_INT); $mform->setDefault('completionstartonenrol', 0); } /// customizable role names in this course //-------------------------------------------------------------------------------- $mform->addElement('header', 'rolerenaming', get_string('rolerenaming')); $mform->addHelpButton('rolerenaming', 'rolerenaming'); if ($roles = get_all_roles()) { if ($coursecontext) { $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS_RAW); } $assignableroles = get_roles_for_contextlevels(CONTEXT_COURSE); foreach ($roles as $role) { $mform->addElement('text', 'role_' . $role->id, get_string('yourwordforx', '', $role->name)); if (isset($role->localname)) { $mform->setDefault('role_' . $role->id, $role->localname); } $mform->setType('role_' . $role->id, PARAM_TEXT); if (!in_array($role->id, $assignableroles)) { $mform->setAdvanced('role_' . $role->id); } } } // customisable profile fields //-------------------------------------------------------------------------------- profile_definition($mform); //-------------------------------------------------------------------------------- $this->add_action_buttons(); //-------------------------------------------------------------------------------- $mform->addElement('hidden', 'id', null); $mform->setType('id', PARAM_INT); /// finally set the current form data //-------------------------------------------------------------------------------- profile_load_data($course); $this->set_data($course); }
public function definition() { global $DB; $mform = $this->_form; $instance = $this->_customdata; $this->instance = $instance; $plugin = enrol_get_plugin('self'); $heading = $plugin->get_instance_name($instance); $mform->addElement('header', 'selfheader', $heading); if ($instance->password) { $heading = $plugin->get_instance_name($instance); $mform->addElement('header', 'selfheader', $heading); //change the id of self enrolment key input as there can be multiple self enrolment methods $mform->addElement('passwordunmask', 'enrolpassword', get_string('password', 'enrol_self'), array('id' => $instance->id . "_enrolpassword")); } else { // nothing? } $mform->addElement('html', '<p>' . $instance->customtext1 . '</p>'); $mform->addElement('textarea', 'applydescription', get_string('comment', 'enrol_apply'), 'cols="80"'); //user profile global $USER, $CFG, $DB; require_once $CFG->libdir . '/gdlib.php'; require_once $CFG->dirroot . '/user/edit_form.php'; require_once $CFG->dirroot . '/user/editlib.php'; require_once $CFG->dirroot . '/user/profile/lib.php'; require_once $CFG->dirroot . '/user/lib.php'; $user = $DB->get_record('user', array('id' => $USER->id)); $editoroptions = $filemanageroptions = null; $apply_setting = $DB->get_records_sql("select name,value from " . $CFG->prefix . "config_plugins where plugin='enrol_apply'"); $show_standard_user_profile = $show_extra_user_profile = false; if ($instance->customint1 != '') { $instance->customint1 == 0 ? $show_standard_user_profile = true : ($show_standard_user_profile = false); } else { $apply_setting['show_standard_user_profile']->value == 0 ? $show_standard_user_profile = true : ($show_standard_user_profile = false); } if ($instance->customint2 != '') { $instance->customint2 == 0 ? $show_extra_user_profile = true : ($show_extra_user_profile = false); } else { $apply_setting['show_extra_user_profile']->value == 0 ? $show_extra_user_profile = true : ($show_extra_user_profile = false); } if ($show_standard_user_profile) { useredit_shared_definition($mform, $editoroptions, $filemanageroptions); } if ($show_extra_user_profile) { profile_definition($mform, $user->id); } $profile_default_values = $user; if (is_object($profile_default_values)) { $profile_default_values = (array) $profile_default_values; } $mform->setDefaults($profile_default_values); $this->add_action_buttons(false, get_string('enrolme', 'enrol_self')); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->setDefault('id', $instance->courseid); $mform->addElement('hidden', 'instance'); $mform->setType('instance', PARAM_INT); $mform->setDefault('instance', $instance->id); //$mform->addElement('html',"<script type='text/javascript' src='../../lib/jquery/jquery-1.10.2.min.js'></script>"); //$mform->addElement('html','<script>$(document).ready(function(){$(".collapsible-actions a").trigger("click");})</script>'); //$mform->addElement('html','<script type="text/javascript">$(document).ready(function(){setTimeout(function(){$(".collapseexpand").trigger("click");},3000)})</script>'); }
/** * Define the form. */ public function definition() { global $CFG, $COURSE, $USER; $mform = $this->_form; $editoroptions = null; $filemanageroptions = null; $usernotfullysetup = user_not_fully_set_up($USER); 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; if (empty($user->country)) { // We must unset the value here so $CFG->country can be used as default one. unset($user->country); } // 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); // Shared fields. useredit_shared_definition($mform, $editoroptions, $filemanageroptions, $user); // Extra settigs. if (!empty($CFG->disableuserimages) || $usernotfullysetup) { $mform->removeElement('deletepicture'); $mform->removeElement('imagefile'); $mform->removeElement('imagealt'); } // If the user isn't fully set up, let them know that they will be able to change // their profile picture once their profile is complete. if ($usernotfullysetup) { $userpicturewarning = $mform->createElement('warning', 'userpicturewarning', 'notifymessage', get_string('newpictureusernotsetup')); $enabledusernamefields = useredit_get_enabled_name_fields(); if ($mform->elementExists('moodle_additional_names')) { $mform->insertElementBefore($userpicturewarning, 'moodle_additional_names'); } else { if ($mform->elementExists('moodle_interests')) { $mform->insertElementBefore($userpicturewarning, 'moodle_interests'); } else { $mform->insertElementBefore($userpicturewarning, 'moodle_optional'); } } // This is expected to exist when the form is submitted. $imagefile = $mform->createElement('hidden', 'imagefile'); $mform->insertElementBefore($imagefile, 'userpicturewarning'); } // Next the customisable profile fields. profile_definition($mform, $userid); $this->add_action_buttons(false, get_string('updatemyprofile')); $this->set_data($user); }
function definition (){ global $CFG, $USER; $mform =& $this->_form; $columns =& $this->_customdata; // I am the template user, why should it be the administrator? we have roles now, other ppl may use this script ;-) $templateuser = $USER; // upload settings and file $mform->addElement('header', 'settingsheader', get_string('settings')); $mform->addElement('static', 'uutypelabel', get_string('uuoptype', 'admin') ); $choices = array(0 => get_string('infilefield', 'auth'), 1 => get_string('createpasswordifneeded', 'auth')); $mform->addElement('select', 'uupasswordnew', get_string('uupasswordnew', 'admin'), $choices); $mform->setDefault('uupasswordnew', 1); $mform->disabledIf('uupasswordnew', 'uutype', 'eq', UU_UPDATE); $choices = array(0 => get_string('nochanges', 'admin'), 1 => get_string('uuupdatefromfile', 'admin'), 2 => get_string('uuupdateall', 'admin'), 3 => get_string('uuupdatemissing', 'admin')); $mform->addElement('select', 'uuupdatetype', get_string('uuupdatetype', 'admin'), $choices); $mform->setDefault('uuupdatetype', 0); $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uuupdatetype', 'uutype', 'eq', UU_ADDINC); $choices = array(0 => get_string('nochanges', 'admin'), 1 => get_string('update')); $mform->addElement('select', 'uupasswordold', get_string('uupasswordold', 'admin'), $choices); $mform->setDefault('uupasswordold', 0); $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uupasswordold', 'uutype', 'eq', UU_ADDINC); $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 0); $mform->disabledIf('uupasswordold', 'uuupdatetype', 'eq', 3); $mform->addElement('selectyesno', 'uuallowrenames', get_string('allowrenames', 'admin')); $mform->setDefault('uuallowrenames', 0); $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uuallowrenames', 'uutype', 'eq', UU_ADDINC); $mform->addElement('selectyesno', 'uuallowdeletes', get_string('allowdeletes', 'admin')); $mform->setDefault('uuallowdeletes', 0); $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDNEW); $mform->disabledIf('uuallowdeletes', 'uutype', 'eq', UU_ADDINC); $mform->addElement('selectyesno', 'uunoemailduplicates', get_string('uunoemailduplicates', 'admin')); $mform->setDefault('uunoemailduplicates', 1); $choices = array(0 => get_string('no'), 1 => get_string('uubulknew', 'admin'), 2 => get_string('uubulkupdated', 'admin'), 3 => get_string('uubulkall', 'admin')); $mform->addElement('select', 'uubulk', get_string('uubulk', 'admin'), $choices); $mform->setDefault('uubulk', 0); // roles selection $showroles = false; foreach ($columns as $column) { if (preg_match('/^type\d+$/', $column)) { $showroles = true; break; } } if ($showroles) { $mform->addElement('header', 'rolesheader', get_string('roles')); $choices = uu_allowed_roles(true); $mform->addElement('select', 'uulegacy1', get_string('uulegacy1role', 'admin'), $choices); if ($studentroles = get_archetype_roles('student')) { foreach ($studentroles as $role) { if (isset($choices[$role->id])) { $mform->setDefault('uulegacy1', $role->id); break; } } unset($studentroles); } $mform->addElement('select', 'uulegacy2', get_string('uulegacy2role', 'admin'), $choices); if ($editteacherroles = get_archetype_roles('editingteacher')) { foreach ($editteacherroles as $role) { if (isset($choices[$role->id])) { $mform->setDefault('uulegacy2', $role->id); break; } } unset($editteacherroles); } $mform->addElement('select', 'uulegacy3', get_string('uulegacy3role', 'admin'), $choices); if ($teacherroles = get_archetype_roles('teacher')) { foreach ($teacherroles as $role) { if (isset($choices[$role->id])) { $mform->setDefault('uulegacy3', $role->id); break; } } unset($teacherroles); } } // default values $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'admin')); $mform->addElement('text', 'username', get_string('username'), 'size="20"'); $mform->addRule('username', get_string('requiredtemplate', 'admin'), 'required', null, 'client'); // only enabled and known to work plugins $choices = uu_allowed_auths(); $mform->addElement('select', 'auth', get_string('chooseauthmethod','auth'), $choices); $mform->setDefault('auth', 'manual'); // manual is a sensible backwards compatible default $mform->addHelpButton('auth', 'chooseauthmethod', 'auth'); $mform->setAdvanced('auth'); $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"'); $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse')); $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices); $mform->setDefault('maildisplay', 2); $choices = array(0 => get_string('textformat'), 1 => get_string('htmlformat')); $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices); $mform->setDefault('mailformat', 1); $mform->setAdvanced('mailformat'); $choices = array(0 => get_string('emaildigestoff'), 1 => get_string('emaildigestcomplete'), 2 => get_string('emaildigestsubjects')); $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices); $mform->setDefault('maildigest', 0); $mform->setAdvanced('maildigest'); $choices = array(0 => get_string('autosubscribeyes'), 1 => get_string('autosubscribeno')); $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices); $mform->setDefault('autosubscribe', 1); $editors = editors_get_enabled(); if (count($editors) > 1) { $choices = array(); $choices['0'] = get_string('texteditor'); $choices['1'] = get_string('htmleditor'); $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices); $mform->setDefault('htmleditor', 1); } else { $mform->addElement('hidden', 'htmleditor'); $mform->setDefault('htmleditor', 1); $mform->setType('htmleditor', PARAM_INT); } if (empty($CFG->enableajax)) { $mform->addElement('static', 'ajax', get_string('ajaxuse'), get_string('ajaxno')); } else { $choices = array( 0 => get_string('ajaxno'), 1 => get_string('ajaxyes')); $mform->addElement('select', 'ajax', get_string('ajaxuse'), $choices); $mform->setDefault('ajax', 1); } $mform->setAdvanced('ajax'); $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"'); $mform->setType('city', PARAM_MULTILANG); if (empty($CFG->defaultcity)) { $mform->setDefault('city', $templateuser->city); } else { $mform->setDefault('city', $CFG->defaultcity); } $mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries()); if (empty($CFG->country)) { $mform->setDefault('country', $templateuser->country); } else { $mform->setDefault('country', $CFG->country); } $mform->setAdvanced('country'); $choices = get_list_of_timezones(); $choices['99'] = get_string('serverlocaltime'); $mform->addElement('select', 'timezone', get_string('timezone'), $choices); $mform->setDefault('timezone', $templateuser->timezone); $mform->setAdvanced('timezone'); $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations()); $mform->setDefault('lang', $templateuser->lang); $mform->setAdvanced('lang'); $editoroptions = array('maxfiles'=>0, 'maxbytes'=>0, 'trusttext'=>false, 'forcehttps'=>false); $mform->addElement('editor', 'description', get_string('userdescription'), null, $editoroptions); $mform->setType('description', PARAM_CLEANHTML); $mform->addHelpButton('description', 'userdescription'); $mform->setAdvanced('description'); $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"'); $mform->setAdvanced('url'); $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="64" size="25"'); $mform->setType('idnumber', PARAM_NOTAGS); $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"'); $mform->setType('institution', PARAM_MULTILANG); $mform->setDefault('institution', $templateuser->institution); $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"'); $mform->setType('department', PARAM_MULTILANG); $mform->setDefault('department', $templateuser->department); $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"'); $mform->setType('phone1', PARAM_NOTAGS); $mform->setAdvanced('phone1'); $mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"'); $mform->setType('phone2', PARAM_NOTAGS); $mform->setAdvanced('phone2'); $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"'); $mform->setType('address', PARAM_MULTILANG); $mform->setAdvanced('address'); // Next the profile defaults profile_definition($mform); // hidden fields $mform->addElement('hidden', 'iid'); $mform->setType('iid', PARAM_INT); $mform->addElement('hidden', 'previewrows'); $mform->setType('previewrows', PARAM_INT); $mform->addElement('hidden', 'readcount'); $mform->setType('readcount', PARAM_INT); $mform->addElement('hidden', 'uutype'); $mform->setType('uutype', PARAM_INT); $this->add_action_buttons(true, get_string('uploadusers', 'admin')); }