Esempio n. 1
0
 /**
  * Used to delete a page.
  *
  * @todo make sure we not only delete the page but also all parts and all children!
  *
  * @param int $id Id of page to delete
  */
 public function delete($id)
 {
     // security (dont delete the root page)
     if ($id > 1) {
         // find the page to delete
         if ($page = Record::findByIdFrom('Page', $id)) {
             // check for permission to delete this page
             if (!AuthUser::hasPermission('page_delete') && $page->is_protected) {
                 Flash::set('error', __('You do not have permission to access the requested page!'));
                 redirect(get_url('page'));
             }
             // need to delete all page_parts too !!
             PagePart::deleteByPageId($id);
             if ($page->delete()) {
                 Observer::notify('page_delete', $page);
                 Flash::set('success', __('Page :title has been deleted!', array(':title' => $page->title)));
             } else {
                 Flash::set('error', __('Page :title has not been deleted!', array(':title' => $page->title)));
             }
         } else {
             Flash::set('error', __('Page not found!'));
         }
     } else {
         Flash::set('error', __('Action disabled!'));
     }
     redirect(get_url('page'));
 }
Esempio n. 2
0
 /**
  * Used to delete a page.
  *
  * @todo make sure we not only delete the page but also all parts and all children!
  *
  * @param int $id Id of page to delete
  */
 public function delete($id)
 {
     // Sanity checks
     use_helper('Validate');
     if (!Validate::numeric($id)) {
         Flash::set('error', __('Invalid input found!'));
         redirect(get_url());
     }
     // CSRF checks
     if (isset($_GET['csrf_token'])) {
         $csrf_token = $_GET['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'page/delete/' . $id)) {
             Flash::set('error', __('Invalid CSRF token found!'));
             redirect(get_url('page'));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         redirect(get_url('page'));
     }
     // security (dont delete the root page)
     if ($id > 1) {
         // find the page to delete
         if ($page = Record::findByIdFrom('Page', $id)) {
             // check for permission to delete this page
             if (!AuthUser::hasPermission('page_delete') && $page->is_protected) {
                 Flash::set('error', __('You do not have permission to access the requested page!'));
                 redirect(get_url('page'));
             }
             // need to delete all page_parts too !!
             PagePart::deleteByPageId($id);
             if ($page->delete()) {
                 Observer::notify('page_delete', $page);
                 Flash::set('success', __('Page :title has been deleted!', array(':title' => $page->title)));
             } else {
                 Flash::set('error', __('Page :title has not been deleted!', array(':title' => $page->title)));
             }
         } else {
             Flash::set('error', __('Page is not found!'));
         }
     } else {
         Flash::set('error', __('Action disabled!'));
     }
     redirect(get_url('page'));
 }
Esempio n. 3
0
 public function beforeDelete()
 {
     $ret = false;
     $ret = self::deleteChildrenOf($this->id);
     $ret = PagePart::deleteByPageId($this->id);
     $ret = PageTag::deleteByPageId($this->id);
     return $ret;
 }
Esempio n. 4
0
 public function beforeDelete()
 {
     if (!Observer::notify('page_before_delete', $this)) {
         return false;
     }
     if (!self::deleteChildrenOf($this->id) || !PagePart::deleteByPageId($this->id) || !PageTag::deleteByPageId($this->id)) {
         return false;
     }
     return true;
 }