ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 ()
 
 _getModerators ($a_ref_id)
 get all users assigned to local role il_frm_moderator_<frm_ref_id> (static) More...
 
 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 15 of file class.ilForumNotification.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumNotification::__construct (   $ref_id)

Constructor public.

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

References $lng, and $ref_id.

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

Member Function Documentation

◆ _clearForcedForumNotifications()

static ilForumNotification::_clearForcedForumNotifications (   $a_parameter)
static

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

References $forum_id, $ilDB, and $ref_id.

Referenced by ilForumAppEventListener\handleEvent().

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

◆ _getModerators()

ilForumNotification::_getModerators (   $a_ref_id)

get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)

Parameters
int$a_ref_idreference id
Returns
array user_ids public

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

References ilObject\_lookupTitle().

Referenced by ilObjForumGUI\updateUserNotifications().

372  {
373  global $rbacreview;
374 
375  $role_arr = $rbacreview->getRolesOfRoleFolder($a_ref_id);
376 
377  foreach ($role_arr as $role_id)
378  {
379  //$roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
380  $title = ilObject::_lookupTitle($role_id);
381  if ($title == "il_frm_moderator_".$a_ref_id)
382  {
383  #return $rbacreview->assignedUsers($roleObj->getId());
384  return $title = $rbacreview->assignedUsers($role_id);
385  }
386  }
387 
388  return array();
389  }
static _lookupTitle($a_id)
lookup object title
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isParentNodeGrpCrs()

static ilForumNotification::_isParentNodeGrpCrs (   $a_ref_id)
static

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

References ilObjectFactory\getInstanceByRefId().

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

297  {
298  global $tree;
299 
300  $parent_ref_id = $tree->getParentId($a_ref_id);
301  $parent_obj = ilObjectFactory::getInstanceByRefId($parent_ref_id);
302 
303  if($parent_obj->getType() == 'crs' || $parent_obj->getType() == 'grp')
304  return $parent_obj->getType();
305  else return false;
306  }
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 253 of file class.ilForumNotification.php.

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

Referenced by ilPDSelectedItemsBlockGUI\confirmedUnsubscribe(), and ilForumAppEventListener\handleEvent().

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

◆ checkForumsExistsInsert()

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

Definition at line 217 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(), ilForumAppEventListener\handleEvent(), and ilObjCourse\register().

218  {
219  global $ilUser;
220 
221  include_once 'Modules/Forum/classes/class.ilForumProperties.php';
222 
223  $node_data = self::getCachedNodeData($ref_id);
224 
225  foreach($node_data as $data)
226  {
227  //check frm_properties if frm_noti is enabled
228  $frm_noti = new ilForumNotification($data['ref_id']);
229  if($user_id != 0)
230  {
231  $frm_noti->setUserId($user_id);
232  }
233  else $frm_noti->setUserId($ilUser->getId());
234 
236  $frm_noti->setAdminForce($admin_force);
237 
239  if($user_toggle) $frm_noti->setAdminForce(1);
240 
241  if($admin_force == 1 || $user_toggle == 1)
242  {
243  $frm_noti->setUserToggle($user_toggle);
244  $frm_noti->setForumId($data['obj_id']);
245  if($frm_noti->existsNotification() == false)
246  {
247  $frm_noti->insertAdminForce();
248  }
249  }
250  }
251  }
Class ilForumNotification.
static _isUserToggleNoti($a_obj_id)
static _isAdminForceNoti($a_obj_id)
global $ilUser
Definition: imgupload.php:15
+ 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 334 of file class.ilForumNotification.php.

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

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

◆ deleteAdminForce()

ilForumNotification::deleteAdminForce ( )

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

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

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

◆ deleteNotificationAllUsers()

ilForumNotification::deleteNotificationAllUsers ( )

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

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

Referenced by ilObjForumGUI\infoScreenObject().

406  {
407  global $ilDB;
408 
409  $res = $ilDB->manipulateF('
410  DELETE FROM frm_notification
411  WHERE frm_id = %s
412  AND user_id_noti > %s',
413  array('integer', 'integer'),
414  array($this->getForumId(), 0));
415  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteUserToggle()

ilForumNotification::deleteUserToggle ( )

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

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

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

◆ existsNotification()

ilForumNotification::existsNotification ( )
Returns
bool

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

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

476  {
477  global $ilDB;
478 
479  $res = $ilDB->queryF('
480  SELECT * FROM frm_notification
481  WHERE user_id = %s
482  AND frm_id = %s
483  AND admin_force_noti = %s',
484  array('integer', 'integer', 'integer'),
485  array($this->getUserId(), $this->getForumId(), $this->getAdminForce()));
486 
487  if($row = $ilDB->numRows($res) > 0)
488  {
489  return true;
490  }
491  return false;
492  }
global $ilDB
+ Here is the call graph for this function:

◆ getAdminForce()

ilForumNotification::getAdminForce ( )

Definition at line 85 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 285 of file class.ilForumNotification.php.

References $ref_id.

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

◆ getForumId()

ilForumNotification::getForumId ( )

◆ getForumRefId()

ilForumNotification::getForumRefId ( )

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

References $ref_id.

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

◆ getNotificationId()

ilForumNotification::getNotificationId ( )

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

References $notification_id.

◆ getThreadId()

ilForumNotification::getThreadId ( )

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

References $thread_id.

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

◆ getUserId()

ilForumNotification::getUserId ( )

◆ getUserIdNoti()

ilForumNotification::getUserIdNoti ( )

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

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

◆ getUserToggle()

ilForumNotification::getUserToggle ( )

Definition at line 95 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 156 of file class.ilForumNotification.php.

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

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

◆ isAdminForceNotification()

ilForumNotification::isAdminForceNotification ( )

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

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

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

◆ isUserToggleNotification()

ilForumNotification::isUserToggleNotification ( )

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

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

Referenced by ilObjForumGUI\getUserNotificationTableData().

138  {
139  global $ilDB;
140 
141  $res = $ilDB->queryF('
142  SELECT user_toggle_noti FROM frm_notification
143  WHERE user_id = %s
144  AND frm_id = %s
145  AND user_id_noti > %s',
146  array('integer', 'integer', 'integer'),
147  array($this->getUserId(), $this->getForumId(), 0 ));
148 
149  while($row = $ilDB->fetchAssoc($res))
150  {
151  return $row['user_toggle_noti'];
152  }
153 
154  }
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 435 of file class.ilForumNotification.php.

References $ilDB, $res, and $row.

Referenced by ilForum\mergeThreads().

436  {
437  // check notifications etc..
438  global $ilDB;
439 
440  $res = $ilDB->queryF('SELECT notification_id, user_id FROM frm_notification
441  WHERE frm_id = %s
442  AND thread_id = %s
443  ORDER BY user_id ASC',
444  array('integer', 'integer'), array(0, $merge_source_thread_id));
445 
446  $res_2 = $ilDB->queryF('SELECT user_id FROM frm_notification
447  WHERE frm_id = %s
448  AND thread_id = %s
449  ORDER BY user_id ASC',
450  array('integer', 'integer'), array(0, $merge_target_thread_id));
451 
452  $users_already_notified = $ilDB->fetchAssoc($res_2);
453  while($row = $ilDB->fetchAssoc($res))
454  {
455  if(in_array($row['user_id'], $users_already_notified))
456  {
457  // delete source notification because already exists for target_id
458  $ilDB->manipulatef('DELETE FROM frm_notification WHERE notification_id = %s',
459  array('integer'), array($row['notification_id']));
460  }
461  else
462  {
463  // update source notification
464  $ilDB->update('frm_notification',
465  array('thread_id' => array('integer', $merge_target_thread_id)),
466  array('thread_id' => array('integer', $merge_source_thread_id)
467  ));
468  }
469  }
470  }
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilForumNotification::read ( )

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

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

418  {
419  global $ilDB;
420  $result = array();
421 
422  $query = $ilDB->queryF('
423  SELECT * FROM frm_notification WHERE
424  frm_id = %s',
425  array('integer'),
426  array($this->getForumId()));
427 
428  while($row = $ilDB->fetchAssoc($query))
429  {
430  $result[$row['user_id']] = $row;
431  }
432  return $result;
433  }
$result
global $ilDB
+ Here is the call graph for this function:

◆ setAdminForce()

ilForumNotification::setAdminForce (   $a_admin_force)

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

Referenced by ilObjForumGUI\getIcon().

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

◆ setForumId()

ilForumNotification::setForumId (   $a_forum_id)

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

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

◆ setForumRefId()

ilForumNotification::setForumRefId (   $a_ref_id)

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

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

◆ setNotificationId()

ilForumNotification::setNotificationId (   $a_notification_id)

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

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

◆ setThreadId()

ilForumNotification::setThreadId (   $a_thread_id)

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

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

◆ setUserId()

ilForumNotification::setUserId (   $a_user_id)

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

Referenced by ilObjForumGUI\getUserNotificationTableData().

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

◆ setUserIdNoti()

ilForumNotification::setUserIdNoti (   $a_user_id_noti)

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

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

◆ setUserToggle()

ilForumNotification::setUserToggle (   $a_user_toggle)

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

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

◆ update()

ilForumNotification::update ( )

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

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

392  {
393  global $ilDB;
394 
395  $res = $ilDB->manipulateF('
396  UPDATE frm_notification
397  SET admin_force_noti = %s,
398  user_toggle_noti = %s
399  WHERE user_id = %s
400  AND frm_id = %s',
401  array('integer','integer','integer','integer'),
402  array($this->getAdminForce(), $this->getUserToggle(), $this->getUserId(), $this->getForumId()));
403  }
global $ilDB
+ Here is the call graph for this function:

◆ updateUserToggle()

ilForumNotification::updateUserToggle ( )

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

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

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

Field Documentation

◆ $admin_force

ilForumNotification::$admin_force
private

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

Referenced by checkForumsExistsInsert(), and getAdminForce().

◆ $forum_id

ilForumNotification::$forum_id
private

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

Referenced by _clearForcedForumNotifications(), and getForumId().

◆ $node_data_cache

ilForumNotification::$node_data_cache = array()
staticprotected

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

◆ $notification_id

ilForumNotification::$notification_id
private

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

Referenced by getNotificationId().

◆ $ref_id

◆ $thread_id

ilForumNotification::$thread_id
private

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

Referenced by getThreadId().

◆ $user_id

ilForumNotification::$user_id
private

◆ $user_toggle

ilForumNotification::$user_toggle
private

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

Referenced by checkForumsExistsInsert(), and getUserToggle().


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