124 $this->logger =
$GLOBALS[
'DIC']->logger()->frm();
128 $lng->loadLanguageModule(
'forum');
130 $this->logger->info(
'Started forum notification job ...');
132 if(!($last_run_datetime = $ilSetting->get(
'cron_forum_notification_last_date')))
134 $last_run_datetime = null;
137 $this->num_sent_messages = 0;
138 $cj_start_date =
date(
'Y-m-d H:i:s');
140 if($last_run_datetime != null &&
141 checkDate(
date(
'm', strtotime($last_run_datetime)),
date(
'd', strtotime($last_run_datetime)),
date(
'Y', strtotime($last_run_datetime))))
143 $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);
162 $res = $ilDB->queryf(
' 163 SELECT frm_threads.thr_subject thr_subject, 164 frm_data.top_name top_name, 165 frm_data.top_frm_fk obj_id, 166 frm_notification.user_id user_id, 167 frm_threads.thr_pk thread_id, 169 FROM frm_notification, frm_posts, frm_threads, frm_data 170 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND '.$new_posts_condition.
' 171 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 172 OR (frm_threads.thr_pk = frm_notification.thread_id 173 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 174 AND frm_posts.pos_display_user_id != frm_notification.user_id 175 ORDER BY frm_posts.pos_date ASC',
180 $numRows = $ilDB->numRows(
$res);
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);
197 $res = $ilDB->queryf(
' 198 SELECT frm_threads.thr_subject thr_subject, 199 frm_data.top_name top_name, 200 frm_data.top_frm_fk obj_id, 201 frm_notification.user_id user_id, 202 frm_threads.thr_pk thread_id, 204 FROM frm_notification, frm_posts, frm_threads, frm_data 205 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND '.$updated_condition.
' 206 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 207 OR (frm_threads.thr_pk = frm_notification.thread_id 208 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 209 AND frm_posts.pos_display_user_id != frm_notification.user_id 210 ORDER BY frm_posts.pos_date ASC',
215 $numRows = $ilDB->numRows(
$res);
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);
232 $res = $ilDB->queryf(
' 233 SELECT frm_threads.thr_subject thr_subject, 234 frm_data.top_name top_name, 235 frm_data.top_frm_fk obj_id, 236 frm_notification.user_id user_id, 237 frm_threads.thr_pk thread_id, 239 FROM frm_notification, frm_posts, frm_threads, frm_data 240 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND '.$censored_condition.
' 241 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 242 OR (frm_threads.thr_pk = frm_notification.thread_id 243 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 244 AND (frm_posts.pos_display_user_id != frm_notification.user_id) 245 ORDER BY frm_posts.pos_date ASC',
250 $numRows = $ilDB->numRows(
$res);
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);
267 $res = $ilDB->queryf(
' 268 SELECT frm_threads.thr_subject thr_subject, 269 frm_data.top_name top_name, 270 frm_data.top_frm_fk obj_id, 271 frm_notification.user_id user_id, 272 frm_threads.thr_pk thread_id, 274 FROM frm_notification, frm_posts, frm_threads, frm_data 275 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND '.$uncensored_condition.
' 276 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 277 OR (frm_threads.thr_pk = frm_notification.thread_id 278 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 279 AND frm_posts.pos_display_user_id != frm_notification.user_id 280 ORDER BY frm_posts.pos_date ASC',
285 $numRows = $ilDB->numRows(
$res);
288 $this->logger->info(sprintf(
'Sending notifications for %s "uncensored posting" events ...', $numRows));
290 $this->logger->info(sprintf(
'Sent notifications for uncensored postings ...'));
296 $res = $ilDB->queryF(
' 297 SELECT frm_posts_deleted.thread_title thr_subject, 298 frm_posts_deleted.forum_title top_name, 299 frm_posts_deleted.obj_id obj_id, 300 frm_notification.user_id user_id, 301 frm_posts_deleted.pos_display_user_id, 302 frm_posts_deleted.pos_usr_alias, 303 frm_posts_deleted.deleted_id, 304 frm_posts_deleted.post_date pos_date, 305 frm_posts_deleted.post_title pos_subject, 306 frm_posts_deleted.post_message pos_message 308 FROM frm_notification, frm_posts_deleted 310 WHERE ( frm_posts_deleted.obj_id = frm_notification.frm_id 311 OR frm_posts_deleted.thread_id = frm_notification.thread_id) 312 AND frm_posts_deleted.pos_display_user_id != frm_notification.user_id 313 AND frm_posts_deleted.is_thread_deleted = %s 314 ORDER BY frm_posts_deleted.post_date ASC',
316 $numRows = $ilDB->numRows(
$res);
319 $this->logger->info(sprintf(
'Sending notifications for %s "deleted threads" events ...', $numRows));
321 if(count(self::$deleted_ids_cache) > 0)
323 $ilDB->manipulate(
'DELETE FROM frm_posts_deleted WHERE '. $ilDB->in(
'deleted_id', self::$deleted_ids_cache,
false,
'integer'));
324 $this->logger->info(
'Deleted obsolete entries of table "frm_posts_deleted" ...');
326 $this->logger->info(sprintf(
'Sent notifications for deleted threads ...'));
332 $res = $ilDB->queryF(
' 333 SELECT frm_posts_deleted.thread_title thr_subject, 334 frm_posts_deleted.forum_title top_name, 335 frm_posts_deleted.obj_id obj_id, 336 frm_notification.user_id user_id, 337 frm_posts_deleted.pos_display_user_id, 338 frm_posts_deleted.pos_usr_alias, 339 frm_posts_deleted.deleted_id, 340 frm_posts_deleted.post_date pos_date, 341 frm_posts_deleted.post_title pos_subject, 342 frm_posts_deleted.post_message pos_message 344 FROM frm_notification, frm_posts_deleted 346 WHERE ( frm_posts_deleted.obj_id = frm_notification.frm_id 347 OR frm_posts_deleted.thread_id = frm_notification.thread_id) 348 AND frm_posts_deleted.pos_display_user_id != frm_notification.user_id 349 AND frm_posts_deleted.is_thread_deleted = %s 350 ORDER BY frm_posts_deleted.post_date ASC',
353 $numRows = $ilDB->numRows(
$res);
356 $this->logger->info(sprintf(
'Sending notifications for %s "deleted postings" events ...', $numRows));
358 if(count(self::$deleted_ids_cache) > 0)
360 $ilDB->manipulate(
'DELETE FROM frm_posts_deleted WHERE '. $ilDB->in(
'deleted_id', self::$deleted_ids_cache,
false,
'integer'));
361 $this->logger->info(
'Deleted entries from table "frm_posts_deleted" ...');
363 $this->logger->info(sprintf(
'Sent notifications for deleted postings ...'));
366 $ilSetting->set(
'cron_forum_notification_last_date', $cj_start_date);
368 $mess =
'Sent '.$this->num_sent_messages.
' messages.';
370 $this->logger->info($mess);
371 $this->logger->info(
'Finished forum notification job');
374 if($this->num_sent_messages)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const TYPE_THREAD_DELETED
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