Ejemplo n.º 1
0
 public function add_new_ref_link_list()
 {
     if (!fse_try_to_login()) {
         header("location:/fse_login");
         return;
     }
     $page_id = $this->post('cID');
     $project_id = $this->post('projectID');
     $area_handle = $this->post('areaHandle');
     $domain_handle = $this->post('domainHandle');
     $volume_handle = $this->post('volumeHandle');
     $part_handle = $this->post('partHandle');
     $chapter_handle = $this->post('chapterHandle');
     $page_path = ProjectInfo::assemblePath($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle);
     if (!isset($_SESSION['FSEInfo'])) {
         set_page_action_status($page_id, t('New Reference'), 'error', t('You do not sign in or session expired.'));
         header("Location: {$page_path}");
         return;
     }
     $project_info = ProjectInfo::getBasicInfo($project_id);
     if ($project_info == false) {
         set_page_action_status($page_id, t('New Reference'), 'error', t('No such project!'));
         header("Location: {$page_path}");
         return;
     }
     $fse_id = $_SESSION['FSEInfo']['fse_id'];
     if ($domain_handle == 'community' && $part_handle != 'na') {
     } else {
         if (substr(ProjectInfo::getUserRights($project_id, $fse_id), 1, 1) != 't') {
             set_page_action_status($page_id, t('New Reference'), 'error', t('You have no right to edit the content of this project.'));
             header("Location: {$page_path}");
             return;
         }
     }
     $type_handle = 'post-reference:markdown_extra:none:none:none';
     $section_subject = t('Reference');
     $section_content = '';
     for ($i = 0; $i < DocSectionManager::MAX_ATTACHED_FILES; $i++) {
         $ref_title = $this->post("refTitle{$i}");
         $ref_link = $this->post("refLink{$i}");
         if (strlen($ref_title) > 0 && strlen($ref_link) > DocSectionManager::MIN_LINK_STRLEN) {
             $section_content .= "1. [{$ref_title}]({$ref_link})\n";
         }
     }
     if (mb_strlen($section_content) < self::MIN_CONTENT_LEN) {
         set_page_action_status($page_id, t('New Reference'), 'error', t('Too short content!'));
         header("Location: {$page_path}");
         return;
     }
     $section_manager = new DocSectionManager();
     $res = $section_manager->addNewSection($fse_id, $page_id, $area_handle, $project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle, $type_handle, $section_subject, $section_content, '[]');
     if ($res != DocSectionManager::EC_OK) {
         set_page_action_status($page_id, t('New Reference'), 'error', t('Failed to add a new section: %s', $section_manager->getErrorMessage($res)));
         header("Location: {$page_path}");
         return;
     }
     set_page_action_status($page_id, t('New Reference'), 'success', t('Succeed to add new reference.'));
     ProjectInfo::onChangeThreads($project_id, $domain_handle, $volume_handle, $part_handle);
     header("Location: {$page_path}");
 }
Ejemplo n.º 2
0
 public static function addOwnerMemberSection($project_id, $fse_info = false)
 {
     /* add owner member section on misc page */
     if ($fse_info == false) {
         $project_info = ProjectInfo::getBasicInfo($project_id);
         if ($project_info == false) {
             exit(0);
         }
         $fse_info = FSEInfo::getNameInfo($project_info['fse_id']);
         $fse_info = FSEInfo::getBasicProfile($fse_info['user_name']);
     } else {
         $fse_info['avatar_url'] = get_url_from_file_id($fse_info['avatar_file_id']);
     }
     $page_path = self::assemblePath($project_id, 'misc');
     $about_page = Page::getByPath($page_path);
     $type_handle = 'member:markdown_safe:' . $fse_info['user_name'] . ':primary:none';
     $section_content = sprintf(self::OWNER_MARKDOWN_TEXT, FSEInfo::getPersonalHomeLink($fse_info, true), FSEInfo::getPersonalHomeLink($fse_info), $fse_info['avatar_url'], ProjectInfo::$mRoleDescriptions[substr($project_id, -2)]['owner'], h5($fse_info['self_desc']));
     $section_manager = new DocSectionManager();
     $res = $section_manager->addNewSection($fse_info['fse_id'], $about_page->getCollectionID(), 'Members', $project_id, 'misc', 'na', 'na', 'na', $type_handle, '', $section_content, '[]');
 }