Esempio n. 1
0
 public function add_new_thread_reply()
 {
     if (!fse_try_to_login()) {
         header("location:/fse_login");
         return;
     }
     $page_id = $this->post('cID');
     $area_handle = $this->post('areaHandle');
     $project_id = $this->post('projectID');
     $domain_handle = $this->post('domainHandle');
     $volume_handle = $this->post('volumeHandle');
     $part_handle = $this->post('partHandle');
     $chapter_handle = $this->post('chapterHandle');
     $post_subject = $this->post('postSubject');
     $post_content = $this->post('postContent');
     $page_path = ProjectInfo::assemblePath($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle);
     $page = Page::getByPath($page_path);
     if ($page->getCollectionID() != $page_id) {
         header("Location: /");
         return;
     }
     if (mb_strlen($post_content) < self::MIN_CONTENT_LEN) {
         set_page_action_status($page_id, t('New Reply'), 'error', t('Too short content!'));
         header("Location: {$page_path}");
         return;
     }
     if (!fse_try_to_login()) {
         set_page_action_status($page_id, t('New Reply'), 'error', t('You do not sign in or session expired.'));
         header("Location: {$page_path}");
         return;
     }
     $attached_files = '[';
     for ($i = 0; $i < DocSectionManager::MAX_ATTACHED_FILES; $i++) {
         $attached_file_id = (int) $this->post("attachmentFile{$i}");
         if ($attached_file_id > 0) {
             $attached_files .= "{$attached_file_id}, ";
         }
     }
     $attached_files = rtrim($attached_files, ', ');
     $attached_files .= ']';
     $curr_fse_id = $_SESSION['FSEInfo']['fse_id'];
     /* Add a section for the new subject */
     $type_handle = "post:markdown_extra:none:none:none";
     $section_manager = new DocSectionManager();
     $res = $section_manager->addNewSection($curr_fse_id, $page_id, $area_handle, $project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle, $type_handle, $post_subject, $post_content, $attached_files);
     if ($res != DocSectionManager::EC_OK) {
         set_page_action_status($page_id, t('New Reply'), 'error', $section_manager->getErrorMessage($res));
         header("Location: {$page_path}");
         return;
     }
     ProjectInfo::onUpdateProjectChapterInfo($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle);
     ProjectInfo::onChangeThreads($project_id, $domain_handle, $volume_handle, $part_handle);
     set_page_action_status($page_id, t('New Reply'), 'success', t('Succeed to add new reply.'));
     header("Location: {$page_path}");
 }