diff --git a/lib/documentmanagement/DocumentLink.inc b/lib/documentmanagement/DocumentLink.inc index ff908be..95eff0c 100644 --- a/lib/documentmanagement/DocumentLink.inc +++ b/lib/documentmanagement/DocumentLink.inc @@ -26,7 +26,7 @@ * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa * @package lib.documentmanagement */ -class DocumentLink { +class DocumentLink extends KTEntity { /** primary key value */ var $iId; @@ -98,77 +98,17 @@ class DocumentLink { $this->iChildDocumentID = $iNewValue; } - /** - * Store the current object in the database - * - * @return boolean on successful store, false otherwise and set $_SESSION["errorMessage"] - * - */ - function create() { - global $default, $lang_err_database, $lang_err_object_exists; - //if the object hasn't been created - if ($this->iId < 0) { - $sTable = $default->document_link_table; - $aFieldValues = array( - 'parent_document_id' => $this->iParentDocumentID, - 'child_document_id' => $this->iChildDocumentID, - ); - $id =& DBUtil::autoInsert($sTable, $aFieldValues); - - if (PEAR::isError($id)) { - $_SESSION["errorMessage"] = $id->toString(); - return false; - } - $this->iId = $id; - return true; - } - $_SESSION["errorMessage"] = $lang_err_object_exists."id = ".$this->iId." table = document_fields"; - return false; - } + function _fieldValues () { + return array( + 'parent_document_id' => $this->iParentDocumentID, + 'child_document_id' => $this->iChildDocumentID, + ); + } - /** - * Update the values in the database table with the object's current values - * - * @return boolean true on successful update, false otherwise and set $_SESSION["errorMessage"] - * - */ - function update() { - global $default, $lang_err_database, $lang_err_object_key; - //only update if the object has been stored - if ($this->iId > 0) { - $sql = $default->db; - $result = $sql->query("UPDATE $default->document_link_table SET parent_document_id = $this->iParentDocumentID, child_document_id = $this->iChildDocumentID WHERE id = $this->iId"); - if ($result) { - return true; - } - $_SESSION["errorMessage"] = $lang_err_database; - return false; - } - $_SESSION["errorMessage"] = $lang_err_object_key; - return false; - } - - /** - * Delete the current object from the database - * - * @return boolean true on successful deletion, false otherwise and set $_SESSION["errorMessage"] - * - */ - function delete() { - global $default, $lang_err_database, $lang_err_object_key; - //only delete the object if it exists in the database - if ($this->iId >= 0) { - $sql = $default->db; - $result = $sql->query("DELETE FROM $default->document_link_table WHERE id = $this->iId"); - if ($result) { - return true; - } - $_SESSION["errorMessage"] = $lang_err_database; - return false; - } - $_SESSION["errorMessage"] = $lang_err_object_key; - return false; - } + function _table () { + global $default; + return $default->document_link_table; + } /** * Static function.