ILIAS  release_8 Revision v8.24
class.ilUserCronCheckAccounts.php
Go to the documentation of this file.
1<?php
2
24{
25 protected int $counter = 0;
26
27 public function getId(): string
28 {
29 return "user_check_accounts";
30 }
31
32 public function getTitle(): string
33 {
34 global $DIC;
35
36 $lng = $DIC['lng'];
37
38 return $lng->txt("check_user_accounts");
39 }
40
41 public function getDescription(): string
42 {
43 global $DIC;
44
45 $lng = $DIC['lng'];
46
47 return $lng->txt("check_user_accounts_desc");
48 }
49
50 public function getDefaultScheduleType(): int
51 {
53 }
54
55 public function getDefaultScheduleValue(): ?int
56 {
57 return null;
58 }
59
60 public function hasAutoActivation(): bool
61 {
62 return false;
63 }
64
65 public function hasFlexibleSchedule(): bool
66 {
67 return false;
68 }
69
70 public function run(): ilCronJobResult
71 {
73 global $DIC;
74
75 $ilDB = $DIC['ilDB'];
76 $ilLog = $DIC['ilLog'];
77
79
80 $now = time();
81 $two_weeks_in_seconds = $now + (60 * 60 * 24 * 14); // #14630
82
83 // all users who are currently active and expire in the next 2 weeks
84 $query = "SELECT usr_id, login, time_limit_until " .
85 "FROM usr_data " .
86 "WHERE time_limit_message = '0' " .
87 "AND time_limit_unlimited = '0' " .
88 "AND time_limit_from < " . $ilDB->quote($now, "integer") . " " .
89 "AND time_limit_until > " . $ilDB->quote($now, "integer") . " " .
90 "AND time_limit_until < " . $ilDB->quote($two_weeks_in_seconds, "integer");
91
92 $res = $ilDB->query($query);
93
95 $senderFactory = $GLOBALS['DIC']["mail.mime.sender.factory"];
96 $sender = $senderFactory->system();
97
98 while ($row = $ilDB->fetchObject($res)) {
99 $expires = $row->time_limit_until;
100 $login = $row->login;
101 $usr_id = $row->usr_id;
102
104 $lng->loadLanguageModule('mail');
105
106 $salutation = ilMail::getSalutation($usr_id, $lng);
107
108 $body = $salutation . "\n\n";
109 $body .= sprintf(
110 $lng->txt('account_expires_body'),
111 $login,
112 ILIAS_HTTP_PATH,
113 strftime('%Y-%m-%d %R', $expires)
114 );
115
117
118 // force email
119 $mail = new ilMail(ANONYMOUS_USER_ID);
120 $mail->enqueue(
122 "",
123 "",
124 $lng->txt('account_expires_subject'),
125 $body,
126 []
127 );
128
129 // set status 'mail sent'
130 $query = "UPDATE usr_data SET time_limit_message = '1' WHERE usr_id = '" . $usr_id . "'";
131 $ilDB->query($query);
132
133 // Send log message
134 $ilLog->write('Cron: (checkUserAccounts()) sent message to ' . $login . '.');
135
136 $this->counter++;
137 }
138
140
141 if ($this->counter) {
143 }
144 $result = new ilCronJobResult();
145 $result->setStatus($status);
146 return $result;
147 }
148
149 // #13288 / #12345
150 protected function txt(
151 string $language,
152 string $key,
153 string $module = 'common'
154 ): string {
155 return ilLanguage::_lookupEntry($language, $module, $key);
156 }
157
158 protected function checkNotConfirmedUserAccounts(): void
159 {
160 global $DIC;
161
162 $ilDB = $DIC['ilDB'];
163 $ilLog = $DIC['ilLog'];
164
165 $oRegSettigs = new ilRegistrationSettings();
166
167 $query = 'SELECT usr_id FROM usr_data '
168 . 'WHERE (reg_hash IS NOT NULL AND reg_hash != %s)'
169 . 'AND active = %s '
170 . 'AND create_date < %s';
171 $res = $ilDB->queryF(
172 $query,
173 array('text', 'integer', 'timestamp'),
174 array('', 0, date('Y-m-d H:i:s', time() - $oRegSettigs->getRegistrationHashLifetime()))
175 );
176 while ($row = $ilDB->fetchAssoc($res)) {
177 $oUser = ilObjectFactory::getInstanceByObjId((int) $row['usr_id']);
178 $oUser->delete();
179 $ilLog->write('Cron: Deleted ' . $oUser->getLogin() . ' [' . $oUser->getId() . '] ' . __METHOD__);
180
181 $this->counter++;
182 }
183 }
184}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
const SCHEDULE_TYPE_DAILY
@depracated This will be replaced with an ENUM in ILIAS 9
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
language handling
static _getAutoGeneratedMessageString(ilLanguage $lang=null)
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
static _lookupEmail(int $a_user_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjAuthSettingsGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
hasAutoActivation()
Is to be activated on "installation", does only work for ILIAS core cron jobs.
txt(string $language, string $key, string $module='common')
const ANONYMOUS_USER_ID
Definition: constants.php:27
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69
string $key
Consumer key/client ID value.
Definition: System.php:193
$query
$lng