Skip to content

Commit

Permalink
Merge branch 'w12_MDL-26803_20_userupload' of git://github.com/skodak…
Browse files Browse the repository at this point in the history
…/moodle
  • Loading branch information
Sam Hemelryk committed Mar 21, 2011
2 parents b89d39b + 22a7796 commit 37fff87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion admin/uploaduser_form.php
Expand Up @@ -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);

Expand Down
9 changes: 5 additions & 4 deletions lib/cronlib.php
Expand Up @@ -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)) {
Expand Down

0 comments on commit 37fff87

Please sign in to comment.