Permalink
Browse files

MDL-25778 add defaultcity option

This is based on patch by Jonathan Harker.
  • Loading branch information...
1 parent d911c72 commit fa7f750c60db0a65ad69d6fd5caaccd0ce057cb8 @skodak skodak committed Feb 14, 2011
Showing with 25 additions and 1 deletion.
  1. +1 −0 admin/settings/location.php
  2. +4 −0 admin/uploaduser.php
  3. +4 −0 auth/db/auth.php
  4. +8 −0 auth/ldap/auth.php
  5. +2 −0 lang/en/admin.php
  6. +3 −0 login/signup_form.php
  7. +3 −1 user/editlib.php
@@ -10,6 +10,7 @@
$options[99] = get_string('timezonenotforced', 'admin');
$temp->add(new admin_setting_configselect('forcetimezone', get_string('forcetimezone', 'admin'), get_string('helpforcetimezone', 'admin'), 99, $options));
$temp->add(new admin_settings_country_select('country', get_string('country', 'admin'), get_string('configcountry', 'admin'), 0));
+ $temp->add(new admin_setting_configtext('defaultcity', get_string('defaultcity', 'admin'), get_string('defaultcity_help', 'admin'), ''));
$temp->add(new admin_setting_heading('iplookup', get_string('iplookup', 'admin'), get_string('iplookupinfo', 'admin')));
$temp->add(new admin_setting_configfile('geoipfile', get_string('geoipfile', 'admin'), get_string('configgeoipfile', 'admin', $CFG->dataroot.'/geoip/'), $CFG->dataroot.'/geoip/GeoLiteCity.dat'));
View
@@ -572,6 +572,10 @@
$user->timemodified = time();
$user->timecreated = time();
+ if (!empty($CFG->defaultcity) and !property_exists($user, 'city')) {
+ $user->city = $CFG->defaultcity;
+ }
+
if (isset($user->auth) && empty($user->auth)) {
$user->auth = 'manual';
}
View
@@ -358,6 +358,10 @@ function sync_users($do_updates=false) {
echo "\t"; print_string('auth_dbreviveduser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id)); echo "\n";
} else {
+ if (!empty($CFG->defaultcity) and !property_exists($user, 'city')) {
+ $user->city = $CFG->defaultcity;
+ }
+
$id = $DB->insert_record ('user',$user); // it is truly a new user
echo "\t"; print_string('auth_dbinsertuser','auth_db',array('name'=>$user->username, 'id'=>$id)); echo "\n";
// if relevant, tag for password generation
View
@@ -490,6 +490,10 @@ function user_signup($user, $notify=true) {
print_error('auth_ldap_create_error', 'auth_ldap');
}
+ if (!empty($CFG->defaultcity) and !property_exists($user, 'city')) {
+ $user->city = $CFG->defaultcity;
+ }
+
$user->id = $DB->insert_record('user', $user);
// Save any custom profile field information
@@ -849,6 +853,10 @@ function sync_users($do_updates=true) {
$user->lang = $CFG->lang;
}
+ if (!empty($CFG->defaultcity) and !property_exists($user, 'city')) {
+ $user->city = $CFG->defaultcity;
+ }
+
$id = $DB->insert_record('user', $user);
echo "\t"; print_string('auth_dbinsertuser', 'auth_db', array('name'=>$user->username, 'id'=>$id)); echo "\n";
if (!empty($this->config->forcechangepassword)) {
View
@@ -429,6 +429,8 @@
$string['debugstringids'] = 'Show origin of languages strings';
$string['debugvalidators'] = 'Show validator links';
$string['defaultallowedmodules'] = 'Default allowed modules';
+$string['defaultcity'] = 'Default city';
+$string['defaultcity_help'] = 'A city entered here will be the default city when creating new user accounts.';
$string['defaulthomepage'] = 'Default home page for users';
$string['defaultrequestcategory'] = 'Default category for course requests';
$string['defaultsettinginfo'] = 'Default: {$a}';
View
@@ -79,6 +79,9 @@ function definition() {
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="20"');
$mform->setType('city', PARAM_TEXT);
$mform->addRule('city', get_string('missingcity'), 'required', null, 'server');
+ if (!empty($CFG->defaultcity)) {
+ $mform->setDefault('city', $CFG->defaultcity);
+ }
$country = get_string_manager()->get_list_of_countries();
$default_country[''] = get_string('selectacountry');
View
@@ -194,7 +194,9 @@ function useredit_shared_definition(&$mform, $editoroptions = null) {
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
$mform->setType('city', PARAM_MULTILANG);
$mform->addRule('city', $strrequired, 'required', null, 'client');
-
+ if (!empty($CFG->defaultcity)) {
+ $mform->setDefault('city', $CFG->defaultcity);
+ }
$choices = get_string_manager()->get_list_of_countries();
$choices= array(''=>get_string('selectacountry').'...') + $choices;

0 comments on commit fa7f750

Please sign in to comment.