| Línea 43... |
Línea 43... |
| 43 |
*/
|
43 |
*/
|
| 44 |
public function execute() {
|
44 |
public function execute() {
|
| 45 |
global $DB;
|
45 |
global $DB;
|
| Línea 46... |
Línea 46... |
| 46 |
|
46 |
|
| - |
|
47 |
// Generate new password emails for users - ppl expect these generated asap.
|
| - |
|
48 |
if (
|
| - |
|
49 |
$DB->record_exists_select(
|
| 47 |
// Generate new password emails for users - ppl expect these generated asap.
|
50 |
'user_preferences',
|
| - |
|
51 |
'name = ? AND ' . $DB->sql_compare_text('value', 2) . ' = ?',
|
| - |
|
52 |
['create_password', '1']
|
| - |
|
53 |
)
|
| 48 |
if ($DB->count_records('user_preferences', array('name' => 'create_password', 'value' => '1'))) {
|
54 |
) {
|
| 49 |
mtrace('Creating passwords for new users...');
|
55 |
mtrace('Creating passwords for new users...');
|
| 50 |
$userfieldsapi = \core_user\fields::for_name();
|
56 |
$userfieldsapi = \core_user\fields::for_name();
|
| - |
|
57 |
$usernamefields = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
|
| 51 |
$usernamefields = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
|
58 |
[$sort, $sortparams] = users_order_by_sql('u');
|
| 52 |
$newusers = $DB->get_recordset_sql("SELECT u.id as id, u.email, u.auth, u.deleted,
|
59 |
$newusers = $DB->get_recordset_sql("SELECT u.id as id, u.email, u.auth, u.deleted,
|
| 53 |
u.suspended, u.emailstop, u.mnethostid, u.mailformat,
|
60 |
u.suspended, u.emailstop, u.mnethostid, u.mailformat,
|
| 54 |
$usernamefields, u.username, u.lang,
|
61 |
$usernamefields, u.username, u.lang,
|
| 55 |
p.id as prefid
|
62 |
p.id as prefid
|
| 56 |
FROM {user} u
|
63 |
FROM {user} u
|
| 57 |
JOIN {user_preferences} p ON u.id=p.userid
|
64 |
JOIN {user_preferences} p ON u.id = p.userid
|
| - |
|
65 |
WHERE p.name = 'create_password'
|
| - |
|
66 |
AND " . $DB->sql_compare_text('p.value', 2) . " = '1'
|
| 58 |
WHERE p.name='create_password' AND p.value='1' AND
|
67 |
AND u.email <> ''
|
| 59 |
u.email !='' AND u.suspended = 0 AND
|
68 |
AND u.suspended = 0
|
| - |
|
69 |
AND u.auth <> 'nologin'
|
| - |
|
70 |
AND u.deleted = 0
|
| Línea 60... |
Línea 71... |
| 60 |
u.auth != 'nologin' AND u.deleted = 0");
|
71 |
ORDER BY $sort ASC", $sortparams);
|
| 61 |
|
72 |
|
| 62 |
// Note: we can not send emails to suspended accounts.
|
73 |
// Note: we can not send emails to suspended accounts.
|
| 63 |
foreach ($newusers as $newuser) {
|
74 |
foreach ($newusers as $newuser) {
|