Example #1
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] = auth_get_plugin_title($module);
     }
     $mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $auth_options);
     $mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod', 'auth')));
     $mform->setAdvanced('auth');
     $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'));
 }
Example #2
0
 $temp->add(new admin_setting_special_registerauth());
 $temp->add(new admin_setting_configselect('guestloginbutton', get_string('guestloginbutton', 'auth'), get_string('showguestlogin', 'auth'), '1', array('0' => get_string('hide'), '1' => get_string('show'))));
 $temp->add(new admin_setting_configtext('alternateloginurl', get_string('alternateloginurl', 'auth'), get_string('alternatelogin', 'auth', htmlspecialchars($CFG->wwwroot . '/login/index.php')), ''));
 $temp->add(new admin_setting_configtext('forgottenpasswordurl', get_string('forgottenpasswordurl', 'auth'), get_string('forgottenpassword', 'auth'), ''));
 $temp->add(new admin_setting_configtextarea('auth_instructions', get_string('instructions', 'auth'), get_string('authinstructions', 'auth'), ''));
 $temp->add(new admin_setting_configtext('allowemailaddresses', get_string('allowemailaddresses', 'admin'), get_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS));
 $temp->add(new admin_setting_configtext('denyemailaddresses', get_string('denyemailaddresses', 'admin'), get_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS));
 $temp->add(new admin_setting_configcheckbox('verifychangedemail', get_string('verifychangedemail', 'admin'), get_string('configverifychangedemail', 'admin'), 1));
 $temp->add(new admin_setting_configtext('recaptchapublickey', get_string('recaptchapublickey', 'admin'), get_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS));
 $temp->add(new admin_setting_configtext('recaptchaprivatekey', get_string('recaptchaprivatekey', 'admin'), get_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
 $ADMIN->add('authsettings', $temp);
 if ($auths = get_list_of_plugins('auth')) {
     $authsenabled = get_enabled_auth_plugins();
     $authbyname = array();
     foreach ($auths as $auth) {
         $strauthname = auth_get_plugin_title($auth);
         $authbyname[$strauthname] = $auth;
     }
     ksort($authbyname);
     foreach ($authbyname as $strauthname => $authname) {
         if (file_exists($CFG->dirroot . '/auth/' . $authname . '/settings.php')) {
             // do not show disabled auths in tree, keep only settings link on manage page
             $settings = new admin_settingpage('authsetting' . $authname, $strauthname, 'moodle/site:config', !in_array($authname, $authsenabled));
             if ($ADMIN->fulltree) {
                 include $CFG->dirroot . '/auth/' . $authname . '/settings.php';
             }
             // TODO: finish implementation of common settings - locking, etc.
             $ADMIN->add('authsettings', $settings);
         } else {
             $ADMIN->add('authsettings', new admin_externalpage('authsetting' . $authname, $strauthname, "{$CFG->wwwroot}/{$CFG->admin}/auth_config.php?auth={$authname}", 'moodle/site:config', !in_array($authname, $authsenabled)));
         }
Example #3
0
 /**
  * Return the properly translated human-friendly title of this auth plugin
  */
 function get_title()
 {
     return auth_get_plugin_title($this->authtype);
 }
Example #4
0
/**
 * Returns list of auth plugins that are enabled and known to work.
 */
function uu_allowed_auths()
{
    global $CFG;
    // only following plugins are guaranteed to work properly
    // TODO: add support for more plguins in 2.0
    $whitelist = array('manual', 'nologin', 'none', 'email');
    $plugins = get_enabled_auth_plugins();
    $choices = array();
    foreach ($plugins as $plugin) {
        $choices[$plugin] = auth_get_plugin_title($plugin);
    }
    return $choices;
}
Example #5
0
 /**
  * Creates known user filter if present
  * @param string $fieldname
  * @param boolean $advanced
  * @return object filter
  */
 function get_field($fieldname, $advanced)
 {
     global $USER, $CFG, $SITE;
     switch ($fieldname) {
         case 'username':
             return new user_filter_text('username', get_string('username'), $advanced, 'username');
         case 'realname':
             return new user_filter_text('realname', get_string('fullname'), $advanced, sql_fullname());
         case 'lastname':
             return new user_filter_text('lastname', get_string('lastname'), $advanced, 'lastname');
         case 'firstname':
             return new user_filter_text('firstname', get_string('firstname'), $advanced, 'firstname');
         case 'email':
             return new user_filter_text('email', get_string('email'), $advanced, 'email');
         case 'city':
             return new user_filter_text('city', get_string('city'), $advanced, 'city');
         case 'country':
             return new user_filter_select('country', get_string('country'), $advanced, 'country', get_list_of_countries(), $USER->country);
         case 'confirmed':
             return new user_filter_yesno('confirmed', get_string('confirmed', 'admin'), $advanced, 'confirmed');
         case 'profile':
             return new user_filter_profilefield('profile', get_string('profile'), $advanced);
         case 'courserole':
             return new user_filter_courserole('courserole', get_string('courserole', 'filters'), $advanced);
         case 'systemrole':
             return new user_filter_globalrole('systemrole', get_string('globalrole', 'role'), $advanced);
         case 'firstaccess':
             return new user_filter_date('firstaccess', get_string('firstaccess', 'filters'), $advanced, 'firstaccess');
         case 'lastaccess':
             return new user_filter_date('lastaccess', get_string('lastaccess'), $advanced, 'lastaccess');
         case 'lastlogin':
             return new user_filter_date('lastlogin', get_string('lastlogin'), $advanced, 'lastlogin');
         case 'timemodified':
             return new user_filter_date('timemodified', get_string('lastmodified'), $advanced, 'timemodified');
         case 'auth':
             $plugins = get_list_of_plugins('auth');
             $choices = array();
             foreach ($plugins as $auth) {
                 $choices[$auth] = auth_get_plugin_title($auth);
             }
             return new user_filter_simpleselect('auth', get_string('authentication'), $advanced, 'auth', $choices);
         case 'mnethostid':
             // include all hosts even those deleted or otherwise problematic
             if (!($hosts = get_records('mnet_host', '', '', 'id', 'id, wwwroot, name'))) {
                 $hosts = array();
             }
             $choices = array();
             foreach ($hosts as $host) {
                 if ($host->id == $CFG->mnet_localhost_id) {
                     $choices[$host->id] = format_string($SITE->fullname) . ' (' . get_string('local') . ')';
                 } else {
                     if (empty($host->wwwroot)) {
                         // All hosts
                         continue;
                     } else {
                         $choices[$host->id] = $host->name . ' (' . $host->wwwroot . ')';
                     }
                 }
             }
             if ($usedhosts = get_fieldset_sql("SELECT DISTINCT mnethostid FROM {$CFG->prefix}user WHERE deleted=0")) {
                 foreach ($usedhosts as $hostid) {
                     if (empty($hosts[$hostid])) {
                         $choices[$hostid] = 'id: ' . $hostid . ' (' . get_string('error') . ')';
                     }
                 }
             }
             if (count($choices) < 2) {
                 return null;
                 // filter not needed
             }
             return new user_filter_simpleselect('mnethostid', 'mnethostid', $advanced, 'mnethostid', $choices);
         default:
             return null;
     }
 }