public function version_move($table, $model, $page_pid, $page_sid, $type) { if (!is_numeric($page_pid)) { throw new Exception("Must pass subject id", 1); } if (!is_numeric($page_sid)) { throw new Exception("Must pass target id", 1); } if ($page_pid == $page_sid) { throw new Exception("Subject and target cannot be the same", 1); } $types = array('move_to_last_child', 'move_to_first_child', 'move_to_next_sibling', 'move_to_prev_sibling'); if (!in_array($type, $types)) { throw new Exception("Must pass move type", 1); } versions_helper::version_position_table($table); $id_node = ORM::factory($model)->where('page_pid', $page_pid)->find(); $item = ORM::factory($model)->where('page_pid', $page_sid)->find(); if (!$item->loaded) { throw new Exception("Subject not loaded", 1); } if (!$id_node->loaded) { throw new Exception("Target not loaded", 1); } $result = $item->{$type}($id_node); if (!$result) { throw new Exception("Problem with move", 1); } }
/** * 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); }