public function delete_blog() { if (!fse_try_to_login()) { header("location:/fse_login"); return; } $curr_page_id = $this->post('cID'); $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'); $curr_page_path = Page::getByID($curr_page_id)->getCollectionPath(); $form_token_name = $this->post('formTokenName'); $form_token = $this->post('formToken'); if ($_SESSION[$form_token_name] != $form_token) { set_page_action_status($curr_page_id, t('Delete Blog'), 'error', t('Bad request or session expired!')); unset($_SESSION[$form_token_name]); header("Location: {$curr_page_path}"); return; } unset($_SESSION[$form_token_name]); $cpt_page_path = ProjectInfo::assemblePath($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle); $chapter_page = Page::getByPath($cpt_page_path); if ($chapter_page->getCollectionID() == false) { set_page_action_status($curr_page_id, t('Delete Blog'), 'error', t('No such blog page!')); header("Location: {$curr_page_path}"); return; } $chapter_page->delete(); $db = Loader::db(); $doc_lang = substr($project_id, -2); $db->Execute("DELETE FROM fsen_chapter_tags_{$doc_lang} WHERE chapter_handle=?", array($chapter_handle)); $db->Execute('DELETE FROM fsen_chapter_categories WHERE chapter_handle=?', array($chapter_handle)); $db->Execute("DELETE FROM fsen_project_doc_volume_part_chapters_{$doc_lang}\n\tWHERE project_id=? AND domain_handle=? AND volume_handle=? AND part_handle=? AND chapter_handle=?", array($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle)); ProjectInfo::onDeleteBlog($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle); set_page_action_status($curr_page_id, t('Delete Blog'), 'success', t('Succeed to delete the blog.')); header("Location: {$curr_page_path}"); }