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}"); }