ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilForumCronNotification Class Reference

Forum notifications. More...

+ Inheritance diagram for ilForumCronNotification:
+ Collaboration diagram for ilForumCronNotification:

Public Member Functions

 __construct (?ilDBInterface $database=null, ?ilForumNotificationCache $notificationCache=null, ?ilLanguage $lng=null, ?ilSetting $settings=null, ?\ILIAS\Refinery\Factory $refinery=null, ?JobManager $cronManager=null)
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 hasCustomSettings ()
 
 keepAlive ()
 
 run ()
 
 sendCronForumNotification (ilDBStatement $res, int $notification_type)
 
 existsProviderObject (int $provider_id, int $notification_type)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
- 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

 getRefIdsByObjId (int $a_obj_id)
 
 getFirstAccessibleRefIdBUserAndObjId (int $a_user_id, int $a_obj_id)
 

Private Member Functions

 addProviderObject (int $provider_id, array $row, int $notification_type)
 
 resetProviderCache ()
 
 sendNotificationForNewPosts (string $threshold_date)
 
 sendNotificationForUpdatedPosts (string $threshold_date)
 
 sendNotificationForCensoredPosts (string $threshold_date)
 
 sendNotificationForUncensoredPosts (string $threshold_date)
 
 sendNotificationForDeletedThreads ()
 
 sendNotificationForDeletedPosts ()
 
 sendNotification (ilDBStatement $res, string $actionName, int $notificationType)
 
 sendDeleteNotifications (ilDBStatement $res, string $action, string $actionDescription, int $notificationType)
 
 createForumPostSql (string $condition)
 
 createSelectOfDeletionNotificationsSql ()
 

Private Attributes

const int KEEP_ALIVE_CHUNK_SIZE = 25
 
const int DEFAULT_MAX_NOTIFICATION_AGE_IN_DAYS = 30
 
readonly ilLanguage $lng
 
readonly ilSetting $settings
 
ilLogger $logger
 
ilTree $tree
 
int $num_sent_messages = 0
 
readonly ilDBInterface $ilDB
 
readonly ilForumNotificationCache $notificationCache
 
readonly ILIAS Refinery Factory $refinery
 
readonly JobManager $cronManager
 

Static Private Attributes

static array $providerObject = []
 
static array $deleted_ids_cache = []
 
static array $ref_ids_by_obj_id = []
 
static array $accessible_ref_ids_by_user = []
 
static array $container_by_frm_ref_id = []
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\Cron\CronJob
JobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Detailed Description

Forum notifications.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Nadia Matuschek nmatu.nosp@m.sche.nosp@m.k@dat.nosp@m.abay.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilForumCronNotification::__construct ( ?ilDBInterface  $database = null,
?ilForumNotificationCache  $notificationCache = null,
?ilLanguage  $lng = null,
?ilSetting  $settings = null,
?\ILIAS\Refinery\Factory  $refinery = null,
?JobManager  $cronManager = null 
)

Definition at line 57 of file class.ilForumCronNotification.php.

64 {
65 global $DIC;
66
67 $this->settings = $settings ?? new ilSetting('frma');
68 $this->lng = $lng ?? $DIC->language();
69 $this->ilDB = $database ?? $DIC->database();
70 $this->notificationCache = $notificationCache ?? new ilForumNotificationCache();
71 $this->refinery = $refinery ?? $DIC->refinery();
72 $this->cronManager = $cronManager ?? $DIC->cron()->manager();
73 }
readonly ILIAS Refinery Factory $refinery
readonly ilForumNotificationCache $notificationCache
Class ilForumNotificationCache.
ILIAS Setting Class.
global $DIC
Definition: shib_login.php:26

References $cronManager, $DIC, $notificationCache, ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ activationWasToggled()

ilForumCronNotification::activationWasToggled ( ilDBInterface  $db,
ilSetting  $setting,
bool  $a_currently_active 
)

Definition at line 378 of file class.ilForumCronNotification.php.

378 : void
379 {
380 $value = 1;
381 // propagate cron-job setting to object setting
382 if ($a_currently_active) {
383 $value = 2;
384 }
385
386 $setting->set('forum_notification', (string) $value);
387 }
set(string $a_key, string $a_val)

References ilSetting\set().

+ Here is the call graph for this function:

◆ addCustomSettingsToForm()

ilForumCronNotification::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Definition at line 389 of file class.ilForumCronNotification.php.

389 : void
390 {
391 $this->lng->loadLanguageModule('forum');
392
393 $max_notification_age = new ilNumberInputGUI(
394 $this->lng->txt('frm_max_notification_age'),
395 'max_notification_age'
396 );
397 $max_notification_age->setSize(5);
398 $max_notification_age->setSuffix($this->lng->txt('frm_max_notification_age_unit'));
399 $max_notification_age->setRequired(true);
400 $max_notification_age->allowDecimals(false);
401 $max_notification_age->setMinValue(1);
402 $max_notification_age->setInfo($this->lng->txt('frm_max_notification_age_info'));
403 $max_notification_age->setValue(
404 $this->settings->get(
405 'max_notification_age',
406 (string) self::DEFAULT_MAX_NOTIFICATION_AGE_IN_DAYS
407 )
408 );
409
410 $a_form->addItem($max_notification_age);
411 }
This class represents a number property in a property form.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ addProviderObject()

ilForumCronNotification::addProviderObject ( int  $provider_id,
array  $row,
int  $notification_type 
)
private
Parameters
array<string,string|int|float|null>$row

Definition at line 357 of file class.ilForumCronNotification.php.

357 : void
358 {
359 $tmp_provider = new ilForumCronNotificationDataProvider($row, $notification_type, $this->notificationCache);
360 self::$providerObject[$provider_id . '_' . $notification_type] = $tmp_provider;
361 self::$providerObject[$provider_id . '_' . $notification_type]->addRecipient((int) $row['user_id']);
362 }

Referenced by sendCronForumNotification().

+ Here is the caller graph for this function:

◆ addToExternalSettingsForm()

ilForumCronNotification::addToExternalSettingsForm ( int  $a_form_id,
array &  $a_fields,
bool  $a_is_active 
)
Parameters
array<string,mixed>$a_fields

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 369 of file class.ilForumCronNotification.php.

369 : void
370 {
372 $a_fields['cron_forum_notification'] = $a_is_active ?
373 $this->lng->txt('enabled') :
374 $this->lng->txt('disabled');
375 }
376 }

References ilAdministrationSettingsFormHandler\FORM_FORUM, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ createForumPostSql()

ilForumCronNotification::createForumPostSql ( string  $condition)
private

Definition at line 607 of file class.ilForumCronNotification.php.

607 : string
608 {
609 return '
610 SELECT frm_threads.thr_subject thr_subject,
611 frm_data.top_name top_name,
612 frm_data.top_frm_fk obj_id,
613 frm_notification.user_id user_id,
614 frm_threads.thr_pk thread_id,
615 frm_posts.*
616 FROM frm_notification, frm_posts, frm_threads, frm_data, frm_posts_tree
617 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND ' . $condition . '
618 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id)
619 OR (frm_threads.thr_pk = frm_notification.thread_id
620 AND frm_data.top_pk = frm_threads.thr_top_fk) )
621 AND frm_posts.pos_author_id != frm_notification.user_id
622 AND frm_posts_tree.pos_fk = frm_posts.pos_pk AND frm_posts_tree.parent_pos != 0
623 ORDER BY frm_posts.pos_date ASC';
624 }

Referenced by sendNotificationForCensoredPosts(), sendNotificationForNewPosts(), sendNotificationForUncensoredPosts(), and sendNotificationForUpdatedPosts().

+ Here is the caller graph for this function:

◆ createSelectOfDeletionNotificationsSql()

ilForumCronNotification::createSelectOfDeletionNotificationsSql ( )
private

Definition at line 626 of file class.ilForumCronNotification.php.

626 : string
627 {
628 return '
629 SELECT frm_posts_deleted.thread_title thr_subject,
630 frm_posts_deleted.forum_title top_name,
631 frm_posts_deleted.obj_id obj_id,
632 frm_notification.user_id user_id,
633 frm_posts_deleted.pos_display_user_id,
634 frm_posts_deleted.pos_usr_alias,
635 frm_posts_deleted.deleted_id,
636 frm_posts_deleted.post_date pos_date,
637 frm_posts_deleted.post_title pos_subject,
638 frm_posts_deleted.post_message pos_message,
639 frm_posts_deleted.deleted_by
640
641 FROM frm_notification, frm_posts_deleted
642
643 WHERE ( frm_posts_deleted.obj_id = frm_notification.frm_id
644 OR frm_posts_deleted.thread_id = frm_notification.thread_id)
645 AND frm_posts_deleted.pos_display_user_id != frm_notification.user_id
646 AND frm_posts_deleted.is_thread_deleted = %s
647 AND frm_notification.interested_events & %s
648 ORDER BY frm_posts_deleted.post_date ASC';
649 }

Referenced by sendNotificationForDeletedPosts(), and sendNotificationForDeletedThreads().

+ Here is the caller graph for this function:

◆ existsProviderObject()

ilForumCronNotification::existsProviderObject ( int  $provider_id,
int  $notification_type 
)

Definition at line 349 of file class.ilForumCronNotification.php.

349 : bool
350 {
351 return isset(self::$providerObject[$provider_id . '_' . $notification_type]);
352 }

Referenced by sendCronForumNotification().

+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilForumCronNotification::getDefaultScheduleType ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 90 of file class.ilForumCronNotification.php.

91 {
92 return JobScheduleType::IN_HOURS;
93 }

◆ getDefaultScheduleValue()

ilForumCronNotification::getDefaultScheduleValue ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 95 of file class.ilForumCronNotification.php.

95 : ?int
96 {
97 return 1;
98 }

◆ getDescription()

ilForumCronNotification::getDescription ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 85 of file class.ilForumCronNotification.php.

85 : string
86 {
87 return $this->lng->txt('cron_forum_notification_crob_desc');
88 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getFirstAccessibleRefIdBUserAndObjId()

ilForumCronNotification::getFirstAccessibleRefIdBUserAndObjId ( int  $a_user_id,
int  $a_obj_id 
)
protected

Definition at line 210 of file class.ilForumCronNotification.php.

210 : int
211 {
212 global $DIC;
213 $ilAccess = $DIC->access();
214
215 if (!array_key_exists($a_user_id, self::$accessible_ref_ids_by_user)) {
216 self::$accessible_ref_ids_by_user[$a_user_id] = [];
217 }
218
219 if (!array_key_exists($a_obj_id, self::$accessible_ref_ids_by_user[$a_user_id])) {
220 $accessible_ref_id = 0;
221 foreach ($this->getRefIdsByObjId($a_obj_id) as $ref_id) {
222 if ($ilAccess->checkAccessOfUser($a_user_id, 'read', '', $ref_id)) {
223 $accessible_ref_id = $ref_id;
224 break;
225 }
226 }
227 self::$accessible_ref_ids_by_user[$a_user_id][$a_obj_id] = $accessible_ref_id;
228 }
229
230 return (int) self::$accessible_ref_ids_by_user[$a_user_id][$a_obj_id];
231 }
$ref_id
Definition: ltiauth.php:66

References $DIC, $ref_id, and getRefIdsByObjId().

Referenced by sendCronForumNotification().

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

◆ getId()

ilForumCronNotification::getId ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 75 of file class.ilForumCronNotification.php.

75 : string
76 {
77 return 'frm_notification';
78 }

Referenced by keepAlive().

+ Here is the caller graph for this function:

◆ getRefIdsByObjId()

ilForumCronNotification::getRefIdsByObjId ( int  $a_obj_id)
protected
Returns
list<int>

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

201 : array
202 {
203 if (!array_key_exists($a_obj_id, self::$ref_ids_by_obj_id)) {
204 self::$ref_ids_by_obj_id[$a_obj_id] = array_values(ilObject::_getAllReferences($a_obj_id));
205 }
206
207 return self::$ref_ids_by_obj_id[$a_obj_id];
208 }
static _getAllReferences(int $id)
get all reference ids for object ID

References ilObject\_getAllReferences().

Referenced by getFirstAccessibleRefIdBUserAndObjId().

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

◆ getTitle()

ilForumCronNotification::getTitle ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 80 of file class.ilForumCronNotification.php.

80 : string
81 {
82 return $this->lng->txt('cron_forum_notification');
83 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ hasAutoActivation()

ilForumCronNotification::hasAutoActivation ( )

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

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 100 of file class.ilForumCronNotification.php.

100 : bool
101 {
102 return false;
103 }

◆ hasCustomSettings()

ilForumCronNotification::hasCustomSettings ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 110 of file class.ilForumCronNotification.php.

110 : bool
111 {
112 return true;
113 }

◆ hasFlexibleSchedule()

ilForumCronNotification::hasFlexibleSchedule ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 105 of file class.ilForumCronNotification.php.

105 : bool
106 {
107 return true;
108 }

◆ keepAlive()

ilForumCronNotification::keepAlive ( )

Definition at line 115 of file class.ilForumCronNotification.php.

115 : void
116 {
117 $this->logger->debug('Sending ping to cron manager ...');
118 $this->cronManager->ping($this->getId());
119 $this->logger->debug(sprintf('Current memory usage: %s', memory_get_usage(true)));
120 }

References getId(), and ILIAS\Repository\logger().

Referenced by sendCronForumNotification(), and sendNotification().

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

◆ resetProviderCache()

ilForumCronNotification::resetProviderCache ( )
private

Definition at line 364 of file class.ilForumCronNotification.php.

364 : void
365 {
366 self::$providerObject = [];
367 }

Referenced by sendCronForumNotification().

+ Here is the caller graph for this function:

◆ run()

ilForumCronNotification::run ( )

Reimplemented from ILIAS\Cron\CronJob.

Definition at line 122 of file class.ilForumCronNotification.php.

122 : JobResult
123 {
124 global $DIC;
125
126 $this->logger = $DIC->logger()->frm();
127 $this->tree = $DIC->repositoryTree();
128
129 $status = JobResult::STATUS_NO_ACTION;
130
131 $this->lng->loadLanguageModule('forum');
132
133 $this->logger->info('Started forum notification job ...');
134
135 if (!($last_run_datetime = $this->settings->get('cron_forum_notification_last_date'))) {
136 $last_run_datetime = null;
137 }
138
139 $this->num_sent_messages = 0;
140 $cj_start_date = date('Y-m-d H:i:s');
141
142 if ((string) $this->settings->get('max_notification_age', '') === '') {
143 $this->logger->info(sprintf(
144 'No maximum notification age set, %s days will be used to determine the ' .
145 'left interval when querying the relevant forum events.',
146 self::DEFAULT_MAX_NOTIFICATION_AGE_IN_DAYS
147 ));
148 }
149
150 if ($last_run_datetime !== null &&
151 checkdate(
152 (int) date('m', strtotime($last_run_datetime)),
153 (int) date('d', strtotime($last_run_datetime)),
154 (int) date('Y', strtotime($last_run_datetime))
155 )) {
156 $threshold = max(
157 strtotime($last_run_datetime),
158 strtotime('-' . (int) $this->settings->get('max_notification_age', (string) self::DEFAULT_MAX_NOTIFICATION_AGE_IN_DAYS) . ' days')
159 );
160 } else {
161 $threshold = strtotime('-' . (int) $this->settings->get('max_notification_age', (string) self::DEFAULT_MAX_NOTIFICATION_AGE_IN_DAYS) . ' days');
162 }
163
164 $this->logger->info(sprintf('Threshold for forum event determination is: %s', date('Y-m-d H:i:s', $threshold)));
165
166 $threshold_date = date('Y-m-d H:i:s', $threshold);
167
168 $this->sendNotificationForNewPosts($threshold_date);
169
170 $this->sendNotificationForUpdatedPosts($threshold_date);
171
172 $this->sendNotificationForCensoredPosts($threshold_date);
173
174 $this->sendNotificationForUncensoredPosts($threshold_date);
175
177
179
180 $this->settings->set('cron_forum_notification_last_date', $cj_start_date);
181
182 $mess = 'Sent ' . $this->num_sent_messages . ' messages.';
183
184 $this->logger->info($mess);
185 $this->logger->info('Finished forum notification job');
186
187 $result = new JobResult();
188 if ($this->num_sent_messages !== 0) {
189 $status = JobResult::STATUS_OK;
190 $result->setMessage($mess);
191 }
192
193 $result->setStatus($status);
194
195 return $result;
196 }
sendNotificationForUncensoredPosts(string $threshold_date)
sendNotificationForUpdatedPosts(string $threshold_date)
sendNotificationForCensoredPosts(string $threshold_date)
sendNotificationForNewPosts(string $threshold_date)

References $DIC, ILIAS\Repository\lng(), ILIAS\Repository\logger(), sendNotificationForCensoredPosts(), sendNotificationForDeletedPosts(), sendNotificationForDeletedThreads(), sendNotificationForNewPosts(), sendNotificationForUncensoredPosts(), sendNotificationForUpdatedPosts(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ saveCustomSettings()

ilForumCronNotification::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Definition at line 413 of file class.ilForumCronNotification.php.

413 : bool
414 {
415 $this->settings->set(
416 'max_notification_age',
417 $this->refinery->in()->series([
418 $this->refinery->byTrying([
419 $this->refinery->kindlyTo()->int(),
420 $this->refinery->in()->series([
421 $this->refinery->kindlyTo()->float(),
422 $this->refinery->kindlyTo()->int()
423 ])
424 ]),
425 $this->refinery->kindlyTo()->string()
426 ])->transform($a_form->getInput('max_notification_age'))
427 );
428 return true;
429 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...

References ilPropertyFormGUI\getInput(), ILIAS\Repository\refinery(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ sendCronForumNotification()

ilForumCronNotification::sendCronForumNotification ( ilDBStatement  $res,
int  $notification_type 
)

Definition at line 233 of file class.ilForumCronNotification.php.

233 : void
234 {
235 global $DIC;
236 $ilDB = $DIC->database();
237
238 while ($row = $ilDB->fetchAssoc($res)) {
239 if ($notification_type === ilForumMailNotification::TYPE_POST_DELETED
240 || $notification_type === ilForumMailNotification::TYPE_THREAD_DELETED) {
241 // important! save the deleted_id to cache before proceeding getFirstAccessibleRefIdBUserAndObjId !
242 self::$deleted_ids_cache[$row['deleted_id']] = $row['deleted_id'];
243 }
244
245 if (defined('ANONYMOUS_USER_ID') && (int) $row['user_id'] === ANONYMOUS_USER_ID) {
246 continue;
247 }
248
249 $ref_id = $this->getFirstAccessibleRefIdBUserAndObjId((int) $row['user_id'], (int) $row['obj_id']);
250 if ($ref_id < 1) {
251 $this->logger->debug(
252 sprintf(
253 'The recipient with id %s has no "read" permission for object with id %s',
254 $row['user_id'],
255 $row['obj_id']
256 )
257 );
258 continue;
259 }
260
261 $row['ref_id'] = $ref_id;
262
263 $container = $this->determineClosestContainer($ref_id);
264 $row['closest_container'] = null;
265 if ($container instanceof ilObjCourse || $container instanceof ilObjGroup) {
266 $row['closest_container'] = $container;
267 }
268
269 $provider_id = isset($row['deleted_id']) ? -((int) $row['deleted_id']) : (int) $row['pos_pk'];
270 if ($this->existsProviderObject($provider_id, $notification_type)) {
271 self::$providerObject[$provider_id . '_' . $notification_type]->addRecipient((int) $row['user_id']);
272 } else {
273 $this->addProviderObject($provider_id, $row, $notification_type);
274 }
275 }
276
277 $usrIdsToPreload = [];
278 foreach (self::$providerObject as $provider) {
279 if ($provider->getPosAuthorId() !== 0) {
280 $usrIdsToPreload[$provider->getPosAuthorId()] = $provider->getPosAuthorId();
281 }
282 if ($provider->getPosDisplayUserId() !== 0) {
283 $usrIdsToPreload[$provider->getPosDisplayUserId()] = $provider->getPosDisplayUserId();
284 }
285 if ($provider->getPostUpdateUserId() !== 0) {
286 $usrIdsToPreload[$provider->getPostUpdateUserId()] = $provider->getPostUpdateUserId();
287 }
288 }
289
290 ilForumAuthorInformationCache::preloadUserObjects(array_unique($usrIdsToPreload));
291
292 $i = 0;
293 foreach (self::$providerObject as $provider) {
294 if ($i > 0 && ($i % self::KEEP_ALIVE_CHUNK_SIZE) === 0) {
295 $this->keepAlive();
296 }
297
298 $recipients = array_unique($provider->getCronRecipients());
299
300 $this->logger->info(
301 sprintf(
302 'Trying to send forum notifications for posting id "%s", type "%s" and recipients: %s',
303 $provider->getPostId(),
304 $notification_type,
305 implode(', ', $recipients)
306 )
307 );
308
309 $mailNotification = new ilForumMailNotification($provider, $this->logger);
310 $mailNotification->setIsCronjob(true);
311 $mailNotification->setType($notification_type);
312 $mailNotification->setRecipients($recipients);
313
314 $mailNotification->send();
315
316 $this->num_sent_messages += count($provider->getCronRecipients());
317 $this->logger->info('Sent notifications ... ');
318
319 ++$i;
320 }
321
322 $this->resetProviderCache();
323 }
existsProviderObject(int $provider_id, int $notification_type)
getFirstAccessibleRefIdBUserAndObjId(int $a_user_id, int $a_obj_id)
addProviderObject(int $provider_id, array $row, int $notification_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjGroup.
const ANONYMOUS_USER_ID
Definition: constants.php:27
fetchAssoc(ilDBStatement $statement)
$res
Definition: ltiservices.php:69
$provider
Definition: ltitoken.php:80
$container
@noRector
Definition: wac.php:37

References $container, $DIC, $ilDB, $provider, $ref_id, $res, addProviderObject(), ANONYMOUS_USER_ID, existsProviderObject(), ilDBInterface\fetchAssoc(), getFirstAccessibleRefIdBUserAndObjId(), ILIAS\Repository\int(), keepAlive(), ILIAS\Repository\logger(), ilForumAuthorInformationCache\preloadUserObjects(), resetProviderCache(), ilForumMailNotification\TYPE_POST_DELETED, and ilForumMailNotification\TYPE_THREAD_DELETED.

Referenced by sendDeleteNotifications(), and sendNotification().

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

◆ sendDeleteNotifications()

ilForumCronNotification::sendDeleteNotifications ( ilDBStatement  $res,
string  $action,
string  $actionDescription,
int  $notificationType 
)
private

Definition at line 580 of file class.ilForumCronNotification.php.

585 : void {
586 $numRows = $this->ilDB->numRows($res);
587 if ($numRows > 0) {
588 $this->logger->info(sprintf('Sending notifications for %s "%s" events ...', $numRows, $actionDescription));
589 $this->sendCronForumNotification($res, $notificationType);
590 if (self::$deleted_ids_cache !== []) {
591 $this->ilDB->manipulate(
592 'DELETE FROM frm_posts_deleted WHERE ' . $this->ilDB->in(
593 'deleted_id',
594 self::$deleted_ids_cache,
595 false,
597 )
598 );
599 $this->logger->info('Deleted obsolete entries of table "' . $action . '" ...');
600 }
601 $this->logger->info(sprintf('Sent notifications for %s ...', $actionDescription));
602 }
603
604 $this->keepAlive();
605 }
sendCronForumNotification(ilDBStatement $res, int $notification_type)

References ILIAS\Repository\logger(), sendCronForumNotification(), and ilDBConstants\T_INTEGER.

Referenced by sendNotificationForDeletedPosts(), and sendNotificationForDeletedThreads().

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

◆ sendNotification()

ilForumCronNotification::sendNotification ( ilDBStatement  $res,
string  $actionName,
int  $notificationType 
)
private

Definition at line 568 of file class.ilForumCronNotification.php.

568 : void
569 {
570 $numRows = $this->ilDB->numRows($res);
571 if ($numRows > 0) {
572 $this->logger->info(sprintf('Sending notifications for %s "%s" events ...', $numRows, $actionName));
573 $this->sendCronForumNotification($res, $notificationType);
574 $this->logger->info(sprintf('Sent notifications for %s ...', $actionName));
575 }
576
577 $this->keepAlive();
578 }

References $res, keepAlive(), ILIAS\Repository\logger(), and sendCronForumNotification().

Referenced by sendNotificationForCensoredPosts(), sendNotificationForNewPosts(), sendNotificationForUncensoredPosts(), and sendNotificationForUpdatedPosts().

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

◆ sendNotificationForCensoredPosts()

ilForumCronNotification::sendNotificationForCensoredPosts ( string  $threshold_date)
private

Definition at line 482 of file class.ilForumCronNotification.php.

482 : void
483 {
484 $condition = '
485 frm_notification.interested_events & %s AND
486 frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND
487 (frm_posts.pos_cens_date >= %s AND frm_posts.pos_cens_date > frm_posts.pos_activation_date ) ';
488 $types = [
493 ];
494 $values = [ilForumNotificationEvents::CENSORED, 1, 1, $threshold_date];
495
496 $res = $this->ilDB->queryF(
497 $this->createForumPostSql($condition),
498 $types,
499 $values
500 );
501
502 $this->sendNotification(
503 $res,
504 'censored posting',
506 );
507 }
sendNotification(ilDBStatement $res, string $actionName, int $notificationType)

References $res, ilForumNotificationEvents\CENSORED, createForumPostSql(), sendNotification(), ilDBConstants\T_INTEGER, ilDBConstants\T_TIMESTAMP, and ilForumMailNotification\TYPE_POST_CENSORED.

Referenced by run().

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

◆ sendNotificationForDeletedPosts()

ilForumCronNotification::sendNotificationForDeletedPosts ( )
private

Definition at line 552 of file class.ilForumCronNotification.php.

552 : void
553 {
554 $res = $this->ilDB->queryF(
558 );
559
561 $res,
562 'frm_posts_deleted',
563 'deleted postings',
565 );
566 }
sendDeleteNotifications(ilDBStatement $res, string $action, string $actionDescription, int $notificationType)

References $res, createSelectOfDeletionNotificationsSql(), ilForumNotificationEvents\POST_DELETED, sendDeleteNotifications(), ilDBConstants\T_INTEGER, and ilForumMailNotification\TYPE_POST_DELETED.

Referenced by run().

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

◆ sendNotificationForDeletedThreads()

ilForumCronNotification::sendNotificationForDeletedThreads ( )
private

Definition at line 536 of file class.ilForumCronNotification.php.

536 : void
537 {
538 $res = $this->ilDB->queryF(
542 );
543
545 $res,
546 'frm_threads_deleted',
547 'deleted threads',
549 );
550 }

References $res, createSelectOfDeletionNotificationsSql(), sendDeleteNotifications(), ilDBConstants\T_INTEGER, ilForumNotificationEvents\THREAD_DELETED, and ilForumMailNotification\TYPE_THREAD_DELETED.

Referenced by run().

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

◆ sendNotificationForNewPosts()

ilForumCronNotification::sendNotificationForNewPosts ( string  $threshold_date)
private

Definition at line 431 of file class.ilForumCronNotification.php.

431 : void
432 {
433 $condition = '
434
435 frm_posts.pos_status = %s AND (
436 (frm_posts.pos_date >= %s AND frm_posts.pos_date = frm_posts.pos_activation_date) OR
437 (frm_posts.pos_activation_date >= %s AND frm_posts.pos_date < frm_posts.pos_activation_date)
438 ) ';
440 $values = [1, $threshold_date, $threshold_date];
441
442 $res = $this->ilDB->queryF(
443 $this->createForumPostSql($condition),
444 $types,
445 $values
446 );
447
448 $this->sendNotification(
449 $res,
450 'new posting',
452 );
453 }

References $res, createForumPostSql(), sendNotification(), ilDBConstants\T_INTEGER, ilDBConstants\T_TIMESTAMP, and ilForumMailNotification\TYPE_POST_NEW.

Referenced by run().

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

◆ sendNotificationForUncensoredPosts()

ilForumCronNotification::sendNotificationForUncensoredPosts ( string  $threshold_date)
private

Definition at line 509 of file class.ilForumCronNotification.php.

509 : void
510 {
511 $condition = '
512 frm_notification.interested_events & %s AND
513 frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND
514 (frm_posts.pos_cens_date >= %s AND frm_posts.pos_cens_date > frm_posts.pos_activation_date ) ';
515 $types = [
520 ];
521 $values = [ilForumNotificationEvents::UNCENSORED, 0, 1, $threshold_date];
522
523 $res = $this->ilDB->queryF(
524 $this->createForumPostSql($condition),
525 $types,
526 $values
527 );
528
529 $this->sendNotification(
530 $res,
531 'uncensored posting',
533 );
534 }

References $res, createForumPostSql(), sendNotification(), ilDBConstants\T_INTEGER, ilDBConstants\T_TIMESTAMP, ilForumMailNotification\TYPE_POST_UNCENSORED, and ilForumNotificationEvents\UNCENSORED.

Referenced by run().

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

◆ sendNotificationForUpdatedPosts()

ilForumCronNotification::sendNotificationForUpdatedPosts ( string  $threshold_date)
private

Definition at line 455 of file class.ilForumCronNotification.php.

455 : void
456 {
457 $condition = '
458 frm_notification.interested_events & %s AND
459 frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND
460 (frm_posts.pos_update > frm_posts.pos_date AND frm_posts.pos_update >= %s) ';
461 $types = [
466 ];
467 $values = [ilForumNotificationEvents::UPDATED, 0, 1, $threshold_date];
468
469 $res = $this->ilDB->queryF(
470 $this->createForumPostSql($condition),
471 $types,
472 $values
473 );
474
475 $this->sendNotification(
476 $res,
477 'updated posting',
479 );
480 }

References $res, createForumPostSql(), sendNotification(), ilDBConstants\T_INTEGER, ilDBConstants\T_TIMESTAMP, ilForumMailNotification\TYPE_POST_UPDATED, and ilForumNotificationEvents\UPDATED.

Referenced by run().

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

Field Documentation

◆ $accessible_ref_ids_by_user

array ilForumCronNotification::$accessible_ref_ids_by_user = []
staticprivate

Definition at line 43 of file class.ilForumCronNotification.php.

◆ $container_by_frm_ref_id

array ilForumCronNotification::$container_by_frm_ref_id = []
staticprivate

Definition at line 45 of file class.ilForumCronNotification.php.

◆ $cronManager

readonly JobManager ilForumCronNotification::$cronManager
private

Definition at line 55 of file class.ilForumCronNotification.php.

Referenced by __construct().

◆ $deleted_ids_cache

array ilForumCronNotification::$deleted_ids_cache = []
staticprivate

Definition at line 39 of file class.ilForumCronNotification.php.

◆ $ilDB

readonly ilDBInterface ilForumCronNotification::$ilDB
private

Definition at line 52 of file class.ilForumCronNotification.php.

Referenced by sendCronForumNotification().

◆ $lng

readonly ilLanguage ilForumCronNotification::$lng
private

Definition at line 47 of file class.ilForumCronNotification.php.

◆ $logger

ilLogger ilForumCronNotification::$logger
private

Definition at line 49 of file class.ilForumCronNotification.php.

◆ $notificationCache

readonly ilForumNotificationCache ilForumCronNotification::$notificationCache
private

Definition at line 53 of file class.ilForumCronNotification.php.

Referenced by __construct().

◆ $num_sent_messages

int ilForumCronNotification::$num_sent_messages = 0
private

Definition at line 51 of file class.ilForumCronNotification.php.

◆ $providerObject

array ilForumCronNotification::$providerObject = []
staticprivate

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

◆ $ref_ids_by_obj_id

array ilForumCronNotification::$ref_ids_by_obj_id = []
staticprivate

Definition at line 41 of file class.ilForumCronNotification.php.

◆ $refinery

readonly ILIAS Refinery Factory ilForumCronNotification::$refinery
private

Definition at line 54 of file class.ilForumCronNotification.php.

◆ $settings

readonly ilSetting ilForumCronNotification::$settings
private

Definition at line 48 of file class.ilForumCronNotification.php.

◆ $tree

ilTree ilForumCronNotification::$tree
private

Definition at line 50 of file class.ilForumCronNotification.php.

◆ DEFAULT_MAX_NOTIFICATION_AGE_IN_DAYS

const int ilForumCronNotification::DEFAULT_MAX_NOTIFICATION_AGE_IN_DAYS = 30
private

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

◆ KEEP_ALIVE_CHUNK_SIZE

const int ilForumCronNotification::KEEP_ALIVE_CHUNK_SIZE = 25
private

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


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