Skip to content

Commit

Permalink
MDL-25778 fix default country and city on user upload form and revert…
Browse files Browse the repository at this point in the history
… change in auth plugins

Auth plugins should have separate defaults from site defaults).
  • Loading branch information
skodak committed Feb 15, 2011
1 parent fa7f750 commit 9449d0c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
4 changes: 0 additions & 4 deletions admin/uploaduser.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,6 @@
$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
12 changes: 10 additions & 2 deletions admin/uploaduser_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,18 @@ function definition (){

$mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
$mform->setType('city', PARAM_MULTILANG);
$mform->setDefault('city', $templateuser->city);
if (empty($CFG->defaultcity)) {
$mform->setDefault('city', $templateuser->city);
} else {
$mform->setDefault('city', $CFG->defaultcity);
}

$mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
$mform->setDefault('country', $templateuser->country);
if (empty($CFG->country)) {
$mform->setDefault('country', $templateuser->country);
} else {
$mform->setDefault('country', $CFG->country);
}
$mform->setAdvanced('country');

$choices = get_list_of_timezones();
Expand Down
4 changes: 0 additions & 4 deletions auth/db/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,6 @@ 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: 0 additions & 8 deletions auth/ldap/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,6 @@ 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 @@ -853,10 +849,6 @@ 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

0 comments on commit 9449d0c

Please sign in to comment.