Commit 944c9e4e2087f49910d7825ad4eea842192e242b

Authored by Neil Blakey-Milner
1 parent edcdf335

Switch to using KTEntity


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3039 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/DocumentLink.inc
... ... @@ -26,7 +26,7 @@
26 26 * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
27 27 * @package lib.documentmanagement
28 28 */
29   -class DocumentLink {
  29 +class DocumentLink extends KTEntity {
30 30  
31 31 /** primary key value */
32 32 var $iId;
... ... @@ -98,77 +98,17 @@ class DocumentLink {
98 98 $this->iChildDocumentID = $iNewValue;
99 99 }
100 100  
101   - /**
102   - * Store the current object in the database
103   - *
104   - * @return boolean on successful store, false otherwise and set $_SESSION["errorMessage"]
105   - *
106   - */
107   - function create() {
108   - global $default, $lang_err_database, $lang_err_object_exists;
109   - //if the object hasn't been created
110   - if ($this->iId < 0) {
111   - $sTable = $default->document_link_table;
112   - $aFieldValues = array(
113   - 'parent_document_id' => $this->iParentDocumentID,
114   - 'child_document_id' => $this->iChildDocumentID,
115   - );
116   - $id =& DBUtil::autoInsert($sTable, $aFieldValues);
117   -
118   - if (PEAR::isError($id)) {
119   - $_SESSION["errorMessage"] = $id->toString();
120   - return false;
121   - }
122   - $this->iId = $id;
123   - return true;
124   - }
125   - $_SESSION["errorMessage"] = $lang_err_object_exists."id = ".$this->iId." table = document_fields";
126   - return false;
127   - }
  101 + function _fieldValues () {
  102 + return array(
  103 + 'parent_document_id' => $this->iParentDocumentID,
  104 + 'child_document_id' => $this->iChildDocumentID,
  105 + );
  106 + }
128 107  
129   - /**
130   - * Update the values in the database table with the object's current values
131   - *
132   - * @return boolean true on successful update, false otherwise and set $_SESSION["errorMessage"]
133   - *
134   - */
135   - function update() {
136   - global $default, $lang_err_database, $lang_err_object_key;
137   - //only update if the object has been stored
138   - if ($this->iId > 0) {
139   - $sql = $default->db;
140   - $result = $sql->query("UPDATE $default->document_link_table SET parent_document_id = $this->iParentDocumentID, child_document_id = $this->iChildDocumentID WHERE id = $this->iId");
141   - if ($result) {
142   - return true;
143   - }
144   - $_SESSION["errorMessage"] = $lang_err_database;
145   - return false;
146   - }
147   - $_SESSION["errorMessage"] = $lang_err_object_key;
148   - return false;
149   - }
150   -
151   - /**
152   - * Delete the current object from the database
153   - *
154   - * @return boolean true on successful deletion, false otherwise and set $_SESSION["errorMessage"]
155   - *
156   - */
157   - function delete() {
158   - global $default, $lang_err_database, $lang_err_object_key;
159   - //only delete the object if it exists in the database
160   - if ($this->iId >= 0) {
161   - $sql = $default->db;
162   - $result = $sql->query("DELETE FROM $default->document_link_table WHERE id = $this->iId");
163   - if ($result) {
164   - return true;
165   - }
166   - $_SESSION["errorMessage"] = $lang_err_database;
167   - return false;
168   - }
169   - $_SESSION["errorMessage"] = $lang_err_object_key;
170   - return false;
171   - }
  108 + function _table () {
  109 + global $default;
  110 + return $default->document_link_table;
  111 + }
172 112  
173 113 /**
174 114 * Static function.
... ...