- Logger::log("public_server: cron start");
-
- $r = q("SELECT * FROM `user` WHERE `account_expires_on` < UTC_TIMESTAMP() + INTERVAL 5 DAY AND
- `account_expires_on` > '%s' AND
- `expire_notification_sent` <= '%s'",
- DBA::NULL_DATETIME, DBA::NULL_DATETIME);
-
- if (DBA::isResult($r)) {
- foreach ($r as $rr) {
- notification([
- 'type' => Notification/Type::SYSTEM,
- 'uid' => $rr['uid'],
- 'system_type' => 'public_server_expire',
- 'source_name' => DI::l10n()->t('Administrator'),
- 'source_link' => DI::baseUrl()->get(),
- 'source_photo' => DI::baseUrl()->get() . '/images/person-80.jpg',
- ]);
-
- $fields = ['expire_notification_sent' => DateTimeFormat::utcNow()];
- DBA::update('user', $fields, ['uid' => $rr['uid']]);
- }
+ Logger::notice("public_server: cron start");
+
+ $users = DBA::selectToArray('user', [], ["`account_expires_on` > ? AND `account_expires_on` < ?
+ AND `expire_notification_sent` <= ?", DBA::NULL_DATETIME, DateTimeFormat::utc('now + 5 days'), DBA::NULL_DATETIME]);
+ foreach ($users as $rr) {
+ DI::notify()->createFromArray([
+ 'type' => Notification\Type::SYSTEM,
+ 'event' => 'SYSTEM_PUBLIC_SERVER_EXPIRATION',
+ 'uid' => $rr['uid'],
+ 'system_type' => 'public_server_expire',
+ 'source_name' => DI::l10n()->t('Administrator'),
+ 'source_link' => DI::baseUrl(),
+ 'source_photo' => DI::baseUrl() . '/images/person-80.jpg',
+ ]);
+
+ $fields = ['expire_notification_sent' => DateTimeFormat::utcNow()];
+ DBA::update('user', $fields, ['uid' => $rr['uid']]);