19declare(strict_types=1);
42 if (isset(
$DIC[
'ilDB'])) {
43 $this->db =
$DIC[
'ilDB'];
46 if (isset(
$DIC[
'lng'])) {
47 $this->
lng = $DIC[
'lng'];
50 if (isset(
$DIC[
'ilDB'])) {
51 $this->log =
$DIC[
'ilLog'];
57 return 'user_check_accounts';
62 return $this->
lng->txt(
'check_user_accounts');
67 return $this->
lng->txt(
'check_user_accounts_desc');
72 return JobScheduleType::DAILY;
92 $status = JobResult::STATUS_NO_ACTION;
95 $two_weeks_in_seconds = $now + (60 * 60 * 24 * 14);
98 $query =
'SELECT usr_id, login, time_limit_until ' .
100 'WHERE expiration_reminder_sent = 0 ' .
101 'AND time_limit_unlimited = 0 ' .
102 'AND time_limit_from < ' . $this->db->quote($now,
'integer') .
' ' .
103 'AND time_limit_until > ' . $this->db->quote($now,
'integer') .
' ' .
104 'AND time_limit_until < ' . $this->db->quote($two_weeks_in_seconds,
'integer');
106 $res = $this->db->query($query);
108 while ($row = $this->db->fetchObject(
$res)) {
109 $expires = $row->time_limit_until;
110 $login = $row->login;
111 $usr_id = $row->usr_id;
118 $body = $salutation .
"\n\n";
120 $lng->
txt(
'account_expires_body'),
123 date(
'Y-m-d H:i', $expires)
134 $lng->
txt(
'account_expires_subject'),
140 $query =
'UPDATE usr_data SET expiration_reminder_sent = 1' . PHP_EOL
141 .
"WHERE usr_id = {$this->db->quote($usr_id, ilDBConstants::T_INTEGER)}";
142 $this->db->query($query);
145 $this->log->write(
'Cron: (checkUserAccounts()) sent message to ' . $login .
'.');
150 if ($this->counter) {
151 $status = JobResult::STATUS_OK;
154 $result->setStatus($status);
Component logger with individual log levels by component id.
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
static _getAutoGeneratedMessageString(?ilLanguage $lang=null)
static _lookupEmail(int $a_user_id)
This cron send notifications about expiring user accounts.
hasAutoActivation()
Is to be activated on "installation", does only work for ILIAS core cron jobs.
getDefaultScheduleValue()
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc