119 $lng->loadLanguageModule(
'forum');
121 if(!($last_run_datetime = $ilSetting->get(
'cron_forum_notification_last_date')))
123 $last_run_datetime = null;
126 $this->num_sent_messages = 0;
127 $cj_start_date = date(
'Y-m-d H:i:s');
129 if($last_run_datetime != null &&
130 checkDate(date(
'm', strtotime($last_run_datetime)), date(
'd', strtotime($last_run_datetime)), date(
'Y', strtotime($last_run_datetime))))
132 $threshold = max(strtotime($last_run_datetime), strtotime(
'-' . (
int)$this->settings->get(
'max_notification_age', 30) .
' days', time()));
136 $threshold = strtotime(
'-' . (
int)$this->settings->get(
'max_notification_age', 30) .
' days', time());
139 $threshold_date = date(
'Y-m-d H:i:s', $threshold);
140 $new_posts_condition =
' 141 frm_posts.pos_status = %s AND ( 142 (frm_posts.pos_date >= %s AND frm_posts.pos_date = frm_posts.pos_activation_date) OR 143 (frm_posts.pos_activation_date >= %s AND frm_posts.pos_date < frm_posts.pos_activation_date) 145 $types = array(
'integer',
'timestamp',
'timestamp');
146 $values = array(1, $threshold_date, $threshold_date);
149 $res = $ilDB->queryf(
' 150 SELECT frm_threads.thr_subject thr_subject, 151 frm_data.top_name top_name, 152 frm_data.top_frm_fk obj_id, 153 frm_notification.user_id user_id, 154 frm_threads.thr_pk thread_id, 156 FROM frm_notification, frm_posts, frm_threads, frm_data 157 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND '.$new_posts_condition.
' 158 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 159 OR (frm_threads.thr_pk = frm_notification.thread_id 160 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 161 AND frm_posts.pos_display_user_id != frm_notification.user_id 162 ORDER BY frm_posts.pos_date ASC',
167 $numRows = $ilDB->numRows(
$res);
176 $updated_condition =
' 177 frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND 178 (frm_posts.pos_update > frm_posts.pos_date AND frm_posts.pos_update >= %s ) ';
179 $types = array(
'integer',
'integer',
'timestamp');
180 $values = array(0, 1, $threshold_date);
182 $res = $ilDB->queryf(
' 183 SELECT frm_threads.thr_subject thr_subject, 184 frm_data.top_name top_name, 185 frm_data.top_frm_fk obj_id, 186 frm_notification.user_id user_id, 187 frm_threads.thr_pk thread_id, 189 FROM frm_notification, frm_posts, frm_threads, frm_data 190 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND '.$updated_condition.
' 191 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 192 OR (frm_threads.thr_pk = frm_notification.thread_id 193 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 194 AND frm_posts.pos_display_user_id != frm_notification.user_id 195 ORDER BY frm_posts.pos_date ASC',
200 $numRows = $ilDB->numRows(
$res);
207 $censored_condition =
' 208 frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND 209 (frm_posts.pos_cens_date >= %s AND frm_posts.pos_cens_date > frm_posts.pos_activation_date ) ';
210 $types = array(
'integer',
'integer',
'timestamp');
211 $values = array(1, 1, $threshold_date );
213 $res = $ilDB->queryf(
' 214 SELECT frm_threads.thr_subject thr_subject, 215 frm_data.top_name top_name, 216 frm_data.top_frm_fk obj_id, 217 frm_notification.user_id user_id, 218 frm_threads.thr_pk thread_id, 220 FROM frm_notification, frm_posts, frm_threads, frm_data 221 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND '.$censored_condition.
' 222 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 223 OR (frm_threads.thr_pk = frm_notification.thread_id 224 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 225 AND (frm_posts.pos_display_user_id != frm_notification.user_id) 226 ORDER BY frm_posts.pos_date ASC',
231 $numRows = $ilDB->numRows(
$res);
240 $uncensored_condition =
' 241 frm_posts.pos_cens = %s AND frm_posts.pos_status = %s AND 242 ( frm_posts.pos_cens_date >= %s AND frm_posts.pos_cens_date > frm_posts.pos_activation_date )';
243 $types = array(
'integer',
'integer',
'timestamp');
244 $values = array(0, 1, $threshold_date);
246 $res = $ilDB->queryf(
' 247 SELECT frm_threads.thr_subject thr_subject, 248 frm_data.top_name top_name, 249 frm_data.top_frm_fk obj_id, 250 frm_notification.user_id user_id, 251 frm_threads.thr_pk thread_id, 253 FROM frm_notification, frm_posts, frm_threads, frm_data 254 WHERE frm_posts.pos_thr_fk = frm_threads.thr_pk AND '.$uncensored_condition.
' 255 AND ((frm_threads.thr_top_fk = frm_data.top_pk AND frm_data.top_frm_fk = frm_notification.frm_id) 256 OR (frm_threads.thr_pk = frm_notification.thread_id 257 AND frm_data.top_pk = frm_threads.thr_top_fk) ) 258 AND frm_posts.pos_display_user_id != frm_notification.user_id 259 ORDER BY frm_posts.pos_date ASC',
264 $numRows = $ilDB->numRows(
$res);
273 $res = $ilDB->queryF(
' 274 SELECT frm_posts_deleted.thread_title thr_subject, 275 frm_posts_deleted.forum_title top_name, 276 frm_posts_deleted.obj_id obj_id, 277 frm_notification.user_id user_id, 278 frm_posts_deleted.pos_display_user_id, 279 frm_posts_deleted.pos_usr_alias, 280 frm_posts_deleted.deleted_id, 281 frm_posts_deleted.post_date pos_date, 282 frm_posts_deleted.post_title pos_subject, 283 frm_posts_deleted.post_message pos_message 285 FROM frm_notification, frm_posts_deleted 287 WHERE ( frm_posts_deleted.obj_id = frm_notification.frm_id 288 OR frm_posts_deleted.thread_id = frm_notification.thread_id) 289 AND frm_posts_deleted.pos_display_user_id != frm_notification.user_id 290 AND frm_posts_deleted.is_thread_deleted = %s 291 ORDER BY frm_posts_deleted.post_date ASC',
292 array(
'integer'), array(1));
293 $numRows = $ilDB->numRows(
$res);
297 if(count(self::$deleted_ids_cache) > 0)
299 $ilDB->manipulate(
'DELETE FROM frm_posts_deleted WHERE '. $ilDB->in(
'deleted_id', self::$deleted_ids_cache,
false,
'integer'));
300 $ilLog->write(__METHOD__ .
':DELETED ENTRIES: frm_posts_deleted');
307 $res = $ilDB->queryF(
' 308 SELECT frm_posts_deleted.thread_title thr_subject, 309 frm_posts_deleted.forum_title top_name, 310 frm_posts_deleted.obj_id obj_id, 311 frm_notification.user_id user_id, 312 frm_posts_deleted.pos_display_user_id, 313 frm_posts_deleted.pos_usr_alias, 314 frm_posts_deleted.deleted_id, 315 frm_posts_deleted.post_date pos_date, 316 frm_posts_deleted.post_title pos_subject, 317 frm_posts_deleted.post_message pos_message 319 FROM frm_notification, frm_posts_deleted 321 WHERE ( frm_posts_deleted.obj_id = frm_notification.frm_id 322 OR frm_posts_deleted.thread_id = frm_notification.thread_id) 323 AND frm_posts_deleted.pos_display_user_id != frm_notification.user_id 324 AND frm_posts_deleted.is_thread_deleted = %s 325 ORDER BY frm_posts_deleted.post_date ASC',
326 array(
'integer'), array(0));
328 $numRows = $ilDB->numRows(
$res);
332 if(count(self::$deleted_ids_cache) > 0)
334 $ilDB->manipulate(
'DELETE FROM frm_posts_deleted WHERE '. $ilDB->in(
'deleted_id', self::$deleted_ids_cache,
false,
'integer'));
335 $ilLog->write(__METHOD__ .
':DELETED ENTRIES: frm_posts_deleted');
339 $ilSetting->set(
'cron_forum_notification_last_date', $cj_start_date);
341 $mess =
'Sent '.$this->num_sent_messages.
' messages.';
342 $ilLog->write(__METHOD__.
': '.$mess);
345 if($this->num_sent_messages)
const TYPE_THREAD_DELETED
Cron job result data container.
const TYPE_POST_UNCENSORED