ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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, ilCronManager $cronManager=null)
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 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 ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?CronJobScheduleType $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 (?CronJobScheduleType $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 ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 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 KEEP_ALIVE_CHUNK_SIZE = 25
 
const DEFAULT_MAX_NOTIFICATION_AGE_IN_DAYS = 30
 
ilLanguage $lng
 
ilSetting $settings
 
ilLogger $logger
 
ilTree $tree
 
int $num_sent_messages = 0
 
ilDBInterface $ilDB
 
ilForumNotificationCache $notificationCache
 
ILIAS Refinery Factory $refinery
 
ilCronManager $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 ilCronJob
CronJobScheduleType $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 28 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,
ilCronManager  $cronManager = null 
)

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

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

61  {
62  global $DIC;
63 
64  $this->settings = $settings ?? new ilSetting('frma');
65  $this->lng = $lng ?? $DIC->language();
66  $this->ilDB = $database ?? $DIC->database();
67  $this->notificationCache = $notificationCache ?? new ilForumNotificationCache();
68  $this->refinery = $refinery ?? $DIC->refinery();
69  $this->cronManager = $cronManager ?? $DIC->cron()->manager();
70  }
global $DIC
Definition: feed.php:28
Class ilForumNotificationCache.
+ 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 375 of file class.ilForumCronNotification.php.

References ilSetting\set().

375  : void
376  {
377  $value = 1;
378  // propagate cron-job setting to object setting
379  if ($a_currently_active) {
380  $value = 2;
381  }
382 
383  $setting->set('forum_notification', (string) $value);
384  }
set(string $a_key, string $a_val)
+ Here is the call graph for this function:

◆ addCustomSettingsToForm()

ilForumCronNotification::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

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

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

386  : void
387  {
388  $this->lng->loadLanguageModule('forum');
389 
390  $max_notification_age = new ilNumberInputGUI(
391  $this->lng->txt('frm_max_notification_age'),
392  'max_notification_age'
393  );
394  $max_notification_age->setSize(5);
395  $max_notification_age->setSuffix($this->lng->txt('frm_max_notification_age_unit'));
396  $max_notification_age->setRequired(true);
397  $max_notification_age->allowDecimals(false);
398  $max_notification_age->setMinValue(1);
399  $max_notification_age->setInfo($this->lng->txt('frm_max_notification_age_info'));
400  $max_notification_age->setValue(
401  $this->settings->get(
402  'max_notification_age',
403  (string) self::DEFAULT_MAX_NOTIFICATION_AGE_IN_DAYS
404  )
405  );
406 
407  $a_form->addItem($max_notification_age);
408  }
+ 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 354 of file class.ilForumCronNotification.php.

Referenced by sendCronForumNotification().

354  : void
355  {
356  $tmp_provider = new ilForumCronNotificationDataProvider($row, $notification_type, $this->notificationCache);
357  self::$providerObject[$provider_id . '_' . $notification_type] = $tmp_provider;
358  self::$providerObject[$provider_id . '_' . $notification_type]->addRecipient((int) $row['user_id']);
359  }
+ Here is the caller graph for this function:

◆ addToExternalSettingsForm()

ilForumCronNotification::addToExternalSettingsForm ( int  $a_form_id,
array &  $a_fields,
bool  $a_is_active 
)

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

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

366  : void
367  {
369  $a_fields['cron_forum_notification'] = $a_is_active ?
370  $this->lng->txt('enabled') :
371  $this->lng->txt('disabled');
372  }
373  }
+ Here is the call graph for this function:

◆ createForumPostSql()

ilForumCronNotification::createForumPostSql ( string  $condition)
private

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

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

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

◆ createSelectOfDeletionNotificationsSql()

ilForumCronNotification::createSelectOfDeletionNotificationsSql ( )
private

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

Referenced by sendNotificationForDeletedPosts(), and sendNotificationForDeletedThreads().

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

◆ existsProviderObject()

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

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

Referenced by sendCronForumNotification().

346  : bool
347  {
348  return isset(self::$providerObject[$provider_id . '_' . $notification_type]);
349  }
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilForumCronNotification::getDefaultScheduleType ( )

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

88  {
89  return CronJobScheduleType::SCHEDULE_TYPE_IN_HOURS;
90  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getDefaultScheduleValue()

ilForumCronNotification::getDefaultScheduleValue ( )

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

92  : ?int
93  {
94  return 1;
95  }

◆ getDescription()

ilForumCronNotification::getDescription ( )

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

References ILIAS\Repository\lng().

82  : string
83  {
84  return $this->lng->txt('cron_forum_notification_crob_desc');
85  }
+ Here is the call graph for this function:

◆ getFirstAccessibleRefIdBUserAndObjId()

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

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

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

Referenced by sendCronForumNotification().

207  : int
208  {
209  global $DIC;
210  $ilAccess = $DIC->access();
211 
212  if (!array_key_exists($a_user_id, self::$accessible_ref_ids_by_user)) {
213  self::$accessible_ref_ids_by_user[$a_user_id] = [];
214  }
215 
216  if (!array_key_exists($a_obj_id, self::$accessible_ref_ids_by_user[$a_user_id])) {
217  $accessible_ref_id = 0;
218  foreach ($this->getRefIdsByObjId($a_obj_id) as $ref_id) {
219  if ($ilAccess->checkAccessOfUser($a_user_id, 'read', '', $ref_id)) {
220  $accessible_ref_id = $ref_id;
221  break;
222  }
223  }
224  self::$accessible_ref_ids_by_user[$a_user_id][$a_obj_id] = $accessible_ref_id;
225  }
226 
227  return (int) self::$accessible_ref_ids_by_user[$a_user_id][$a_obj_id];
228  }
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilForumCronNotification::getId ( )

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

Referenced by keepAlive().

72  : string
73  {
74  return 'frm_notification';
75  }
+ Here is the caller graph for this function:

◆ getRefIdsByObjId()

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

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

References ilObject\_getAllReferences().

Referenced by getFirstAccessibleRefIdBUserAndObjId().

198  : array
199  {
200  if (!array_key_exists($a_obj_id, self::$ref_ids_by_obj_id)) {
201  self::$ref_ids_by_obj_id[$a_obj_id] = array_values(ilObject::_getAllReferences($a_obj_id));
202  }
203 
204  return self::$ref_ids_by_obj_id[$a_obj_id];
205  }
static _getAllReferences(int $id)
get all reference ids for object ID
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitle()

ilForumCronNotification::getTitle ( )

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

References ILIAS\Repository\lng().

77  : string
78  {
79  return $this->lng->txt('cron_forum_notification');
80  }
+ Here is the call graph for this function:

◆ hasAutoActivation()

ilForumCronNotification::hasAutoActivation ( )

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

97  : bool
98  {
99  return false;
100  }

◆ hasCustomSettings()

ilForumCronNotification::hasCustomSettings ( )

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

107  : bool
108  {
109  return true;
110  }

◆ hasFlexibleSchedule()

ilForumCronNotification::hasFlexibleSchedule ( )

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

102  : bool
103  {
104  return true;
105  }

◆ keepAlive()

ilForumCronNotification::keepAlive ( )

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

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

Referenced by sendCronForumNotification(), sendDeleteNotifications(), and sendNotification().

112  : void
113  {
114  $this->logger->debug('Sending ping to cron manager ...');
115  $this->cronManager->ping($this->getId());
116  $this->logger->debug(sprintf('Current memory usage: %s', memory_get_usage(true)));
117  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetProviderCache()

ilForumCronNotification::resetProviderCache ( )
private

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

Referenced by sendCronForumNotification().

361  : void
362  {
363  self::$providerObject = [];
364  }
+ Here is the caller graph for this function:

◆ run()

ilForumCronNotification::run ( )

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

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

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

◆ saveCustomSettings()

ilForumCronNotification::saveCustomSettings ( ilPropertyFormGUI  $a_form)

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

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

410  : bool
411  {
412  $this->settings->set(
413  'max_notification_age',
414  $this->refinery->in()->series([
415  $this->refinery->byTrying([
416  $this->refinery->kindlyTo()->int(),
417  $this->refinery->in()->series([
418  $this->refinery->kindlyTo()->float(),
419  $this->refinery->kindlyTo()->int()
420  ])
421  ]),
422  $this->refinery->kindlyTo()->string()
423  ])->transform($a_form->getInput('max_notification_age'))
424  );
425  return true;
426  }
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-...
+ Here is the call graph for this function:

◆ sendCronForumNotification()

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

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

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

Referenced by sendDeleteNotifications(), and sendNotification().

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

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

Referenced by sendNotificationForDeletedPosts(), and sendNotificationForDeletedThreads().

582  : void {
583  $numRows = $this->ilDB->numRows($res);
584  if ($numRows > 0) {
585  $this->logger->info(sprintf('Sending notifications for %s "%s" events ...', $numRows, $actionDescription));
586  $this->sendCronForumNotification($res, $notificationType);
587  if (self::$deleted_ids_cache !== []) {
588  $this->ilDB->manipulate(
589  'DELETE FROM frm_posts_deleted WHERE ' . $this->ilDB->in(
590  'deleted_id',
591  self::$deleted_ids_cache,
592  false,
594  )
595  );
596  $this->logger->info('Deleted obsolete entries of table "' . $action . '" ...');
597  }
598  $this->logger->info(sprintf('Sent notifications for %s ...', $actionDescription));
599  }
600 
601  $this->keepAlive();
602  }
sendCronForumNotification(ilDBStatement $res, int $notification_type)
+ 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 565 of file class.ilForumCronNotification.php.

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

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

565  : void
566  {
567  $numRows = $this->ilDB->numRows($res);
568  if ($numRows > 0) {
569  $this->logger->info(sprintf('Sending notifications for %s "%s" events ...', $numRows, $actionName));
570  $this->sendCronForumNotification($res, $notificationType);
571  $this->logger->info(sprintf('Sent notifications for %s ...', $actionName));
572  }
573 
574  $this->keepAlive();
575  }
sendCronForumNotification(ilDBStatement $res, int $notification_type)
+ 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 479 of file class.ilForumCronNotification.php.

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

Referenced by run().

479  : void
480  {
481  $condition = '
482  frm_notification.interested_events & %s AND
483  frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND
484  (frm_posts.pos_cens_date >= %s AND frm_posts.pos_cens_date > frm_posts.pos_activation_date ) ';
485  $types = [
490  ];
491  $values = [ilForumNotificationEvents::CENSORED, 1, 1, $threshold_date];
492 
493  $res = $this->ilDB->queryF(
494  $this->createForumPostSql($condition),
495  $types,
496  $values
497  );
498 
499  $this->sendNotification(
500  $res,
501  'censored posting',
503  );
504  }
$res
Definition: ltiservices.php:69
sendNotification(ilDBStatement $res, string $actionName, int $notificationType)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendNotificationForDeletedPosts()

ilForumCronNotification::sendNotificationForDeletedPosts ( )
private

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

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

Referenced by run().

549  : void
550  {
551  $res = $this->ilDB->queryF(
555  );
556 
558  $res,
559  'frm_posts_deleted',
560  'deleted postings',
562  );
563  }
$res
Definition: ltiservices.php:69
sendDeleteNotifications(ilDBStatement $res, string $action, string $actionDescription, int $notificationType)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendNotificationForDeletedThreads()

ilForumCronNotification::sendNotificationForDeletedThreads ( )
private

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

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

Referenced by run().

533  : void
534  {
535  $res = $this->ilDB->queryF(
539  );
540 
542  $res,
543  'frm_threads_deleted',
544  'deleted threads',
546  );
547  }
$res
Definition: ltiservices.php:69
sendDeleteNotifications(ilDBStatement $res, string $action, string $actionDescription, int $notificationType)
+ 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 428 of file class.ilForumCronNotification.php.

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

Referenced by run().

428  : void
429  {
430  $condition = '
431 
432  frm_posts.pos_status = %s AND (
433  (frm_posts.pos_date >= %s AND frm_posts.pos_date = frm_posts.pos_activation_date) OR
434  (frm_posts.pos_activation_date >= %s AND frm_posts.pos_date < frm_posts.pos_activation_date)
435  ) ';
437  $values = [1, $threshold_date, $threshold_date];
438 
439  $res = $this->ilDB->queryF(
440  $this->createForumPostSql($condition),
441  $types,
442  $values
443  );
444 
445  $this->sendNotification(
446  $res,
447  'new posting',
449  );
450  }
$res
Definition: ltiservices.php:69
sendNotification(ilDBStatement $res, string $actionName, int $notificationType)
+ 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 506 of file class.ilForumCronNotification.php.

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

Referenced by run().

506  : void
507  {
508  $condition = '
509  frm_notification.interested_events & %s AND
510  frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND
511  (frm_posts.pos_cens_date >= %s AND frm_posts.pos_cens_date > frm_posts.pos_activation_date ) ';
512  $types = [
517  ];
518  $values = [ilForumNotificationEvents::UNCENSORED, 0, 1, $threshold_date];
519 
520  $res = $this->ilDB->queryF(
521  $this->createForumPostSql($condition),
522  $types,
523  $values
524  );
525 
526  $this->sendNotification(
527  $res,
528  'uncensored posting',
530  );
531  }
$res
Definition: ltiservices.php:69
sendNotification(ilDBStatement $res, string $actionName, int $notificationType)
+ 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 452 of file class.ilForumCronNotification.php.

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

Referenced by run().

452  : void
453  {
454  $condition = '
455  frm_notification.interested_events & %s AND
456  frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND
457  (frm_posts.pos_update > frm_posts.pos_date AND frm_posts.pos_update >= %s) ';
458  $types = [
463  ];
464  $values = [ilForumNotificationEvents::UPDATED, 0, 1, $threshold_date];
465 
466  $res = $this->ilDB->queryF(
467  $this->createForumPostSql($condition),
468  $types,
469  $values
470  );
471 
472  $this->sendNotification(
473  $res,
474  'updated posting',
476  );
477  }
$res
Definition: ltiservices.php:69
sendNotification(ilDBStatement $res, string $actionName, int $notificationType)
+ 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 40 of file class.ilForumCronNotification.php.

◆ $container_by_frm_ref_id

array ilForumCronNotification::$container_by_frm_ref_id = []
staticprivate

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

◆ $cronManager

ilCronManager ilForumCronNotification::$cronManager
private

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

◆ $deleted_ids_cache

array ilForumCronNotification::$deleted_ids_cache = []
staticprivate

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

◆ $ilDB

ilDBInterface ilForumCronNotification::$ilDB
private

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

◆ $lng

ilLanguage ilForumCronNotification::$lng
private

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

◆ $logger

ilLogger ilForumCronNotification::$logger
private

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

◆ $notificationCache

ilForumNotificationCache ilForumCronNotification::$notificationCache
private

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

◆ $num_sent_messages

int ilForumCronNotification::$num_sent_messages = 0
private

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

◆ $providerObject

array ilForumCronNotification::$providerObject = []
staticprivate

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

◆ $ref_ids_by_obj_id

array ilForumCronNotification::$ref_ids_by_obj_id = []
staticprivate

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

◆ $refinery

ILIAS Refinery Factory ilForumCronNotification::$refinery
private

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

◆ $settings

ilSetting ilForumCronNotification::$settings
private

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

◆ $tree

ilTree ilForumCronNotification::$tree
private

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

◆ DEFAULT_MAX_NOTIFICATION_AGE_IN_DAYS

const ilForumCronNotification::DEFAULT_MAX_NOTIFICATION_AGE_IN_DAYS = 30
private

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

◆ KEEP_ALIVE_CHUNK_SIZE

const ilForumCronNotification::KEEP_ALIVE_CHUNK_SIZE = 25
private

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


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