36 $this->lng = $DIC->language();
37 $this->db = $DIC->database();
38 $this->
user = $DIC->user();
40 $this->forum_id = $DIC[
'ilObjDataCache']->lookupObjId(
$ref_id);
45 $this->notification_id = $a_notification_id;
53 $this->user_id = $a_user_id;
62 $this->forum_id = $a_forum_id;
71 $this->thread_id = $a_thread_id;
81 $this->admin_force = $a_admin_force;
91 $this->user_toggle = $a_user_toggle;
100 $this->ref_id = $a_ref_id;
110 $this->user_id_noti = $a_user_id_noti;
115 return $this->user_id_noti;
120 $res = $this->db->queryF(
122 SELECT admin_force_noti FROM frm_notification 125 AND user_id_noti > %s ',
126 array(
'integer',
'integer',
'integer'),
130 while (
$row = $this->db->fetchAssoc(
$res)) {
131 return $row[
'admin_force_noti'];
137 $res = $this->db->queryF(
139 SELECT user_toggle_noti FROM frm_notification 142 AND user_id_noti > %s',
143 array(
'integer',
'integer',
'integer'),
147 while (
$row = $this->db->fetchAssoc(
$res)) {
148 return $row[
'user_toggle_noti'];
154 $next_id = $this->db->nextId(
'frm_notification');
155 $this->db->manipulateF(
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'),
167 $this->db->manipulateF(
169 DELETE FROM frm_notification 172 AND admin_force_noti = %s 173 AND user_id_noti > %s',
174 array(
'integer',
'integer',
'integer',
'integer'),
181 $this->db->manipulateF(
183 DELETE FROM frm_notification 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'),
196 $this->db->manipulateF(
198 UPDATE frm_notification 199 SET user_toggle_noti = %s 202 AND admin_force_noti = %s',
203 array(
'integer',
'integer',
'integer',
'integer'),
217 $node_data = self::getCachedNodeData(
$ref_id);
219 foreach ($node_data as
$data) {
225 $frm_noti->setUserId(
$ilUser->getId());
233 $frm_noti->setAdminForce(1);
238 $frm_noti->setForumId($data[
'obj_id']);
239 if ($frm_noti->existsNotification() ==
false) {
240 $frm_noti->insertAdminForce();
251 $node_data = self::getCachedNodeData(
$ref_id);
253 foreach ($node_data as
$data) {
257 $moderator_ids = $objFrmMods->getCurrentModerators();
262 $frm_noti->setUserId(
$ilUser->getId());
265 $frm_noti->setForumId($data[
'obj_id']);
266 if (!in_array($frm_noti->getUserId(), $moderator_ids)) {
267 $frm_noti->deleteAdminForce();
278 if (!array_key_exists(
$ref_id, self::$node_data_cache)) {
280 $node_data = $DIC->repositoryTree()->getSubTree(
281 $DIC->repositoryTree()->getNodeData(
$ref_id),
285 $node_data = array_filter($node_data,
function ($forum_node) use ($DIC,
$ref_id) {
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') {
294 self::$node_data_cache[
$ref_id] = $node_data;
297 return self::$node_data_cache[
$ref_id];
308 $parent_ref_id = $DIC->repositoryTree()->getParentId($a_ref_id);
311 if ($parent_obj->getType() ==
'crs' || $parent_obj->getType() ==
'grp') {
312 return $parent_obj->getType();
324 $ilDB = $DIC->database();
325 $ilObjDataCache = $DIC[
'ilObjDataCache'];
327 if (!$a_parameter[
'tree'] ==
'tree') {
331 $ref_id = $a_parameter[
'source_id'];
332 $is_parent = self::_isParentNodeGrpCrs(
$ref_id);
339 DELETE FROM frm_notification 341 AND admin_force_noti = %s',
342 array(
'integer',
'integer'),
355 $tree = $DIC->repositoryTree();
360 if ($parent_obj->getType() ==
'crs') {
362 } elseif ($parent_obj->getType() ==
'grp') {
367 if ($parent_obj->getType() ==
'crs' || $parent_obj->getType() ==
'grp') {
369 $admin_ids = $oParticipants->getAdmins();
370 $tutor_ids = $oParticipants->getTutors();
372 $result = array_unique(array_merge($moderator_ids, $admin_ids, $tutor_ids));
379 $this->db->manipulateF(
381 UPDATE frm_notification 382 SET admin_force_noti = %s, 383 user_toggle_noti = %s 386 array(
'integer',
'integer',
'integer',
'integer'),
393 $this->db->manipulateF(
395 DELETE FROM frm_notification 397 AND user_id_noti > %s',
398 array(
'integer',
'integer'),
407 $query = $this->db->queryF(
409 SELECT * FROM frm_notification WHERE 415 while (
$row = $this->db->fetchAssoc(
$query)) {
429 $ilDB = $DIC->database();
432 'SELECT notification_id, user_id FROM frm_notification 435 ORDER BY user_id ASC',
436 array(
'integer',
'integer'),
437 array(0, $merge_source_thread_id)
440 $res_2 =
$ilDB->queryF(
441 'SELECT DISTINCT user_id FROM frm_notification 444 ORDER BY user_id ASC',
445 array(
'integer',
'integer'),
446 array(0, $merge_target_thread_id)
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'];
455 if (isset($users_already_notified[
$row[
'user_id']])) {
458 'DELETE FROM frm_notification WHERE notification_id = %s',
460 array($row[
'notification_id'])
466 array(
'thread_id' => array(
'integer', $merge_target_thread_id)),
467 array(
'thread_id' => array(
'integer', $merge_source_thread_id)
479 $res = $this->db->queryF(
481 SELECT * FROM frm_notification 484 AND admin_force_noti = %s',
485 array(
'integer',
'integer',
'integer'),
489 if (
$row = $this->db->numRows(
$res) > 0) {
500 $sourceNotificationSettings =
new self($sourceRefId);
501 $records = $sourceNotificationSettings->read();
static _isParentNodeGrpCrs($a_ref_id)
deleteNotificationAllUsers()
isUserToggleNotification()
isAdminForceNotification()
setUserIdNoti($a_user_id_noti)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
setAdminForce($a_admin_force)
static getCachedNodeData($ref_id)
Class ilForumNotification.
setThreadId($a_thread_id)
static mergeThreadNotificiations($merge_source_thread_id, $merge_target_thread_id)
setUserToggle($a_user_toggle)
static _clearForcedForumNotifications($a_parameter)
foreach($_POST as $key=> $value) $res
static _isUserToggleNoti($a_obj_id)
static _isAdminForceNoti($a_obj_id)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static checkForumsExistsDelete($ref_id, $user_id=0)
__construct($ref_id)
Constructor public.
static checkParentNodeTree($ref_id)
cloneFromSource(int $sourceRefId)
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)
static checkForumsExistsInsert($ref_id, $user_id=0)
setNotificationId($a_notification_id)