Skip to content

Commit

Permalink
Merge branch 'w07_MDL-25778_20_defaultcity' of git://github.com/skoda…
Browse files Browse the repository at this point in the history
…k/moodle
  • Loading branch information
stronk7 committed Feb 14, 2011
2 parents 2453531 + fa7f750 commit 2623f6b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions admin/settings/location.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
4 changes: 4 additions & 0 deletions admin/uploaduser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
4 changes: 4 additions & 0 deletions auth/db/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions auth/ldap/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 2 additions & 0 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}';
Expand Down
3 changes: 3 additions & 0 deletions login/signup_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion user/editlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2623f6b

Please sign in to comment.