/**
  *
  */
 public function showModerators()
 {
     /**
      * @var $ilToolbar ilToolbarGUI
      * @var $lng       ilLanguage
      */
     global $ilToolbar, $lng;
     include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
     ilRepositorySearchGUI::fillAutoCompleteToolbar($this, $ilToolbar, array('auto_complete_name' => $lng->txt('user'), 'submit_name' => $lng->txt('add'), 'add_search' => true, 'add_from_container' => $this->oForumModerators->getRefId()));
     $tbl = new ilTable2GUI($this);
     $tbl->setId('frm_show_mods_tbl_' . (int) $_GET['ref_id']);
     $tbl->setFormAction($this->ctrl->getFormAction($this, 'detachModeratorRole'));
     $tbl->setTitle($this->lng->txt('frm_moderators'));
     $tbl->setRowTemplate('tpl.forum_moderators_table_row.html', 'Modules/Forum');
     $tbl->setDefaultOrderField('login');
     $entries = $this->oForumModerators->getCurrentModerators();
     $num = count($entries);
     if ($num > 1) {
         $tbl->addColumn('', 'check', '1%', true);
         $tbl->setSelectAllCheckbox('usr_id');
         $tbl->addMultiCommand('detachModeratorRole', $this->lng->txt('frm_detach_moderator_role'));
     } else {
         if (!$entries) {
             $tbl->setNoEntriesText($this->lng->txt('frm_moderators_not_exist_yet'));
         }
     }
     $tbl->addColumn($this->lng->txt('login'), 'login', '30%');
     $tbl->addColumn($this->lng->txt('firstname'), 'firstname', '30%');
     $tbl->addColumn($this->lng->txt('lastname'), 'lastname', '30%');
     $result = array();
     $i = 0;
     foreach ($entries as $usr_id) {
         /**
          * @var $user ilObjUser
          */
         $user = ilObjectFactory::getInstanceByObjId($usr_id);
         if ($num > 1) {
             $result[$i]['check'] = ilUtil::formCheckbox(false, 'usr_id[]', $user->getId());
         }
         $result[$i]['login'] = $user->getLogin();
         $result[$i]['firstname'] = $user->getFirstname();
         $result[$i]['lastname'] = $user->getLastname();
         ++$i;
     }
     $tbl->setData($result);
     $this->tpl->setContent($tbl->getHTML());
 }
 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();
         }
     }
 }
 /**
  * Clone forum moderator role
  * @access public
  * @param object $new_obj forum object
  */
 public function cloneAutoGeneratedRoles($new_obj)
 {
     /**
      * @var $rbacadmin  ilRbacAdmin
      * @var $rbacreview ilRbacReview
      */
     global $ilLog, $rbacadmin, $rbacreview;
     $moderator = ilObjForum::_lookupModeratorRole($this->getRefId());
     $new_moderator = ilObjForum::_lookupModeratorRole($new_obj->getRefId());
     $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->getRefId());
     $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
     if (!$moderator || !$new_moderator || !$source_rolf || !$target_rolf) {
         $ilLog->write(__METHOD__ . ' : Error cloning auto generated role: il_frm_moderator');
     }
     $rbacadmin->copyRolePermissions($moderator, $source_rolf, $target_rolf, $new_moderator, true);
     $ilLog->write(__METHOD__ . ' : Finished copying of role il_frm_moderator.');
     include_once './Modules/Forum/classes/class.ilForumModerators.php';
     $obj_mods = new ilForumModerators($this->getRefId());
     $old_mods = array();
     $old_mods = $obj_mods->getCurrentModerators();
     foreach ($old_mods as $user_id) {
         $rbacadmin->assignUser($new_moderator, $user_id);
     }
 }
Example #4
0
 /**
  * Clone forum moderator role
  * @access public
  * @param object $new_obj forum object
  */
 public function cloneAutoGeneratedRoles($new_obj)
 {
     /**
      * @var $rbacadmin  ilRbacAdmin
      * @var $ilLog      ilLog
      */
     global $ilLog, $rbacadmin;
     $moderator = ilObjForum::_lookupModeratorRole($this->getRefId());
     $new_moderator = ilObjForum::_lookupModeratorRole($new_obj->getRefId());
     if (!$moderator || !$new_moderator || !$this->getRefId() || !$new_obj->getRefId()) {
         $ilLog->write(__METHOD__ . ' : Error cloning auto generated role: il_frm_moderator');
     }
     $rbacadmin->copyRolePermissions($moderator, $this->getRefId(), $new_obj->getRefId(), $new_moderator, true);
     $ilLog->write(__METHOD__ . ' : Finished copying of role il_frm_moderator.');
     include_once './Modules/Forum/classes/class.ilForumModerators.php';
     $obj_mods = new ilForumModerators($this->getRefId());
     $old_mods = $obj_mods->getCurrentModerators();
     foreach ($old_mods as $user_id) {
         // The object owner is already member of the moderator role when this method is called
         // Since the new static caches are introduced with ILIAS 5.0, a database error occurs if we try to assign the user here.
         if ($this->getOwner() != $user_id) {
             $rbacadmin->assignUser($new_moderator, $user_id);
         }
     }
 }