예제 #1
0
 public function delete_member()
 {
     if (!fse_try_to_login()) {
         header("location:/fse_login");
         return;
     }
     $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');
     $section_id = $this->post('sectionID');
     $member_username = $this->post('memberUsername');
     $page_path = ProjectInfo::assemblePath($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle);
     $page_id = Page::getByPath($page_path)->getCollectionID();
     if ($page_id <= 0) {
         header('Location: /');
         return;
     }
     if (!fse_try_to_login()) {
         set_page_action_status($page_id, t('Delete Member'), 'error', t('You do not sign in or session expired.'));
         header("Location: {$page_path}");
         return;
     }
     $curr_fse_id = $_SESSION['FSEInfo']['fse_id'];
     $curr_rights = ProjectInfo::getUserRights($project_id, $curr_fse_id);
     if ($curr_rights[0] != 't') {
         set_page_action_status($page_id, t('Delete Member'), 'error', t('You have no right to edit member roles.'));
         header("Location: {$page_path}");
         return;
     }
     $fse_info = FSEInfo::getBasicProfile($member_username);
     if ($fse_info == false) {
         set_page_action_status($page_id, t('Delete Member'), 'error', t('No such user!'));
         header("Location: {$page_path}");
         return;
     }
     ProjectInfo::removeMember($project_id, $fse_info['fse_id']);
     $section_manager = new DocSectionManager();
     $res = $section_manager->deleteSection($project_id, $domain_handle, $section_id);
     if ($res != DocSectionManager::EC_OK) {
         set_page_action_status($page_id, t('Delete Member'), 'error', t('Failed to add/edit member roles: %s', $section_manager->getErrorMessage($res)));
         header("Location: {$page_path}");
         return;
     }
     set_page_action_status($page_id, t('Delete Member'), 'success', t('Succeed to delete the member.'));
     header("Location: {$page_path}");
 }