예제 #1
0
 private function updateUserNotifications($update_all_users = false)
 {
     include_once 'Modules/Forum/classes/class.ilForumNotification.php';
     $oParticipants = $this->getParticipantsObject();
     $frm_noti = new ilForumNotification($this->object->getRefId());
     $moderator_ids = $frm_noti->_getModerators($this->object->getRefId());
     $admin_ids = $oParticipants->getAdmins();
     $member_ids = $oParticipants->getMembers();
     $tutor_ids = $oParticipants->getTutors();
     $all_forum_users = array_merge($moderator_ids, $admin_ids, $member_ids, $tutor_ids);
     $all_forum_users = array_unique($all_forum_users);
     $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) && $update_all_users) {
             $frm_noti->update();
         } else {
             if ($frm_noti->existsNotification() == false) {
                 $frm_noti->insertAdminForce();
             }
         }
     }
 }
 public static function checkForumsExistsInsert($ref_id, $user_id = 0)
 {
     global $ilUser;
     include_once 'Modules/Forum/classes/class.ilForumProperties.php';
     $node_data = self::getCachedNodeData($ref_id);
     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());
         }
         $admin_force = ilForumProperties::_isAdminForceNoti($data['obj_id']);
         $frm_noti->setAdminForce($admin_force);
         $user_toggle = ilForumProperties::_isUserToggleNoti($data['obj_id']);
         if ($user_toggle) {
             $frm_noti->setAdminForce(1);
         }
         if ($admin_force == 1 || $user_toggle == 1) {
             $frm_noti->setUserToggle($user_toggle);
             $frm_noti->setForumId($data['obj_id']);
             if ($frm_noti->existsNotification() == false) {
                 $frm_noti->insertAdminForce();
             }
         }
     }
 }
예제 #3
0
 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();
                     }
                 }
             }
         }
     }
 }