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');
     }
 }
    /**
     * generate new dataset in frm_threads
     * @param	integer	$topic
     * @param	integer	$user
     * @param	string	$subject
     * @param	string	$message
     * @param	integer	$notify
     * @param	integer	$notify_posts
     * @param	integer	$anonymize
     * @param	datetime	$date
     * @return	integer	new post ID
     * @access public
     */
    public function generateThread($forum_id, $user, $subject, $message, $notify, $notify_posts, $alias = '', $date = '')
    {
        global $ilDB;
        $objNewThread = new ilForumTopic();
        $objNewThread->setForumId($forum_id);
        $objNewThread->setUserId($user);
        $objNewThread->setSubject($subject);
        if ($date == "") {
            $objNewThread->setCreateDate(date("Y-m-d H:i:s"));
        } else {
            if (strpos($date, "-") > 0) {
                $objNewThread->setCreateDate($date);
            } else {
                $objNewThread->setCreateDate(date("Y-m-d H:i:s", $date));
            }
        }
        $objNewThread->setImportName($this->getImportName());
        $objNewThread->setUserAlias($alias);
        $objNewThread->insert();
        if ($notify_posts == 1) {
            $objNewThread->enableNotification($user);
        }
        // update forum
        $statement = $ilDB->manipulateF('
			UPDATE frm_data 
			SET top_num_threads = top_num_threads + 1
			WHERE top_pk = %s', array('integer'), array($forum_id));
        return $this->generatePost($forum_id, $objNewThread->getId(), $user, $message, 0, $notify, $subject, $alias, $objNewThread->getCreateDate());
    }