Exemplo n.º 1
0
 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'));
 }
Exemplo n.º 2
0
 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'));
 }
Exemplo n.º 3
0
 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 $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);
 }
Exemplo n.º 5
0
 /**
  * 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);
 }
Exemplo n.º 6
0
    /**
     * 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);
    }
Exemplo n.º 7
0
 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'));
 }
Exemplo n.º 8
0
 /**
  * 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'));
 }
Exemplo n.º 9
0
 /**
  * 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);
 }
Exemplo n.º 10
0
 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>');
 }