本文整理汇总了PHP中get_list_of_countries函数的典型用法代码示例。如果您正苦于以下问题:PHP get_list_of_countries函数的具体用法?PHP get_list_of_countries怎么用?PHP get_list_of_countries使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_list_of_countries函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
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'));
}
示例2: definition
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');
}
示例3: definition
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'));
}
示例4: openid_resp_to_user
/**
* 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
//.........这里部分代码省略.........
示例5: useredit_shared_definition
//.........这里部分代码省略.........
$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);
示例6: definition
/**
* 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);
}
示例7: unset
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 {
示例8: redirect
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);
示例9: definition
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();
}
示例10: _create_account
/**
* 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;
}
示例11: cm_get_list_of_countries
/**
* 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;
}
示例12: definition
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'));
}
示例13: get_field
/**
* 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;
}
}
示例14: print_user
/**
* 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 .= ' (' . 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 . '&user=' . $user->id . '">' . 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 . '&user=' . $user->id . '">' . $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
//.........这里部分代码省略.........
示例15: definition
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'));
}