/** * Deletes a page (and also if existing its subpages) from the database * */ function remove() { if ($success = parent::remove()) { $sortorder = $this->getSortOrder(); if ($this->id) { $success = $success && query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='pages' AND `objectid`=" . $this->id); $success = $success && query("DELETE FROM " . prefix('comments') . " WHERE ownerid = " . $this->getID() . ' AND type="pages"'); // delete any comments // remove subpages $mychild = strlen($sortorder) + 4; $result = query_full_array('SELECT * FROM ' . prefix('pages') . " WHERE `sort_order` like '" . $sortorder . "-%'"); if (is_array($result)) { foreach ($result as $row) { if (strlen($row['sort_order']) == $mychild) { $subpage = newPage($row['titlelink']); $success = $success && $subpage->remove(); } } } } } return $success; }
/** * Deletes an news article from the database * */ function remove() { if ($success = parent::remove()) { if ($this->id) { $success = query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='news' AND `objectid`=" . $this->getID()); $success = $success && query("DELETE FROM " . prefix('news2cat') . " WHERE news_id = " . $this->getID()); // delete the category association $success = $success && query("DELETE FROM " . prefix('comments') . " WHERE ownerid = " . $this->getID() . ' AND type="news"'); // delete any comments } } return $success; }