Esempio n. 1
0
        $db = Loader::db();
        $section_info = DocSectionManager::getSectionInfo($domain_handle, $section_id);
        if (count($section_info) == 0) {
            $error_info = t('No such section ID!');
        } else {
            if ($current_ver_code == 0 || $current_ver_code > $section_info['max_ver_code']) {
                $error_info = t('Bad request!');
            } else {
                $project_id = $section_info['project_id'];
                $doc_lang = substr($project_id, -2);
                $project_info = ProjectInfo::getBasicInfo($project_id);
                if ($project_info == false) {
                    $error_info = t('Bad project');
                } else {
                    $curr_fse_id = $_SESSION['FSEInfo']['fse_id'];
                    $user_rights = ProjectInfo::getUserRights($project_id, $curr_fse_id);
                    if (($section_info['status'] == DocSectionManager::SS_ADMIN_DELETED || $section_info['status'] == DocSectionManager::SS_ADMIN_SHIELDED) && $user_rights[2] != 't') {
                        $error_info = t('You have no right to recover a deleted/shielded post by the administrator.');
                    } else {
                        if ($user_rights[2] != 't' && $section_info['author_id'] != $curr_fse_id) {
                            $error_info = t('You have no right to recover the post.');
                        }
                    }
                }
                $form_action = "/fse_settings/projects/recover_post";
            }
        }
    } else {
        $error_info = t('Bad Request!');
    }
}
Esempio n. 2
0
 $db = Loader::db();
 $section_info = DocSectionManager::getSectionInfo($domain_handle, $section_id);
 if (count($section_info) == 0) {
     $error_info = t('No such section ID!');
 } else {
     if ($current_ver_code > $section_info['max_ver_code']) {
         $error_info = t('Bad request: bad version!');
     } else {
         $project_id = $section_info['project_id'];
         $doc_lang = substr($project_id, -2);
         $form_action = "/fse_settings/projects/edit_member_roles";
         $project_info = ProjectInfo::getBasicInfo($project_id);
         if ($project_info == false) {
             $error_info = t('Bad project.');
         } else {
             if (substr(ProjectInfo::getUserRights($project_id, $_SESSION['FSEInfo']['fse_id']), 0, 1) != 't') {
                 $error_info = t('You have no right to edit member roles.');
             } else {
                 $filename = DocSectionManager::getSectionContentPath($section_id, $current_ver_code, 'org');
                 $fp = fopen($filename, "r");
                 if ($fp) {
                     $author_id = trim(fgets($fp));
                     $type_handle = trim(fgets($fp));
                     $attached_files = fgets($fp);
                     $section_subject = trim(fgets($fp));
                     $section_content = fread($fp, filesize($filename));
                     fclose($fp);
                 }
                 $json = Loader::helper('json');
                 $attached_files = $json->decode($attached_files);
                 if (is_array($attached_files) == false) {
Esempio n. 3
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}");
 }
Esempio n. 4
0
    public function login($is_mobile_theme = false, $project_id = false)
    {
        $ret_info = new ReturnInfo();
        $ret_info->status = 'bad';
        $ret_info->detail = '';
        $ret_info->user_name = 'na';
        $ret_info->nick_name = 'na';
        $ret_info->project_rights = '0123456789abcdef';
        if (fse_try_to_login()) {
            $ret_info->status = 'ok';
            $ret_info->user_name = $_SESSION['FSEInfo']['user_name'];
            $ret_info->nick_name = $_SESSION['FSEInfo']['nick_name'];
            if ($project_id && ProjectInfo::getDomainName($project_id, 'home')) {
                $res = ProjectInfo::getUserRights($project_id, $_SESSION['FSEInfo']['fse_id']);
                if ($res) {
                    $ret_info->project_rights = $res;
                }
            }
            $link = FSEInfo::getPersonalHomeLink();
            if ($is_mobile_theme == 'true') {
                $ret_info->detail = '
<li>
	<a class="menu-item with-icon" href="' . $link . '" title="Personal homepage">
		<span class="glyphicon glyphicon-user"></span> ' . $ret_info->nick_name . '</a>
</li>
<li>
	<a class="menu-item with-icon" href="/fse_settings">
		<span class="glyphicon glyphicon-cogwheel"></span>
		' . t('Settings') . '
	</a>
</li>
<li>
	<a class="menu-item with-icon" href="/fse_logout/logout">
		<span class="glyphicon glyphicon-log-out"></span>
		' . t('Sign out') . '
	</a>
</li>';
            } else {
                $ret_info->detail = '
<li>
	<a class="inline-list" href="' . $link . '" title="Personal homepage">
		<span class="glyphicon glyphicon-user"></span> ' . $ret_info->nick_name . '</a>
</li>
<li>
	<a class="inline-list only-icon" href="/fse_settings" title="Settings">
		<span class="glyphicon glyphicon-cogwheel"></span></a>
</li>
<li>
		<a class="inline-list only-icon" href="/fse_logout/logout" title="Sign out">
			<span class="glyphicon glyphicon-log-out"></span></a>
</li>';
            }
        } else {
            if ($is_mobile_theme == 'true') {
                $ret_info->detail = '
<li>
	<a class="menu-item" href="/fse_login">' . t('Sign in') . '</a>
</li>
<li>
	<a class="menu-item" href="/fse_register">' . t('Sign up') . '</a>
</li>';
            } else {
                $ret_info->detail = '
<li>
	<a class="button" href="/fse_login">' . t('Sign in') . '</a>
</li>
<li>
	<a class="button button-blue" href="/fse_register">' . t('Sign up') . '</a>
</li>';
            }
        }
        $js = Loader::helper('json');
        echo $js->encode($ret_info);
        exit(0);
    }