public static function checkForumsExistsDelete($ref_id, $user_id = 0) { global $ilUser; $node_data = self::getCachedNodeData($ref_id); include_once 'Modules/Forum/classes/class.ilForumModerators.php'; foreach ($node_data as $data) { //check frm_properties if frm_noti is enabled $frm_noti = new ilForumNotification($data['ref_id']); $objFrmMods = new ilForumModerators($data['ref_id']); $moderator_ids = $objFrmMods->getCurrentModerators(); if ($user_id != 0) { $frm_noti->setUserId($user_id); } else { $frm_noti->setUserId($ilUser->getId()); } $frm_noti->setForumId($data['obj_id']); if (!in_array($frm_noti->getUserId(), $moderator_ids)) { $frm_noti->deleteAdminForce(); } } }
public function isUserAllowedToDeactivateNotification() { if ($this->objProperties->getNotificationType() == 'default') { return true; } if ($this->objProperties->isUserToggleNoti() == 0) { return true; } if ($this->isParentObjectCrsOrGrp()) { } global $ilUser; include_once 'Modules/Forum/classes/class.ilForumNotification.php'; $frm_noti = new ilForumNotification((int) $_GET['ref_id']); $frm_noti->setUserId($ilUser->getId()); $user_toggle = (int) $frm_noti->isUserToggleNotification(); if ($user_toggle == 0) { return true; } return false; }
protected function initHeaderAction($a_sub_type = null, $a_sub_id = null) { /** * @var $ilUser ilObjUser */ global $ilUser; $lg = parent::initHeaderAction(); // Workaround: Do not show "desktop actions" in thread view if ($this->objCurrentTopic->getId()) { $container_obj = null; $lg->setContainerObject($container_obj); } if ($lg instanceof ilObjForumListGUI) { include_once 'Modules/Forum/classes/class.ilForumNotification.php'; $frm_noti = new ilForumNotification((int) $_GET['ref_id']); $frm_noti->setUserId($ilUser->getId()); $user_toggle = $frm_noti->isUserToggleNotification(); // Notification button $notificiation_enabled = false; if ($ilUser->getId() != ANONYMOUS_USER_ID && $this->ilias->getSetting('forum_notification') != 0 && $user_toggle != 1) { $frm = $this->object->Forum; $frm->setForumId($this->object->getId()); $frm->setForumRefId($this->object->getRefId()); $frm->setMDB2Wherecondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId())); if ($this->objCurrentTopic->getId()) { $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId()); } if ($frm->isForumNotificationEnabled($ilUser->getId())) { $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'disableForumNotification'), "forums_disable_forum_notification"); $notificiation_enabled = true; } else { $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'enableForumNotification'), "forums_enable_forum_notification"); } if ($this->objCurrentTopic->getId()) { if ($this->objCurrentTopic->isNotificationEnabled($ilUser->getId())) { $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'toggleThreadNotification'), "forums_disable_notification"); $notificiation_enabled = true; } else { $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'toggleThreadNotification'), "forums_enable_notification"); } } $this->ctrl->setParameter($this, 'thr_pk', ''); if ($notificiation_enabled) { $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_on.png"), $this->lng->txt("frm_notification_activated")); } else { $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_off.png"), $this->lng->txt("frm_notification_deactivated")); } } } return $lg; }
public static function checkForumsExistsDelete($ref_id, $user_id = 0) { global $tree, $ilUser; $node_data = $tree->getChildsByType($ref_id, 'frm'); foreach ($node_data as $data) { //check frm_properties if frm_noti is enabled $frm_noti = new ilForumNotification($data['ref_id']); if ($user_id != 0) { $frm_noti->setUserId($user_id); } else { $frm_noti->setUserId($ilUser->getId()); } $frm_noti->setForumId($data['obj_id']); $frm_noti->deleteAdminForce(); } }
/** * */ public function detachModeratorRole() { if (!isset($_POST['usr_id']) || !is_array($_POST['usr_id'])) { ilUtil::sendFailure($this->lng->txt('frm_moderators_select_at_least_one')); return $this->showModerators(); } $entries = $this->oForumModerators->getCurrentModerators(); if (count($_POST['usr_id']) == count($entries)) { ilUtil::sendFailure($this->lng->txt('frm_at_least_one_moderator')); return $this->showModerators(); } include_once "Modules/Forum/classes/class.ilForumNotification.php"; $isCrsGrp = ilForumNotification::_isParentNodeGrpCrs($this->ref_id); if ($isCrsGrp) { global $tree; $parent_ref_id = $tree->getParentId($this->ref_id); include_once "Services/Membership/classes/class.ilParticipants.php"; } include_once "Modules/Forum/classes/class.ilForumProperties.php"; $objFrmProps = ilForumProperties::getInstance(ilObject::_lookupObjId($this->ref_id)); $frm_noti_type = $objFrmProps->getNotificationType(); foreach ($_POST['usr_id'] as $usr_id) { $this->oForumModerators->detachModeratorRole((int) $usr_id); if ($isCrsGrp && $frm_noti_type != 'default') { if (!ilParticipants::_isParticipant($this->ref_id, $usr_id)) { $tmp_frm_noti = new ilForumNotification($this->ref_id); $tmp_frm_noti->setUserId((int) $usr_id); $tmp_frm_noti->setForumId(ilObject::_lookupObjId($this->ref_id)); $tmp_frm_noti->deleteAdminForce(); } } } ilUtil::sendSuccess($this->lng->txt('frm_moderators_detached_role_successfully'), true); $this->ctrl->redirect($this, 'showModerators'); }