public function remove() { if (empty($_GET['instance_id'])) { die('invalid instance_id'); } $instance_id = valid::id_key($_GET['instance_id']); $db = Database::instance(); # get the instance $instance = $db->query("\n SELECT * FROM pages_tools\n WHERE id = '{$instance_id}'\n AND fk_site = '{$this->site_id}'\n ")->current(); if (!is_object($instance)) { die('invalid instance'); } # get the tool. $tool = ORM::factory('tool')->where('fk_site', $this->site_id)->find($instance->tool_id); # is this tool protected? if ('yes' == $tool->system_tool->protected) { # get the page. $page = ORM::factory('page')->where('fk_site', $this->site_id)->find($instance->page_id); # remove the protected signifier for this page. yaml::delete_value($this->site_name, 'pages_config', $page->page_name); } # delete the instance. $db->delete('pages_tools', array('id' => $instance_id, 'fk_site' => $this->site_id)); die('Tool instance removed from page.'); }
public function delete($page_id = NULL) { valid::id_key($page_id); $page = ORM::factory('page', $page_id); if (!$page->loaded) { die('invalid page'); } # is this page set as homepage? if ($page->page_name == $this->homepage) { die('Cannot delete the current home page. Specify a new home page first.'); } # is this page a folder with children? # we can delete them all, OR just not allow parents to be deleted. $children = self::get_folder_filenames($page->page_name, 'all_children'); if (0 < count($children)) { die('A page must have no sub-pages before it can be deleted.'); } #$id_set .= ','. implode(',', $folders_array[$page->page_name]); # if deleting a protected page yaml::delete_value($this->site_name, 'pages_config', $page->page_name); ORM::factory('page')->where('fk_site', $this->site_id)->delete($page_id); die('Page deleted.'); }