ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 
 getCrsGrpMemberToNotify ()
 
 _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 _isParentNodeGrpCrs ($a_ref_id)
 
static _clearForcedForumNotifications ($a_parameter)
 
static checkParentNodeTree ($ref_id)
 
static mergeThreadNotificiations ($merge_source_thread_id, $merge_target_thread_id)
 

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 32 of file class.ilForumNotification.php.

References $lng, and $ref_id.

33  {
34  global $ilObjDataCache,$lng,$ilias;
35 
36  $this->lng = $lng;
37  $this->ilias = $ilias;
38  $this->ref_id = $ref_id;
39  $this->forum_id = $ilObjDataCache->lookupObjId($ref_id);
40 
41  }
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 299 of file class.ilForumNotification.php.

References $forum_id, and $ref_id.

Referenced by ilForumAppEventListener\handleEvent().

300  {
301  global $ilDB, $ilObjDataCache;
302 
303  if(!$a_parameter['tree'] == 'tree')
304  {
305  return;
306  }
307 
308  $ref_id = $a_parameter['source_id'];
309  $is_parent = self::_isParentNodeGrpCrs($ref_id);
310 
311  if($is_parent)
312  {
313  $forum_id = $ilObjDataCache->lookupObjId($ref_id);
314 
315  $ilDB->manipulateF('
316  DELETE FROM frm_notification
317  WHERE frm_id = %s
318  AND admin_force_noti = %s',
319  array('integer','integer'),
320  array($forum_id, 1));
321  }
322  }
+ 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 361 of file class.ilForumNotification.php.

References ilObject\_lookupTitle().

Referenced by ilObjForumGUI\updateUserNotifications().

362  {
363  global $rbacreview;
364 
365  $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
366  $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
367 
368  foreach ($role_arr as $role_id)
369  {
370  //$roleObj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
371  $title = ilObject::_lookupTitle($role_id);
372  if ($title == "il_frm_moderator_".$a_ref_id)
373  {
374  #return $rbacreview->assignedUsers($roleObj->getId());
375  return $title = $rbacreview->assignedUsers($role_id);
376  }
377  }
378 
379  return array();
380  }
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 286 of file class.ilForumNotification.php.

References ilObjectFactory\getInstanceByRefId().

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

287  {
288  global $tree;
289 
290  $parent_ref_id = $tree->getParentId($a_ref_id);
291  $parent_obj = ilObjectFactory::getInstanceByRefId($parent_ref_id);
292 
293  if($parent_obj->getType() == 'crs' || $parent_obj->getType() == 'grp')
294  return $parent_obj->getType();
295  else return false;
296  }
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 257 of file class.ilForumNotification.php.

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

Referenced by ilPDSelectedItemsBlockGUI\confirmedUnsubscribe(), ilObjGroupGUI\deleteMembersObject(), ilObjCourseGUI\performUnsubscribeObject(), ilCourseParticipantsGroupsGUI\remove(), ilObjCourseGUI\removeMembersObject(), and ilObjGroupGUI\unsubscribeObject().

258  {
259  global $tree, $ilUser;
260 
261  $node_data = $tree->getChildsByType($ref_id, 'frm');
262 
263  include_once 'Modules/Forum/classes/class.ilForumModerators.php';
264 
265  foreach($node_data as $data)
266  {
267  //check frm_properties if frm_noti is enabled
268  $frm_noti = new ilForumNotification($data['ref_id']);
269  $objFrmMods = new ilForumModerators($data['ref_id']);
270  $moderator_ids = $objFrmMods->getCurrentModerators();
271 
272  if($user_id != 0)
273  {
274  $frm_noti->setUserId($user_id);
275  }
276  else $frm_noti->setUserId($ilUser->getId());
277 
278  $frm_noti->setForumId($data['obj_id']);
279  if(!in_array($frm_noti->getUserId(), $moderator_ids))
280  {
281  $frm_noti->deleteAdminForce();
282  }
283  }
284  }
Class ilForumNotification.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
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 222 of file class.ilForumNotification.php.

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

Referenced by ilCourseParticipantsGroupsGUI\add(), ilGroupRegistrationGUI\add(), ilCourseRegistrationGUI\add(), ilObjGroupGUI\addUserObject(), ilObjGroupGUI\assignFromWaitingListObject(), ilObjCourseGUI\assignFromWaitingListObject(), ilObjCourseGUI\assignMembersObject(), ilObjGroupGUI\assignSubscribersObject(), ilObjCourseGUI\assignSubscribersObject(), and ilObjCourse\register().

223  {
224  global $tree, $ilUser;
225 
226  include_once 'Modules/Forum/classes/class.ilForumProperties.php';
227 
228  $node_data = $tree->getChildsByType($ref_id, 'frm');
229  foreach($node_data as $data)
230  {
231  //check frm_properties if frm_noti is enabled
232  $frm_noti = new ilForumNotification($data['ref_id']);
233  if($user_id != 0)
234  {
235  $frm_noti->setUserId($user_id);
236  }
237  else $frm_noti->setUserId($ilUser->getId());
238 
240  $frm_noti->setAdminForce($admin_force);
241 
243  if($user_toggle) $frm_noti->setAdminForce(1);
244 
245  if($admin_force == 1 || $user_toggle == 1)
246  {
247  $frm_noti->setUserToggle($user_toggle);
248  $frm_noti->setForumId($data['obj_id']);
249  if($frm_noti->existsNotification() == false)
250  {
251  $frm_noti->insertAdminForce();
252  }
253  }
254  }
255  }
Class ilForumNotification.
static _isUserToggleNoti($a_obj_id)
static _isAdminForceNoti($a_obj_id)
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
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 324 of file class.ilForumNotification.php.

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

325  {
326  global $tree;
327 
328  $parent_ref_id = $tree->getParentId($ref_id);
329  $parent_obj = ilObjectFactory::getInstanceByRefId($parent_ref_id);
330 
331  if($parent_obj->getType() == 'crs')
332  {
333  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
334  $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId());
335  }
336  else if($parent_obj->getType() == 'grp')
337  {
338  include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
339  $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId());
340  }
341 
342  $result = array();
343  if($parent_obj->getType() == 'crs' || $parent_obj->getType() == 'grp')
344  {
345  $moderator_ids = self::_getModerators($ref_id);
346  $admin_ids = $oParticipants->getAdmins();
347  $tutor_ids = $oParticipants->getTutors();
348 
349  $result = array_unique(array_merge($moderator_ids,$admin_ids,$tutor_ids));
350  }
351  return $result;
352  }
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 167 of file class.ilForumNotification.php.

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

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

◆ deleteNotificationAllUsers()

ilForumNotification::deleteNotificationAllUsers ( )

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

References $res, and getForumId().

Referenced by ilObjForumGUI\infoScreenObject().

397  {
398  global $ilDB;
399 
400  $res = $ilDB->manipulateF('
401  DELETE FROM frm_notification
402  WHERE frm_id = %s
403  AND user_id_noti > %s',
404  array('integer', 'integer'),
405  array($this->getForumId(), 0));
406  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteUserToggle()

ilForumNotification::deleteUserToggle ( )

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

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

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

◆ existsNotification()

ilForumNotification::existsNotification ( )
Returns
bool

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

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

467  {
468  global $ilDB;
469 
470  $res = $ilDB->queryF('
471  SELECT * FROM frm_notification
472  WHERE user_id = %s
473  AND frm_id = %s
474  AND admin_force_noti = %s',
475  array('integer', 'integer', 'integer'),
476  array($this->getUserId(), $this->getForumId(), $this->getAdminForce()));
477 
478  if($row = $ilDB->numRows($res) > 0)
479  {
480  return true;
481  }
482  return false;
483  }
+ Here is the call graph for this function:

◆ getAdminForce()

ilForumNotification::getAdminForce ( )

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

References $admin_force.

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

+ Here is the caller graph for this function:

◆ getCrsGrpMemberToNotify()

ilForumNotification::getCrsGrpMemberToNotify ( )

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

212  {
213  global $ilDB;
214 
215  }

◆ getForumId()

ilForumNotification::getForumId ( )

◆ getForumRefId()

ilForumNotification::getForumRefId ( )

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

References $ref_id.

103  {
104  return $this->ref_id;
105  }

◆ getNotificationId()

ilForumNotification::getNotificationId ( )

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

References $notification_id.

◆ getThreadId()

ilForumNotification::getThreadId ( )

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

References $thread_id.

74  {
75  return $this->thread_id;
76  }

◆ getUserId()

ilForumNotification::getUserId ( )

◆ getUserIdNoti()

ilForumNotification::getUserIdNoti ( )

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

114  {
115  return $this->user_id_noti;
116  }

◆ getUserToggle()

ilForumNotification::getUserToggle ( )

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

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

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

◆ isAdminForceNotification()

ilForumNotification::isAdminForceNotification ( )

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

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

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

◆ isUserToggleNotification()

ilForumNotification::isUserToggleNotification ( )

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

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

Referenced by ilObjForumGUI\getUserNotificationTableData().

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

References $res, and $row.

Referenced by ilForum\mergeThreads().

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

◆ read()

ilForumNotification::read ( )

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

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

409  {
410  global $ilDB;
411  $result = array();
412 
413  $query = $ilDB->queryF('
414  SELECT * FROM frm_notification WHERE
415  frm_id = %s',
416  array('integer'),
417  array($this->getForumId()));
418 
419  while($row = $ilDB->fetchAssoc($query))
420  {
421  $result[$row['user_id']] = $row;
422  }
423  return $result;
424  }
$result
+ Here is the call graph for this function:

◆ setAdminForce()

ilForumNotification::setAdminForce (   $a_admin_force)

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

Referenced by ilObjForumGUI\getIcon().

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

◆ setForumId()

ilForumNotification::setForumId (   $a_forum_id)

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

61  {
62  $this->forum_id = $a_forum_id;
63  }

◆ setForumRefId()

ilForumNotification::setForumRefId (   $a_ref_id)

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

99  {
100  $this->ref_id = $a_ref_id;
101  }

◆ setNotificationId()

ilForumNotification::setNotificationId (   $a_notification_id)

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

44  {
45  $this->notification_id = $a_notification_id;
46  }

◆ setThreadId()

ilForumNotification::setThreadId (   $a_thread_id)

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

70  {
71  $this->thread_id = $a_thread_id;
72  }

◆ setUserId()

ilForumNotification::setUserId (   $a_user_id)

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

Referenced by ilObjForumGUI\getUserNotificationTableData().

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

◆ setUserIdNoti()

ilForumNotification::setUserIdNoti (   $a_user_id_noti)

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

109  {
110  $this->user_id_noti = $a_user_id_noti;
111  }

◆ setUserToggle()

ilForumNotification::setUserToggle (   $a_user_toggle)

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

90  {
91  $this->user_toggle = $a_user_toggle;
92  }

◆ update()

ilForumNotification::update ( )

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

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

383  {
384  global $ilDB;
385 
386  $res = $ilDB->manipulateF('
387  UPDATE frm_notification
388  SET admin_force_noti = %s,
389  user_toggle_noti = %s
390  WHERE user_id = %s
391  AND frm_id = %s',
392  array('integer','integer','integer','integer'),
393  array($this->getAdminForce(), $this->getUserToggle(), $this->getUserId(), $this->getForumId()));
394  }
+ Here is the call graph for this function:

◆ updateUserToggle()

ilForumNotification::updateUserToggle ( )

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

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

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

Field Documentation

◆ $admin_force

ilForumNotification::$admin_force
private

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

Referenced by checkForumsExistsInsert(), and getAdminForce().

◆ $forum_id

ilForumNotification::$forum_id
private

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

Referenced by _clearForcedForumNotifications(), and getForumId().

◆ $notification_id

ilForumNotification::$notification_id
private

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

Referenced by getNotificationId().

◆ $ref_id

◆ $thread_id

ilForumNotification::$thread_id
private

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

Referenced by getThreadId().

◆ $user_id

ilForumNotification::$user_id
private

◆ $user_toggle

ilForumNotification::$user_toggle
private

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

Referenced by checkForumsExistsInsert(), and getUserToggle().


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