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 showMembersObject() { /** * @var $tree ilTree * @var $tpl ilTemplate * @var $ilTabs ilTabsGUI * @var $ilAccess ilAccessHandler * @var $ilErr ilErr */ global $tree, $tpl, $ilTabs, $ilAccess, $ilErr; if (!$ilAccess->checkAccess('write', '', $this->ref_id)) { $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE); } $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_members_list.html', 'Modules/Forum'); $ilTabs->setTabActive('settings'); $this->settingsTabs(); // instantiate the property form if (!$this->initNotificationSettingsForm()) { // if the form was just created set the values fetched from database $this->notificationSettingsForm->setValuesByArray(array('notification_type' => $this->objProperties->getNotificationType(), 'adm_force' => (bool) $this->objProperties->isAdminForceNoti(), 'usr_toggle' => (bool) $this->objProperties->isUserToggleNoti())); } // set form html into template $tpl->setVariable('NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML()); include_once 'Modules/Forum/classes/class.ilForumNotification.php'; include_once 'Modules/Forum/classes/class.ilObjForum.php'; $frm_noti = new ilForumNotification($this->object->getRefId()); $oParticipants = $this->getParticipantsObject(); $moderator_ids = $frm_noti->_getModerators($this->object->getRefId()); $admin_ids = $oParticipants->getAdmins(); $member_ids = $oParticipants->getMembers(); $tutor_ids = $oParticipants->getTutors(); if ($this->objProperties->getNotificationType() == 'default') { // update forum_notification table include_once 'Modules/Forum/classes/class.ilForumNotification.php'; $forum_noti = new ilForumNotification($this->object->getRefId()); $forum_noti->setAdminForce($this->objProperties->isAdminForceNoti()); $forum_noti->setUserToggle($this->objProperties->isUserToggleNoti()); $forum_noti->setForumId($this->objProperties->getObjId()); } else { if ($this->objProperties->getNotificationType() == 'per_user') { $moderators = $this->getUserNotificationTableData($moderator_ids, $frm_noti); $admins = $this->getUserNotificationTableData($admin_ids, $frm_noti); $members = $this->getUserNotificationTableData($member_ids, $frm_noti); $tutors = $this->getUserNotificationTableData($tutor_ids, $frm_noti); $this->__showMembersTable($moderators, $admins, $members, $tutors); } } }
public function showMembersObject() { /** * @var $tree ilTree * @var $tpl ilTemplate * @var $ilTabs ilTabsGUI * @var $ilAccess ilAccessHandler * @var $ilErr ilErr */ global $tree, $tpl, $ilTabs, $ilAccess, $ilErr; if (!$ilAccess->checkAccess('write', '', $this->ref_id)) { $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE); } $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_members_list.html', 'Modules/Forum'); $ilTabs->setTabActive('settings'); $this->settingsTabs(); // instantiate the property form if (!$this->initNotificationSettingsForm()) { // if the form was just created set the values fetched from database $this->notificationSettingsForm->setValuesByArray(array('notification_type' => $this->objProperties->getNotificationType(), 'adm_force' => (bool) $this->objProperties->isAdminForceNoti(), 'usr_toggle' => (bool) $this->objProperties->isUserToggleNoti())); } // set form html into template $tpl->setVariable('NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML()); include_once 'Modules/Forum/classes/class.ilForumNotification.php'; include_once 'Modules/Forum/classes/class.ilObjForum.php'; $frm_noti = new ilForumNotification($this->object->getRefId()); // check if there a parent-node is a grp or crs $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp'); $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs'); if ($grp_ref_id == 0 && $crs_ref_id == 0) { $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE); } /** * @var $oParticipants ilParticipants */ $oParticipants = null; if ($grp_ref_id > 0) { $parent_obj = ilObjectFactory::getInstanceByRefId($grp_ref_id); include_once 'Modules/Group/classes/class.ilGroupParticipants.php'; $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId()); } else { if ($crs_ref_id > 0) { $parent_obj = ilObjectFactory::getInstanceByRefId($crs_ref_id); include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId()); } } $moderator_ids = $frm_noti->_getModerators($this->object->getRefId()); $admin_ids = $oParticipants->getAdmins(); $member_ids = $oParticipants->getMembers(); $tutor_ids = $oParticipants->getTutors(); $moderators = array(); $admins = array(); $members = array(); $tutors = array(); $all_forum_users = array_merge($moderator_ids, $admin_ids, $member_ids, $tutor_ids); $all_forum_users = array_unique($all_forum_users); if ($this->objProperties->getNotificationType() == 'default') { // update forum_notification table include_once 'Modules/Forum/classes/class.ilForumNotification.php'; $forum_noti = new ilForumNotification($this->object->getRefId()); $forum_noti->setAdminForce($this->objProperties->isAdminForceNoti()); $forum_noti->setUserToggle($this->objProperties->isUserToggleNoti()); $forum_noti->setForumId($this->objProperties->getObjId()); if (isset($_POST['notification_type']) && $_POST['notification_type'] == 'default') { // delete all notifications set by admin $forum_noti->deleteNotificationAllUsers(); } } else { if ($this->objProperties->getNotificationType() == 'per_user') { $counter = 0; foreach ($moderator_ids as $user_id) { $frm_noti->setUserId($user_id); #$admin_force_noti = $frm_noti->isAdminForceNotification(); $user_toggle_noti = $frm_noti->isUserToggleNotification(); $icon_ok = $this->getIcon(!$user_toggle_noti); $moderators[$counter]['user_id'] = ilUtil::formCheckbox(0, 'user_id[]', $user_id); $moderators[$counter]['login'] = ilObjUser::_lookupLogin($user_id); $name = ilObjUser::_lookupName($user_id); $moderators[$counter]['firstname'] = $name['firstname']; $moderators[$counter]['lastname'] = $name['lastname']; $moderators[$counter]['user_toggle_noti'] = $icon_ok; $counter++; } $counter = 0; foreach ($admin_ids as $user_id) { $frm_noti->setUserId($user_id); #$admin_force_noti = $frm_noti->isAdminForceNotification(); $user_toggle_noti = $frm_noti->isUserToggleNotification(); $icon_ok = $this->getIcon(!$user_toggle_noti); $admins[$counter]['user_id'] = ilUtil::formCheckbox(0, 'user_id[]', $user_id); $admins[$counter]['login'] = ilObjUser::_lookupLogin($user_id); $name = ilObjUser::_lookupName($user_id); $admins[$counter]['firstname'] = $name['firstname']; $admins[$counter]['lastname'] = $name['lastname']; $admins[$counter]['user_toggle_noti'] = $icon_ok; $counter++; } $counter = 0; foreach ($member_ids as $user_id) { $frm_noti->setUserId($user_id); #$admin_force_noti = $frm_noti->isAdminForceNotification(); $user_toggle_noti = $frm_noti->isUserToggleNotification(); $icon_ok = $this->getIcon(!$user_toggle_noti); $members[$counter]['user_id'] = ilUtil::formCheckbox(0, 'user_id[]', $user_id); $members[$counter]['login'] = ilObjUser::_lookupLogin($user_id); $name = ilObjUser::_lookupName($user_id); $members[$counter]['firstname'] = $name['firstname']; $members[$counter]['lastname'] = $name['lastname']; $members[$counter]['user_toggle_noti'] = $icon_ok; $counter++; } $counter = 0; foreach ($tutor_ids as $user_id) { $frm_noti->setUserId($user_id); #$admin_force_noti = $frm_noti->isAdminForceNotification(); $user_toggle_noti = $frm_noti->isUserToggleNotification(); $icon_ok = $this->getIcon(!$user_toggle_noti); $tutors[$counter]['user_id'] = ilUtil::formCheckbox(0, 'user_id[]', $user_id); $tutors[$counter]['login'] = ilObjUser::_lookupLogin($user_id); $name = ilObjUser::_lookupName($user_id); $tutors[$counter]['firstname'] = $name['firstname']; $tutors[$counter]['lastname'] = $name['lastname']; $tutors[$counter]['user_toggle_noti'] = $icon_ok; $counter++; } $this->__showMembersTable($moderators, $admins, $members, $tutors); } else { $frm_noti = new ilForumNotification($this->object->getRefId()); $all_notis = $frm_noti->read(); foreach ($all_forum_users as $user_id) { $frm_noti->setUserId($user_id); $frm_noti->setAdminForce(1); $frm_noti->setUserToggle($this->objProperties->isUserToggleNoti()); if (array_key_exists($user_id, $all_notis)) { $frm_noti->update(); } else { if ($frm_noti->existsNotification() == false && !in_array($user_id, $moderator_ids)) { $frm_noti->insertAdminForce(); } } } } } }
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'); }