ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilTimingsCronReminder Class Reference
+ Inheritance diagram for ilTimingsCronReminder:
+ Collaboration diagram for ilTimingsCronReminder:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 hasCustomSettings ()
 
 run ()
 
- Public Member Functions inherited from ILIAS\Cron\CronJob
 setDateTimeProvider (?\Closure $date_time_provider)
 
 isDue (?\DateTimeImmutable $last_run, ?JobScheduleType $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?JobScheduleType $a_type, ?int $a_value)
 Update current schedule (if flexible) More...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 usesLegacyForms ()
 
 getCustomConfigurationInput (\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, \ilLanguage $lng)
 
 addCustomSettingsToForm (\ilPropertyFormGUI $a_form)
 
 saveCustomConfiguration (mixed $form_data)
 
 saveCustomSettings (\ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (\ilDBInterface $db, \ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Protected Member Functions

 gatherUsers ()
 Read all active users. More...
 
 gatherUsersWithExceededTimings ()
 
 getNewExceededObjectForUser ()
 
 getFreshlyStartedObjectsForUser ()
 
 buildExceededMails (array $users_with_exceeded_objects)
 
 buildFreshlyStartedMails (array $users_with_freshly_started_objects)
 
 buildTopMailBody (int $user_id, string $language_variable)
 
 fillObjectListForMailBody (array $objects, ilTemplate $tpl)
 
 getUserLanguage (int $user_id)
 
 buildMailSalutation (int $user_id, ilTemplate $tpl)
 
 sendExceededMail (int $user_id, array $ref_ids, string $mail_body)
 
 sendFreshlyStartedMail (int $user_id, array $ref_ids, string $mail_body)
 
 markExceededInDatabase (int $user_id, array $ref_ids)
 
 markFreshlyStartedInDatabase (int $user_id, array $ref_ids)
 
 getAlreadySentNotifications (int $user_id, bool $for_exceeded=true)
 
 getInformationForRefId (int $ref_id)
 
 getExceededObjectsForUser (int $user_id)
 
 getObjectsWithTimingsForUser (int $user_id)
 
 hasUserActivatedNotification (int $user_id)
 

Protected Attributes

ilLogger $log
 
ilLanguage $lng
 
ilLanguage $user_lang
 
ilDBInterface $db
 
ilObjectDataCache $obj_data_cache
 
- Protected Attributes inherited from ILIAS\Cron\CronJob
JobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Private Attributes

array $users_with_exceeded_timings
 
array $users
 
int $now
 

Static Private Attributes

static array $objects_information
 

Detailed Description

Definition at line 25 of file class.ilTimingsCronReminder.php.

Constructor & Destructor Documentation

◆ __construct()

ilTimingsCronReminder::__construct ( )

Constructor.

Definition at line 42 of file class.ilTimingsCronReminder.php.

43 {
44 global $DIC;
45
46 $this->log = $DIC->logger()->crs();
47 $this->lng = $DIC->language();
48 $this->lng->loadLanguageModule('crs');
49 $this->db = $DIC->database();
50 $this->obj_data_cache = $DIC['ilObjDataCache'];
51
52 self::$objects_information = [];
53 $this->users_with_exceeded_timings = [];
54 $this->users = [];
55 $this->now = time();
56 }
global $DIC
Definition: shib_login.php:26

References $DIC, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildExceededMails()

ilTimingsCronReminder::buildExceededMails ( array  $users_with_exceeded_objects)
protected

Definition at line 201 of file class.ilTimingsCronReminder.php.

201 : void
202 {
203 $this->log->debug('Start.');
204 if (is_array($users_with_exceeded_objects)) {
205 $this->log->debug('...found ' . count($users_with_exceeded_objects));
206 foreach ($users_with_exceeded_objects as $user_id => $exceeded_objects) {
207 $tpl = $this->buildTopMailBody($user_id, 'timings_cron_reminder_exceeded_start');
208 $has_exceeded = $this->fillObjectListForMailBody($exceeded_objects, $tpl);
209
210 if ($has_exceeded) {
211 $this->sendExceededMail($user_id, $exceeded_objects, $tpl->get());
212 $this->log->debug('start sending exceeded mail to user: ' . $user_id);
213 }
214 }
215 } else {
216 $this->log->warning('no array given.');
217 }
218
219 $this->log->debug('end.');
220 }
buildTopMailBody(int $user_id, string $language_variable)
sendExceededMail(int $user_id, array $ref_ids, string $mail_body)
fillObjectListForMailBody(array $objects, ilTemplate $tpl)

References $user_id, buildTopMailBody(), fillObjectListForMailBody(), and sendExceededMail().

Referenced by getNewExceededObjectForUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFreshlyStartedMails()

ilTimingsCronReminder::buildFreshlyStartedMails ( array  $users_with_freshly_started_objects)
protected

Definition at line 222 of file class.ilTimingsCronReminder.php.

222 : void
223 {
224 $this->log->debug('start.');
225 if (is_array($users_with_freshly_started_objects)) {
226 $this->log->debug('...found ' . count($users_with_freshly_started_objects));
227 foreach ($users_with_freshly_started_objects as $user_id => $freshly_started_objects) {
228 $tpl = $this->buildTopMailBody($user_id, 'timings_cron_reminder_freshly_start');
229 $has_freshly_started = $this->fillObjectListForMailBody($freshly_started_objects, $tpl);
230
231 if ($has_freshly_started) {
232 $this->sendFreshlyStartedMail($user_id, $freshly_started_objects, $tpl->get());
233 }
234 }
235 } else {
236 $this->log->debug('no array given.');
237 }
238
239 $this->log->debug('end.');
240 }
sendFreshlyStartedMail(int $user_id, array $ref_ids, string $mail_body)

References $user_id, buildTopMailBody(), fillObjectListForMailBody(), and sendFreshlyStartedMail().

Referenced by getFreshlyStartedObjectsForUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildMailSalutation()

ilTimingsCronReminder::buildMailSalutation ( int  $user_id,
ilTemplate  $tpl 
)
protected

Definition at line 280 of file class.ilTimingsCronReminder.php.

280 : void
281 {
283 if (is_array($name)) {
284 $salutation = $this->user_lang->txt('mail_salutation_n') . ' ';
285 if (($name['gender'] ?? "") != '') {
286 $salutation .= $this->user_lang->txt('salutation_' . $name['gender']) . ' ';
287 }
288 if ($name['title'] != '') {
289 $salutation .= $name['title'] . ' ';
290 }
291 $tpl->setVariable('SALUTATION', $salutation);
292 $tpl->setVariable('FIRSTNAME', $name['firstname']);
293 $tpl->setVariable('LASTNAME', $name['lastname']);
294 $this->log->debug('Salutation: ' . $salutation . ' Firstname: ' . $name['firstname'] . ' Lastname: ' . $name['lastname']);
295 } else {
296 $this->log->debug('did not get an array from _lookupName.');
297 }
298 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
static _lookupName(int $a_user_id)

References $user_id, ilObjUser\_lookupName(), and HTML_Template_IT\setVariable().

Referenced by buildTopMailBody().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTopMailBody()

ilTimingsCronReminder::buildTopMailBody ( int  $user_id,
string  $language_variable 
)
protected

Definition at line 242 of file class.ilTimingsCronReminder.php.

242 : ilTemplate
243 {
244 $this->log->debug('start...');
245 $tpl = new ilTemplate('tpl.crs_timings_cron_reminder_mail.html', true, true, 'components/ILIAS/Course');
246
248 $this->buildMailSalutation($user_id, $tpl);
249 $tpl->setVariable('START_BODY', $this->user_lang->txt($language_variable));
250 $this->log->debug('for user: ' . $user_id . ' end.');
251 return $tpl;
252 }
special template class to simplify handling of ITX/PEAR
buildMailSalutation(int $user_id, ilTemplate $tpl)

References $user_id, buildMailSalutation(), and getUserLanguage().

Referenced by buildExceededMails(), and buildFreshlyStartedMails().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillObjectListForMailBody()

ilTimingsCronReminder::fillObjectListForMailBody ( array  $objects,
ilTemplate  $tpl 
)
protected

Definition at line 254 of file class.ilTimingsCronReminder.php.

254 : bool
255 {
256 $has_elements = false;
257 foreach ($objects as $object_id => $object_details) {
258 if ($object_details['type'] != 'fold') {
259 $tpl->setCurrentBlock('items');
260 $tpl->setVariable('HREF', $object_details['url']);
261 $tpl->setVariable('ITEM_TITLE', $object_details['title']);
262 $tpl->parseCurrentBlock();
263 $has_elements = true;
264 }
265 }
266 $tpl->setVariable('INSTALLATION_SIGNATURE', \ilMail::_getInstallationSignature());
267 $this->log->debug('found elements: ' . $has_elements);
268 return $has_elements;
269 }
static _getInstallationSignature()
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

References ilMail\_getInstallationSignature(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

Referenced by buildExceededMails(), and buildFreshlyStartedMails().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gatherUsers()

ilTimingsCronReminder::gatherUsers ( )
protected

Read all active users.

Definition at line 119 of file class.ilTimingsCronReminder.php.

119 : void
120 {
121 $now = time();
122 $query = $this->db->queryF(
123 'SELECT usr_id FROM usr_data WHERE
124 (active = 1 AND time_limit_unlimited = 1) OR
125 (active = 1 AND time_limit_unlimited = 0 AND time_limit_from < %s AND time_limit_until > %s)',
126 ['integer', 'integer'],
127 [$now, $now]
128 );
129 while ($row = $this->db->fetchAssoc($query)) {
130 $usr_id = (int) $row['usr_id'];
131 $this->users[$usr_id] = $usr_id;
132 }
133 $this->log->debug('Found ' . count($this->users) . ' users.');
134 }

References $now, and ILIAS\Repository\int().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gatherUsersWithExceededTimings()

ilTimingsCronReminder::gatherUsersWithExceededTimings ( )
protected

Definition at line 136 of file class.ilTimingsCronReminder.php.

136 : void
137 {
138 $this->users_with_exceeded_timings = ilTimingsUser::lookupTimingsExceededByUser($this->users);
139 $this->log->debug('Found ' . count($this->users_with_exceeded_timings) . ' users with exceeded timings.');
140 }
static lookupTimingsExceededByUser(array $a_user_ids)
Check if users currently exceeded ANY object.

References ilTimingsUser\lookupTimingsExceededByUser().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAlreadySentNotifications()

ilTimingsCronReminder::getAlreadySentNotifications ( int  $user_id,
bool  $for_exceeded = true 
)
protected

Definition at line 375 of file class.ilTimingsCronReminder.php.

375 : array
376 {
377 $ref_ids = [];
379
380 if (!$for_exceeded) {
382 }
383
384 $result = $this->db->queryF(
385 'SELECT * FROM ' . $table . ' WHERE ' .
386 'user_id = %s',
387 ['integer'],
388 [$user_id]
389 );
390
391 while ($record = $this->db->fetchAssoc($result)) {
392 $ref_ids[$record['ref_id']] = $record['ref_id'];
393 }
394 return $ref_ids;
395 }

References $user_id, ilCourseConstants\CRON_TIMINGS_EXCEEDED_TABLE, and ilCourseConstants\CRON_TIMINGS_STARTED_TABLE.

Referenced by getFreshlyStartedObjectsForUser(), and getNewExceededObjectForUser().

+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilTimingsCronReminder::getDefaultScheduleType ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 73 of file class.ilTimingsCronReminder.php.

74 {
75 return JobScheduleType::DAILY;
76 }

◆ getDefaultScheduleValue()

ilTimingsCronReminder::getDefaultScheduleValue ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 78 of file class.ilTimingsCronReminder.php.

78 : ?int
79 {
80 return null;
81 }

◆ getDescription()

ilTimingsCronReminder::getDescription ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 68 of file class.ilTimingsCronReminder.php.

68 : string
69 {
70 return $this->lng->txt('timings_reminder_notifications_info');
71 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getExceededObjectsForUser()

ilTimingsCronReminder::getExceededObjectsForUser ( int  $user_id)
protected

Definition at line 415 of file class.ilTimingsCronReminder.php.

415 : array
416 {
417 $tmp = [];
418 return ilTimingsUser::lookupTimings([$user_id], $tmp, true);
419 }
static lookupTimings(array $a_user_ids, ?array &$a_meta=null, bool $a_only_exceeded=true)
Lookup references, users with exceeded timings.

References $user_id, and ilTimingsUser\lookupTimings().

Referenced by getNewExceededObjectForUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFreshlyStartedObjectsForUser()

ilTimingsCronReminder::getFreshlyStartedObjectsForUser ( )
protected

Definition at line 168 of file class.ilTimingsCronReminder.php.

168 : void
169 {
170 $users_with_new_started_object = [];
171
172 if (is_array($this->users) && $this->users !== []) {
173 foreach ($this->users as $key => $user_id) {
174 $objects = $this->getObjectsWithTimingsForUser($user_id);
175 if (is_array($objects) && $objects !== []) {
176 $obj_data = [];
177 $already_notified = $this->getAlreadySentNotifications($user_id, false);
178 $this->log->debug('User_id ' . $user_id . ' was already notified for ' . count($already_notified) . ' elements ');
179 $objects = array_diff_key($objects, $already_notified);
180 foreach ($objects as $ref_id => $v) {
181 $obj_data[$ref_id] = $this->getInformationForRefId($ref_id);
182
183 if (is_array($v)) {
184 if ((isset($v['end']) && isset($v['start'])) && $v['end'] > $this->now) {
185 if ($v['start'] < $this->now) {
186 $users_with_new_started_object[$user_id][$ref_id] = $obj_data[$ref_id];
187 }
188 } else {
189 $this->log->debug('End is already older than today no notification send for user_id ' . $user_id . ' on ref_id ' . $ref_id);
190 }
191 }
192 }
193 }
194 }
195 $this->log->debug('Found ' . count($users_with_new_started_object) . ' users with freshly started timings.');
196
197 $this->buildFreshlyStartedMails($users_with_new_started_object);
198 }
199 }
buildFreshlyStartedMails(array $users_with_freshly_started_objects)
getAlreadySentNotifications(int $user_id, bool $for_exceeded=true)
$ref_id
Definition: ltiauth.php:66

References $ref_id, $user_id, buildFreshlyStartedMails(), getAlreadySentNotifications(), getInformationForRefId(), and getObjectsWithTimingsForUser().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilTimingsCronReminder::getId ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 58 of file class.ilTimingsCronReminder.php.

58 : string
59 {
60 return 'crs_timings_reminder';
61 }

◆ getInformationForRefId()

ilTimingsCronReminder::getInformationForRefId ( int  $ref_id)
protected

Definition at line 397 of file class.ilTimingsCronReminder.php.

397 : array
398 {
399 if (!array_key_exists($ref_id, self::$objects_information)) {
400 $obj_id = $this->obj_data_cache->lookupObjId($ref_id);
401 $type = $this->obj_data_cache->lookupType($obj_id);
402 $value = [
403 'title' => $this->obj_data_cache->lookupTitle($obj_id),
404 'type' => $type,
405 'url' => ilLink::_getLink($ref_id, $type),
406 'obj_id' => $obj_id
407 ];
408 self::$objects_information[$ref_id] = $value;
409
410 $this->log->debug('ilTimingsCronReminder->getInformationForRefId: ...cached object information for => ' . $value['type'] . ' => ' . $value['title']);
411 }
412 return self::$objects_information[$ref_id];
413 }

References $ref_id.

Referenced by getFreshlyStartedObjectsForUser(), and getNewExceededObjectForUser().

+ Here is the caller graph for this function:

◆ getNewExceededObjectForUser()

ilTimingsCronReminder::getNewExceededObjectForUser ( )
protected

Definition at line 142 of file class.ilTimingsCronReminder.php.

142 : void
143 {
144 $users_with_exceeded_objects = [];
145
146 if (is_array($this->users_with_exceeded_timings) && $this->users_with_exceeded_timings !== []) {
147 foreach ($this->users_with_exceeded_timings as $key => $user_id) {
148 $objects = $this->getExceededObjectsForUser($user_id);
149 if (is_array($objects) && $objects !== []) {
150 $obj_data = [];
151 $already_notified = $this->getAlreadySentNotifications($user_id);
152 $objects = array_diff_key($objects, $already_notified);
153 foreach (array_keys($objects) as $ref_id) {
154 $detail_data = $this->getInformationForRefId($ref_id);
155 $obj_data[$ref_id] = $detail_data;
156 }
157 if ($obj_data !== []) {
158 $users_with_exceeded_objects[$user_id] = $obj_data;
159 }
160 }
161 }
162 $this->log->debug('Found ' . count($users_with_exceeded_objects) . ' users with new exceeded timings.');
163
164 $this->buildExceededMails($users_with_exceeded_objects);
165 }
166 }
buildExceededMails(array $users_with_exceeded_objects)

References $ref_id, $user_id, buildExceededMails(), getAlreadySentNotifications(), getExceededObjectsForUser(), and getInformationForRefId().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjectsWithTimingsForUser()

ilTimingsCronReminder::getObjectsWithTimingsForUser ( int  $user_id)
protected

Definition at line 421 of file class.ilTimingsCronReminder.php.

421 : array
422 {
423 $meta = [];
424 $timings_obj_list = ilTimingsUser::lookupTimings([$user_id], $meta, false);
425 return $meta[$user_id] ?? [];
426 }

References $user_id, and ilTimingsUser\lookupTimings().

Referenced by getFreshlyStartedObjectsForUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitle()

ilTimingsCronReminder::getTitle ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 63 of file class.ilTimingsCronReminder.php.

63 : string
64 {
65 return $this->lng->txt('timings_reminder_notifications');
66 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getUserLanguage()

ilTimingsCronReminder::getUserLanguage ( int  $user_id)
protected

Definition at line 271 of file class.ilTimingsCronReminder.php.

271 : void
272 {
273 $this->log->debug('start...');
275 $this->user_lang->loadLanguageModule('crs');
276 $this->user_lang->loadLanguageModule('mail');
277 $this->log->debug('user language for user ' . $user_id . ' is ' . $this->user_lang->getLangKey() . ' end.');
278 }
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.

References $user_id, and ilLanguageFactory\_getLanguageOfUser().

Referenced by buildTopMailBody().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasAutoActivation()

ilTimingsCronReminder::hasAutoActivation ( )

Is to be activated on "installation", does only work for ILIAS core cron jobs.

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 83 of file class.ilTimingsCronReminder.php.

83 : bool
84 {
85 return false;
86 }

◆ hasCustomSettings()

ilTimingsCronReminder::hasCustomSettings ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 93 of file class.ilTimingsCronReminder.php.

93 : bool
94 {
95 return false;
96 }

◆ hasFlexibleSchedule()

ilTimingsCronReminder::hasFlexibleSchedule ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 88 of file class.ilTimingsCronReminder.php.

88 : bool
89 {
90 return false;
91 }

◆ hasUserActivatedNotification()

ilTimingsCronReminder::hasUserActivatedNotification ( int  $user_id)
protected

Definition at line 428 of file class.ilTimingsCronReminder.php.

428 : bool
429 {
430 return true;
431 }

Referenced by sendExceededMail(), and sendFreshlyStartedMail().

+ Here is the caller graph for this function:

◆ markExceededInDatabase()

ilTimingsCronReminder::markExceededInDatabase ( int  $user_id,
array  $ref_ids 
)
protected

Definition at line 347 of file class.ilTimingsCronReminder.php.

347 : void
348 {
349 foreach (array_keys($ref_ids) as $ref_id) {
350 $this->db->manipulateF(
351 'INSERT INTO ' . ilCourseConstants::CRON_TIMINGS_EXCEEDED_TABLE . ' (user_id, ref_id, sent) VALUES ' .
352 ' (%s,%s,%s)',
353 ['integer', 'integer', 'integer'],
354 [$user_id, $ref_id, $this->now]
355 );
356
357 $this->log->debug('ilTimingsCronReminder->markExceededInDatabase: Marked exceeded in Database. User ' . $user_id . ' ref_id ' . $ref_id);
358 }
359 }

References $ref_id, $user_id, and ilCourseConstants\CRON_TIMINGS_EXCEEDED_TABLE.

Referenced by sendExceededMail().

+ Here is the caller graph for this function:

◆ markFreshlyStartedInDatabase()

ilTimingsCronReminder::markFreshlyStartedInDatabase ( int  $user_id,
array  $ref_ids 
)
protected

Definition at line 361 of file class.ilTimingsCronReminder.php.

361 : void
362 {
363 foreach (array_keys($ref_ids) as $ref_id) {
364 $this->db->manipulateF(
365 'INSERT INTO ' . ilCourseConstants::CRON_TIMINGS_STARTED_TABLE . ' (user_id, ref_id, sent) VALUES ' .
366 ' (%s,%s,%s)',
367 ['integer', 'integer', 'integer'],
368 [$user_id, $ref_id, $this->now]
369 );
370
371 $this->log->debug('ilTimingsCronReminder->markFreshlyStartedInDatabase: Marked freshly started in Database. User ' . $user_id . ' ref_id ' . $ref_id);
372 }
373 }

References $ref_id, $user_id, and ilCourseConstants\CRON_TIMINGS_STARTED_TABLE.

Referenced by sendFreshlyStartedMail().

+ Here is the caller graph for this function:

◆ run()

ilTimingsCronReminder::run ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 98 of file class.ilTimingsCronReminder.php.

98 : JobResult
99 {
100 $this->log->debug('Start.');
101
102 $result = new JobResult();
103
104 $this->gatherUsers();
108
109 $result->setStatus(JobResult::STATUS_OK);
110
111 $this->log->debug('End');
112
113 return $result;
114 }
gatherUsers()
Read all active users.

References gatherUsers(), gatherUsersWithExceededTimings(), getFreshlyStartedObjectsForUser(), and getNewExceededObjectForUser().

+ Here is the call graph for this function:

◆ sendExceededMail()

ilTimingsCronReminder::sendExceededMail ( int  $user_id,
array  $ref_ids,
string  $mail_body 
)
protected

Definition at line 300 of file class.ilTimingsCronReminder.php.

300 : void
301 {
303 if ($login != '') {
304 $mail = new ilMail(ANONYMOUS_USER_ID);
306 $mail->enqueue(
307 $login,
308 '',
309 '',
310 $this->user_lang->txt('timings_cron_reminder_exceeded_subject'),
311 $mail_body,
312 [],
313 true
314 );
315 $this->log->debug('...mail send for user ' . $user_id . ' to mail ' . $login . ' has exceeded timings for ' . $mail_body);
316 $this->markExceededInDatabase($user_id, $ref_ids);
317 } else {
318 $this->log->debug('... no mail was sent because user ' . $user_id . ' has deactivated their notifications and has no coaches assigned.');
319 }
320 } else {
321 $this->log->debug('Not send. User ' . $user_id . ' has no email.');
322 }
323 }
static _lookupLogin(int $a_user_id)
markExceededInDatabase(int $user_id, array $ref_ids)
const ANONYMOUS_USER_ID
Definition: constants.php:27

References $user_id, ilObjUser\_lookupLogin(), ANONYMOUS_USER_ID, hasUserActivatedNotification(), and markExceededInDatabase().

Referenced by buildExceededMails().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendFreshlyStartedMail()

ilTimingsCronReminder::sendFreshlyStartedMail ( int  $user_id,
array  $ref_ids,
string  $mail_body 
)
protected

Definition at line 325 of file class.ilTimingsCronReminder.php.

325 : void
326 {
328
329 if ($login != '' && $this->hasUserActivatedNotification($user_id)) {
330 $mail = new ilMail(ANONYMOUS_USER_ID);
331 $mail->enqueue(
332 $login,
333 '',
334 '',
335 $this->user_lang->txt('timings_cron_reminder_started_subject'),
336 $mail_body,
337 [],
338 true
339 );
340 $this->log->debug('...mail send for user ' . $user_id . ' to mail ' . $login . ' has freshly started timings for ' . $mail_body);
341 $this->markFreshlyStartedInDatabase($user_id, $ref_ids);
342 } else {
343 $this->log->debug('Not send. User ' . $user_id . ' has no email.');
344 }
345 }
markFreshlyStartedInDatabase(int $user_id, array $ref_ids)

References $user_id, ilObjUser\_lookupLogin(), ANONYMOUS_USER_ID, hasUserActivatedNotification(), and markFreshlyStartedInDatabase().

Referenced by buildFreshlyStartedMails().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilTimingsCronReminder::$db
protected

Definition at line 36 of file class.ilTimingsCronReminder.php.

◆ $lng

ilLanguage ilTimingsCronReminder::$lng
protected

Definition at line 34 of file class.ilTimingsCronReminder.php.

◆ $log

ilLogger ilTimingsCronReminder::$log
protected

Definition at line 33 of file class.ilTimingsCronReminder.php.

◆ $now

int ilTimingsCronReminder::$now
private

Definition at line 31 of file class.ilTimingsCronReminder.php.

Referenced by gatherUsers().

◆ $obj_data_cache

ilObjectDataCache ilTimingsCronReminder::$obj_data_cache
protected

Definition at line 37 of file class.ilTimingsCronReminder.php.

◆ $objects_information

array ilTimingsCronReminder::$objects_information
staticprivate

Definition at line 27 of file class.ilTimingsCronReminder.php.

◆ $user_lang

ilLanguage ilTimingsCronReminder::$user_lang
protected

Definition at line 35 of file class.ilTimingsCronReminder.php.

◆ $users

array ilTimingsCronReminder::$users
private

Definition at line 30 of file class.ilTimingsCronReminder.php.

◆ $users_with_exceeded_timings

array ilTimingsCronReminder::$users_with_exceeded_timings
private

Definition at line 29 of file class.ilTimingsCronReminder.php.


The documentation for this class was generated from the following file: