Пример #1
0
             $temp_user = fullclone($user);
             $temp_user->email = $usernew->preference_newemail;
             $temp_user->emailstop = NULL;
             $a = new stdClass();
             $a->url = $CFG->wwwroot . '/user/emailupdate.php?key=' . $usernew->preference_newemailkey . '&id=' . $user->id;
             $a->site = $SITE->fullname;
             $a->fullname = fullname($user, true);
             $emailupdatemessage = get_string('auth_emailupdatemessage', 'auth', $a);
             $emailupdatetitle = get_string('auth_emailupdatetitle', 'auth', $a);
             if (!($mail_results = email_to_user($temp_user, get_admin(), $emailupdatetitle, $emailupdatemessage))) {
                 die("could not send email!");
             }
         }
     } else {
         // End If - calendar.php
         modifyQSUser($olduserinfo);
         admin_webservicefailed_email($olduserinfo, 'modifyUser');
         error('Error updating user record (VL)');
     }
 } else {
     error('Error updating user record (QS)');
 }
 // reload from db
 $usernew = get_record('user', 'id', $user->id);
 events_trigger('user_updated', $usernew);
 setWSUserDefaultTimeZone($USER->username, $usernew);
 //Added: 01.03.2011 - calendar.php
 if ($USER->id == $user->id) {
     // Override old $USER session variable if needed
     foreach ((array) $usernew as $variable => $value) {
         $USER->{$variable} = $value;
    }
} else {
    redirect($CFG->wwwroot . '/index.php');
}
// get values from form for actions on this page
$param = new stdClass();
// Parameters: create a URL that displays the last (largest) quiz id and name. (eg. 2 Test Exam)
$records = get_records('user');
// returns more users.
$users = get_users_listing("username");
$counter = 0;
$errors = 0;
$errmessage = "";
foreach ($users as $user) {
    if ($user->username != 'admin') {
        //echo $user->username."<br/>";
        try {
            editUserProfile($USER->username, $user);
            modifyQSUser($user);
            enrollUsersAvailCourses($USER->username, $user->username);
            $counter++;
        } catch (Exception $e) {
            $errors++;
            $errmessage .= $u->username . "<br/>";
        }
    }
}
echo $counter . " user(s) accounts has been updated.<br/>";
if ($errors > 0) {
    echo "<br/><b>" . $errors . " errors have occured for the following accounts:<br/></b>" . $errmessage;
}