Example #1
0
 public function performThreadsActionObject()
 {
     /**
      * @var $ilUser ilObjUser
      */
     global $ilUser;
     unset($_SESSION['threads2move']);
     unset($_SESSION['frm_topic_paste_expand']);
     if (isset($_POST['thread_ids']) && is_array($_POST['thread_ids'])) {
         if (isset($_POST['selected_cmd']) && $_POST['selected_cmd'] == 'move') {
             if ($this->is_moderator) {
                 $_SESSION['threads2move'] = $_POST['thread_ids'];
                 $this->moveThreadsObject();
             }
         } else {
             if ($_POST['selected_cmd'] == 'enable_notifications' && $this->ilias->getSetting('forum_notification') != 0) {
                 for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
                     $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
                     $tmp_obj->enableNotification($ilUser->getId());
                     unset($tmp_obj);
                 }
                 $this->ctrl->redirect($this, 'showThreads');
             } else {
                 if ($_POST['selected_cmd'] == 'disable_notifications' && $this->ilias->getSetting('forum_notification') != 0) {
                     for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
                         $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
                         $tmp_obj->disableNotification($ilUser->getId());
                         unset($tmp_obj);
                     }
                     $this->ctrl->redirect($this, 'showThreads');
                 } else {
                     if ($_POST['selected_cmd'] == 'close') {
                         if ($this->is_moderator) {
                             for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
                                 $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
                                 $tmp_obj->close();
                                 unset($tmp_obj);
                             }
                         }
                         $this->ctrl->redirect($this, 'showThreads');
                     } else {
                         if ($_POST['selected_cmd'] == 'reopen') {
                             if ($this->is_moderator) {
                                 for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
                                     $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
                                     $tmp_obj->reopen();
                                     unset($tmp_obj);
                                 }
                             }
                             $this->ctrl->redirect($this, 'showThreads');
                         } else {
                             if ($_POST['selected_cmd'] == 'makesticky') {
                                 if ($this->is_moderator) {
                                     for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
                                         $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
                                         $tmp_obj->makeSticky();
                                         unset($tmp_obj);
                                     }
                                 }
                                 $this->ctrl->redirect($this, 'showThreads');
                             } else {
                                 if ($_POST['selected_cmd'] == 'unmakesticky') {
                                     if ($this->is_moderator) {
                                         for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
                                             $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
                                             $tmp_obj->unmakeSticky();
                                             unset($tmp_obj);
                                         }
                                     }
                                     $this->ctrl->redirect($this, 'showThreads');
                                 } else {
                                     if ($_POST['selected_cmd'] == 'editThread') {
                                         if ($this->is_moderator) {
                                             $count = count($_POST['thread_ids']);
                                             if ($count != 1) {
                                                 ilUtil::sendInfo($this->lng->txt('select_max_one_thread'), true);
                                                 $this->ctrl->redirect($this, 'showThreads');
                                             } else {
                                                 foreach ($_POST['thread_ids'] as $thread_id) {
                                                     return $this->editThreadObject($thread_id, null);
                                                 }
                                             }
                                         }
                                         $this->ctrl->redirect($this, 'showThreads');
                                     } else {
                                         if ($_POST['selected_cmd'] == 'html') {
                                             $this->ctrl->setCmd('exportHTML');
                                             $this->ctrl->setCmdClass('ilForumExportGUI');
                                             $this->executeCommand();
                                         } else {
                                             if ($_POST['selected_cmd'] == 'confirmDeleteThreads') {
                                                 $this->confirmDeleteThreads();
                                             } else {
                                                 if ($_POST['selected_cmd'] == 'merge') {
                                                     $this->mergeThreadsObject();
                                                 } else {
                                                     ilUtil::sendInfo($this->lng->txt('topics_please_select_one_action'), true);
                                                     $this->ctrl->redirect($this, 'showThreads');
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'), true);
         $this->ctrl->redirect($this, 'showThreads');
     }
 }