public function delete($id = NULL) { if ($id === NULL) { $id = $this->id; } $descendants = $this->descendants(TRUE)->find_all(); foreach ($descendants as $descendant) { $this->db->delete('page_contents', array('page_id' => $descendant->id)); } if ($id === $this->id and isset(self::$page_cache[$this->_identifier])) { unset(self::$page_cache[$this->_identifier]); } return parent::delete($id); }
public function delete() { $old = clone $this; module::event("item_before_delete", $this); $parent = $this->parent(); if ($parent->album_cover_item_id == $this->id) { item::remove_album_cover($parent); } $path = $this->file_path(); $resize_path = $this->resize_path(); $thumb_path = $this->thumb_path(); parent::delete(); if (is_dir($path)) { @dir::unlink($path); @dir::unlink(dirname($resize_path)); @dir::unlink(dirname($thumb_path)); } else { @unlink($path); @unlink($resize_path); @unlink($thumb_path); } module::event("item_deleted", $old); }
public function delete($ignored_id = null) { if (!$this->loaded()) { // Concurrent deletes may result in this item already being gone. Ignore it. return; } if ($this->id == 1) { $v = new Validation(array("id")); $v->add_error("id", "cant_delete_root_album"); ORM_Validation_Exception::handle_validation($this->table_name, $v); } $old = clone $this; module::event("item_before_delete", $this); $parent = $this->parent(); if ($parent->album_cover_item_id == $this->id) { item::remove_album_cover($parent); } $path = $this->file_path(); $resize_path = $this->resize_path(); $thumb_path = $this->thumb_path(); parent::delete(); if (is_dir($path)) { // Take some precautions against accidentally deleting way too much $delete_resize_path = dirname($resize_path); $delete_thumb_path = dirname($thumb_path); if ($delete_resize_path == VARPATH . "resizes" || $delete_thumb_path == VARPATH . "thumbs" || $path == VARPATH . "albums") { throw new Exception("@todo DELETING_TOO_MUCH ({$delete_resize_path}, {$delete_thumb_path}, {$path})"); } @dir::unlink($path); @dir::unlink($delete_resize_path); @dir::unlink($delete_thumb_path); } else { @unlink($path); @unlink($resize_path); @unlink($thumb_path); } module::event("item_deleted", $old); }
/** * Removes a node and it's descendants. * * $usless_param prevents a strict error that breaks PHPUnit like hell! * @access public * @param bool $descendants remove the descendants? */ public function delete($version, $usless_param = NULL) { versions_helper::version_position_table($this->table_name, $version); parent::delete($usless_param); }
/** * Deletes a single post or multiple posts, ignoring relationships. * * @return ORM * @throws Gleez_Exception * @uses Path::delete */ public function delete($query = NULL) { if (!$this->_loaded) { throw new Gleez_Exception('Cannot delete :model model because it is not loaded.', array(':model' => $this->_object_name)); } $source = $this->rawurl; parent::delete($query); // Delete the path aliases associated with this object Path::delete(array('source' => $source)); unset($source); return $this; }
public function delete() { $original_path = $this->file_path(); $original_resize_path = $this->resize_path(); $original_thumb_path = $this->thumb_path(); // If there is no name, the path is invalid so don't try to delete if (!empty($this->name)) { if ($this->is_album()) { dir::unlink(dirname($original_path)); dir::unlink(dirname($original_resize_path)); dir::unlink(dirname($original_thumb_path)); } else { unlink($original_path); unlink($original_resize_path); unlink($original_thumb_path); } } parent::delete(); }
/** * Deletes a single post or multiple posts, ignoring relationships. * * @return ORM * @throws Gleez_Exception * @uses Path::delete */ public function delete($soft = FALSE) { if (!$this->_loaded) { throw new Gleez_Exception('Cannot delete :model model because it is not loaded.', array(':model' => $this->_object_name)); } if (is_array($this->_deleted_column) && $soft == TRUE) { } else { $source = $this->rawurl; parent::delete($soft); // Delete the path aliases associated with this object Path::delete(array('source' => $source)); unset($source); } return $this; }