Commit 524b80cb5d07d1ae01f6f0f870f17a9f9aa0f5ce
1 parent
8db82a58
document type class
and modifications to document field class due to changes in db git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1103 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
214 additions
and
4 deletions
lib/documentmanagement/DocumentField.inc
| @@ -18,6 +18,10 @@ class DocumentField { | @@ -18,6 +18,10 @@ class DocumentField { | ||
| 18 | var $sName; | 18 | var $sName; |
| 19 | /** document field data type */ | 19 | /** document field data type */ |
| 20 | var $sDataType; | 20 | var $sDataType; |
| 21 | + /** is_generic */ | ||
| 22 | + var $bIsGeneric; | ||
| 23 | + /**has lookup*/ | ||
| 24 | + var $bHasLookup; | ||
| 21 | 25 | ||
| 22 | /** | 26 | /** |
| 23 | * Default constructor | 27 | * Default constructor |
| @@ -26,11 +30,14 @@ class DocumentField { | @@ -26,11 +30,14 @@ class DocumentField { | ||
| 26 | * @param Document field data type | 30 | * @param Document field data type |
| 27 | * | 31 | * |
| 28 | */ | 32 | */ |
| 29 | - function DocumentField($sNewName, $sNewDataType) { | 33 | + function DocumentField($sNewName, $sNewDataType, $bNewIsGeneric, $bNewHasLookup) { |
| 30 | //object not created yet | 34 | //object not created yet |
| 31 | $this->iId = -1; | 35 | $this->iId = -1; |
| 32 | $this->sName = $sNewName; | 36 | $this->sName = $sNewName; |
| 33 | $this->sDataType = $sNewDataType; | 37 | $this->sDataType = $sNewDataType; |
| 38 | + $this->bIsGeneric = $bNewIsGeneric; | ||
| 39 | + $this->bHasLookup = $bNewHasLookup; | ||
| 40 | + | ||
| 34 | } | 41 | } |
| 35 | 42 | ||
| 36 | /** | 43 | /** |
| @@ -83,6 +90,51 @@ class DocumentField { | @@ -83,6 +90,51 @@ class DocumentField { | ||
| 83 | $this->sDataType = $sNewValue; | 90 | $this->sDataType = $sNewValue; |
| 84 | } | 91 | } |
| 85 | 92 | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * Get the document field's generic or not | ||
| 96 | + * | ||
| 97 | + * @return String document field's data type | ||
| 98 | + * | ||
| 99 | + */ | ||
| 100 | + function getIsGeneric() { | ||
| 101 | + return $this->bIsGeneric; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + /** | ||
| 105 | + * Set the document field's genericness | ||
| 106 | + * | ||
| 107 | + * @param Document field's new data type | ||
| 108 | + * | ||
| 109 | + */ | ||
| 110 | + function setIsGeneric($sNewValue) { | ||
| 111 | + $this->bIsGeneric = $sNewValue; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + | ||
| 115 | + | ||
| 116 | + /** | ||
| 117 | + * Get the document field's lookup or not | ||
| 118 | + * | ||
| 119 | + * @return String document field's data type | ||
| 120 | + * | ||
| 121 | + */ | ||
| 122 | + function getHasLookup() { | ||
| 123 | + return $this->bHasLookup; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + /** | ||
| 127 | + * Set the document field's lookup | ||
| 128 | + * | ||
| 129 | + * @param Document field's new data type | ||
| 130 | + * | ||
| 131 | + */ | ||
| 132 | + function setHasLookup($sNewValue) { | ||
| 133 | + $this->bHasLookup = $sNewValue; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + | ||
| 137 | + | ||
| 86 | /** | 138 | /** |
| 87 | * Store the current object in the database | 139 | * Store the current object in the database |
| 88 | * | 140 | * |
| @@ -94,7 +146,7 @@ class DocumentField { | @@ -94,7 +146,7 @@ class DocumentField { | ||
| 94 | //if the object hasn't been created | 146 | //if the object hasn't been created |
| 95 | if ($this->iId < 0) { | 147 | if ($this->iId < 0) { |
| 96 | $sql = $default->db; | 148 | $sql = $default->db; |
| 97 | - $result = $sql->query("INSERT INTO " . $default->owl_fields_table . " (name, data_type) VALUES ('" . addslashes($this->sName) . "', '" . addslashes($this->sDataType) . "')"); | 149 | + $result = $sql->query("INSERT INTO " . $default->owl_fields_table . " (name, data_type,is_generic,has_lookup) VALUES ('" . addslashes($this->sName) . "', '" . addslashes($this->sDataType) . "', '" . $this->bIsGeneric . "', '" . $this->bHasLookup ."')"); |
| 98 | if ($result) { | 150 | if ($result) { |
| 99 | $this->iId = $sql->insert_id(); | 151 | $this->iId = $sql->insert_id(); |
| 100 | return true; | 152 | return true; |
| @@ -117,7 +169,7 @@ class DocumentField { | @@ -117,7 +169,7 @@ class DocumentField { | ||
| 117 | //only update if the object has been stored | 169 | //only update if the object has been stored |
| 118 | if ($this->iId > 0) { | 170 | if ($this->iId > 0) { |
| 119 | $sql = $default->db; | 171 | $sql = $default->db; |
| 120 | - $result = $sql->query("UPDATE " . $default->owl_fields_table . " SET name = '" . addslashes($this->sName) . "', data_type = '" . addslashes($this->sDataType) . "' WHERE id = $this->iId"); | 172 | + $result = $sql->query("UPDATE " . $default->owl_fields_table . " SET name = '" . addslashes($this->sName) . "', data_type = '" . addslashes($this->sDataType) . "', is_generic = '" . $this->bIsGeneric . "', has_lookup = '" . $this->bHasLookup . "' WHERE id = $this->iId"); |
| 121 | if ($result) { | 173 | if ($result) { |
| 122 | return true; | 174 | return true; |
| 123 | } | 175 | } |
| @@ -164,7 +216,7 @@ class DocumentField { | @@ -164,7 +216,7 @@ class DocumentField { | ||
| 164 | $result = $sql->query("SELECT * FROM $default->owl_fields_table WHERE id = $iDocumentFieldsID"); | 216 | $result = $sql->query("SELECT * FROM $default->owl_fields_table WHERE id = $iDocumentFieldsID"); |
| 165 | if ($result) { | 217 | if ($result) { |
| 166 | if ($sql->next_record()) { | 218 | if ($sql->next_record()) { |
| 167 | - $oDocumentField = & new DocumentField(stripslashes($sql->f("name")), stripslashes($sql->f("data_type"))); | 219 | + $oDocumentField = & new DocumentField(stripslashes($sql->f("name")), stripslashes($sql->f("data_type")), $sql->f("is_generic"), $sql->f("has_lookup")); |
| 168 | $oDocumentField->iId = $sql->f("id"); | 220 | $oDocumentField->iId = $sql->f("id"); |
| 169 | return $oDocumentField; | 221 | return $oDocumentField; |
| 170 | } | 222 | } |
lib/documentmanagement/DocumentType.inc
0 โ 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | +* | ||
| 4 | +* Class DocumentType | ||
| 5 | +* | ||
| 6 | +* Represents a document type as per the database document_types_lookup table | ||
| 7 | +* | ||
| 8 | +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | ||
| 9 | +* @date 19 January 2003 | ||
| 10 | +* @package lib.documentmanagement | ||
| 11 | +*/ | ||
| 12 | + | ||
| 13 | +class DocumentType { | ||
| 14 | + | ||
| 15 | + /** primary key value */ | ||
| 16 | + var $iId; | ||
| 17 | + /** document type name */ | ||
| 18 | + var $sName; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * Default constructor | ||
| 22 | + * | ||
| 23 | + * @param Name of document type | ||
| 24 | + * @param document type data type | ||
| 25 | + * | ||
| 26 | + */ | ||
| 27 | + function DocumentType($sNewName) { | ||
| 28 | + //object not created yet | ||
| 29 | + $this->iId = -1; | ||
| 30 | + $this->sName = $sNewName; | ||
| 31 | + | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Get the document type's primary key value | ||
| 36 | + * | ||
| 37 | + * @return int document type's primary key value | ||
| 38 | + * | ||
| 39 | + */ | ||
| 40 | + function getID() { | ||
| 41 | + return $this->iId; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * Get the document type's name | ||
| 46 | + * | ||
| 47 | + * @return String document type's name | ||
| 48 | + * | ||
| 49 | + */ | ||
| 50 | + function getName() { | ||
| 51 | + return $this->sName; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * Set the document type's name | ||
| 56 | + * | ||
| 57 | + * @param document type's new name | ||
| 58 | + * | ||
| 59 | + */ | ||
| 60 | + function setName($sNewValue) { | ||
| 61 | + $this->sName = $sNewValue; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * Store the current object in the database | ||
| 66 | + * | ||
| 67 | + * @return boolean on successful store, false otherwise and set $_SESSION["errorMessage"] | ||
| 68 | + * | ||
| 69 | + */ | ||
| 70 | + function create() { | ||
| 71 | + global $default, $lang_err_database, $lang_err_object_exists; | ||
| 72 | + //if the object hasn't been created | ||
| 73 | + if ($this->iId < 0) { | ||
| 74 | + $sql = $default->db; | ||
| 75 | + $result = $sql->query("INSERT INTO " . $default->owl_document_types_table . " (name) VALUES ('" . addslashes($this->sName) . "')"); | ||
| 76 | + if ($result) { | ||
| 77 | + $this->iId = $sql->insert_id(); | ||
| 78 | + return true; | ||
| 79 | + } | ||
| 80 | + $_SESSION["errorMessage"] = $lang_err_database; | ||
| 81 | + return false; | ||
| 82 | + } | ||
| 83 | + $_SESSION["errorMessage"] = $lang_err_object_exists . "id = " . $this->iId . " table = document_types"; | ||
| 84 | + return false; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * Update the values in the database table with the object's current values | ||
| 89 | + * | ||
| 90 | + * @return boolean true on successful update, false otherwise and set $_SESSION["errorMessage"] | ||
| 91 | + * | ||
| 92 | + */ | ||
| 93 | + function update() { | ||
| 94 | + global $default, $lang_err_database, $lang_err_object_key; | ||
| 95 | + //only update if the object has been stored | ||
| 96 | + if ($this->iId > 0) { | ||
| 97 | + $sql = $default->db; | ||
| 98 | + $result = $sql->query("UPDATE " . $default->owl_document_types_table . " SET name = '" . addslashes($this->sName) . "' WHERE id = $this->iId"); | ||
| 99 | + if ($result) { | ||
| 100 | + return true; | ||
| 101 | + } | ||
| 102 | + $_SESSION["errorMessage"] = $lang_err_database; | ||
| 103 | + return false; | ||
| 104 | + } | ||
| 105 | + $_SESSION["errorMessage"] = $lang_err_object_key; | ||
| 106 | + return false; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + /** | ||
| 110 | + * Delete the current object from the database | ||
| 111 | + * | ||
| 112 | + * @return boolean true on successful deletion, false otherwise and set $_SESSION["errorMessage"] | ||
| 113 | + * | ||
| 114 | + */ | ||
| 115 | + function delete() { | ||
| 116 | + global $default, $lang_err_database, $lang_err_object_key; | ||
| 117 | + //only delete the object if it exists in the database | ||
| 118 | + if ($this->iId >= 0) { | ||
| 119 | + $sql = $default->db; | ||
| 120 | + $result = $sql->query("DELETE FROM " . $default->owl_document_types_table . " WHERE id = $this->iId"); | ||
| 121 | + if ($result) { | ||
| 122 | + return true; | ||
| 123 | + } | ||
| 124 | + $_SESSION["errorMessage"] = $lang_err_database; | ||
| 125 | + return false; | ||
| 126 | + } | ||
| 127 | + $_SESSION["errorMessage"] = $lang_err_object_key; | ||
| 128 | + return false; | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + /** | ||
| 132 | + * Static function. | ||
| 133 | + * Given a document_fields primary key it will create a | ||
| 134 | + * DocumentTypes object and populate it with the | ||
| 135 | + * corresponding database values | ||
| 136 | + * | ||
| 137 | + * @return DocumentType populated DocumentType object on successful query, false otherwise and set $_SESSION["errorMessage"] | ||
| 138 | + */ | ||
| 139 | + function & get($iDocumentTypeID) { | ||
| 140 | + global $default; | ||
| 141 | + $sql = $default->db; | ||
| 142 | + $result = $sql->query("SELECT * FROM ". $default->owl_document_types_table ." WHERE id = $iDocumentTypeID"); | ||
| 143 | + if ($result) { | ||
| 144 | + if ($sql->next_record()) { | ||
| 145 | + $oDocumentType = & new DocumentType(stripslashes($sql->f("name"))); | ||
| 146 | + $oDocumentType->iId = $sql->f("id"); | ||
| 147 | + return $oDocumentType; | ||
| 148 | + } | ||
| 149 | + $_SESSION["errorMessage"] = $lang_err_object_not_exist . "id = " . $iDocumentID . " table = document_types"; | ||
| 150 | + return false; | ||
| 151 | + } | ||
| 152 | + $_SESSION["errorMessage"] = $lang_err_database; | ||
| 153 | + return false; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +?> |