ILIAS  release_7 Revision v7.30-3-g800a261c036
ilForumNotification Class Reference

Class ilForumNotification. More...

+ Collaboration diagram for ilForumNotification:

Public Member Functions

 __construct ($ref_id)
 Constructor @access 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 ()
 
 cloneFromSource (int $sourceRefId)
 

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
 
 $db
 
 $user
 

Detailed Description

Class ilForumNotification.

Author
Nadia Matuschek nmatu.nosp@m.sche.nosp@m.k@dat.nosp@m.abay.nosp@m..de
Version
$Id:$

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

Constructor & Destructor Documentation

◆ __construct()

ilForumNotification::__construct (   $ref_id)

Constructor @access public.

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

33 {
34 global $DIC;
35
36 $this->lng = $DIC->language();
37 $this->db = $DIC->database();
38 $this->user = $DIC->user();
39 $this->ref_id = $ref_id;
40 $this->forum_id = $DIC['ilObjDataCache']->lookupObjId($ref_id);
41 }
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24

References $DIC, $ref_id, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _clearForcedForumNotifications()

static ilForumNotification::_clearForcedForumNotifications (   $a_parameter)
static
Parameters
$a_parameter

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

322 {
323 global $DIC;
324 $ilDB = $DIC->database();
325 $ilObjDataCache = $DIC['ilObjDataCache'];
326
327 if (!$a_parameter['tree'] == 'tree') {
328 return;
329 }
330
331 $ref_id = $a_parameter['source_id'];
333
334 if ($is_parent) {
335 $forum_id = $ilObjDataCache->lookupObjId($ref_id);
336
337 $ilDB->manipulateF(
338 '
339 DELETE FROM frm_notification
340 WHERE frm_id = %s
341 AND admin_force_noti = %s',
342 array('integer','integer'),
343 array($forum_id, 1)
344 );
345 }
346 }
static _isParentNodeGrpCrs($a_ref_id)
global $ilDB

References $DIC, and $ilDB.

◆ _isParentNodeGrpCrs()

static ilForumNotification::_isParentNodeGrpCrs (   $a_ref_id)
static
Parameters
$a_ref_id
Returns
bool

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

305 {
306 global $DIC;
307
308 $parent_ref_id = $DIC->repositoryTree()->getParentId($a_ref_id);
309 $parent_obj = ilObjectFactory::getInstanceByRefId($parent_ref_id);
310
311 if ($parent_obj->getType() == 'crs' || $parent_obj->getType() == 'grp') {
312 return $parent_obj->getType();
313 } else {
314 return false;
315 }
316 }
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id

References $DIC, and ilObjectFactory\getInstanceByRefId().

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

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

247 {
248 global $DIC;
249 $ilUser = $DIC->user();
250
251 $node_data = self::getCachedNodeData($ref_id);
252
253 foreach ($node_data as $data) {
254 //check frm_properties if frm_noti is enabled
255 $frm_noti = new ilForumNotification($data['ref_id']);
256 $objFrmMods = new ilForumModerators($data['ref_id']);
257 $moderator_ids = $objFrmMods->getCurrentModerators();
258
259 if ($user_id != 0) {
260 $frm_noti->setUserId($user_id);
261 } else {
262 $frm_noti->setUserId($ilUser->getId());
263 }
264
265 $frm_noti->setForumId($data['obj_id']);
266 if (!in_array($frm_noti->getUserId(), $moderator_ids)) {
267 $frm_noti->deleteAdminForce();
268 }
269 }
270 }
Class ilForumModerators.
Class ilForumNotification.
$ilUser
Definition: imgupload.php:18
$data
Definition: storeScorm.php:23

References $data, $DIC, $ilUser, $ref_id, $user_id, and getCachedNodeData().

Referenced by ilPDSelectedItemsBlockGUI\confirmedUnsubscribe().

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

◆ checkForumsExistsInsert()

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

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

213 {
214 global $DIC;
215 $ilUser = $DIC->user();
216
217 $node_data = self::getCachedNodeData($ref_id);
218
219 foreach ($node_data as $data) {
220 //check frm_properties if frm_noti is enabled
221 $frm_noti = new ilForumNotification($data['ref_id']);
222 if ($user_id != 0) {
223 $frm_noti->setUserId($user_id);
224 } else {
225 $frm_noti->setUserId($ilUser->getId());
226 }
227
229 $frm_noti->setAdminForce($admin_force);
230
232 if ($user_toggle) {
233 $frm_noti->setAdminForce(1);
234 }
235
236 if ($admin_force == 1 || $user_toggle == 1) {
237 $frm_noti->setUserToggle($user_toggle);
238 $frm_noti->setForumId($data['obj_id']);
239 if ($frm_noti->existsNotification() == false) {
240 $frm_noti->insertAdminForce();
241 }
242 }
243 }
244 }
static _isUserToggleNoti($a_obj_id)
static _isAdminForceNoti($a_obj_id)

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

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

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

◆ checkParentNodeTree()

static ilForumNotification::checkParentNodeTree (   $ref_id)
static
Parameters
$ref_id
Returns
array

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

353 {
354 global $DIC;
355 $tree = $DIC->repositoryTree();
356
357 $parent_ref_id = $tree->getParentId($ref_id);
358 $parent_obj = ilObjectFactory::getInstanceByRefId($parent_ref_id);
359
360 if ($parent_obj->getType() == 'crs') {
361 $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId());
362 } elseif ($parent_obj->getType() == 'grp') {
363 $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId());
364 }
365
366 $result = array();
367 if ($parent_obj->getType() == 'crs' || $parent_obj->getType() == 'grp') {
368 $moderator_ids = ilForum::_getModerators($ref_id);
369 $admin_ids = $oParticipants->getAdmins();
370 $tutor_ids = $oParticipants->getTutors();
371
372 $result = array_unique(array_merge($moderator_ids, $admin_ids, $tutor_ids));
373 }
374 return $result;
375 }
$result
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getModerators($a_ref_id)
get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.

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

+ Here is the call graph for this function:

◆ cloneFromSource()

ilForumNotification::cloneFromSource ( int  $sourceRefId)
Parameters
int$sourceRefId

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

499 {
500 $sourceNotificationSettings = new self($sourceRefId);
501 $records = $sourceNotificationSettings->read();
502
503 foreach ($records as $usrId => $row) {
504 $this->setUserId($usrId);
505 $this->setAdminForce($row['admin_force_noti']);
506 $this->setUserToggle($row['user_toggle_noti']);
507 $this->setUserIdNoti($row['user_id_noti']);
508
509 $this->insertAdminForce();
510 }
511 }

◆ deleteAdminForce()

ilForumNotification::deleteAdminForce ( )

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

166 {
167 $this->db->manipulateF(
168 '
169 DELETE FROM frm_notification
170 WHERE user_id = %s
171 AND frm_id = %s
172 AND admin_force_noti = %s
173 AND user_id_noti > %s',
174 array('integer', 'integer','integer', 'integer'),
175 array($this->getUserId(), $this->getForumId(), 1, 0)
176 );
177 }

References getForumId(), and getUserId().

+ Here is the call graph for this function:

◆ deleteNotificationAllUsers()

ilForumNotification::deleteNotificationAllUsers ( )

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

392 {
393 $this->db->manipulateF(
394 '
395 DELETE FROM frm_notification
396 WHERE frm_id = %s
397 AND user_id_noti > %s',
398 array('integer', 'integer'),
399 array($this->getForumId(), 0)
400 );
401 }

◆ deleteUserToggle()

ilForumNotification::deleteUserToggle ( )

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

180 {
181 $this->db->manipulateF(
182 '
183 DELETE FROM frm_notification
184 WHERE user_id = %s
185 AND frm_id = %s
186 AND admin_force_noti = %s
187 AND user_toggle_noti = %s
188 AND user_id_noti > %s',
189 array('integer', 'integer','integer','integer', 'integer'),
190 array($this->getUserId(),$this->getForumId(),1,1, 0 )
191 );
192 }

References getForumId(), and getUserId().

+ Here is the call graph for this function:

◆ existsNotification()

ilForumNotification::existsNotification ( )
Returns
bool

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

478 {
479 $res = $this->db->queryF(
480 '
481 SELECT * FROM frm_notification
482 WHERE user_id = %s
483 AND frm_id = %s
484 AND admin_force_noti = %s',
485 array('integer', 'integer', 'integer'),
486 array($this->getUserId(), $this->getForumId(), $this->getAdminForce())
487 );
488
489 if ($row = $this->db->numRows($res) > 0) {
490 return true;
491 }
492 return false;
493 }
foreach($_POST as $key=> $value) $res

References $res.

◆ getAdminForce()

ilForumNotification::getAdminForce ( )

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

84 {
85 return $this->admin_force;
86 }

References $admin_force.

Referenced by insertAdminForce().

+ Here is the caller graph for this function:

◆ getCachedNodeData()

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

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

277 {
278 if (!array_key_exists($ref_id, self::$node_data_cache)) {
279 global $DIC;
280 $node_data = $DIC->repositoryTree()->getSubTree(
281 $DIC->repositoryTree()->getNodeData($ref_id),
282 true,
283 'frm'
284 );
285 $node_data = array_filter($node_data, function ($forum_node) use ($DIC, $ref_id) {
286 // filter out forum if a grp lies in the path (#0027702)
287 foreach ($DIC->repositoryTree()->getNodePath($forum_node['child'], $ref_id) as $path_node) {
288 if ((int) $path_node['child'] !== (int) $ref_id && $path_node['type'] === 'grp') {
289 return false;
290 }
291 }
292 return true;
293 });
294 self::$node_data_cache[$ref_id] = $node_data;
295 }
296
297 return self::$node_data_cache[$ref_id];
298 }

References $DIC, and $ref_id.

Referenced by checkForumsExistsDelete(), and checkForumsExistsInsert().

+ Here is the caller graph for this function:

◆ getForumId()

ilForumNotification::getForumId ( )

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

65 {
66 return $this->forum_id;
67 }

References $forum_id.

Referenced by deleteAdminForce(), deleteUserToggle(), insertAdminForce(), isAdminForceNotification(), isUserToggleNotification(), and updateUserToggle().

+ Here is the caller graph for this function:

◆ getForumRefId()

ilForumNotification::getForumRefId ( )

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

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

References $ref_id.

◆ 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.

◆ getUserId()

ilForumNotification::getUserId ( )

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

56 {
57 return $this->user_id;
58 }

References $user_id.

Referenced by deleteAdminForce(), deleteUserToggle(), insertAdminForce(), isAdminForceNotification(), isUserToggleNotification(), and updateUserToggle().

+ Here is the caller graph for this function:

◆ 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.

94 {
95 return $this->user_toggle;
96 }

References $user_toggle.

Referenced by insertAdminForce(), and updateUserToggle().

+ Here is the caller graph for this function:

◆ insertAdminForce()

ilForumNotification::insertAdminForce ( )

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

153 {
154 $next_id = $this->db->nextId('frm_notification');
155 $this->db->manipulateF(
156 '
157 INSERT INTO frm_notification
158 (notification_id, user_id, frm_id, admin_force_noti, user_toggle_noti, user_id_noti)
159 VALUES(%s,%s,%s,%s,%s,%s)',
160 array('integer', 'integer', 'integer', 'integer', 'integer', 'integer'),
161 array($next_id, $this->getUserId(), $this->getForumId(), $this->getAdminForce(), $this->getUserToggle(), $this->user->getId())
162 );
163 }

References getAdminForce(), getForumId(), getUserId(), getUserToggle(), and user().

+ Here is the call graph for this function:

◆ isAdminForceNotification()

ilForumNotification::isAdminForceNotification ( )

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

119 {
120 $res = $this->db->queryF(
121 '
122 SELECT admin_force_noti FROM frm_notification
123 WHERE user_id = %s
124 AND frm_id = %s
125 AND user_id_noti > %s ',
126 array('integer','integer', 'integer'),
127 array($this->getUserId(), $this->getForumId(), 0)
128 );
129
130 while ($row = $this->db->fetchAssoc($res)) {
131 return $row['admin_force_noti'];
132 }
133 }

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

+ Here is the call graph for this function:

◆ isUserToggleNotification()

ilForumNotification::isUserToggleNotification ( )

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

136 {
137 $res = $this->db->queryF(
138 '
139 SELECT user_toggle_noti FROM frm_notification
140 WHERE user_id = %s
141 AND frm_id = %s
142 AND user_id_noti > %s',
143 array('integer', 'integer', 'integer'),
144 array($this->getUserId(), $this->getForumId(), 0 )
145 );
146
147 while ($row = $this->db->fetchAssoc($res)) {
148 return $row['user_toggle_noti'];
149 }
150 }

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

Referenced by ilForumSettingsGUI\getUserNotificationTableData().

+ 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
Parameters
$merge_source_thread_id
$merge_target_thread_id

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

426 {
427 // check notifications etc..
428 global $DIC;
429 $ilDB = $DIC->database();
430
431 $res = $ilDB->queryF(
432 'SELECT notification_id, user_id FROM frm_notification
433 WHERE frm_id = %s
434 AND thread_id = %s
435 ORDER BY user_id ASC',
436 array('integer', 'integer'),
437 array(0, $merge_source_thread_id)
438 );
439
440 $res_2 = $ilDB->queryF(
441 'SELECT DISTINCT user_id FROM frm_notification
442 WHERE frm_id = %s
443 AND thread_id = %s
444 ORDER BY user_id ASC',
445 array('integer', 'integer'),
446 array(0, $merge_target_thread_id)
447 );
448
449 $users_already_notified = array();
450 while ($users_row = $ilDB->fetchAssoc($res_2)) {
451 $users_already_notified[$users_row['user_id']] = $users_row['user_id'];
452 }
453
454 while ($row = $ilDB->fetchAssoc($res)) {
455 if (isset($users_already_notified[$row['user_id']])) {
456 // delete source notification because already exists for target_id
457 $ilDB->manipulatef(
458 'DELETE FROM frm_notification WHERE notification_id = %s',
459 array('integer'),
460 array($row['notification_id'])
461 );
462 } else {
463 // update source notification
464 $ilDB->update(
465 'frm_notification',
466 array('thread_id' => array('integer', $merge_target_thread_id)),
467 array('thread_id' => array('integer', $merge_source_thread_id)
468 )
469 );
470 }
471 }
472 }

References $DIC, $ilDB, and $res.

Referenced by ilForum\mergeThreads().

+ Here is the caller graph for this function:

◆ read()

ilForumNotification::read ( )

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

404 {
405 $result = array();
406
407 $query = $this->db->queryF(
408 '
409 SELECT * FROM frm_notification WHERE
410 frm_id = %s',
411 array('integer'),
412 array($this->getForumId())
413 );
414
415 while ($row = $this->db->fetchAssoc($query)) {
416 $result[$row['user_id']] = $row;
417 }
418 return $result;
419 }
$query

References $query, and $result.

◆ setAdminForce()

ilForumNotification::setAdminForce (   $a_admin_force)

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

80 {
81 $this->admin_force = $a_admin_force;
82 }

◆ 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.

52 {
53 $this->user_id = $a_user_id;
54 }

Referenced by ilForumSettingsGUI\getUserNotificationTableData().

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

378 {
379 $this->db->manipulateF(
380 '
381 UPDATE frm_notification
382 SET admin_force_noti = %s,
383 user_toggle_noti = %s
384 WHERE user_id = %s
385 AND frm_id = %s',
386 array('integer','integer','integer','integer'),
387 array($this->getAdminForce(), $this->getUserToggle(), $this->getUserId(), $this->getForumId())
388 );
389 }

◆ updateUserToggle()

ilForumNotification::updateUserToggle ( )

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

195 {
196 $this->db->manipulateF(
197 '
198 UPDATE frm_notification
199 SET user_toggle_noti = %s
200 WHERE user_id = %s
201 AND frm_id = %s
202 AND admin_force_noti = %s',
203 array('integer','integer','integer','integer'),
204 array($this->getUserToggle(), $this->getUserId(),$this->getForumId(), 1)
205 );
206 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $admin_force

ilForumNotification::$admin_force
private

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

Referenced by checkForumsExistsInsert(), and getAdminForce().

◆ $db

ilForumNotification::$db
private

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

◆ $forum_id

ilForumNotification::$forum_id
private

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

Referenced by getForumId().

◆ $node_data_cache

ilForumNotification::$node_data_cache = array()
staticprotected

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

◆ $notification_id

ilForumNotification::$notification_id
private

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

Referenced by getNotificationId().

◆ $ref_id

ilForumNotification::$ref_id
private

◆ $thread_id

ilForumNotification::$thread_id
private

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

Referenced by getThreadId().

◆ $user

ilForumNotification::$user
private

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

◆ $user_id

ilForumNotification::$user_id
private

◆ $user_toggle

ilForumNotification::$user_toggle
private

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

Referenced by checkForumsExistsInsert(), and getUserToggle().


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