124 $ilDB = $DIC->database();
126 $lng = $DIC->language();
128 $this->logger = $DIC->logger()->frm();
132 $lng->loadLanguageModule(
'forum');
134 $this->logger->info(
'Started forum notification job ...');
136 if (!($last_run_datetime =
$ilSetting->get(
'cron_forum_notification_last_date'))) {
137 $last_run_datetime = null;
140 $this->num_sent_messages = 0;
141 $cj_start_date =
date(
'Y-m-d H:i:s');
143 if ($last_run_datetime != null &&
144 checkDate(
date(
'm', strtotime($last_run_datetime)),
date(
'd', strtotime($last_run_datetime)),
date(
'Y', strtotime($last_run_datetime)))) {
145 $threshold = max(strtotime($last_run_datetime), strtotime(
'-' . (
int) $this->
settings->get(
'max_notification_age', 30) .
' days',
time()));
147 $threshold = strtotime(
'-' . (
int) $this->
settings->get(
'max_notification_age', 30) .
' days',
time());
150 $this->logger->info(sprintf(
'Threshold for forum event determination is: %s',
date(
'Y-m-d H:i:s', $threshold)));
152 $threshold_date =
date(
'Y-m-d H:i:s', $threshold);
153 $new_posts_condition =
' 154 frm_posts.pos_status = %s AND ( 155 (frm_posts.pos_date >= %s AND frm_posts.pos_date = frm_posts.pos_activation_date) OR 156 (frm_posts.pos_activation_date >= %s AND frm_posts.pos_date < frm_posts.pos_activation_date) 158 $types =
array(
'integer',
'timestamp',
'timestamp');
159 $values =
array(1, $threshold_date, $threshold_date);
164 SELECT frm_threads.thr_subject thr_subject, 165 frm_data.top_name top_name, 166 frm_data.top_frm_fk obj_id, 167 frm_notification.user_id user_id, 168 frm_threads.thr_pk thread_id, 170 FROM frm_notification, frm_posts, frm_threads, frm_data 171 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND ' . $new_posts_condition .
' 172 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 173 OR (frm_threads.thr_pk = frm_notification.thread_id 174 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 175 AND frm_posts.pos_display_user_id != frm_notification.user_id 176 ORDER BY frm_posts.pos_date ASC',
183 $this->logger->info(sprintf(
'Sending notifications for %s "new posting" events ...', $numRows));
185 $this->logger->info(sprintf(
'Sent notifications for new postings ...'));
191 $updated_condition =
' 192 frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND 193 (frm_posts.pos_update > frm_posts.pos_date AND frm_posts.pos_update >= %s) ';
194 $types =
array(
'integer',
'integer',
'timestamp');
195 $values =
array(0, 1, $threshold_date);
199 SELECT frm_threads.thr_subject thr_subject, 200 frm_data.top_name top_name, 201 frm_data.top_frm_fk obj_id, 202 frm_notification.user_id user_id, 203 frm_threads.thr_pk thread_id, 205 FROM frm_notification, frm_posts, frm_threads, frm_data 206 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND ' . $updated_condition .
' 207 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 208 OR (frm_threads.thr_pk = frm_notification.thread_id 209 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 210 AND frm_posts.pos_display_user_id != frm_notification.user_id 211 ORDER BY frm_posts.pos_date ASC',
218 $this->logger->info(sprintf(
'Sending notifications for %s "updated posting" events ...', $numRows));
220 $this->logger->info(sprintf(
'Sent notifications for updated postings ...'));
226 $censored_condition =
' 227 frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND 228 (frm_posts.pos_cens_date >= %s AND frm_posts.pos_cens_date > frm_posts.pos_activation_date ) ';
229 $types =
array(
'integer',
'integer',
'timestamp');
230 $values =
array(1, 1, $threshold_date);
234 SELECT frm_threads.thr_subject thr_subject, 235 frm_data.top_name top_name, 236 frm_data.top_frm_fk obj_id, 237 frm_notification.user_id user_id, 238 frm_threads.thr_pk thread_id, 240 FROM frm_notification, frm_posts, frm_threads, frm_data 241 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND ' . $censored_condition .
' 242 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 243 OR (frm_threads.thr_pk = frm_notification.thread_id 244 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 245 AND (frm_posts.pos_display_user_id != frm_notification.user_id) 246 ORDER BY frm_posts.pos_date ASC',
253 $this->logger->info(sprintf(
'Sending notifications for %s "censored posting" events ...', $numRows));
255 $this->logger->info(sprintf(
'Sent notifications for new censored ...'));
261 $uncensored_condition =
' 262 frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND 263 (frm_posts.pos_cens_date >= %s AND frm_posts.pos_cens_date > frm_posts.pos_activation_date ) ';
264 $types =
array(
'integer',
'integer',
'timestamp');
265 $values =
array(0, 1, $threshold_date);
269 SELECT frm_threads.thr_subject thr_subject, 270 frm_data.top_name top_name, 271 frm_data.top_frm_fk obj_id, 272 frm_notification.user_id user_id, 273 frm_threads.thr_pk thread_id, 275 FROM frm_notification, frm_posts, frm_threads, frm_data 276 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND ' . $uncensored_condition .
' 277 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 278 OR (frm_threads.thr_pk = frm_notification.thread_id 279 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 280 AND frm_posts.pos_display_user_id != frm_notification.user_id 281 ORDER BY frm_posts.pos_date ASC',
288 $this->logger->info(sprintf(
'Sending notifications for %s "uncensored posting" events ...', $numRows));
290 $this->logger->info(sprintf(
'Sent notifications for uncensored postings ...'));
298 SELECT frm_posts_deleted.thread_title thr_subject, 299 frm_posts_deleted.forum_title top_name, 300 frm_posts_deleted.obj_id obj_id, 301 frm_notification.user_id user_id, 302 frm_posts_deleted.pos_display_user_id, 303 frm_posts_deleted.pos_usr_alias, 304 frm_posts_deleted.deleted_id, 305 frm_posts_deleted.post_date pos_date, 306 frm_posts_deleted.post_title pos_subject, 307 frm_posts_deleted.post_message pos_message, 308 frm_posts_deleted.deleted_by 310 FROM frm_notification, frm_posts_deleted 312 WHERE ( frm_posts_deleted.obj_id = frm_notification.frm_id 313 OR frm_posts_deleted.thread_id = frm_notification.thread_id) 314 AND frm_posts_deleted.pos_display_user_id != frm_notification.user_id 315 AND frm_posts_deleted.is_thread_deleted = %s 316 ORDER BY frm_posts_deleted.post_date ASC',
322 $this->logger->info(sprintf(
'Sending notifications for %s "deleted threads" events ...', $numRows));
324 if (count(self::$deleted_ids_cache) > 0) {
325 $ilDB->manipulate(
'DELETE FROM frm_posts_deleted WHERE ' .
$ilDB->in(
'deleted_id', self::$deleted_ids_cache,
false,
'integer'));
326 $this->logger->info(
'Deleted obsolete entries of table "frm_posts_deleted" ...');
328 $this->logger->info(sprintf(
'Sent notifications for deleted threads ...'));
336 SELECT frm_posts_deleted.thread_title thr_subject, 337 frm_posts_deleted.forum_title top_name, 338 frm_posts_deleted.obj_id obj_id, 339 frm_notification.user_id user_id, 340 frm_posts_deleted.pos_display_user_id, 341 frm_posts_deleted.pos_usr_alias, 342 frm_posts_deleted.deleted_id, 343 frm_posts_deleted.post_date pos_date, 344 frm_posts_deleted.post_title pos_subject, 345 frm_posts_deleted.post_message pos_message, 346 frm_posts_deleted.deleted_by 348 FROM frm_notification, frm_posts_deleted 350 WHERE ( frm_posts_deleted.obj_id = frm_notification.frm_id 351 OR frm_posts_deleted.thread_id = frm_notification.thread_id) 352 AND frm_posts_deleted.pos_display_user_id != frm_notification.user_id 353 AND frm_posts_deleted.is_thread_deleted = %s 354 ORDER BY frm_posts_deleted.post_date ASC',
361 $this->logger->info(sprintf(
'Sending notifications for %s "deleted postings" events ...', $numRows));
363 if (count(self::$deleted_ids_cache) > 0) {
364 $ilDB->manipulate(
'DELETE FROM frm_posts_deleted WHERE ' .
$ilDB->in(
'deleted_id', self::$deleted_ids_cache,
false,
'integer'));
365 $this->logger->info(
'Deleted entries from table "frm_posts_deleted" ...');
367 $this->logger->info(sprintf(
'Sent notifications for deleted postings ...'));
370 $ilSetting->set(
'cron_forum_notification_last_date', $cj_start_date);
372 $mess =
'Sent ' . $this->num_sent_messages .
' messages.';
374 $this->logger->info($mess);
375 $this->logger->info(
'Finished forum notification job');
378 if ($this->num_sent_messages) {
sendCronForumNotification($res, $notification_type)
const TYPE_THREAD_DELETED
foreach($_POST as $key=> $value) $res
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Cron job result data container.
const TYPE_POST_UNCENSORED