ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilForumCronNotification Class Reference

Forum notifications. More...

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

Public Member Functions

 __construct ()
 
 getId ()
 Get id. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 hasCustomSettings ()
 
 keepAlive ()
 
 run ()
 
 existsProviderObject ($post_id)
 
 activationWasToggled ($a_currently_active)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $a_value)
 Update current schedule (if flexible) More...
 
 getValidScheduleTypes ()
 Get all available schedule types. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Data Fields

const KEEP_ALIVE_CHUNK_SIZE = 25
 
- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 

Static Public Attributes

static $providerObject = array()
 

Protected Member Functions

 getRefIdsByObjId ($a_obj_id)
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Protected Attributes

 $settings
 
 $num_sent_messages = 0
 

Static Protected Attributes

static $deleted_ids_cache = array()
 
static $ref_ids_by_obj_id = array()
 
static $accessible_ref_ids_by_user = array()
 

Private Member Functions

 addProviderObject ($row)
 
 resetProviderCache ()
 

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 13 of file class.ilForumCronNotification.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumCronNotification::__construct ( )

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

51 {
52 $this->settings = new ilSetting('frma');
53 }
ILIAS Setting Class.

Member Function Documentation

◆ activationWasToggled()

ilForumCronNotification::activationWasToggled (   $a_currently_active)
Parameters
bool$a_currently_active

Reimplemented from ilCronJob.

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

526 {
527 global $ilSetting;
528
529 // propagate cron-job setting to object setting
530 if((bool)$a_currently_active)
531 {
532 $ilSetting->set('forum_notification', 2);
533 }
534 else
535 {
536 $ilSetting->set('forum_notification', 1);
537 }
538 }
global $ilSetting
Definition: privfeed.php:40

References $ilSetting.

◆ addProviderObject()

ilForumCronNotification::addProviderObject (   $row)
private
Parameters
$row

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

485 {
486 $tmp_provider = new ilForumCronNotificationDataProvider($row);
487
488 self::$providerObject[$row['pos_pk']] = $tmp_provider;
489 self::$providerObject[$row['pos_pk']]->addRecipient($row['user_id']);
490 }

References $row.

◆ existsProviderObject()

ilForumCronNotification::existsProviderObject (   $post_id)
Parameters
$post_id
Returns
bool

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

473 {
474 if(isset(self::$providerObject[$post_id]))
475 {
476 return true;
477 }
478 return false;
479 }

◆ getDefaultScheduleType()

ilForumCronNotification::getDefaultScheduleType ( )

Get schedule type.

Returns
int

Reimplemented from ilCronJob.

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

75 {
77 }
const SCHEDULE_TYPE_IN_HOURS

References ilCronJob\SCHEDULE_TYPE_IN_HOURS.

◆ getDefaultScheduleValue()

ilForumCronNotification::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

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

80 {
81 return 1;
82 }

◆ getDescription()

ilForumCronNotification::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

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

68 {
69 global $lng;
70
71 return $lng->txt("cron_forum_notification_crob_desc");
72 }
global $lng
Definition: privfeed.php:40

References $lng.

◆ getId()

ilForumCronNotification::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

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

56 {
57 return "frm_notification";
58 }

Referenced by keepAlive().

+ Here is the caller graph for this function:

◆ getRefIdsByObjId()

ilForumCronNotification::getRefIdsByObjId (   $a_obj_id)
protected
Parameters
int$a_obj_id
Returns
array

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

359 {
360 if(!array_key_exists($a_obj_id, self::$ref_ids_by_obj_id))
361 {
362 self::$ref_ids_by_obj_id[$a_obj_id] = ilObject::_getAllReferences($a_obj_id);
363 }
364
365 return (array)self::$ref_ids_by_obj_id[$a_obj_id];
366 }
static _getAllReferences($a_id)
get all reference ids of object

References ilObject\_getAllReferences().

+ Here is the call graph for this function:

◆ getTitle()

ilForumCronNotification::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

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

61 {
62 global $lng;
63
64 return $lng->txt("cron_forum_notification");
65 }

References $lng.

◆ hasAutoActivation()

ilForumCronNotification::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

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

85 {
86 return false;
87 }

◆ hasCustomSettings()

ilForumCronNotification::hasCustomSettings ( )
Returns
bool

Reimplemented from ilCronJob.

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

98 {
99 return true;
100 }

◆ hasFlexibleSchedule()

ilForumCronNotification::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

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

90 {
91 return true;
92 }

◆ keepAlive()

ilForumCronNotification::keepAlive ( )

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

106 {
107 \ilCronManager::ping($this->getId());
108 }
static ping($a_job_id)
Keep cron job alive.

References getId(), and ilCronManager\ping().

Referenced by run().

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

◆ resetProviderCache()

ilForumCronNotification::resetProviderCache ( )
private

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

496 {
497 self::$providerObject = array();
498 }

◆ run()

ilForumCronNotification::run ( )
Returns
ilCronJobResult

Reimplemented from ilCronJob.

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

114 {
115 global $ilDB, $ilLog, $ilSetting, $lng;
116
118
119 $lng->loadLanguageModule('forum');
120
121 if(!($last_run_datetime = $ilSetting->get('cron_forum_notification_last_date')))
122 {
123 $last_run_datetime = null;
124 }
125
126 $this->num_sent_messages = 0;
127 $cj_start_date = date('Y-m-d H:i:s');
128
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))))
131 {
132 $threshold = max(strtotime($last_run_datetime), strtotime('-' . (int)$this->settings->get('max_notification_age', 30) . ' days', time()));
133 }
134 else
135 {
136 $threshold = strtotime('-' . (int)$this->settings->get('max_notification_age', 30) . ' days', time());
137 }
138
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)
144 ) ';
145 $types = array('integer', 'timestamp', 'timestamp');
146 $values = array(1, $threshold_date, $threshold_date);
147
148 /*** new posts ***/
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,
155 frm_posts.*
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',
163 $types,
164 $values
165 );
166
167 $numRows = $ilDB->numRows($res);
168 if($numRows > 0)
169 {
170 $this->sendCronForumNotification($res, ilForumMailNotification::TYPE_POST_NEW);
171 }
172
173 $this->keepAlive();
174
175 /*** updated posts ***/
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);
181
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,
188 frm_posts.*
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',
196 $types,
197 $values
198 );
199
200 $numRows = $ilDB->numRows($res);
201 if($numRows > 0)
202 {
203 $this->sendCronForumNotification($res, ilForumMailNotification::TYPE_POST_UPDATED);
204 }
205
206 /*** censored posts ***/
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 );
212
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,
219 frm_posts.*
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',
227 $types,
228 $values
229 );
230
231 $numRows = $ilDB->numRows($res);
232 if($numRows > 0)
233 {
234 $this->sendCronForumNotification($res, ilForumMailNotification::TYPE_POST_CENSORED);
235 }
236
237 $this->keepAlive();
238
239 /*** uncensored posts ***/
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);
245
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,
252 frm_posts.*
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',
260 $types,
261 $values
262 );
263
264 $numRows = $ilDB->numRows($res);
265 if($numRows > 0)
266 {
267 $this->sendCronForumNotification($res, ilForumMailNotification::TYPE_POST_UNCENSORED);
268 }
269
270 $this->keepAlive();
271
272 /*** deleted threads ***/
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
284
285 FROM frm_notification, frm_posts_deleted
286
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);
294 if($numRows > 0)
295 {
296 $this->sendCronForumNotification($res, ilForumMailNotification::TYPE_THREAD_DELETED);
297 if(count(self::$deleted_ids_cache) > 0)
298 {
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');
301 }
302 }
303
304 $this->keepAlive();
305
306 /*** deleted posts ***/
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
318
319 FROM frm_notification, frm_posts_deleted
320
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));
327
328 $numRows = $ilDB->numRows($res);
329 if($numRows > 0)
330 {
331 $this->sendCronForumNotification($res, ilForumMailNotification::TYPE_POST_DELETED);
332 if(count(self::$deleted_ids_cache) > 0)
333 {
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');
336 }
337 }
338
339 $ilSetting->set('cron_forum_notification_last_date', $cj_start_date);
340
341 $mess = 'Sent '.$this->num_sent_messages.' messages.';
342 $ilLog->write(__METHOD__.': '.$mess);
343
344 $result = new ilCronJobResult();
345 if($this->num_sent_messages)
346 {
348 $result->setMessage($mess);
349 };
350 $result->setStatus($status);
351 return $result;
352 }
$result
Cron job result data container.
global $ilDB

References $ilDB, $ilLog, $ilSetting, $lng, $res, $result, keepAlive(), ilCronJobResult\STATUS_NO_ACTION, ilCronJobResult\STATUS_OK, ilForumMailNotification\TYPE_POST_CENSORED, ilForumMailNotification\TYPE_POST_DELETED, ilForumMailNotification\TYPE_POST_NEW, ilForumMailNotification\TYPE_POST_UNCENSORED, ilForumMailNotification\TYPE_POST_UPDATED, and ilForumMailNotification\TYPE_THREAD_DELETED.

+ Here is the call graph for this function:

◆ saveCustomSettings()

ilForumCronNotification::saveCustomSettings ( ilPropertyFormGUI  $a_form)
Parameters
ilPropertyFormGUI$a_form
Returns
bool

Reimplemented from ilCronJob.

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

569 {
570 $this->settings->set('max_notification_age', $a_form->getInput('max_notification_age'));
571 return true;
572 }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.

References ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

Field Documentation

◆ $accessible_ref_ids_by_user

ilForumCronNotification::$accessible_ref_ids_by_user = array()
staticprotected

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

◆ $deleted_ids_cache

ilForumCronNotification::$deleted_ids_cache = array()
staticprotected

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

◆ $num_sent_messages

ilForumCronNotification::$num_sent_messages = 0
protected

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

◆ $providerObject

ilForumCronNotification::$providerObject = array()
static

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

◆ $ref_ids_by_obj_id

ilForumCronNotification::$ref_ids_by_obj_id = array()
staticprotected

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

◆ $settings

ilForumCronNotification::$settings
protected

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

◆ KEEP_ALIVE_CHUNK_SIZE

const ilForumCronNotification::KEEP_ALIVE_CHUNK_SIZE = 25

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


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