Commit 1fe2071570ea478679c904257616fe03416e7164
1 parent
2d13e2ec
added archiving restoration request table, class, sitemap entries and test
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2078 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
274 additions
and
33 deletions
config/dmsDefaults.php
| ... | ... | @@ -131,6 +131,7 @@ $default->owl_archiving_date_settings_table = "archiving_date_settings"; |
| 131 | 131 | $default->owl_archiving_utilisation_settings_table = "archiving_utilisation_settings"; |
| 132 | 132 | $default->owl_time_period_table = "time_period"; |
| 133 | 133 | $default->owl_time_unit_lookup_table = "time_unit_lookup"; |
| 134 | +$default->owl_archive_restoration_table = "archive_restoration_request"; | |
| 134 | 135 | $default->owl_status_table = "status_lookup"; |
| 135 | 136 | |
| 136 | 137 | // logo file that must reside inside lang/graphics directory |
| ... | ... | @@ -168,7 +169,7 @@ $default->siteMap->addPage("modifyDocumentGenericMetaData", "/presentation/lookA |
| 168 | 169 | $default->siteMap->addPage("archiveDocument", "/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/archiveDocumentBL.php", "Manage Documents", User, "Archive Document", false); |
| 169 | 170 | $default->siteMap->addPage("addDocumentArchiveSettings", "/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/addArchiveSettingsBL.php", "Manage Documents", User, "Add Document Archive Settings", false); |
| 170 | 171 | $default->siteMap->addPage("modifyDocumentArchiveSettings", "/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/modifyArchiveSettingsBL.php", "Manage Documents", User, "Modify Document Archive Settings", false); |
| 171 | - | |
| 172 | +$default->siteMap->addPage("requestDocumentRestore", "/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/requestDocumentRestoreBL.php", "Manage Documents", User, "Request Document Restoration", false); | |
| 172 | 173 | |
| 173 | 174 | $default->siteMap->addPage("addFolder", "/presentation/lookAndFeel/knowledgeTree/foldermanagement/addFolderBL.php", "Manage Documents", User, "Add A Folder"); |
| 174 | 175 | $default->siteMap->addPage("addFolderDocType", "/presentation/lookAndFeel/knowledgeTree/foldermanagement/addFolderDocTypeBL.php", "Manage Documents", User, ""); | ... | ... |
lib/archiving/ArchiveRestorationRequest.inc
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * $Id$ | |
| 5 | + * | |
| 6 | + * Represents restoration request 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.archiving | |
| 13 | + */ | |
| 14 | + | |
| 15 | +class ArchiveRestorationRequest { | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * The primary key | |
| 19 | + */ | |
| 20 | + var $iId; | |
| 21 | + /** | |
| 22 | + * The document to be restored | |
| 23 | + */ | |
| 24 | + var $iDocumentID; | |
| 25 | + /** | |
| 26 | + * The user requesting the restoration | |
| 27 | + */ | |
| 28 | + var $iRequestUserID; | |
| 29 | + /** | |
| 30 | + * The administrator to perform the restore | |
| 31 | + */ | |
| 32 | + var $iAdminUserID; | |
| 33 | + /** | |
| 34 | + * Timestamp | |
| 35 | + */ | |
| 36 | + var $dDateTime; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * Constructs an archive restoration request instance | |
| 40 | + * | |
| 41 | + * @param integer the document id | |
| 42 | + * @param integer the request user id | |
| 43 | + * @param integer the admin user id | |
| 44 | + */ | |
| 45 | + function ArchiveRestorationRequest($iNewDocumentID, $iNewRequestUserID, $iNewAdminUserID, $dNewDateTime = "") { | |
| 46 | + global $default; | |
| 47 | + | |
| 48 | + // primary key not set as this is not stored yet | |
| 49 | + $this->iId = -1; | |
| 50 | + $this->iDocumentID = $iNewDocumentID; | |
| 51 | + $this->iRequestUserID = $iNewRequestUserID; | |
| 52 | + $this->iAdminUserID = $iNewAdminUserID; | |
| 53 | + $this->dDateTime = strlen($dNewDateTime) == 0 ? getCurrentDateTime() : $dNewDateTime; | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Gets the primary key | |
| 58 | + */ | |
| 59 | + function getID(){ | |
| 60 | + return $this->iId; | |
| 61 | + } | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * Gets the document id | |
| 65 | + */ | |
| 66 | + function getDocumentID(){ | |
| 67 | + return $this->iDocumentID; | |
| 68 | + } | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Sets the document id | |
| 72 | + * | |
| 73 | + * @param integer the new document id | |
| 74 | + */ | |
| 75 | + function setDocumentID($iNewDocumentID){ | |
| 76 | + $this->iDocumentID = $iNewDocumentID; | |
| 77 | + } | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * Gets the request user | |
| 81 | + */ | |
| 82 | + function getRequestUserID(){ | |
| 83 | + return $this->iRequestUserID; | |
| 84 | + } | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * Sets the request user | |
| 88 | + * | |
| 89 | + * @param integer the new user id | |
| 90 | + */ | |
| 91 | + function setRequestUserID($iNewRequestUserID){ | |
| 92 | + $this->iRequestUserID = $iNewRequestUserID; | |
| 93 | + } | |
| 94 | + | |
| 95 | + /** | |
| 96 | + * Gets the admin user | |
| 97 | + */ | |
| 98 | + function getAdminUserID(){ | |
| 99 | + return $this->iAdminUserID; | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * Sets the admin user | |
| 104 | + * | |
| 105 | + * @param integer the new user id | |
| 106 | + */ | |
| 107 | + function setAdminUserID($iNewAdminUserID){ | |
| 108 | + $this->iAdminUserID = $iNewAdminUserID; | |
| 109 | + } | |
| 110 | + | |
| 111 | + /** | |
| 112 | + * Gets the datetime | |
| 113 | + */ | |
| 114 | + function getDateTime(){ | |
| 115 | + return $this->dDateTime; | |
| 116 | + } | |
| 117 | + | |
| 118 | + /** | |
| 119 | + * Sets the datetime | |
| 120 | + * | |
| 121 | + * @param datetime the new date time | |
| 122 | + */ | |
| 123 | + function setDateTime($dNewDateTime){ | |
| 124 | + $this->dDateTime = $dNewDateTime; | |
| 125 | + } | |
| 126 | + | |
| 127 | + /** | |
| 128 | + * Inserts the restoration request into the database | |
| 129 | + * | |
| 130 | + * @return boolean true on successful update, false otherwise | |
| 131 | + */ | |
| 132 | + function create(){ | |
| 133 | + global $default; | |
| 134 | + //if the id >= 0, then the object has already been created | |
| 135 | + if ($this->iId < 0) { | |
| 136 | + $sql = $default->db; | |
| 137 | + $result = $sql->query("INSERT INTO $default->owl_archive_restoration_table (document_id, request_user_id, admin_user_id, datetime) " . | |
| 138 | + "VALUES ($this->iDocumentID, $this->iRequestUserID, $this->iAdminUserID, '$this->dDateTime')"); | |
| 139 | + if ($result) { | |
| 140 | + //set the current primary key | |
| 141 | + $this->iId = $sql->insert_id(); | |
| 142 | + return true; | |
| 143 | + } | |
| 144 | + return false; | |
| 145 | + } | |
| 146 | + return false; | |
| 147 | + } | |
| 148 | + | |
| 149 | + /** | |
| 150 | + * Update the restoration request current values in the database | |
| 151 | + * | |
| 152 | + * @return boolean true on successful update, false otherwise | |
| 153 | + */ | |
| 154 | + function update(){ | |
| 155 | + global $default; | |
| 156 | + if ($this->iId >= 0) { | |
| 157 | + $sql = $default->db; | |
| 158 | + $sQuery = "UPDATE $default->owl_archive_restoration_table SET " . | |
| 159 | + "document_id = $this->iDocumentID, " . | |
| 160 | + "request_user_id = $this->iRequestUserID, " . | |
| 161 | + "admin_user_id = $this->iAdminUserID, " . | |
| 162 | + "datetime = '$this->dDateTime' " . | |
| 163 | + "WHERE id = $this->iId"; | |
| 164 | + $result = $sql->query($sQuery); | |
| 165 | + if ($result) { | |
| 166 | + return true; | |
| 167 | + } | |
| 168 | + return false; | |
| 169 | + } | |
| 170 | + return false; | |
| 171 | + } | |
| 172 | + | |
| 173 | + /** | |
| 174 | + * Delete the current restoration request from the database. Set the primary key to -1 | |
| 175 | + * on successful deletion | |
| 176 | + * | |
| 177 | + * @return boolean true and reset id to -1 on successful deletion, false otherwise | |
| 178 | + */ | |
| 179 | + function delete() { | |
| 180 | + global $default; | |
| 181 | + if ($this->iId >= 0) { | |
| 182 | + $sql = $default->db; | |
| 183 | + $result = $sql->query("DELETE FROM $default->owl_archive_restoration_table WHERE id = $this->iId"); | |
| 184 | + if ($result) { | |
| 185 | + $this->iId = -1; | |
| 186 | + return true; | |
| 187 | + } | |
| 188 | + return false; | |
| 189 | + } | |
| 190 | + return false; | |
| 191 | + } | |
| 192 | + | |
| 193 | + /** | |
| 194 | + * Static function. Given a document primary key will create | |
| 195 | + * a ArchiveRestorationRequest object and populate it with the corresponding | |
| 196 | + * database values | |
| 197 | + * | |
| 198 | + * @return ArchiveRestorationRequest populated ArchiveRestorationRequest object on success, false otherwise | |
| 199 | + */ | |
| 200 | + function & getFromDocumentID($iDocumentID) { | |
| 201 | + global $default; | |
| 202 | + $sql = $default->db; | |
| 203 | + $sql->query("SELECT * FROM $default->owl_archive_restoration_table WHERE document_id = $iDocumentID"); | |
| 204 | + if ($sql->next_record()) { | |
| 205 | + $oArchiveRestorationRequest = & new ArchiveRestorationRequest($sql->f("document_id"), $sql->f("request_user_id"), $sql->f("admin_user_id"), $sql->f("datetime")); | |
| 206 | + $oArchiveRestorationRequest->iId = $sql->f("id"); | |
| 207 | + return $oArchiveRestorationRequest; | |
| 208 | + } | |
| 209 | + return false; | |
| 210 | + } | |
| 211 | + | |
| 212 | + /** | |
| 213 | + * Static function. Given a news item primary key will create | |
| 214 | + * a ArchiveRestorationRequest object and populate it with the corresponding | |
| 215 | + * database values | |
| 216 | + * | |
| 217 | + * @return ArchiveRestorationRequest populated ArchiveRestorationRequest object on success, false otherwise | |
| 218 | + */ | |
| 219 | + function & get($iArchiveRestorationRequestID) { | |
| 220 | + global $default; | |
| 221 | + $sql = $default->db; | |
| 222 | + $sql->query("SELECT * FROM $default->owl_archive_restoration_table WHERE id = $iArchiveRestorationRequestID"); | |
| 223 | + if ($sql->next_record()) { | |
| 224 | + $oArchiveRestorationRequest = & new ArchiveRestorationRequest($sql->f("document_id"), $sql->f("request_user_id"), $sql->f("admin_user_id"), $sql->f("datetime")); | |
| 225 | + $oArchiveRestorationRequest->iId = $iArchiveRestorationRequestID; | |
| 226 | + return $oArchiveRestorationRequest; | |
| 227 | + } | |
| 228 | + return false; | |
| 229 | + } | |
| 230 | + | |
| 231 | + /** | |
| 232 | + * Static function | |
| 233 | + * Get a list of ArchiveRestorationRequest objects | |
| 234 | + * | |
| 235 | + * @param String Where clause (optional) | |
| 236 | + * @return Array array of ArchiveRestorationRequest objects, false otherwise | |
| 237 | + */ | |
| 238 | + function getList($sWhereClause = null) { | |
| 239 | + global $default; | |
| 240 | + $aArchiveRestorationRequestArray = array(); | |
| 241 | + $sql = $default->db; | |
| 242 | + $result = $sql->query("SELECT * FROM $default->owl_archive_restoration_table " . (isset($sWhereClause) ? " WHERE " . $sWhereClause : "")); | |
| 243 | + if ($result) { | |
| 244 | + while ($sql->next_record()) { | |
| 245 | + $aArchiveRestorationRequestArray[] = & new ArchiveRestorationRequest($sql->f("document_id"), $sql->f("request_user_id"), $sql->f("admin_user_id"), $sql->f("datetime")); | |
| 246 | + } | |
| 247 | + return $aArchiveRestorationRequestArray; | |
| 248 | + } | |
| 249 | + return false; | |
| 250 | + } | |
| 251 | +} | |
| 0 | 252 | \ No newline at end of file | ... | ... |
sql/tables.sql
| ... | ... | @@ -7,6 +7,14 @@ lastused DATETIME, |
| 7 | 7 | ip CHAR(30) |
| 8 | 8 | ) TYPE = InnoDB; |
| 9 | 9 | |
| 10 | +CREATE TABLE archive_restoration_request ( | |
| 11 | +id INTEGER NOT NULL UNIQUE AUTO_INCREMENT, | |
| 12 | +document_id INTEGER NOT NULL, | |
| 13 | +request_user_id INTEGER NOT NULL, | |
| 14 | +admin_user_id INTEGER NOT NULL, | |
| 15 | +datetime DATETIME NOT NULL | |
| 16 | +) TYPE = InnoDB; | |
| 17 | + | |
| 10 | 18 | CREATE TABLE archiving_type_lookup ( |
| 11 | 19 | id INTEGER NOT NULL UNIQUE AUTO_INCREMENT, |
| 12 | 20 | name CHAR(100) | ... | ... |
sql/upgrade-alter.sql
| ... | ... | @@ -26,6 +26,14 @@ document_transaction_id INTEGER, |
| 26 | 26 | time_period_id INTEGER |
| 27 | 27 | ) TYPE = InnoDB; |
| 28 | 28 | |
| 29 | +CREATE TABLE archive_restoration_request ( | |
| 30 | +id INTEGER NOT NULL UNIQUE AUTO_INCREMENT, | |
| 31 | +document_id INTEGER NOT NULL, | |
| 32 | +request_user_id INTEGER NOT NULL, | |
| 33 | +admin_user_id INTEGER NOT NULL, | |
| 34 | +datetime DATETIME NOT NULL | |
| 35 | +) TYPE = InnoDB; | |
| 36 | + | |
| 29 | 37 | CREATE TABLE dependant_document_instance ( |
| 30 | 38 | id INTEGER NOT NULL UNIQUE AUTO_INCREMENT, |
| 31 | 39 | document_title TEXT NOT NULL, |
| ... | ... | @@ -42,25 +50,6 @@ template_document_id INTEGER, |
| 42 | 50 | group_folder_approval_link_id INTEGER |
| 43 | 51 | ) TYPE = InnoDB; |
| 44 | 52 | |
| 45 | -CREATE TABLE discussion_threads ( | |
| 46 | -id INTEGER NOT NULL UNIQUE AUTO_INCREMENT, | |
| 47 | -document_id INTEGER NOT NULL, | |
| 48 | -first_comment_id INTEGER NOT NULL, | |
| 49 | -last_comment_id INTEGER NOT NULL, | |
| 50 | -views INTEGER NOT NULL, | |
| 51 | -replies INTEGER NOT NULL, | |
| 52 | -creator_id INTEGER NOT NULL | |
| 53 | -)TYPE = InnoDB; | |
| 54 | - | |
| 55 | -CREATE TABLE discussion_comments ( | |
| 56 | -id INTEGER NOT NULL UNIQUE AUTO_INCREMENT, | |
| 57 | -thread_id INTEGER NOT NULL, | |
| 58 | -user_id INTEGER NOT NULL, | |
| 59 | -subject TEXT, | |
| 60 | -body TEXT, | |
| 61 | -date datetime | |
| 62 | -)TYPE = InnoDB; | |
| 63 | - | |
| 64 | 53 | CREATE TABLE document_link ( |
| 65 | 54 | id INTEGER NOT NULL UNIQUE AUTO_INCREMENT, |
| 66 | 55 | parent_document_id INTEGER NOT NULL, |
| ... | ... | @@ -80,17 +69,6 @@ archiving_settings_id INTEGER |
| 80 | 69 | ALTER TABLE folders_users_roles_link ADD column dependant_documents_created bit; |
| 81 | 70 | update folders_users_roles_link set dependant_documents_created = 1; |
| 82 | 71 | |
| 83 | -CREATE TABLE news ( | |
| 84 | -id INTEGER NOT NULL UNIQUE AUTO_INCREMENT, | |
| 85 | -synopsis VARCHAR(255) NOT NULL, | |
| 86 | -body TEXT, | |
| 87 | -rank INTEGER, | |
| 88 | -image TEXT, | |
| 89 | -image_size INTEGER, | |
| 90 | -image_mime_type_id INTEGER, | |
| 91 | -active BIT | |
| 92 | -) TYPE = InnoDB; | |
| 93 | - | |
| 94 | 72 | CREATE TABLE status_lookup ( |
| 95 | 73 | id INTEGER NOT NULL UNIQUE AUTO_INCREMENT, |
| 96 | 74 | name CHAR(255) | ... | ... |
tests/archiving/testSuite.php
| ... | ... | @@ -17,7 +17,8 @@ require_once("../../config/dmsDefaults.php"); |
| 17 | 17 | |
| 18 | 18 | echo "<pre>"; |
| 19 | 19 | |
| 20 | -$aClasses = array("archiving/DocumentArchiving" => array("DocumentID", "ArchivingTypeID", "ArchivingSettingsID"), | |
| 20 | +$aClasses = array("archiving/ArchiveRestorationRequest" => array("DocumentID", "RequestUserID", "AdminUserID", "DateTime"), | |
| 21 | + "archiving/DocumentArchiving" => array("DocumentID", "ArchivingTypeID", "ArchivingSettingsID"), | |
| 21 | 22 | "archiving/TimeUnit" => array("Name"), |
| 22 | 23 | "archiving/ArchivingType" => array("Name"), |
| 23 | 24 | "archiving/ArchivingUtilisationSettings" => array("DocumentTransactionID", "TimePeriodID"), |
| ... | ... | @@ -25,13 +26,15 @@ $aClasses = array("archiving/DocumentArchiving" => array("DocumentID", "Archivin |
| 25 | 26 | "archiving/ArchivingDateSettings" => array("ExpirationDate", "TimePeriodID")); |
| 26 | 27 | |
| 27 | 28 | $aInitialValues = array("1,2,3", |
| 29 | + "1,2,3", | |
| 28 | 30 | "hour", |
| 29 | 31 | "\"blah's\"", |
| 30 | 32 | "5, 1", |
| 31 | 33 | "1, 10", |
| 32 | 34 | "'2002-10-10', 1"); |
| 33 | 35 | |
| 34 | -$aSetValues = array(array(9,8,7), | |
| 36 | +$aSetValues = array(array(4,5,6,"2010-10-10"), | |
| 37 | + array(9,8,7), | |
| 35 | 38 | array("minute"), |
| 36 | 39 | array("fooblar's"), |
| 37 | 40 | array(6,6), | ... | ... |