ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilForumNotification Class Reference

Class ilForumNotification. More...

+ Collaboration diagram for ilForumNotification:

Public Member Functions

 __construct ($ref_id)
 Constructor public. More...
 
 setNotificationId ($a_notification_id)
 
 getNotificationId ()
 
 setUserId ($a_user_id)
 
 getUserId ()
 
 setForumId ($a_forum_id)
 
 getForumId ()
 
 setThreadId ($a_thread_id)
 
 getThreadId ()
 
 setAdminForce ($a_admin_force)
 
 getAdminForce ()
 
 setUserToggle ($a_user_toggle)
 
 getUserToggle ()
 
 setForumRefId ($a_ref_id)
 
 getForumRefId ()
 
 setUserIdNoti ($a_user_id_noti)
 
 getUserIdNoti ()
 
 isAdminForceNotification ()
 
 isUserToggleNotification ()
 
 insertAdminForce ()
 
 deleteAdminForce ()
 
 deleteUserToggle ()
 
 updateUserToggle ()
 
 update ()
 
 deleteNotificationAllUsers ()
 
 read ()
 
 existsNotification ()
 

Static Public Member Functions

static checkForumsExistsInsert ($ref_id, $user_id=0)
 
static checkForumsExistsDelete ($ref_id, $user_id=0)
 
static getCachedNodeData ($ref_id)
 
static _isParentNodeGrpCrs ($a_ref_id)
 
static _clearForcedForumNotifications ($a_parameter)
 
static checkParentNodeTree ($ref_id)
 
static mergeThreadNotificiations ($merge_source_thread_id, $merge_target_thread_id)
 

Static Protected Attributes

static $node_data_cache = array()
 

Private Attributes

 $notification_id
 
 $user_id
 
 $forum_id
 
 $thread_id
 
 $admin_force
 
 $user_toggle
 
 $ref_id
 

Detailed Description

Class ilForumNotification.

Author
Nadia Ahmad nahma.nosp@m.d@da.nosp@m.tabay.nosp@m..de
Version
$Id:$

Definition at line 16 of file class.ilForumNotification.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumNotification::__construct (   $ref_id)

Constructor public.

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

References $lng, and $ref_id.

36  {
37  global $ilObjDataCache,$lng,$ilias;
38 
39  $this->lng = $lng;
40  $this->ilias = $ilias;
41  $this->ref_id = $ref_id;
42  $this->forum_id = $ilObjDataCache->lookupObjId($ref_id);
43 
44  }
redirection script todo: (a better solution should control the processing via a xml file) ...
global $lng
Definition: privfeed.php:17

Member Function Documentation

◆ _clearForcedForumNotifications()

static ilForumNotification::_clearForcedForumNotifications (   $a_parameter)
static

Definition at line 310 of file class.ilForumNotification.php.

References $forum_id, $ilDB, $ref_id, and array.

311  {
312  global $ilDB, $ilObjDataCache;
313 
314  if(!$a_parameter['tree'] == 'tree')
315  {
316  return;
317  }
318 
319  $ref_id = $a_parameter['source_id'];
320  $is_parent = self::_isParentNodeGrpCrs($ref_id);
321 
322  if($is_parent)
323  {
324  $forum_id = $ilObjDataCache->lookupObjId($ref_id);
325 
326  $ilDB->manipulateF('
327  DELETE FROM frm_notification
328  WHERE frm_id = %s
329  AND admin_force_noti = %s',
330  array('integer','integer'),
331  array($forum_id, 1));
332  }
333  }
Create styles array
The data for the language used.
global $ilDB

◆ _isParentNodeGrpCrs()

static ilForumNotification::_isParentNodeGrpCrs (   $a_ref_id)
static

Definition at line 297 of file class.ilForumNotification.php.

References ilObjectFactory\getInstanceByRefId().

Referenced by ilForumModeratorsGUI\addModerator(), and ilForumModeratorsGUI\detachModeratorRole().

298  {
299  global $tree;
300 
301  $parent_ref_id = $tree->getParentId($a_ref_id);
302  $parent_obj = ilObjectFactory::getInstanceByRefId($parent_ref_id);
303 
304  if($parent_obj->getType() == 'crs' || $parent_obj->getType() == 'grp')
305  return $parent_obj->getType();
306  else return false;
307  }
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkForumsExistsDelete()

static ilForumNotification::checkForumsExistsDelete (   $ref_id,
  $user_id = 0 
)
static

Definition at line 254 of file class.ilForumNotification.php.

References $data, $ilUser, $ref_id, and $user_id.

Referenced by ilPDSelectedItemsBlockGUI\confirmedUnsubscribe().

255  {
256  global $ilUser;
257 
258  $node_data = self::getCachedNodeData($ref_id);
259 
260  include_once 'Modules/Forum/classes/class.ilForumModerators.php';
261 
262  foreach($node_data as $data)
263  {
264  //check frm_properties if frm_noti is enabled
265  $frm_noti = new ilForumNotification($data['ref_id']);
266  $objFrmMods = new ilForumModerators($data['ref_id']);
267  $moderator_ids = $objFrmMods->getCurrentModerators();
268 
269  if($user_id != 0)
270  {
271  $frm_noti->setUserId($user_id);
272  }
273  else $frm_noti->setUserId($ilUser->getId());
274 
275  $frm_noti->setForumId($data['obj_id']);
276  if(!in_array($frm_noti->getUserId(), $moderator_ids))
277  {
278  $frm_noti->deleteAdminForce();
279  }
280  }
281  }
Class ilForumNotification.
$ilUser
Definition: imgupload.php:18
Class ilForumModerators.
+ Here is the caller graph for this function:

◆ checkForumsExistsInsert()

static ilForumNotification::checkForumsExistsInsert (   $ref_id,
  $user_id = 0 
)
static

Definition at line 218 of file class.ilForumNotification.php.

References $admin_force, $data, $ilUser, $ref_id, $user_id, $user_toggle, ilForumProperties\_isAdminForceNoti(), and ilForumProperties\_isUserToggleNoti().

Referenced by ilGroupRegistrationGUI\add(), ilCourseRegistrationGUI\add(), and ilObjCourse\register().

219  {
220  global $ilUser;
221 
222  include_once 'Modules/Forum/classes/class.ilForumProperties.php';
223 
224  $node_data = self::getCachedNodeData($ref_id);
225 
226  foreach($node_data as $data)
227  {
228  //check frm_properties if frm_noti is enabled
229  $frm_noti = new ilForumNotification($data['ref_id']);
230  if($user_id != 0)
231  {
232  $frm_noti->setUserId($user_id);
233  }
234  else $frm_noti->setUserId($ilUser->getId());
235 
237  $frm_noti->setAdminForce($admin_force);
238 
240  if($user_toggle) $frm_noti->setAdminForce(1);
241 
242  if($admin_force == 1 || $user_toggle == 1)
243  {
244  $frm_noti->setUserToggle($user_toggle);
245  $frm_noti->setForumId($data['obj_id']);
246  if($frm_noti->existsNotification() == false)
247  {
248  $frm_noti->insertAdminForce();
249  }
250  }
251  }
252  }
Class ilForumNotification.
static _isUserToggleNoti($a_obj_id)
static _isAdminForceNoti($a_obj_id)
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkParentNodeTree()

static ilForumNotification::checkParentNodeTree (   $ref_id)
static

Definition at line 335 of file class.ilForumNotification.php.

References $ref_id, $result, ilGroupParticipants\_getInstanceByObjId(), ilCourseParticipants\_getInstanceByObjId(), ilForum\_getModerators(), array, and ilObjectFactory\getInstanceByRefId().

336  {
337  global $tree;
338 
339  $parent_ref_id = $tree->getParentId($ref_id);
340  $parent_obj = ilObjectFactory::getInstanceByRefId($parent_ref_id);
341 
342  if($parent_obj->getType() == 'crs')
343  {
344  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
345  $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId());
346  }
347  else if($parent_obj->getType() == 'grp')
348  {
349  include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
350  $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId());
351  }
352 
353  $result = array();
354  if($parent_obj->getType() == 'crs' || $parent_obj->getType() == 'grp')
355  {
356  $moderator_ids = ilForum::_getModerators($ref_id);
357  $admin_ids = $oParticipants->getAdmins();
358  $tutor_ids = $oParticipants->getTutors();
359 
360  $result = array_unique(array_merge($moderator_ids,$admin_ids,$tutor_ids));
361  }
362  return $result;
363  }
$result
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Create styles array
The data for the language used.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getModerators($a_ref_id)
get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)
+ Here is the call graph for this function:

◆ deleteAdminForce()

ilForumNotification::deleteAdminForce ( )

Definition at line 170 of file class.ilForumNotification.php.

References $ilDB, $res, array, getForumId(), and getUserId().

171  {
172  global $ilDB;
173 
174  $res = $ilDB->manipulateF('
175  DELETE FROM frm_notification
176  WHERE user_id = %s
177  AND frm_id = %s
178  AND admin_force_noti = %s
179  AND user_id_noti > %s' ,
180  array('integer', 'integer','integer', 'integer'),
181  array($this->getUserId(), $this->getForumId(), 1, 0));
182  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ deleteNotificationAllUsers()

ilForumNotification::deleteNotificationAllUsers ( )

Definition at line 379 of file class.ilForumNotification.php.

References $ilDB, $res, array, and getForumId().

Referenced by ilObjForumGUI\infoScreenObject().

380  {
381  global $ilDB;
382 
383  $res = $ilDB->manipulateF('
384  DELETE FROM frm_notification
385  WHERE frm_id = %s
386  AND user_id_noti > %s',
387  array('integer', 'integer'),
388  array($this->getForumId(), 0));
389  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteUserToggle()

ilForumNotification::deleteUserToggle ( )

Definition at line 184 of file class.ilForumNotification.php.

References $ilDB, $ilUser, $res, array, getForumId(), and getUserId().

185  {
186  global $ilDB, $ilUser;
187 
188  $res = $ilDB->manipulateF('
189  DELETE FROM frm_notification
190  WHERE user_id = %s
191  AND frm_id = %s
192  AND admin_force_noti = %s
193  AND user_toggle_noti = %s
194  AND user_id_noti > %s' ,
195  array('integer', 'integer','integer','integer', 'integer'),
196  array($this->getUserId(),$this->getForumId(),1,1, 0 ));
197 
198  }
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ existsNotification()

ilForumNotification::existsNotification ( )
Returns
bool

Definition at line 449 of file class.ilForumNotification.php.

References $ilDB, $res, $row, array, getAdminForce(), getForumId(), and getUserId().

450  {
451  global $ilDB;
452 
453  $res = $ilDB->queryF('
454  SELECT * FROM frm_notification
455  WHERE user_id = %s
456  AND frm_id = %s
457  AND admin_force_noti = %s',
458  array('integer', 'integer', 'integer'),
459  array($this->getUserId(), $this->getForumId(), $this->getAdminForce()));
460 
461  if($row = $ilDB->numRows($res) > 0)
462  {
463  return true;
464  }
465  return false;
466  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ getAdminForce()

ilForumNotification::getAdminForce ( )

Definition at line 86 of file class.ilForumNotification.php.

References $admin_force.

Referenced by existsNotification(), insertAdminForce(), and update().

+ Here is the caller graph for this function:

◆ getCachedNodeData()

static ilForumNotification::getCachedNodeData (   $ref_id)
static
Parameters
$ref_id

Definition at line 286 of file class.ilForumNotification.php.

References $ref_id.

287  {
288  if(!array_key_exists($ref_id, self::$node_data_cache))
289  {
290  global $tree;
291  self::$node_data_cache[$ref_id] = $tree->getChildsByType($ref_id, 'frm');
292  }
293 
294  return self::$node_data_cache[$ref_id];
295  }

◆ getForumId()

ilForumNotification::getForumId ( )

◆ getForumRefId()

ilForumNotification::getForumRefId ( )

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

References $ref_id.

106  {
107  return $this->ref_id;
108  }

◆ getNotificationId()

ilForumNotification::getNotificationId ( )

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

References $notification_id.

◆ getThreadId()

ilForumNotification::getThreadId ( )

Definition at line 76 of file class.ilForumNotification.php.

References $thread_id.

77  {
78  return $this->thread_id;
79  }

◆ getUserId()

ilForumNotification::getUserId ( )

◆ getUserIdNoti()

ilForumNotification::getUserIdNoti ( )

Definition at line 116 of file class.ilForumNotification.php.

117  {
118  return $this->user_id_noti;
119  }

◆ getUserToggle()

ilForumNotification::getUserToggle ( )

Definition at line 96 of file class.ilForumNotification.php.

References $user_toggle.

Referenced by insertAdminForce(), update(), and updateUserToggle().

+ Here is the caller graph for this function:

◆ insertAdminForce()

ilForumNotification::insertAdminForce ( )

Definition at line 157 of file class.ilForumNotification.php.

References $ilDB, $ilUser, $res, array, getAdminForce(), getForumId(), getUserId(), and getUserToggle().

158  {
159  global $ilDB, $ilUser;
160 
161  $next_id = $ilDB->nextId('frm_notification');
162  $res = $ilDB->manipulateF('
163  INSERT INTO frm_notification
164  (notification_id, user_id, frm_id, admin_force_noti, user_toggle_noti, user_id_noti)
165  VALUES(%s,%s,%s,%s,%s,%s)',
166  array('integer', 'integer', 'integer', 'integer', 'integer', 'integer'),
167  array($next_id, $this->getUserId(), $this->getForumId(), $this->getAdminForce(), $this->getUserToggle(), $ilUser->getId()));
168 
169  }
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ isAdminForceNotification()

ilForumNotification::isAdminForceNotification ( )

Definition at line 121 of file class.ilForumNotification.php.

References $ilDB, $res, $row, array, getForumId(), and getUserId().

122  {
123  global $ilDB;
124 
125  $res = $ilDB->queryF('
126  SELECT admin_force_noti FROM frm_notification
127  WHERE user_id = %s
128  AND frm_id = %s
129  AND user_id_noti > %s ',
130  array('integer','integer', 'integer'),
131  array($this->getUserId(), $this->getForumId(), 0));
132 
133  while($row = $ilDB->fetchAssoc($res))
134  {
135  return $row['admin_force_noti'];
136  }
137  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ isUserToggleNotification()

ilForumNotification::isUserToggleNotification ( )

Definition at line 138 of file class.ilForumNotification.php.

References $ilDB, $res, $row, array, getForumId(), and getUserId().

Referenced by ilObjForumGUI\getUserNotificationTableData().

139  {
140  global $ilDB;
141 
142  $res = $ilDB->queryF('
143  SELECT user_toggle_noti FROM frm_notification
144  WHERE user_id = %s
145  AND frm_id = %s
146  AND user_id_noti > %s',
147  array('integer', 'integer', 'integer'),
148  array($this->getUserId(), $this->getForumId(), 0 ));
149 
150  while($row = $ilDB->fetchAssoc($res))
151  {
152  return $row['user_toggle_noti'];
153  }
154 
155  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mergeThreadNotificiations()

static ilForumNotification::mergeThreadNotificiations (   $merge_source_thread_id,
  $merge_target_thread_id 
)
static

Definition at line 409 of file class.ilForumNotification.php.

References $ilDB, $res, $row, and array.

Referenced by ilForum\mergeThreads().

410  {
411  // check notifications etc..
412  global $ilDB;
413 
414  $res = $ilDB->queryF('SELECT notification_id, user_id FROM frm_notification
415  WHERE frm_id = %s
416  AND thread_id = %s
417  ORDER BY user_id ASC',
418  array('integer', 'integer'), array(0, $merge_source_thread_id));
419 
420  $res_2 = $ilDB->queryF('SELECT user_id FROM frm_notification
421  WHERE frm_id = %s
422  AND thread_id = %s
423  ORDER BY user_id ASC',
424  array('integer', 'integer'), array(0, $merge_target_thread_id));
425 
426  $users_already_notified = $ilDB->fetchAssoc($res_2);
427  while($row = $ilDB->fetchAssoc($res))
428  {
429  if(in_array($row['user_id'], $users_already_notified))
430  {
431  // delete source notification because already exists for target_id
432  $ilDB->manipulatef('DELETE FROM frm_notification WHERE notification_id = %s',
433  array('integer'), array($row['notification_id']));
434  }
435  else
436  {
437  // update source notification
438  $ilDB->update('frm_notification',
439  array('thread_id' => array('integer', $merge_target_thread_id)),
440  array('thread_id' => array('integer', $merge_source_thread_id)
441  ));
442  }
443  }
444  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilForumNotification::read ( )

Definition at line 391 of file class.ilForumNotification.php.

References $ilDB, $query, $result, $row, array, and getForumId().

392  {
393  global $ilDB;
394  $result = array();
395 
396  $query = $ilDB->queryF('
397  SELECT * FROM frm_notification WHERE
398  frm_id = %s',
399  array('integer'),
400  array($this->getForumId()));
401 
402  while($row = $ilDB->fetchAssoc($query))
403  {
404  $result[$row['user_id']] = $row;
405  }
406  return $result;
407  }
$result
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ setAdminForce()

ilForumNotification::setAdminForce (   $a_admin_force)

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

Referenced by ilObjForumGUI\getIcon().

83  {
84  $this->admin_force = $a_admin_force;
85  }
+ Here is the caller graph for this function:

◆ setForumId()

ilForumNotification::setForumId (   $a_forum_id)

Definition at line 63 of file class.ilForumNotification.php.

64  {
65  $this->forum_id = $a_forum_id;
66  }

◆ setForumRefId()

ilForumNotification::setForumRefId (   $a_ref_id)

Definition at line 101 of file class.ilForumNotification.php.

102  {
103  $this->ref_id = $a_ref_id;
104  }

◆ setNotificationId()

ilForumNotification::setNotificationId (   $a_notification_id)

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

47  {
48  $this->notification_id = $a_notification_id;
49  }

◆ setThreadId()

ilForumNotification::setThreadId (   $a_thread_id)

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

73  {
74  $this->thread_id = $a_thread_id;
75  }

◆ setUserId()

ilForumNotification::setUserId (   $a_user_id)

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

Referenced by ilObjForumGUI\getUserNotificationTableData().

55  {
56  $this->user_id = $a_user_id;
57  }
+ Here is the caller graph for this function:

◆ setUserIdNoti()

ilForumNotification::setUserIdNoti (   $a_user_id_noti)

Definition at line 111 of file class.ilForumNotification.php.

112  {
113  $this->user_id_noti = $a_user_id_noti;
114  }

◆ setUserToggle()

ilForumNotification::setUserToggle (   $a_user_toggle)

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

93  {
94  $this->user_toggle = $a_user_toggle;
95  }

◆ update()

ilForumNotification::update ( )

Definition at line 365 of file class.ilForumNotification.php.

References $ilDB, $res, array, getAdminForce(), getForumId(), getUserId(), and getUserToggle().

366  {
367  global $ilDB;
368 
369  $res = $ilDB->manipulateF('
370  UPDATE frm_notification
371  SET admin_force_noti = %s,
372  user_toggle_noti = %s
373  WHERE user_id = %s
374  AND frm_id = %s',
375  array('integer','integer','integer','integer'),
376  array($this->getAdminForce(), $this->getUserToggle(), $this->getUserId(), $this->getForumId()));
377  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ updateUserToggle()

ilForumNotification::updateUserToggle ( )

Definition at line 200 of file class.ilForumNotification.php.

References $ilDB, $res, array, getForumId(), getUserId(), and getUserToggle().

201  {
202  global $ilDB;
203 
204  $res = $ilDB->manipulateF('
205  UPDATE frm_notification
206  SET user_toggle_noti = %s
207  WHERE user_id = %s
208  AND frm_id = %s
209  AND admin_force_noti = %s',
210  array('integer','integer','integer','integer'),
211  array($this->getUserToggle(), $this->getUserId(),$this->getForumId(), 1));
212  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $admin_force

ilForumNotification::$admin_force
private

Definition at line 24 of file class.ilForumNotification.php.

Referenced by checkForumsExistsInsert(), and getAdminForce().

◆ $forum_id

ilForumNotification::$forum_id
private

Definition at line 22 of file class.ilForumNotification.php.

Referenced by _clearForcedForumNotifications(), and getForumId().

◆ $node_data_cache

ilForumNotification::$node_data_cache = array()
staticprotected

Definition at line 18 of file class.ilForumNotification.php.

◆ $notification_id

ilForumNotification::$notification_id
private

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

Referenced by getNotificationId().

◆ $ref_id

◆ $thread_id

ilForumNotification::$thread_id
private

Definition at line 23 of file class.ilForumNotification.php.

Referenced by getThreadId().

◆ $user_id

ilForumNotification::$user_id
private

◆ $user_toggle

ilForumNotification::$user_toggle
private

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

Referenced by checkForumsExistsInsert(), and getUserToggle().


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