Exemple #1
0
 function definition()
 {
     global $USER, $CFG;
     $mform =& $this->_form;
     $mform->addElement('header', '', get_string('createuserandpass'), '');
     $mform->addElement('text', 'username', get_string('username'), 'maxlength="100" size="12"');
     $mform->setType('username', PARAM_NOTAGS);
     $mform->addRule('username', get_string('missingusername'), 'required', null, 'server');
     $mform->addElement('passwordunmask', 'password', get_string('password'), 'maxlength="32" size="12"');
     $mform->setType('password', PARAM_RAW);
     $mform->addRule('password', get_string('missingpassword'), 'required', null, 'server');
     $mform->addElement('header', '', get_string('supplyinfo'), '');
     $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="25"');
     $mform->setType('email', PARAM_NOTAGS);
     $mform->addRule('email', get_string('missingemail'), 'required', null, 'server');
     $mform->addElement('text', 'email2', get_string('emailagain'), 'maxlength="100" size="25"');
     $mform->setType('email2', PARAM_NOTAGS);
     $mform->addRule('email2', get_string('missingemail'), 'required', null, 'server');
     $nameordercheck = new object();
     $nameordercheck->firstname = 'a';
     $nameordercheck->lastname = 'b';
     if (fullname($nameordercheck) == 'b a') {
         // See MDL-4325
         $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
         $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
     } else {
         $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
         $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
     }
     $mform->setType('firstname', PARAM_TEXT);
     $mform->addRule('firstname', get_string('missingfirstname'), 'required', null, 'server');
     $mform->setType('lastname', PARAM_TEXT);
     $mform->addRule('lastname', get_string('missinglastname'), 'required', null, 'server');
     $mform->addElement('text', 'city', get_string('city'), 'maxlength="20" size="20"');
     $mform->setType('city', PARAM_TEXT);
     $mform->addRule('city', get_string('missingcity'), 'required', null, 'server');
     $country = get_list_of_countries();
     $default_country[''] = get_string('selectacountry');
     $country = array_merge($default_country, $country);
     $mform->addElement('select', 'country', get_string('country'), $country);
     $mform->addRule('country', get_string('missingcountry'), 'required', null, 'server');
     if (!empty($CFG->country)) {
         $mform->setDefault('country', $CFG->country);
     } else {
         $mform->setDefault('country', '');
     }
     if (signup_captcha_enabled()) {
         $mform->addElement('recaptcha', 'recaptcha_element', get_string('recaptcha', 'auth'), array('https' => $CFG->loginhttps));
         $mform->setHelpButton('recaptcha_element', array('recaptcha', get_string('recaptcha', 'auth')));
     }
     profile_signup_fields($mform);
     if (!empty($CFG->sitepolicy)) {
         $mform->addElement('header', '', get_string('policyagreement'), '');
         $mform->addElement('static', 'policylink', '', '<a href="' . $CFG->sitepolicy . '" onclick="this.target=\'_blank\'">' . get_String('policyagreementclick') . '</a>');
         $mform->addElement('checkbox', 'policyagreed', get_string('policyaccept'));
         $mform->addRule('policyagreed', get_string('policyagree'), 'required', null, 'server');
     }
     // buttons
     $this->add_action_buttons(true, get_string('createaccount'));
 }
 function definition()
 {
     global $COURSE;
     $mform =& $this->_form;
     $defaultcategory = $this->_customdata['defaultcategory'];
     $contexts = $this->_customdata['contexts'];
     //--------------------------------------------------------------------------------
     $mform->addElement('header', null, get_string("registrationinfotitle", 'qformat_wordtable'));
     $mform->addElement('hidden', 'lang', current_language());
     $mform->addElement('hidden', 'version', $CFG->version);
     $mform->addElement('hidden', 'release', $CFG->release);
     $mform->addElement('hidden', 'courseid', '');
     $mform->addElement('text', 'yolusername', get_string('username'));
     $mform->addRule('yolusername', get_string('required'), 'required', '', 'client');
     $mform->addRule('yolusername', get_string('invalidemail'), 'email', '', 'client');
     $mform->applyFilter('yolusername', 'trim');
     $mform->addElement('password', 'password', get_string("password"));
     $mform->addRule('password', get_string('required'), 'required', '', 'client');
     $mform->addElement('password', 'passwordconfirm', get_string("password"));
     $mform->addRule('passwordconfirm', get_string('required'), 'required', '', 'client');
     // This doesn't work, don't know why
     //$mform->addRule(array('password', 'passwordconfirm'), get_string('registrationpasswordsdonotmatch', 'qformat_wordtable'), 'compare', '', 'client');
     $mform->addElement('static', 'dummy2', '');
     $mform->addElement('text', 'sitename', get_string("fullsitename"));
     $mform->addRule('sitename', get_string('required'), 'required', '', 'client');
     $mform->applyFilter('sitename', 'trim');
     $mform->addElement('text', 'adminname', get_string("administrator"));
     $mform->addRule('adminname', get_string('required'), 'required', '', 'client');
     $mform->applyFilter('adminname', 'trim');
     $mform->addElement('text', 'adminemail', get_string("email"));
     $mform->addRule('adminemail', get_string('required'), 'required', '', 'client');
     $mform->addRule('adminemail', get_string('invalidemail'), 'email', '', 'client');
     $mform->applyFilter('adminemail', 'trim');
     $options[0] = get_string("publicdirectory0");
     $options[1] = get_string("publicdirectory1");
     $options[2] = get_string("publicdirectory2");
     $mform->addElement('select', 'public', get_string("publicdirectory"), $options);
     unset($options);
     /*
             $options[0] = get_string("subtype_free", "qformat_wordtable");
             $options[1] = get_string("subtype_unlimited", "qformat_wordtable");
             $mform->addElement('select', 'subscription', get_string("subscription_type", "qformat_wordtable"), $options );
             unset($options);
     */
     $options[0] = "<500";
     $options[1] = "501-5,000";
     $options[2] = ">5,001";
     $mform->addElement('select', 'sitesize', get_string("users"), $options);
     unset($options);
     $mform->addElement('select', 'country', get_string("selectacountry"), get_list_of_countries());
     $options[0] = get_string("registrationno");
     $options[1] = get_string("registrationyes");
     $mform->addElement('select', 'mailme', get_string("registrationemail"), $options);
     //--------------------------------------------------------------------------------
     $mform->addElement('submit', 'submitbutton', get_string('registrationsend', 'qformat_wordtable'));
     //--------------------------------------------------------------------------------
     $mform->addElement('static', 'dummy', '');
     $mform->closeHeaderBefore('dummy');
 }
 function definition()
 {
     global $USER, $CFG;
     $mform =& $this->_form;
     $mform->addElement('header', '', get_string('createuserandpass'), '');
     $mform->addElement('text', 'username', get_string('username'), 'size="12"');
     $mform->setType('username', PARAM_NOTAGS);
     $mform->addRule('username', get_string('missingusername'), 'required', null, 'client');
     $mform->addElement('password', 'password', get_string('password'), 'size="12"');
     $mform->setType('password', PARAM_RAW);
     $mform->addRule('password', get_string('missingpassword'), 'required', null, 'client');
     $mform->addElement('header', '', get_string('supplyinfo'), '');
     $mform->addElement('text', 'email', get_string('email'), 'size="25"');
     $mform->setType('email', PARAM_NOTAGS);
     $mform->addRule('email', get_string('missingemail'), 'required', null, 'client');
     $mform->addElement('text', 'email2', get_string('emailagain'), 'size="25"');
     $mform->setType('email2', PARAM_NOTAGS);
     $mform->addRule('email2', get_string('missingemail'), 'required', null, 'client');
     $mform->addElement('text', 'firstname', get_string('firstname'), 'size="25"');
     $mform->setType('firstname', PARAM_TEXT);
     $mform->addRule('firstname', get_string('missingfirstname'), 'required', null, 'client');
     $mform->addElement('text', 'lastname', get_string('lastname'), 'size="25"');
     $mform->setType('lastname', PARAM_TEXT);
     $mform->addRule('lastname', get_string('missinglastname'), 'required', null, 'client');
     $mform->addElement('text', 'city', get_string('city'), 'size="20"');
     $mform->setType('city', PARAM_TEXT);
     $mform->addRule('city', get_string('missingcity'), 'required', null, 'client');
     $country = get_list_of_countries();
     $default_country[''] = get_string('selectacountry');
     $country = array_merge($default_country, $country);
     $mform->addElement('select', 'country', get_string('country'), $country);
     $mform->addRule('country', get_string('missingcountry'), 'required', null, 'client');
     if (!empty($CFG->country)) {
         $mform->setDefault('country', $CFG->country);
     } else {
         $mform->setDefault('country', '');
     }
     // buttons
     $this->add_action_buttons(true, get_string('createaccount'));
 }
/**
 * Get attributes from OpenID response and populate 'user'-like structure
 * If matching user exists then return matching user
 *
 * @param string $resp - the OpenID response
 * @return user object - false on multiple matches, or the matching user object 
 *                       _or_ new user object with members:
 *                           username, email, firstname, lastname, country
 */
function openid_resp_to_user(&$resp)
{
    $tmp_users = array();
    $user = new stdClass();
    $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($resp);
    $sreg = $sreg_resp->contents();
    if (defined('ADD_AX_SUPPORT')) {
        $ax_resp = new Auth_OpenID_AX_FetchResponse();
        $ax = $ax_resp->fromSuccessResponse($resp);
    }
    // We'll attempt to use the user's nickname to set their username
    if (isset($sreg['nickname']) && !empty($sreg['nickname']) && !($tmp_users['username'] = get_records('user', 'username', addslashes($sreg['nickname']))) || defined('USE_EMAIL_FOR_USERNAME') && isset($sreg['email']) && !empty($sreg['email']) && !($tmp_users['username_email'] = get_records('user', 'username', $sreg['email']))) {
        $user->username = addslashes(isset($sreg['nickname']) && !empty($sreg['nickname']) ? $sreg['nickname'] : $sreg['email']);
    } else {
        if (defined('ADD_AX_SUPPORT') && (($nickname = get_ax_data(AX_SCHEMA_NICKNAME, $ax)) && !($tmp_users['username'] = get_records('user', 'username', addslashes($nickname))) || defined('USE_EMAIL_FOR_USERNAME') && ($useremail = get_ax_data(AX_SCHEMA_EMAIL, $ax)) && !($tmp_users['username_email'] = get_records('user', 'username', $useremail)))) {
            // better to fall-back to email? may show-up in various display blocks
            $user->username = addslashes($nickname ? $nickname : $useremail);
        } else {
            $user->username = openid_normalize_url_as_username($resp->identity_url);
        }
    }
    // SREG fullname
    if (isset($sreg['fullname']) && !empty($sreg['fullname'])) {
        $name = openid_parse_full_name($sreg['fullname']);
        $user->firstname = addslashes($name['first']);
        $user->lastname = addslashes($name['last']);
    } else {
        if (defined('ADD_AX_SUPPORT') && (get_ax_data(AX_SCHEMA_FULLNAME, $ax) || get_ax_data(AX_SCHEMA_LASTNAME, $ax))) {
            if (get_ax_data(AX_SCHEMA_LASTNAME, $ax)) {
                $user->firstname = addslashes(get_ax_data(AX_SCHEMA_FIRSTNAME, $ax));
                $user->lastname = addslashes(get_ax_data(AX_SCHEMA_LASTNAME, $ax));
            } else {
                // fullname
                $name = openid_parse_full_name(get_ax_data(AX_SCHEMA_FULLNAME, $ax));
                $user->firstname = addslashes($name['first']);
                $user->lastname = addslashes($name['last']);
            }
        }
    }
    if (!empty($user->lastname)) {
        $tmp_users['fullname'] = get_records_select('user', "firstname = '" . $user->firstname . "' AND lastname = '" . $user->lastname . "'");
    }
    // SREG email
    if (!empty($sreg['email']) && !($tmp_users['email'] = get_records('user', 'email', $sreg['email']))) {
        $user->email = addslashes($sreg['email']);
    } else {
        if (defined('ADD_AX_SUPPORT') && ($useremail = get_ax_data(AX_SCHEMA_EMAIL, $ax)) && !($tmp_users['email'] = get_records('user', 'email', $useremail))) {
            $user->email = addslashes($useremail);
        }
    }
    // SREG country
    $country = '';
    if (isset($sreg['country']) && !empty($sreg['country'])) {
        $country = $sreg['country'];
    } else {
        if (defined('ADD_AX_SUPPORT') && get_ax_data(AX_SCHEMA_COUNTRY, $ax)) {
            $country = get_ax_data(AX_SCHEMA_COUNTRY, $ax);
        }
    }
    if (!empty($country)) {
        $country_code = strtoupper($country);
        $countries = get_list_of_countries();
        if (strlen($country) != 2 || !isset($countries[$country_code])) {
            $countries_keys = array_keys($countries);
            $countries_vals = array_values($countries);
            $country_code = array_search($country, $countries_vals);
            if ($country_code > 0) {
                $country_code = $countries_keys[$country_code];
            } else {
                $country_code = '';
            }
        }
        if (!empty($country_code)) {
            $user->country = $country_code;
        }
    }
    /* We're currently not attempting to get language and timezone values
        // SREG language
        if (isset($sreg['language']) && !empty($sreg['language'])) {
        }
    
        // SREG timezone
        if (isset($sreg['timezone']) && !empty($sreg['timezone'])) {
        }
      */
    $config = get_config('auth/openid');
    //error_log("/auth/openid/locallib.php::auth/openid::config=...");
    //err_dump($config);
    //error_log("/auth/openid/locallib.php::openid_resp_to_user() - check for user matching ...");
    //err_dump($user);
    // Map OpenID fields to whether field MUST be unique
    // TBD: make unique fields configurable im OpenID: auth_config_users.html
    // Keys must match keys in tmp_users[] array - set above.
    $openid_fields = array('email' => 1, 'fullname' => 0, 'username' => 0, 'username_email' => 1);
    foreach ($openid_fields as $openid_field => $field_unique) {
        $match_array = str_word_count($config->auth_openid_match_fields, 1, '_');
        $num = !empty($match_array) ? 1 : 0;
        if ($field_unique && !empty($tmp_users[$openid_field]) && count($tmp_users[$openid_field]) > $num) {
            //error_log("/auth/openid/locallib.php::openid_resp_to_user() - multiple matches on count(tmp_users[{$openid_field}])=".count($tmp_users[$openid_field])." ...");
            //err_dump($tmp_users[$openid_field]);
            //error_log("> match_array=...");
            //err_dump($match_array);
            return false;
        }
    }
    $matching_user = null;
    // check tmp_users[] matches for valid existing user,
    // return false if conflicts between matching fields
    if (!empty($config->auth_openid_match_fields)) {
        $openid_match_fields = explode(',', $config->auth_openid_match_fields);
        foreach ($openid_match_fields as $match_field) {
            $match_field = trim($match_field);
            if (!empty($tmp_users[$match_field]) && count($tmp_users[$match_field]) == 1) {
                if (!$matching_user) {
                    $matching_user = reset($tmp_users[$match_field]);
                } else {
                    if ($openid_fields[$match_field] && $matching_user->id != reset($tmp_users[$match_field])->id) {
                        // unique field matches different user!
                        return false;
                    }
                }
            }
        }
    }
    if (!empty($matching_user)) {
        merge_user_fields($matching_user, $user);
        //error_log( "openid_resp_to_user() - merged matching user: ");
        //err_dump($matching_user);
        return $matching_user;
    }
    return $user;
}
Exemple #5
0
 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'));
 }
Exemple #6
0
function useredit_shared_definition(&$mform)
{
    global $CFG, $USER;
    $user = get_record('user', 'id', $USER->id);
    useredit_load_preferences($user, false);
    $strrequired = get_string('required');
    $nameordercheck = new object();
    $nameordercheck->firstname = 'a';
    $nameordercheck->lastname = 'b';
    if (fullname($nameordercheck) == 'b a') {
        // See MDL-4325
        $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
        $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
    } else {
        $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
        $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
    }
    $mform->addRule('firstname', $strrequired, 'required', null, 'client');
    $mform->setType('firstname', PARAM_NOTAGS);
    $mform->addRule('lastname', $strrequired, 'required', null, 'client');
    $mform->setType('lastname', PARAM_NOTAGS);
    // Do not show email field if change confirmation is pending
    if ($CFG->emailchangeconfirmation && !empty($user->preference_newemail)) {
        $notice = get_string('auth_emailchangepending', 'auth', $user);
        $notice .= '<br /><a href="edit.php?cancelemailchange=1&amp;id=' . $user->id . '">' . get_string('auth_emailchangecancel', 'auth') . '</a>';
        $mform->addElement('static', 'emailpending', get_string('email'), $notice);
    } else {
        $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
        $mform->addRule('email', $strrequired, 'required', null, 'client');
    }
    $choices = array();
    $choices['0'] = get_string('emaildisplayno');
    $choices['1'] = get_string('emaildisplayyes');
    $choices['2'] = get_string('emaildisplaycourse');
    $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
    $mform->setDefault('maildisplay', 2);
    $choices = array();
    $choices['0'] = get_string('emailenable');
    $choices['1'] = get_string('emaildisable');
    $mform->addElement('select', 'emailstop', get_string('emailactive'), $choices);
    $mform->setDefault('emailenable', 1);
    $choices = array();
    $choices['0'] = get_string('textformat');
    $choices['1'] = get_string('htmlformat');
    $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
    $mform->setDefault('mailformat', 1);
    $mform->setAdvanced('mailformat');
    if (!empty($CFG->allowusermailcharset)) {
        $choices = array();
        $charsets = get_list_of_charsets();
        if (!empty($CFG->sitemailcharset)) {
            $choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
        } else {
            $choices['0'] = get_string('site') . ' (UTF-8)';
        }
        $choices = array_merge($choices, $charsets);
        $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
        $mform->setAdvanced('preference_mailcharset');
    }
    $choices = array();
    $choices['0'] = get_string('emaildigestoff');
    $choices['1'] = get_string('emaildigestcomplete');
    $choices['2'] = get_string('emaildigestsubjects');
    $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
    $mform->setDefault('maildigest', 0);
    $mform->setAdvanced('maildigest');
    $choices = array();
    $choices['1'] = get_string('autosubscribeyes');
    $choices['0'] = get_string('autosubscribeno');
    $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
    $mform->setDefault('autosubscribe', 1);
    $mform->setAdvanced('autosubscribe');
    if (!empty($CFG->forum_trackreadposts)) {
        $choices = array();
        $choices['0'] = get_string('trackforumsno');
        $choices['1'] = get_string('trackforumsyes');
        $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
        $mform->setDefault('trackforums', 0);
        $mform->setAdvanced('trackforums');
    }
    if ($CFG->htmleditor) {
        $choices = array();
        $choices['0'] = get_string('texteditor');
        $choices['1'] = get_string('htmleditor');
        $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
        $mform->setDefault('htmleditor', 1);
        $mform->setAdvanced('htmleditor');
    }
    if (empty($CFG->enableajax)) {
        $mform->addElement('static', 'ajaxdisabled', get_string('ajaxuse'), get_string('ajaxno'));
        $mform->setAdvanced('ajaxdisabled');
    } else {
        $choices = array();
        $choices['0'] = get_string('ajaxno');
        $choices['1'] = get_string('ajaxyes');
        $mform->addElement('select', 'ajax', get_string('ajaxuse'), $choices);
        $mform->setDefault('ajax', 0);
        $mform->setAdvanced('ajax');
    }
    $choices = array();
    $choices['0'] = get_string('screenreaderno');
    $choices['1'] = get_string('screenreaderyes');
    $mform->addElement('select', 'screenreader', get_string('screenreaderuse'), $choices);
    $mform->setDefault('screenreader', 0);
    $mform->setAdvanced('screenreader');
    $mform->addElement('text', 'city', get_string('city'), 'maxlength="20" size="21"');
    $mform->setType('city', PARAM_MULTILANG);
    $mform->addRule('city', $strrequired, 'required', null, 'client');
    $choices = get_list_of_countries();
    $choices = array('' => get_string('selectacountry') . '...') + $choices;
    $mform->addElement('select', 'country', get_string('selectacountry'), $choices);
    $mform->addRule('country', $strrequired, 'required', null, 'client');
    if (!empty($CFG->country)) {
        $mform->setDefault('country', $CFG->country);
    }
    $choices = get_list_of_timezones();
    $choices['99'] = get_string('serverlocaltime');
    if ($CFG->forcetimezone != 99) {
        $mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]);
    } else {
        $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
        $mform->setDefault('timezone', '99');
    }
    $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_list_of_languages());
    $mform->setDefault('lang', $CFG->lang);
    if (!empty($CFG->allowuserthemes)) {
        $choices = array();
        $choices[''] = get_string('default');
        $choices += get_list_of_themes();
        $mform->addElement('select', 'theme', get_string('preferredtheme'), $choices);
        $mform->setAdvanced('theme');
    }
    $mform->addElement('htmleditor', 'description', get_string('userdescription'));
    $mform->setType('description', PARAM_CLEAN);
    $mform->setHelpButton('description', array('text', get_string('helptext')));
    if (!empty($CFG->gdversion)) {
        $mform->addElement('header', 'moodle_picture', get_string('pictureof'));
        //TODO: Accessibility fix fieldset legend
        $mform->addElement('static', 'currentpicture', get_string('currentpicture'));
        $mform->addElement('checkbox', 'deletepicture', get_string('delete'));
        $mform->setDefault('deletepicture', false);
        $mform->addElement('file', 'imagefile', get_string('newpicture'));
        $mform->setHelpButton('imagefile', array('picture', get_string('helppicture')));
        $mform->addElement('text', 'imagealt', get_string('imagealt'), 'maxlength="100" size="30"');
        $mform->setType('imagealt', PARAM_MULTILANG);
    }
    if (!empty($CFG->usetags)) {
        $mform->addElement('header', 'moodle_interests', get_string('interests'));
        $mform->addElement('textarea', 'interests', get_string('interestslist'), 'cols="45" rows="3"');
        $mform->setHelpButton('interests', array('interestslist', get_string('helpinterestslist'), false, true, false));
    }
    /// Moodle optional fields
    $mform->addElement('header', 'moodle_optional', get_string('optional', 'form'));
    $mform->setAdvanced('moodle_optional');
    $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
    $mform->setType('url', PARAM_URL);
    $mform->addElement('text', 'icq', get_string('icqnumber'), 'maxlength="15" size="25"');
    $mform->setType('icq', PARAM_CLEAN);
    $mform->addElement('text', 'skype', get_string('skypeid'), 'maxlength="50" size="25"');
    $mform->setType('skype', PARAM_CLEAN);
    $mform->addElement('text', 'aim', get_string('aimid'), 'maxlength="50" size="25"');
    $mform->setType('aim', PARAM_CLEAN);
    $mform->addElement('text', 'yahoo', get_string('yahooid'), 'maxlength="50" size="25"');
    $mform->setType('yahoo', PARAM_CLEAN);
    $mform->addElement('text', 'msn', get_string('msnid'), 'maxlength="50" size="25"');
    $mform->setType('msn', PARAM_CLEAN);
    $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="255" size="25"');
    $mform->setType('idnumber', PARAM_CLEAN);
    $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
    $mform->setType('institution', PARAM_MULTILANG);
    $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"');
    $mform->setType('department', PARAM_MULTILANG);
    $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
    $mform->setType('phone1', PARAM_CLEAN);
    $mform->addElement('text', 'phone2', get_string('phone2'), 'maxlength="20" size="25"');
    $mform->setType('phone2', PARAM_CLEAN);
    $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
    $mform->setType('address', PARAM_MULTILANG);
}
Exemple #7
0
 /**
  * items in the form
  */
 public function definition()
 {
     $questions = get_questions();
     $profile_fields = get_profilefields();
     $custom_fields = get_customfields();
     $mform =& $this->_form;
     unset($questions['none']);
     foreach ($questions as $k => $q) {
         $extra = null;
         if (in_array($k, $profile_fields)) {
             if (strcmp($k, 'country') === 0) {
                 $type = 'select';
                 $extra = get_list_of_countries();
             } else {
                 $type = 'text';
             }
         } else {
             if (in_array($k, $custom_fields)) {
                 $field = get_record('user_info_field', 'shortname', $k);
                 if (strcmp($field->datatype, 'menu') === 0) {
                     $type = 'select';
                     $extra = explode("\n", $field->param1);
                     $extra = array_combine($extra, $extra);
                 } else {
                     if (strcmp($field->datatype, 'text') === 0) {
                         $type = 'text';
                     } else {
                         if (strcmp($field->datatype, 'checkbox') === 0) {
                             $type = 'checkbox';
                         } else {
                             if (strcmp($field->datatype, 'textarea') === 0) {
                                 $type = 'textarea';
                             }
                         }
                     }
                 }
             }
         }
         if (!empty($type)) {
             $mform->addElement($type, $k, $q, $extra);
         }
     }
     $group = array();
     $group[] =& $mform->createElement('submit', 'save_exit', get_string('save_exit', 'block_enrol_survey'));
     $group[] =& $mform->createElement('submit', 'update', get_string('update', 'block_enrol_survey'));
     $group[] =& $mform->createElement('cancel');
     $mform->addGroup($group, 'form_buttons', '', array(''), false);
 }
Exemple #8
0
if ($context->id == $frontpagectx->id and $CFG->defaultfrontpageroleid) {
    // default frontpage role is assigned to all site users
    unset($rolenames[$CFG->defaultfrontpageroleid]);
}
// no roles to display yet?
// frontpage course is an exception, on the front page course we should display all users
if (empty($rolenames) && $context->id != $frontpagectx->id) {
    if (has_capability('moodle/role:assign', $context)) {
        redirect($CFG->wwwroot . '/' . $CFG->admin . '/roles/assign.php?contextid=' . $context->id);
    } else {
        print_error('noparticipants');
    }
}
add_to_log($course->id, 'user', 'view all', 'index.php?id=' . $course->id, '');
$bulkoperations = has_capability('moodle/course:bulkmessaging', $context);
$countries = get_list_of_countries();
$strnever = get_string('never');
$datestring->year = get_string('year');
$datestring->years = get_string('years');
$datestring->day = get_string('day');
$datestring->days = get_string('days');
$datestring->hour = get_string('hour');
$datestring->hours = get_string('hours');
$datestring->min = get_string('min');
$datestring->mins = get_string('mins');
$datestring->sec = get_string('sec');
$datestring->secs = get_string('secs');
if ($mode !== NULL) {
    $mode = (int) $mode;
    $SESSION->userindexmode = $mode;
} else {
        break;
    case 3:
        redirect($CFG->wwwroot . '/admin/user/user_bulk_delete.php');
        break;
    case 4:
        redirect($CFG->wwwroot . '/admin/user/user_bulk_display.php');
        break;
    default:
        break;
}
// prepare user filter types
$filters[] = new user_filter_text('username', get_string('username'), 'username');
$filters[] = new user_filter_text('realname', get_string('fullname'), sql_fullname());
$filters[] = new user_filter_text('email', get_string('email'), 'email');
$filters[] = new user_filter_text('city', get_string('city'), 'city');
$filters[] = new user_filter_select('country', get_string('country'), 'country', get_list_of_countries());
$filters[] = new user_filter_yesno('confirmed', get_string('confirm'), 'confirmed');
$filters[] = new user_filter_profilefield('profile', get_string('profile'));
$filters[] = new user_filter_courserole('course', get_string('courserole', 'filters'));
$filters[] = new user_filter_globalrole('system', get_string('globalrole', 'role'));
$filters[] = new user_filter_date('date', get_string('date'), 'lastaccess', array('lastlogin' => get_string('lastlogin'), 'firstaccess' => get_string('firstaccess', 'filters'), 'lastaccess' => get_string('lastaccess'), 'timemodified' => get_string('lastmodified')));
// create the user filter form
$user_filter_form =& new user_filter_form(null, $filters);
// do output
admin_externalpage_setup('userbulk');
admin_externalpage_print_header();
// put the user filter form first
$user_filter_form->display();
// get the SQL filter
$where =& $user_filter_form->getSQLFilter('id<>1 AND NOT deleted');
$ausercount = count_records_select('user', $where);
Exemple #10
0
 /**
  * Creates known user filter if present
  * @param string $fieldname
  * @param boolean $advanced
  * @return object filter
  */
 function get_field($fieldname, $advanced)
 {
     global $USER;
     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('confirm'), $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 'auth':
             $plugins = get_list_of_plugins('auth');
             $choices = array();
             foreach ($plugins as $auth) {
                 $choices[$auth] = get_string("auth_{$auth}title", 'auth');
             }
             return new user_filter_simpleselect('auth', get_string('authentication'), $advanced, 'auth', $choices);
         case 'mnethostid':
             if (!($hosts = get_records('mnet_host', '', '', 'id', 'id, wwwroot, name'))) {
                 return null;
             }
             $choices = array();
             foreach ($hosts as $host) {
                 if (empty($host->wwwroot)) {
                     continue;
                     // skip all hosts
                 }
                 $choices[$host->id] = $host->name . ' (' . $host->wwwroot . ')';
             }
             if (count($choices < 2)) {
                 return null;
                 // filter not needed
             }
             return new user_filter_simpleselect('mnethostid', 'mnethostid', $advanced, 'mnethostid', $choices);
         default:
             return null;
     }
 }
 function definition()
 {
     $mform =& $this->_form;
     // visible elements
     $mform->addElement('header', 'general', get_string('extralocation', 'map'));
     $mform->addElement('text', 'title', get_string('pointtitle', 'map'), array('size' => '64'));
     $mform->addRule('title', null, 'required', null, 'server');
     $mform->addElement('text', 'address', get_string('address'), array('size' => '64'));
     $mform->setType('address', PARAM_TEXT);
     $mform->addElement('text', 'city', get_string('city'), array('size' => '64'));
     $mform->setType('city', PARAM_TEXT);
     //$mform->addRule('city', null, 'required', null, 'server');
     //		$mform->addElement('text', 'state', get_string('state', 'map'), array('size'=>'64'));
     //		$mform->setType('state', PARAM_TEXT);
     $choices = get_list_of_countries();
     $choices = array('' => get_string('selectacountry') . '...') + $choices;
     $mform->addElement('select', 'country', get_string('selectacountry'), $choices);
     //$mform->addRule('country', get_string('required'), 'required', null, 'server');
     if (!empty($CFG->country)) {
         $mform->setDefault('country', $CFG->country);
     }
     //$mform->addElement('checkbox','usePoint',get_string('usepoint','map'));
     $mform->addElement('static', 'info', get_string('coordinates', 'map') . ':', get_string('coordinatesinfo', 'map'));
     $mform->addElement('text', 'latitude', get_string('latitude', 'map'), array('size' => '20'));
     $mform->addElement('text', 'longitude', get_string('longitude', 'map'), array('size' => '20'));
     $mform->addElement('htmleditor', 'text', get_string('description'), array('rows' => '24'));
     $mform->addRule('text', null, 'required', null, 'server');
     // hidden params
     $mform->addElement('hidden', 'id', 0);
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'locationid', 0);
     $mform->addElement('hidden', 'action', 'insertlocation');
     // buttons
     $this->add_action_buttons();
 }
Exemple #12
0
 /**
  * Create a new account using simple registration data if available
  *
  * @access private
  * @param object &$resp An OpenID consumer response object
  * @return object The new user
  */
 function _create_account(&$resp)
 {
     global $CFG, $USER;
     $url = $resp->identity_url;
     $password = hash_internal_user_password('openid');
     $server = $resp->endpoint->server_url;
     $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($resp);
     $sreg = $sreg_resp->contents();
     // We'll attempt to use the user's nickname to set their username
     if (isset($sreg['nickname']) && !empty($sreg['nickname']) && !record_exists('users', 'username', $sreg['nickname'])) {
         $username = $sreg['nickname'];
     } else {
         $username = openid_normalize_url_as_username($url);
     }
     create_user_record($username, $password, 'openid');
     $user = get_complete_user_data('username', $username);
     openid_append_url($user, $url);
     // SREG fullname
     if (isset($sreg['fullname']) && !empty($sreg['fullname'])) {
         $name = openid_parse_full_name($sreg['fullname']);
         $user->firstname = $name['first'];
         $user->lastname = $name['last'];
     }
     // SREG email
     if (isset($sreg['email']) && !empty($sreg['email']) && !record_exists('user', 'email', $sreg['email'])) {
         $user->email = $sreg['email'];
     }
     // SREG country
     if (isset($sreg['country']) && !empty($sreg['country'])) {
         $country = $sreg['country'];
         $country_code = strtoupper($country);
         $countries = get_list_of_countries();
         if (strlen($country) != 2 || !isset($countries[$country_code])) {
             $countries_keys = array_keys($countries);
             $countries_vals = array_values($countries);
             $country_code = array_search($country, $countries_vals);
             if ($country_code > 0) {
                 $country_code = $countries_keys[$country_code];
             } else {
                 $country_code = '';
             }
         }
         if (!empty($country_code)) {
             $user->country = $country_code;
         }
     }
     /* We're currently not attempting to get language and timezone values
        // SREG language
        if (isset($sreg['language']) && !empty($sreg['language'])) {
        }
        
        // SREG timezone
        if (isset($sreg['timezone']) && !empty($sreg['timezone'])) {
        }
        */
     if (function_exists('on_openid_create_account')) {
         on_openid_create_account($resp, $user);
     }
     update_record('user', $user);
     $user = get_complete_user_data('id', $user->id);
     // Redirect the user to their profile page if not set up properly
     if (!empty($user) && user_not_fully_set_up($user)) {
         $USER = clone $user;
         $urltogo = $CFG->wwwroot . '/user/edit.php';
         redirect($urltogo);
     }
     return $user;
 }
Exemple #13
0
/**
 * Return the countries options.
 */
function cm_get_list_of_countries()
{
    static $countries;
    if (empty($countries)) {
        /// Get them from Moodle... Replace this if they should be something else.
        $countries = get_list_of_countries();
    }
    return $countries;
}
 function definition()
 {
     global $CFG;
     $templateuser = $this->_customdata;
     if (empty($templateuser)) {
         if (!($templateuser = get_admin())) {
             error('Could not find site admin');
         }
     }
     $mform =& $this->_form;
     $mform->addElement('file', 'userfile', get_string('file'));
     $mform->addRule('userfile', null, 'required');
     $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'admin'));
     $mform->addElement('text', 'username', get_string('username'), 'size="20"');
     $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->setDefault('auth', $templateuser->auth);
     $mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod', 'auth')));
     $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
     $choices = array(get_string('emaildisplayno'), get_string('emaildisplayyes'), get_string('emaildisplaycourse'));
     $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
     $mform->setDefault('maildisplay', 2);
     $choices = array(get_string('emailenable'), get_string('emaildisable'));
     $mform->addElement('select', 'emailstop', get_string('emailactive'), $choices);
     $choices = array(get_string('textformat'), get_string('htmlformat'));
     $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
     $mform->setDefault('mailformat', 1);
     $choices = array(get_string('autosubscribeyes'), get_string('autosubscribeno'));
     $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
     $mform->setDefault('autosubscribe', 1);
     if ($CFG->htmleditor) {
         $choices = array(get_string('texteditor'), get_string('htmleditor'));
         $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
         $mform->setDefault('htmleditor', 1);
     }
     $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);
     $choices = get_list_of_timezones();
     $choices['99'] = get_string('serverlocaltime');
     $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
     $mform->setDefault('timezone', $templateuser->timezone);
     $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_list_of_languages());
     $mform->setDefault('lang', $templateuser->lang);
     $mform->addElement('htmleditor', 'description', get_string('userdescription'));
     $mform->setType('description', PARAM_CLEAN);
     $mform->setHelpButton('description', array('text', get_string('helptext')));
     $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
     $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->addElement('text', 'phone2', get_string('phone'), 'maxlength="20" size="25"');
     $mform->setType('phone2', PARAM_CLEAN);
     $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
     $mform->setType('address', PARAM_MULTILANG);
     $mform->addElement('header', 'settingsheader', get_string('settings'));
     $choices = array(get_string('infilefield', 'auth'), get_string('createpasswordifneeded', 'auth'));
     $mform->addElement('select', 'createpassword', get_string('passwordhandling', 'auth'), $choices);
     $mform->addElement('selectyesno', 'updateaccounts', get_string('updateaccounts', 'admin'));
     $mform->addElement('selectyesno', 'allowrenames', get_string('allowrenames', 'admin'));
     $choices = array(get_string('addcounter', 'admin'), get_string('skipuser', 'admin'));
     $mform->addElement('select', 'duplicatehandling', get_string('newusernamehandling', 'admin'), $choices);
     $this->add_action_buttons(false, get_string('uploadusers'));
 }
Exemple #15
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;
     }
 }
Exemple #16
0
/**
 * Prints a summary of a user in a nice little box.
 *
 * @uses $CFG
 * @uses $USER
 * @param user $user A {@link $USER} object representing a user
 * @param course $course A {@link $COURSE} object representing a course
 */
function print_user($user, $course, $messageselect = false, $return = false)
{
    global $CFG, $USER;
    $output = '';
    static $string;
    static $datestring;
    static $countries;
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    if (isset($user->context->id)) {
        $usercontext = $user->context;
    } else {
        $usercontext = get_context_instance(CONTEXT_USER, $user->id);
    }
    if (empty($string)) {
        // Cache all the strings for the rest of the page
        $string->email = get_string('email');
        $string->city = get_string('city');
        $string->lastaccess = get_string('lastaccess');
        $string->activity = get_string('activity');
        $string->unenrol = get_string('unenrol');
        $string->loginas = get_string('loginas');
        $string->fullprofile = get_string('fullprofile');
        $string->role = get_string('role');
        $string->name = get_string('name');
        $string->never = get_string('never');
        $datestring->day = get_string('day');
        $datestring->days = get_string('days');
        $datestring->hour = get_string('hour');
        $datestring->hours = get_string('hours');
        $datestring->min = get_string('min');
        $datestring->mins = get_string('mins');
        $datestring->sec = get_string('sec');
        $datestring->secs = get_string('secs');
        $datestring->year = get_string('year');
        $datestring->years = get_string('years');
        $countries = get_list_of_countries();
    }
    /// Get the hidden field list
    if (has_capability('moodle/course:viewhiddenuserfields', $context)) {
        $hiddenfields = array();
    } else {
        $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
    }
    $output .= '<table class="userinfobox">';
    $output .= '<tr>';
    $output .= '<td class="left side">';
    $output .= print_user_picture($user, $course->id, $user->picture, true, true);
    $output .= '</td>';
    $output .= '<td class="content">';
    $output .= '<div class="username">' . fullname($user, has_capability('moodle/site:viewfullnames', $context)) . '</div>';
    $output .= '<div class="info">';
    if (!empty($user->role)) {
        $output .= $string->role . ': ' . $user->role . '<br />';
    }
    if ($user->maildisplay == 1 or $user->maildisplay == 2 and $course->id != SITEID and !isguest() or has_capability('moodle/course:viewhiddenuserfields', $context)) {
        $output .= $string->email . ': <a href="mailto:' . $user->email . '">' . $user->email . '</a><br />';
    }
    if (($user->city or $user->country) and (!isset($hiddenfields['city']) or !isset($hiddenfields['country']))) {
        $output .= $string->city . ': ';
        if ($user->city && !isset($hiddenfields['city'])) {
            $output .= $user->city;
        }
        if (!empty($countries[$user->country]) && !isset($hiddenfields['country'])) {
            if ($user->city && !isset($hiddenfields['city'])) {
                $output .= ', ';
            }
            $output .= $countries[$user->country];
        }
        $output .= '<br />';
    }
    if (!isset($hiddenfields['lastaccess'])) {
        if ($user->lastaccess) {
            $output .= $string->lastaccess . ': ' . userdate($user->lastaccess);
            $output .= '&nbsp; (' . format_time(time() - $user->lastaccess, $datestring) . ')';
        } else {
            $output .= $string->lastaccess . ': ' . $string->never;
        }
    }
    $output .= '</div></td><td class="links">';
    //link to blogs
    if ($CFG->bloglevel > 0) {
        $output .= '<a href="' . $CFG->wwwroot . '/blog/index.php?userid=' . $user->id . '">' . get_string('blogs', 'blog') . '</a><br />';
    }
    //link to notes
    if (!empty($CFG->enablenotes) and has_capability('moodle/notes:manage', $context) || has_capability('moodle/notes:view', $context)) {
        $output .= '<a href="' . $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&amp;user='******'">' . get_string('notes', 'notes') . '</a><br />';
    }
    if (has_capability('moodle/site:viewreports', $context) or has_capability('moodle/user:viewuseractivitiesreport', $usercontext)) {
        $output .= '<a href="' . $CFG->wwwroot . '/course/user.php?id=' . $course->id . '&amp;user='******'">' . $string->activity . '</a><br />';
    }
    if (has_capability('moodle/role:assign', $context) and get_user_roles($context, $user->id, false)) {
        // I can unassing and user has some role
        $output .= '<a href="' . $CFG->wwwroot . '/course/unenrol.php?id=' . $course->id . '&amp;user='******'">' . $string->unenrol . '</a><br />';
    }
    if ($USER->id != $user->id && !session_is_loggedinas() && has_capability('moodle/user:loginas', $context) && !has_capability('moodle/site:doanything', $context, $user->id, false)) {
        $output .= '<a href="' . $CFG->wwwroot . '/course/loginas.php?id=' . $course->id . '&amp;user='******'&amp;sesskey=' . sesskey() . '">' . $string->loginas . '</a><br />';
    }
    $output .= '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $course->id . '">' . $string->fullprofile . '...</a>';
    if (!empty($messageselect)) {
        $output .= '<br /><input type="checkbox" name="user' . $user->id . '" /> ';
    }
    $output .= '</td></tr></table>';
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
Exemple #17
0
 function definition()
 {
     global $USER, $CFG;
     $invite = false;
     $sitecontext = get_context_instance(CONTEXT_SYSTEM);
     if (isloggedin() && has_capability('moodle/local:invitenewuser', $sitecontext)) {
         $invite = true;
     }
     $mform =& $this->_form;
     $mform->addElement('header', '', get_string('createuserandpass'), '');
     $mform->addElement('text', 'username', get_string('username'), 'maxlength="100" size="12"');
     $mform->setType('username', PARAM_NOTAGS);
     $mform->addRule('username', get_string('missingusername'), 'required', null, 'server');
     $mform->addElement('passwordunmask', 'password1', get_string('password'), 'maxlength="32" size="12"');
     $mform->setType('password1', PARAM_RAW);
     $mform->addRule('password1', get_string('missingpassword'), 'required', null, 'server');
     $mform->addElement('passwordunmask', 'password2', get_string('password') . ' (' . get_String('again') . ')', 'maxlength="32" size="12"');
     $mform->setType('password2', PARAM_RAW);
     $mform->addRule('password2', get_string('missingpassword'), 'required', null, 'server');
     $mform->addElement('header', '', get_string('supplyinfo'), '');
     $nameordercheck = new object();
     $nameordercheck->firstname = 'a';
     $nameordercheck->lastname = 'b';
     if (fullname($nameordercheck) == 'b a') {
         // See MDL-4325
         $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
         $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
     } else {
         $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
         $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
     }
     $mform->setType('firstname', PARAM_TEXT);
     $mform->addRule('firstname', get_string('missingfirstname'), 'required', null, 'server');
     $mform->setType('lastname', PARAM_TEXT);
     $mform->addRule('lastname', get_string('missinglastname'), 'required', null, 'server');
     $mform->addElement('text', 'city', get_string('city'), 'maxlength="20" size="20"');
     $mform->setType('city', PARAM_TEXT);
     $mform->addRule('city', get_string('missingcity'), 'required', null, 'server');
     $country = get_list_of_countries();
     $default_country[''] = get_string('selectacountry');
     $country = array_merge($default_country, $country);
     $mform->addElement('select', 'country', get_string('country'), $country);
     $mform->addRule('country', get_string('missingcountry'), 'required', null, 'server');
     if (!empty($CFG->country)) {
         $mform->setDefault('country', $CFG->country);
     } else {
         $mform->setDefault('country', '');
     }
     $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="20" size="20"');
     $mform->setType('idnumber', PARAM_NOTAGS);
     $mform->addRule('idnumber', get_string('missingidnumber', 'local'), 'required', null, 'server');
     profile_signup_fields($mform);
     if (!empty($CFG->sitepolicy)) {
         $mform->addElement('header', '', get_string('policyagreement'), '');
         $mform->addElement('static', 'policylink', '', '<a href="' . $CFG->sitepolicy . '" onclick="this.target=\'_blank\'">' . get_String('policyagreementclick') . '</a>');
         $mform->addElement('checkbox', 'policyagreed', get_string('policyaccept'));
         $mform->addRule('policyagreed', get_string('policyagree'), 'required', null, 'server');
     }
     $mform->addElement('hidden', 'data');
     // buttons
     $this->add_action_buttons(true, get_string('createaccount'));
 }
Exemple #18
0
 function definition()
 {
     global $CFG, $USER;
     $paymentmethodsenabled = get_list_of_payment_methods();
     $paymentmethod = optional_param('paymentmethod', $paymentmethodsenabled[0], PARAM_ALPHA);
     if (!in_array($paymentmethod, $paymentmethodsenabled)) {
         print_error('invalidpaymentmethod', '', '', $paymentmethod);
     }
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $mform->addElement('header', 'general', get_string('paymentrequired'));
     $othermethodstr = $this->other_method_available($paymentmethod);
     if ($othermethodstr) {
         $mform->addElement('static', '', '<div class="mdl-right">' . $othermethodstr . '</div>', '');
     }
     $mform->addElement('hidden', 'id', $course->id);
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'paymentmethod', $paymentmethod);
     $mform->setType('paymentmethod', PARAM_ALPHA);
     $firstlastnamestr = AN_METHOD_CC == $paymentmethod ? get_string('nameoncard', 'enrol_authorize') : get_string('echeckfirslasttname', 'enrol_authorize');
     $firstlastnamegrp = array();
     $firstlastnamegrp[] =& $mform->createElement('text', 'firstname', '', 'size="16"');
     $firstlastnamegrp[] =& $mform->createElement('text', 'lastname', '', 'size="16"');
     $mform->addGroup($firstlastnamegrp, 'firstlastgrp', $firstlastnamestr, '&nbsp;', false);
     $firstlastnamegrprules = array();
     $firstlastnamegrprules['firstname'][] = array(get_string('missingfirstname'), 'required', null, 'client');
     $firstlastnamegrprules['lastname'][] = array(get_string('missinglastname'), 'required', null, 'client');
     $mform->addGroupRule('firstlastgrp', $firstlastnamegrprules);
     $mform->setType('firstname', PARAM_ALPHANUM);
     $mform->setType('lastname', PARAM_ALPHANUM);
     $mform->setDefault('firstname', $USER->firstname);
     $mform->setDefault('lastname', $USER->lastname);
     if (AN_METHOD_CC == $paymentmethod) {
         $mform->addElement('passwordunmask', 'cc', get_string('ccno', 'enrol_authorize'), 'size="20"');
         $mform->setType('cc', PARAM_ALPHANUM);
         $mform->setDefault('cc', '');
         $mform->addRule('cc', get_string('missingcc', 'enrol_authorize'), 'required', null, 'client');
         $mform->addRule('cc', get_string('ccinvalid', 'enrol_authorize'), 'numeric', null, 'client');
         $monthsmenu = array('' => get_string('choose'));
         for ($i = 1; $i <= 12; $i++) {
             $monthsmenu[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B");
         }
         $nowdate = getdate();
         $startyear = $nowdate["year"] - 1;
         $endyear = $startyear + 20;
         $yearsmenu = array('' => get_string('choose'));
         for ($i = $startyear; $i < $endyear; $i++) {
             $yearsmenu[$i] = $i;
         }
         $ccexpiregrp = array();
         $ccexpiregrp[] =& $mform->createElement('select', 'ccexpiremm', '', $monthsmenu);
         $ccexpiregrp[] =& $mform->createElement('select', 'ccexpireyyyy', '', $yearsmenu);
         $mform->addGroup($ccexpiregrp, 'ccexpiregrp', get_string('ccexpire', 'enrol_authorize'), '&nbsp;', false);
         $ccexpiregrprules = array();
         $ccexpiregrprules['ccexpiremm'][] = array(get_string('missingccexpire', 'enrol_authorize'), 'required', null, 'client');
         $ccexpiregrprules['ccexpireyyyy'][] = array(get_string('missingccexpire', 'enrol_authorize'), 'required', null, 'client');
         $mform->addGroupRule('ccexpiregrp', $ccexpiregrprules);
         $mform->setType('ccexpiremm', PARAM_INT);
         $mform->setType('ccexpireyyyy', PARAM_INT);
         $mform->setDefault('ccexpiremm', '');
         $mform->setDefault('ccexpireyyyy', '');
         $creditcardsmenu = array('' => get_string('choose')) + get_list_of_creditcards();
         $mform->addElement('select', 'cctype', get_string('cctype', 'enrol_authorize'), $creditcardsmenu);
         $mform->setType('cctype', PARAM_ALPHA);
         $mform->addRule('cctype', get_string('missingcctype', 'enrol_authorize'), 'required', null, 'client');
         $mform->setDefault('cctype', '');
         $mform->addElement('text', 'cvv', get_string('ccvv', 'enrol_authorize'), 'size="4"');
         $mform->setHelpButton('cvv', array('cvv', get_string('ccvv', 'enrol_authorize'), 'enrol/authorize'), true);
         $mform->setType('cvv', PARAM_ALPHANUM);
         $mform->setDefault('cvv', '');
         $mform->addRule('cvv', get_string('missingcvv', 'enrol_authorize'), 'required', null, 'client');
         $mform->addRule('cvv', get_string('missingcvv', 'enrol_authorize'), 'numeric', null, 'client');
         if (!empty($CFG->an_authcode)) {
             $ccauthgrp = array();
             $ccauthgrp[] =& $mform->createElement('checkbox', 'haveauth', null, get_string('haveauthcode', 'enrol_authorize'));
             $ccauthgrp[] =& $mform->createElement('static', 'nextline', null, '<br />');
             $ccauthgrp[] =& $mform->createElement('text', 'ccauthcode', '', 'size="8"');
             $mform->addGroup($ccauthgrp, 'ccauthgrp', get_string('authcode', 'enrol_authorize'), '&nbsp;', false);
             $mform->setHelpButton('ccauthgrp', array('authcode', get_string('authcode', 'enrol_authorize'), 'enrol/authorize'), true);
             $ccauthgrprules = array();
             $ccauthgrprules['ccauthcode'][] = array(get_string('missingccauthcode', 'enrol_authorize'), 'numeric', null, 'client');
             $mform->addGroupRule('ccauthgrp', $ccauthgrprules);
             $mform->setDefault('haveauth', '');
             $mform->setDefault('ccauthcode', '');
         }
         if (!empty($CFG->an_avs)) {
             $mform->addElement('header', '', '&nbsp;&nbsp;' . get_string('address'), '');
             $mform->addElement('text', 'ccaddress', get_string('address'), 'size="30"');
             $mform->setType('ccaddress', PARAM_ALPHANUM);
             $mform->setDefault('ccaddress', $USER->address);
             $mform->addRule('ccaddress', get_string('missingaddress', 'enrol_authorize'), 'required', null, 'client');
             $citystategrp = array();
             $citystategrp[] =& $mform->createElement('text', 'cccity', '', 'size="14"');
             $citystategrp[] =& $mform->createElement('static', 'sep', null, ' - ');
             $citystategrp[] =& $mform->createElement('text', 'ccstate', '', 'size="8"');
             $mform->addGroup($citystategrp, 'citystategrp', get_string('city') . ' - ' . get_string('state'), '&nbsp;', false);
             $citystategrprules = array();
             $citystategrprules['cccity'][] = array(get_string('missingcity'), 'required', null, 'client');
             $mform->addGroupRule('citystategrp', $citystategrprules);
             $mform->setType('cccity', PARAM_ALPHANUM);
             $mform->setType('ccstate', PARAM_ALPHANUM);
             $mform->setDefault('cccity', $USER->city);
             $mform->setDefault('ccstate', '');
             $mform->addElement('select', 'cccountry', get_string('country'), get_list_of_countries());
             $mform->addRule('cccountry', get_string('missingcountry'), 'required', null, 'client');
             $mform->setType('cccountry', PARAM_ALPHA);
             $mform->setDefault('cccountry', $USER->country);
         } else {
             $mform->addElement('hidden', 'ccstate', '');
             $mform->addElement('hidden', 'ccaddress', $USER->address);
             $mform->addElement('hidden', 'cccity', $USER->city);
             $mform->addElement('hidden', 'cccountry', $USER->country);
         }
     } elseif (AN_METHOD_ECHECK == $paymentmethod) {
         $mform->addElement('text', 'abacode', get_string('echeckabacode', 'enrol_authorize'), 'size="9" maxlength="9"');
         $mform->setHelpButton('abacode', array('aba', get_string('echeckabacode', 'enrol_authorize'), 'enrol/authorize'), true);
         $mform->setType('abacode', PARAM_ALPHANUM);
         $mform->setDefault('abacode', '');
         $mform->addRule('abacode', get_string('missingaba', 'enrol_authorize'), 'required', null, 'client');
         $mform->addRule('abacode', get_string('missingaba', 'enrol_authorize'), 'numeric', null, 'client');
         $mform->addElement('text', 'accnum', get_string('echeckaccnum', 'enrol_authorize'), 'size="20" maxlength="20"');
         $mform->setType('accnum', PARAM_ALPHANUM);
         $mform->setDefault('accnum', '');
         $mform->addRule('accnum', get_string('invalidaccnum', 'enrol_authorize'), 'required', null, 'client');
         $mform->addRule('accnum', get_string('invalidaccnum', 'enrol_authorize'), 'numeric', null, 'client');
         $acctypes = array();
         $acctypesenabled = get_list_of_bank_account_types();
         foreach ($acctypesenabled as $key) {
             $acctypes[$key] = get_string("echeck" . strtolower($key), "enrol_authorize");
         }
         $acctypes = array('' => get_string('choose')) + $acctypes;
         $mform->addElement('select', 'acctype', get_string('echeckacctype', 'enrol_authorize'), $acctypes);
         $mform->setType('acctype', PARAM_ALPHA);
         $mform->addRule('acctype', get_string('invalidacctype', 'enrol_authorize'), 'required', null, 'client');
         $mform->setDefault('acctype', '');
         $mform->addElement('text', 'bankname', get_string('echeckbankname', 'enrol_authorize'), 'size="20" maxlength="50"');
         $mform->setType('bankname', PARAM_ALPHANUM);
         $mform->setDefault('bankname', '');
         $mform->addRule('bankname', get_string('missingbankname', 'enrol_authorize'), 'required', null, 'client');
     }
     $mform->addElement('text', 'cczip', get_string('zipcode', 'enrol_authorize'), 'size="5"');
     $mform->setType('cczip', PARAM_ALPHANUM);
     $mform->setDefault('cczip', '');
     $mform->addRule('cczip', get_string('missingzip', 'enrol_authorize'), 'required', null, 'client');
     $this->add_action_buttons(false, get_string('sendpaymentbutton', 'enrol_authorize'));
 }
 /**
  * Make Custom Filter Options
  *
  * This function handles filters that require custom values (languages, countries, etc).
  *
  * @param string $group  The index of the group to which the sub filter belongs to.
  * @param string $name   The name of the sub filter to process.
  * @param array  $help   An array representing the help icon for the filter
  * @return array The customized options for the selected sub-filter
  */
 function make_filter_options_custom($options, $group, $name)
 {
     switch ($name) {
         case 'fullname':
             $firstname = $this->tables[$group]['user'] . '.firstname';
             $lastname = $this->tables[$group]['user'] . '.lastname';
             $options['dbfield'] = sql_concat($firstname, "' '", $lastname);
             $options['talias'] = '';
             $this->fieldtofiltermap[$group][$options['dbfield']] = generalized_filter_userprofilematch::filtertypetext;
             break;
         case 'country':
             // TBD: new 'country' filter spec???
             $countries = get_list_of_countries();
             $options['choices'] = $countries;
             // TBD: foreach assoc.
             //$this->err_dump($countries, '$countries');
             break;
         case 'confirmed':
             // TBD: yesno filter???
             $options['choices'] = array('0' => 'No', 1 => 'Yes');
             $options['numeric'] = 1;
             //$this->err_dump($myoptions['choices'],'options for confir
             break;
         case 'crsrole':
             $roles = get_records('role', '', '', '', 'id,name');
             $options['choices'] = array();
             foreach ($roles as $role) {
                 $options['choices'][$role->id] = $role->name;
             }
             $options['numeric'] = 1;
             $options['talias'] = $this->tables[$group]['role_assignments'];
             $options['dbfield'] = 'roleid';
             break;
         case 'lang':
             $options['choices'] = get_list_of_languages(true);
             // TBD
             //$this->err_dump($myoptions['choices'], 'list_of_languages
             break;
         case 'crscat':
             break;
         case 'sysrole':
             break;
         case 'auth':
             $auths = get_list_of_plugins('auth');
             //$this->err_dump($auths, '$auths');
             $options['choices'] = array();
             foreach ($auths as $auth) {
                 $options['choices'][$auth] = $auth;
                 // TBD
             }
             break;
     }
     if (array_key_exists($name, $this->_choices)) {
         $options['choices'] = $this->_choices[$name];
     }
     if (array_key_exists($name, $this->_fieldids)) {
         $options['fieldid'] = $this->_fieldids[$name];
     }
     return $options;
 }
echo '<div class="felement ftext">' . $CFG->wwwroot . '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label>' . get_string("currentversion") . '</label></div>';
echo '<div class="felement ftext">' . "{$CFG->release} ({$CFG->version})" . '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="sitename">' . get_string("fullsitename") . '</label></div>';
echo '<div class="felement ftext">';
echo '<input size="50" id="sitename" type="text" name="sitename" value="' . format_string($site->fullname) . '" />';
echo '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="menucountry">' . get_string("country") . '</label></div>';
echo '<div class="felement ftext">';
choose_from_menu(get_list_of_countries(), "country", $admin->country, get_string("selectacountry") . "...", "", "");
echo '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="menupublic">' . "<a href=\"http://moodle.org/sites/?country={$admin->country}\" title=\"" . get_string("publicdirectorytitle") . "\">" . get_string("publicdirectory") . "</a>" . '</label></div>';
echo '<div class="felement ftext">';
$options[0] = get_string("publicdirectory0");
$options[1] = get_string("publicdirectory1");
$options[2] = get_string("publicdirectory2");
choose_from_menu($options, "public", "2", "", "", "");
unset($options);
echo '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="menucontact">' . get_string("registrationcontact") . '</label></div>';
echo '<div class="felement ftext">';
Exemple #21
0
echo '<div class="felement ftext">' . $CFG->wwwroot . '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label>' . get_string("currentversion") . '</label></div>';
echo '<div class="felement ftext">' . "{$CFG->release} ({$CFG->version})" . '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="sitename">' . get_string("fullsitename") . '</label></div>';
echo '<div class="felement ftext">';
echo '<input size="50" id="sitename" type="text" name="sitename" value="' . format_string($site->fullname) . '" />';
echo '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="menucountry">' . get_string("country") . '</label></div>';
echo '<div class="felement ftext">';
$select = html_select::make(get_list_of_countries(), "country", $admin->country, get_string("selectacountry") . "...");
$select->nothingvalue = '';
echo $OUTPUT->select($select);
echo '</div>';
echo '</div>';
echo '<div class="fitem">';
echo '<div class="fitemtitle"><label for="menupublic">' . "<a href=\"http://moodle.org/sites/?country={$admin->country}\" title=\"" . get_string("publicdirectorytitle") . "\">" . get_string("publicdirectory") . "</a>" . '</label></div>';
echo '<div class="felement ftext">';
$options[0] = get_string("publicdirectory0");
$options[1] = get_string("publicdirectory1");
$options[2] = get_string("publicdirectory2");
$select = html_select::make($options, "public", "2", false);
$select->nothingvalue = '';
echo $OUTPUT->select($select);
unset($options);
echo '</div>';
<?php

// $Id$
// "locations" settingpage
$temp = new admin_settingpage('locationsettings', get_string('locationsettings', 'admin'));
$options = get_list_of_timezones();
$options[99] = get_string('serverlocaltime');
$temp->add(new admin_setting_configselect('timezone', get_string('timezone', 'admin'), get_string('configtimezone', 'admin'), 99, $options));
$options[99] = get_string('timezonenotforced', 'admin');
$temp->add(new admin_setting_configselect('forcetimezone', get_string('forcetimezone', 'admin'), get_string('helpforcetimezone', 'admin'), 99, $options));
$options = get_list_of_countries();
$options[0] = get_string('choose') . '...';
$temp->add(new admin_setting_configselect('country', get_string('country', 'admin'), get_string('configcountry', 'admin'), 0, $options));
$iplookups = array();
if ($plugins = get_list_of_plugins('iplookup')) {
    foreach ($plugins as $plugin) {
        $iplookups[$plugin] = $plugin;
    }
}
$temp->add(new admin_setting_configselect('iplookup', get_string('iplookup', 'admin'), get_string('configiplookup', 'admin'), 'hostip', $iplookups));
$ADMIN->add('location', $temp);
$ADMIN->add('location', new admin_externalpage('timezoneimport', get_string('updatetimezones', 'admin'), "{$CFG->wwwroot}/{$CFG->admin}/timezoneimport.php"));
Exemple #23
0
 /**
  * Build form content
  */
 function buildForm()
 {
     $this->_formBuilt = true;
     // rectangle around elements
     $this->addElement('header', 'top_header', get_string('newuser.contactform', 'samouk'));
     $this->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
     $this->setType('email', PARAM_NOTAGS);
     $this->addRule('email', get_string('missingemail'), 'required', null, 'server');
     $nameordercheck = new object();
     $nameordercheck->firstname = 'a';
     $nameordercheck->lastname = 'b';
     if (fullname($nameordercheck) == 'b a') {
         // See MDL-4325
         $this->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
         $this->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
     } else {
         $this->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
         $this->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
     }
     $this->setType('firstname', PARAM_TEXT);
     $this->addRule('firstname', get_string('missingfirstname'), 'required', null, 'server');
     $this->setType('lastname', PARAM_TEXT);
     $this->addRule('lastname', get_string('missinglastname'), 'required', null, 'server');
     // add an address textbox
     $this->addElement('text', 'address', get_string('address'), 'maxlength="70" size="30"');
     $this->setType('address', PARAM_TEXT);
     // add a city textbox
     $this->addElement('text', 'city', get_string('city'), 'maxlength="20" size="30"');
     $this->setType('city', PARAM_TEXT);
     $this->addRule('city', get_string('missingcity'), 'required', null, 'server');
     $country = get_list_of_countries();
     $default_country[''] = get_string('selectacountry');
     $country = array_merge($default_country, $country);
     $this->addElement('select', 'country', get_string('country'), $country, 'width="130"');
     $this->addRule('country', get_string('missingcountry'), 'required', null, 'server');
     $this->setDefault('country', 'CZ');
     // show phone number input box
     $this->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="30"');
     $this->setType('phone1', PARAM_TEXT);
     // add custom profile elements
     profile_signup_fields($this);
     if (!empty($CFG->sitepolicy)) {
         $this->addElement('header', 'top_header', get_string('policyagreement'));
         $this->addElement('static', 'policylink', '', '<a href="' . $CFG->sitepolicy . '" onclick="this.target=\'_blank\'">' . get_String('policyagreementclick') . '</a>');
         $this->addElement('checkbox', 'policyagreed', get_string('policyaccept'));
         $this->addRule('policyagreed', get_string('policyagree'), 'required', null, 'server');
     }
     ShowStepPrediction($this, 2, 4);
     // add command buttons
     $buttons[0] =& HTML_QuickForm::createElement('submit', $this->getButtonName('back'), get_string('button.prev', 'samouk'));
     $buttons[1] =& HTML_QuickForm::createElement('button', 'cancel', get_string('cancel'), array('onclick' => "javascript:location.href='index.php';"));
     $buttons[2] =& HTML_QuickForm::createElement('submit', $this->getButtonName('next'), get_string('button.next', 'samouk'));
     $this->addGroup($buttons, 'buttons', '', '&nbsp;', false);
     $this->setDefaultAction('next');
 }