Permalink
Browse files

Merge branch 'w12_MDL-26803_20_userupload' of git://github.com/skodak…

…/moodle
  • Loading branch information...
2 parents b89d39b + 22a7796 commit 37fff873983974bf0227d815b136b5d35a122c7e Sam Hemelryk committed Mar 21, 2011
Showing with 6 additions and 5 deletions.
  1. +1 −1 admin/uploaduser_form.php
  2. +5 −4 lib/cronlib.php
@@ -231,7 +231,7 @@ function definition () {
$mform->setDefault('maildigest', 0);
$mform->setAdvanced('maildigest');
- $choices = array(0 => get_string('autosubscribeyes'), 1 => get_string('autosubscribeno'));
+ $choices = array(1 => get_string('autosubscribeyes'), 0 => get_string('autosubscribeno'));
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', 1);
View
@@ -287,22 +287,23 @@ function cron_run() {
mtrace('checking for create_password');
if ($DB->count_records('user_preferences', array('name'=>'create_password', 'value'=>'1'))) {
mtrace('creating passwords for new users');
- $newusers = $DB->get_records_sql("SELECT u.id as id, u.email, u.firstname,
+ $newusers = $DB->get_recordset_sql("SELECT u.id as id, u.email, u.firstname,
u.lastname, u.username,
p.id as prefid
FROM {user} u
JOIN {user_preferences} p ON u.id=p.userid
WHERE p.name='create_password' AND p.value='1' AND u.email !='' ");
- foreach ($newusers as $newuserid => $newuser) {
+ foreach ($newusers as $newuser) {
// email user
if (setnew_password_and_mail($newuser)) {
- // remove user pref
- $DB->delete_records('user_preferences', array('id'=>$newuser->prefid));
+ unset_user_preference('create_password', $newuser);
+ set_user_preference('auth_forcepasswordchange', 1, $newuser);
} else {
trigger_error("Could not create and mail new user password!");
}
}
+ $newusers->close();
}
if (!empty($CFG->usetags)) {

0 comments on commit 37fff87

Please sign in to comment.