Commit 1619e8780cc4c8cfb9d4905f43fce4e504b402c2

Authored by michael
1 parent bedc51db

removed old ArchiveSettings class


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1879 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/ArchiveSettings.inc deleted
1 -<?php  
2 -  
3 -/**  
4 - * $Id$  
5 - *  
6 - * Represents archive settings for a document  
7 - *  
8 - * Licensed under the GNU GPL. For full terms see the file COPYING.  
9 - *  
10 - * @version $Revision$  
11 - * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa  
12 - * @package lib.dashboard  
13 - */  
14 -  
15 -class ArchiveSettings {  
16 -  
17 - /**  
18 - * The primary key  
19 - */  
20 - var $iId;  
21 - /**  
22 - * The document ID  
23 - */  
24 - var $iDocumentID;  
25 - /**  
26 - * The archiving method- date or utilisation  
27 - */  
28 - var $sArchivingMethod;  
29 - /**  
30 - * The expiration date  
31 - */  
32 - var $dExpirationDate;  
33 - /**  
34 - * Document transaction utilisation marker  
35 - */  
36 - var $iDocumentTransactionID;  
37 - /**  
38 - * The utilisation threshold  
39 - */  
40 - var $iUtilisationThreshold;  
41 - /**  
42 - * Associative array of date units expressed as seconds  
43 - * ??: there must be a better way to do this?  
44 - */  
45 - // (60*60*24*365); (60*60*30); (60*60*24)  
46 - var $aDateUnits = array("year" => 31536000, "month" => 108000, "day" => 86400);  
47 -  
48 - /**  
49 - * Constructs an archive settings instance  
50 - *  
51 - * @param integer the document id  
52 - * @param string the archiving method  
53 - * @param date the expiration date  
54 - * @param integer the utilisation threshold  
55 - * @param integer the document transaction id  
56 - */  
57 - function ArchiveSettings($iNewDocumentID, $dNewExpirationDate, $iNewUtilisationThreshold, $iNewDocumentTransactionID) {  
58 - global $default;  
59 -  
60 - // primary key not set as this is not stored yet  
61 - $this->iId = -1;  
62 - $this->iDocumentID = $iNewDocumentID;  
63 - $this->dExpirationDate = $dNewExpirationDate;  
64 - $this->iUtilisationThreshold = $iNewUtilisationThreshold;  
65 - $this->iDocumentTransactionID = $iNewDocumentTransactionID;  
66 - $this->setArchivingMethod();  
67 - }  
68 -  
69 - /**  
70 - * Gets the primary key  
71 - */  
72 - function getID(){  
73 - return $this->iId;  
74 - }  
75 -  
76 - /**  
77 - * Gets the document id  
78 - */  
79 - function getDocumentID(){  
80 - return $this->iDocumentID;  
81 - }  
82 -  
83 - /**  
84 - * Sets the document id  
85 - *  
86 - * @param string the new document id  
87 - */  
88 - function setDocumentID($iNewDocumentID){  
89 - $this->iDocumentID = $iNewDocumentID;  
90 - }  
91 -  
92 - /**  
93 - * Gets the expiration date  
94 - */  
95 - function getExpirationDate(){  
96 - return $this->dExpirationDate;  
97 - }  
98 -  
99 - /**  
100 - * Sets the expiration date  
101 - *  
102 - * @param date the new expiration date  
103 - */  
104 - function setExpirationDate($dNewExpirationDate){  
105 - $this->dExpirationDate = $dNewExpirationDate;  
106 - }  
107 -  
108 - /**  
109 - * Sets the expiration period  
110 - */  
111 - function setExpirationPeriod($iNumber, $iUnit) {  
112 - }  
113 -  
114 - /**  
115 - * Gets the document transaction id  
116 - */  
117 - function getDocumentTransactionID(){  
118 - return $this->iDocumentTransactionID;  
119 - }  
120 -  
121 - /**  
122 - * Sets the document transaction id  
123 - *  
124 - * @param date the new document transaction id  
125 - */  
126 - function setDocumentTransactionID($iNewDocumentTransactionID){  
127 - $this->iDocumentTransactionID = $iNewDocumentTransactionID;  
128 - }  
129 -  
130 - /**  
131 - * Gets the utilisation threshold  
132 - */  
133 - function getUtilisationThreshold(){  
134 - return $this->iUtilisationThreshold;  
135 - }  
136 -  
137 - /**  
138 - * Sets the utilisation threshold  
139 - *  
140 - * @param integer the utilisation threshold  
141 - */  
142 - function setUtilisationThreshold($iNewUtilisationThreshold){  
143 - $this->iUtilisationThreshold = $iNewUtilisationThreshold;  
144 - }  
145 -  
146 - /**  
147 - * Returns the type of archiving being done ie. byDate or byTransaction  
148 - */  
149 - function getArchivingMethod() {  
150 - return $this->sArchivingMethod;  
151 - }  
152 -  
153 - /**  
154 - * Sets the archiving method based on the object attributes  
155 - */  
156 - function setArchivingMethod() {  
157 - if ($this->dExpirationDate <> "") {  
158 - $this->sArchivingMethod = "byDate";  
159 - $this->iUtilisationThreshold = 0;  
160 - } else if ($this->iUtilisationThreshold <> 0) {  
161 - $this->sArchivingMethod = "byUtilisation";  
162 - $this->dExpirationDate = "";  
163 -  
164 - }  
165 - }  
166 -  
167 - /**  
168 - * Inserts the archive settings into the database  
169 - *  
170 - * @return boolean true on successful update, false otherwise  
171 - */  
172 - function create(){  
173 - global $default;  
174 - //if the id >= 0, then the object has already been created  
175 - if ($this->iId < 0) {  
176 - $sql = $default->db;  
177 - $result = $sql->query("INSERT INTO $default->owl_archive_settings_table (document_id, expiration_date, document_transaction_id, utilisation_threshold) " .  
178 - "VALUES ($this->iDocumentID, '$this->dExpirationDate', $this->iDocumentTransactionID, $this->iUtilisationThreshold)");  
179 - if ($result) {  
180 - //set the current primary key  
181 - $this->iId = $sql->insert_id();  
182 - // set the archiving method  
183 - $this->setArchivingMethod();  
184 - return true;  
185 - }  
186 - return false;  
187 - }  
188 - return false;  
189 - }  
190 -  
191 - /**  
192 - * Update the archive settings current values in the database  
193 - *  
194 - * @return boolean true on successful update, false otherwise  
195 - */  
196 - function update(){  
197 - global $default;  
198 - if ($this->iId >= 0) {  
199 - $sql = $default->db;  
200 - $sQuery = "UPDATE " . $default->owl_archive_settings_table . " SET " .  
201 - "document_id = " . $this->iDocumentID . ", " .  
202 - "expiration_date = '" . $this->dExpirationDate . "', " .  
203 - "document_transaction_id = $this->iDocumentTransactionID, " .  
204 - "utilisation_threshold = $this->iUtilisationThreshold)" .  
205 - "WHERE id = $this->iId";  
206 - $result = $sql->query($sQuery);  
207 - if ($result) {  
208 - // set the archiving method  
209 - $this->setArchivingMethod();  
210 - return true;  
211 - }  
212 - return false;  
213 - }  
214 - return false;  
215 - }  
216 -  
217 - /**  
218 - * Delete the current archive settings from the database. Set the primary key to -1  
219 - * on successful deletion  
220 - *  
221 - * @return boolean true and reset id to -1 on successful deletion, false otherwise  
222 - */  
223 - function delete() {  
224 - global $default;  
225 - if ($this->iId >= 0) {  
226 - $sql = $default->db;  
227 - $result = $sql->query("DELETE FROM " . $default->owl_archive_settings_table . " WHERE id = $this->iId");  
228 - if ($result) {  
229 - $this->iId = -1;  
230 - return true;  
231 - }  
232 - return false;  
233 - }  
234 - return false;  
235 - }  
236 -  
237 - /**  
238 - * Static function. Given a document primary key will create  
239 - * a ArchiveSettings object and populate it with the corresponding  
240 - * database values  
241 - *  
242 - * @return ArchiveSettings populated ArchiveSettings object on success, false otherwise  
243 - */  
244 - function & getFromDocumentID($iDocumentID) {  
245 - global $default;  
246 - $sql = $default->db;  
247 - $sql->query("SELECT * FROM $default->owl_archive_settings_table WHERE document_id = $iDocumentID");  
248 - if ($sql->next_record()) {  
249 - $oArchiveSettings = & new ArchiveSettings($sql->f("document_id"), $sql->f("expiration_date"), $sql->f("utilisation_threshold"), $sql->f("document_transaction_id"));  
250 - $oArchiveSettings->iId = $sql->f("id");  
251 - return $oArchiveSettings;  
252 - }  
253 - return false;  
254 - }  
255 -  
256 - /**  
257 - * Static function. Given a news item primary key will create  
258 - * a ArchiveSettings object and populate it with the corresponding  
259 - * database values  
260 - *  
261 - * @return ArchiveSettings populated ArchiveSettings object on success, false otherwise  
262 - */  
263 - function & get($iArchiveSettingsID) {  
264 - global $default;  
265 - $sql = $default->db;  
266 - $sql->query("SELECT * FROM $default->owl_archive_settings_table WHERE id = $iArchiveSettingsID");  
267 - if ($sql->next_record()) {  
268 - $oArchiveSettings = & new ArchiveSettings($sql->f("document_id"), $sql->f("expiration_date"), $sql->f("utilisation_threshold"), $sql->f("document_transaction_id"));  
269 - $oArchiveSettings->iId = $iArchiveSettingsID;  
270 - return $oArchiveSettings;  
271 - }  
272 - return false;  
273 - }  
274 -  
275 - /**  
276 - * Static function  
277 - * Get a list of ArchiveSettings objects  
278 - *  
279 - * @param String Where clause (optional)  
280 - * @return Array array of ArchiveSettings objects, false otherwise  
281 - */  
282 - function getList($sWhereClause = null) {  
283 - global $default;  
284 - $aArchiveSettingsArray = array();  
285 - $sql = $default->db;  
286 - $result = $sql->query("SELECT * FROM " . $default->owl_archive_settings_table . (isset($sWhereClause) ? " WHERE " . $sWhereClause : ""));  
287 - if ($result) {  
288 - $iCount = 0;  
289 - while ($sql->next_record()) {  
290 - $oArchiveSettings = & ArchiveSettings::get($sql->f("id"));  
291 - $aArchiveSettingsArray[$iCount++] = $oArchiveSettings;  
292 - }  
293 - return $aArchiveSettingsArray;  
294 - }  
295 - return false;  
296 - }  
297 -}  
298 \ No newline at end of file 0 \ No newline at end of file