ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ($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 15 of file class.ilForumNotification.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumNotification::__construct (   $ref_id)

Constructor @access public.

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

36 {
37 global $DIC;
38
39 $this->lng = $DIC->language();
40 $this->db = $DIC->database();
41 $this->user = $DIC->user();
42 $this->ref_id = $ref_id;
43 $this->forum_id = $DIC['ilObjDataCache']->lookupObjId($ref_id);
44 }
user()
Definition: user.php:4
global $DIC
Definition: saml.php:7

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

315 {
316 global $DIC;
317 $ilDB = $DIC->database();
318 $ilObjDataCache = $DIC['ilObjDataCache'];
319
320 if (!$a_parameter['tree'] == 'tree') {
321 return;
322 }
323
324 $ref_id = $a_parameter['source_id'];
326
327 if ($is_parent) {
328 $forum_id = $ilObjDataCache->lookupObjId($ref_id);
329
330 $ilDB->manipulateF(
331 '
332 DELETE FROM frm_notification
333 WHERE frm_id = %s
334 AND admin_force_noti = %s',
335 array('integer','integer'),
336 array($forum_id, 1)
337 );
338 }
339 }
static _isParentNodeGrpCrs($a_ref_id)
global $ilDB

References $DIC, $forum_id, $ilDB, $ref_id, and _isParentNodeGrpCrs().

+ Here is the call graph for this function:

◆ _isParentNodeGrpCrs()

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

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

298 {
299 global $DIC;
300
301 $parent_ref_id = $DIC->repositoryTree()->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 {
307 return false;
308 }
309 }
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 _clearForcedForumNotifications(), 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 251 of file class.ilForumNotification.php.

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

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

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

346 {
347 global $DIC;
348 $tree = $DIC->repositoryTree();
349
350 $parent_ref_id = $tree->getParentId($ref_id);
351 $parent_obj = ilObjectFactory::getInstanceByRefId($parent_ref_id);
352
353 if ($parent_obj->getType() == 'crs') {
354 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
355 $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId());
356 } elseif ($parent_obj->getType() == 'grp') {
357 include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
358 $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId());
359 }
360
361 $result = array();
362 if ($parent_obj->getType() == 'crs' || $parent_obj->getType() == 'grp') {
363 $moderator_ids = ilForum::_getModerators($ref_id);
364 $admin_ids = $oParticipants->getAdmins();
365 $tutor_ids = $oParticipants->getTutors();
366
367 $result = array_unique(array_merge($moderator_ids, $admin_ids, $tutor_ids));
368 }
369 return $result;
370 }
$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, $ref_id, $result, ilCourseParticipants\_getInstanceByObjId(), ilGroupParticipants\_getInstanceByObjId(), ilForum\_getModerators(), and ilObjectFactory\getInstanceByRefId().

+ Here is the call graph for this function:

◆ cloneFromSource()

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

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

490 {
491 $sourceNotificationSettings = new self($sourceRefId);
492 $records = $sourceNotificationSettings->read();
493
494 foreach ($records as $usrId => $row) {
495 $this->setUserId($usrId);
496 $this->setAdminForce($row['admin_force_noti']);
497 $this->setUserToggle($row['user_toggle_noti']);
498 $this->setUserIdNoti($row['user_id_noti']);
499
500 $this->insertAdminForce();
501 }
502 }
$records
Definition: simple_test.php:22

References $records, $row, insertAdminForce(), setAdminForce(), setUserId(), setUserIdNoti(), and setUserToggle().

+ Here is the call graph for this function:

◆ deleteAdminForce()

ilForumNotification::deleteAdminForce ( )

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

169 {
170 $this->db->manipulateF(
171 '
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 );
180 }

References getForumId(), and getUserId().

+ Here is the call graph for this function:

◆ deleteNotificationAllUsers()

ilForumNotification::deleteNotificationAllUsers ( )

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

387 {
388 $this->db->manipulateF(
389 '
390 DELETE FROM frm_notification
391 WHERE frm_id = %s
392 AND user_id_noti > %s',
393 array('integer', 'integer'),
394 array($this->getForumId(), 0)
395 );
396 }

References getForumId().

+ Here is the call graph for this function:

◆ deleteUserToggle()

ilForumNotification::deleteUserToggle ( )

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

183 {
184 $this->db->manipulateF(
185 '
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 }

References getForumId(), and getUserId().

+ Here is the call graph for this function:

◆ existsNotification()

ilForumNotification::existsNotification ( )
Returns
bool

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

469 {
470 $res = $this->db->queryF(
471 '
472 SELECT * FROM frm_notification
473 WHERE user_id = %s
474 AND frm_id = %s
475 AND admin_force_noti = %s',
476 array('integer', 'integer', 'integer'),
477 array($this->getUserId(), $this->getForumId(), $this->getAdminForce())
478 );
479
480 if ($row = $this->db->numRows($res) > 0) {
481 return true;
482 }
483 return false;
484 }
foreach($_POST as $key=> $value) $res

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

+ Here is the call graph for this function:

◆ getAdminForce()

ilForumNotification::getAdminForce ( )

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

87 {
88 return $this->admin_force;
89 }

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
Returns
mixed

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

284 {
285 if (!array_key_exists($ref_id, self::$node_data_cache)) {
286 global $DIC;
287 self::$node_data_cache[$ref_id] = $DIC->repositoryTree()->getChildsByType($ref_id, 'frm');
288 }
289
290 return self::$node_data_cache[$ref_id];
291 }

References $DIC, and $ref_id.

Referenced by checkForumsExistsDelete(), and checkForumsExistsInsert().

+ Here is the caller graph for this function:

◆ getForumId()

ilForumNotification::getForumId ( )

◆ getForumRefId()

ilForumNotification::getForumRefId ( )

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

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

References $ref_id.

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

◆ getUserId()

ilForumNotification::getUserId ( )

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

59 {
60 return $this->user_id;
61 }

References $user_id.

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

+ Here is the caller graph for this function:

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

97 {
98 return $this->user_toggle;
99 }

References $user_toggle.

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

+ Here is the caller graph for this function:

◆ insertAdminForce()

ilForumNotification::insertAdminForce ( )

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

156 {
157 $next_id = $this->db->nextId('frm_notification');
158 $this->db->manipulateF(
159 '
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(), $this->user->getId())
165 );
166 }

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

Referenced by cloneFromSource().

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

◆ isAdminForceNotification()

ilForumNotification::isAdminForceNotification ( )

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

122 {
123 $res = $this->db->queryF(
124 '
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
133 while ($row = $this->db->fetchAssoc($res)) {
134 return $row['admin_force_noti'];
135 }
136 }

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

+ Here is the call graph for this function:

◆ isUserToggleNotification()

ilForumNotification::isUserToggleNotification ( )

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

139 {
140 $res = $this->db->queryF(
141 '
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
150 while ($row = $this->db->fetchAssoc($res)) {
151 return $row['user_toggle_noti'];
152 }
153 }

References $res, $row, 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 420 of file class.ilForumNotification.php.

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

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

Referenced by ilForum\mergeThreads().

+ Here is the caller graph for this function:

◆ read()

ilForumNotification::read ( )

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

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

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

+ Here is the call graph for this function:

◆ setAdminForce()

ilForumNotification::setAdminForce (   $a_admin_force)

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

83 {
84 $this->admin_force = $a_admin_force;
85 }

Referenced by cloneFromSource().

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

55 {
56 $this->user_id = $a_user_id;
57 }

Referenced by cloneFromSource(), and ilForumSettingsGUI\getUserNotificationTableData().

+ 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 }

Referenced by cloneFromSource().

+ Here is the caller graph for this function:

◆ setUserToggle()

ilForumNotification::setUserToggle (   $a_user_toggle)

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

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

Referenced by cloneFromSource().

+ Here is the caller graph for this function:

◆ update()

ilForumNotification::update ( )

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

373 {
374 $this->db->manipulateF(
375 '
376 UPDATE frm_notification
377 SET admin_force_noti = %s,
378 user_toggle_noti = %s
379 WHERE user_id = %s
380 AND frm_id = %s',
381 array('integer','integer','integer','integer'),
382 array($this->getAdminForce(), $this->getUserToggle(), $this->getUserId(), $this->getForumId())
383 );
384 }

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

+ Here is the call graph for this function:

◆ updateUserToggle()

ilForumNotification::updateUserToggle ( )

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

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

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

+ 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().

◆ $db

ilForumNotification::$db
private

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

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

ilForumNotification::$user
private

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

◆ $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: