Commit 7587a11ae8914bae3f53dd501f3fb95fcc4dc79d

Authored by Neil Blakey-Milner
1 parent 9ebd2912

Moved created time into the document table.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3140 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/Document.inc
@@ -67,6 +67,8 @@ class Document extends KTEntity { @@ -67,6 +67,8 @@ class Document extends KTEntity {
67 var $sParentFolderIDs; 67 var $sParentFolderIDs;
68 /** forward slash deliminated path from file system root */ 68 /** forward slash deliminated path from file system root */
69 var $sFullPath; 69 var $sFullPath;
  70 + /** date the document was created */
  71 + var $dCreated;
70 72
71 /** 73 /**
72 * Document class constructor 74 * Document class constructor
@@ -172,6 +174,10 @@ class Document extends KTEntity { @@ -172,6 +174,10 @@ class Document extends KTEntity {
172 $this->dModified = $dNewValue; 174 $this->dModified = $dNewValue;
173 } 175 }
174 176
  177 + function getCreatedDateTime() {
  178 + return $this->dCreated;
  179 + }
  180 +
175 /** get the document description */ 181 /** get the document description */
176 function getDescription() { 182 function getDescription() {
177 return $this->sDescription; 183 return $this->sDescription;
@@ -352,6 +358,7 @@ class Document extends KTEntity { @@ -352,6 +358,7 @@ class Document extends KTEntity {
352 'parent_folder_ids' => $this->sParentFolderIDs, 358 'parent_folder_ids' => $this->sParentFolderIDs,
353 'full_path' => $this->sFullPath, 359 'full_path' => $this->sFullPath,
354 'status_id' => $this->iStatusID, 360 'status_id' => $this->iStatusID,
  361 + 'created' => $this->dCreated,
355 ); 362 );
356 } 363 }
357 364
@@ -367,6 +374,7 @@ class Document extends KTEntity { @@ -367,6 +374,7 @@ class Document extends KTEntity {
367 * @return boolean true on successful insert, false otherwise 374 * @return boolean true on successful insert, false otherwise
368 */ 375 */
369 function create() { 376 function create() {
  377 + $this->dCreated = getCurrentDateTime();
370 $res = parent::create(); 378 $res = parent::create();
371 379
372 if ($res === true) { 380 if ($res === true) {
@@ -487,6 +495,7 @@ class Document extends KTEntity { @@ -487,6 +495,7 @@ class Document extends KTEntity {
487 $oDocument->setMinorVersionNumber($sql->f("minor_version")); 495 $oDocument->setMinorVersionNumber($sql->f("minor_version"));
488 $oDocument->setIsCheckedOut($sql->f("is_checked_out")); 496 $oDocument->setIsCheckedOut($sql->f("is_checked_out"));
489 $oDocument->setLastModifiedDate($sql->f("modified")); 497 $oDocument->setLastModifiedDate($sql->f("modified"));
  498 + $oDocument->dCreated = $sql->f("created");
490 $oDocument->sParentFolderIDs = $sql->f("parent_folder_ids"); 499 $oDocument->sParentFolderIDs = $sql->f("parent_folder_ids");
491 $oDocument->sFullPath = $sql->f("full_path"); 500 $oDocument->sFullPath = $sql->f("full_path");
492 $oDocument->setCheckedOutUserID($sql->f("checked_out_user_id")); 501 $oDocument->setCheckedOutUserID($sql->f("checked_out_user_id"));
sql/mysql/install/tables.sql
@@ -329,12 +329,14 @@ CREATE TABLE documents ( @@ -329,12 +329,14 @@ CREATE TABLE documents (
329 full_path text, 329 full_path text,
330 checked_out_user_id int(11) default NULL, 330 checked_out_user_id int(11) default NULL,
331 status_id int(11) default NULL, 331 status_id int(11) default NULL,
  332 + created datetime NOT NULL default '0000-00-00 00:00:00',
332 UNIQUE KEY id (id), 333 UNIQUE KEY id (id),
333 KEY fk_document_type_id (document_type_id), 334 KEY fk_document_type_id (document_type_id),
334 KEY fk_creator_id (creator_id), 335 KEY fk_creator_id (creator_id),
335 KEY fk_folder_id (folder_id), 336 KEY fk_folder_id (folder_id),
336 KEY fk_checked_out_user_id (checked_out_user_id), 337 KEY fk_checked_out_user_id (checked_out_user_id),
337 KEY fk_status_id (status_id) 338 KEY fk_status_id (status_id)
  339 + KEY created (created)
338 ) TYPE=InnoDB; 340 ) TYPE=InnoDB;
339 341
340 -- -------------------------------------------------------- 342 -- --------------------------------------------------------
sql/mysql/upgrade/1.2.4-to-1.2.5.sql
@@ -416,3 +416,8 @@ INSERT INTO `zseq_browse_criteria` SELECT MAX(`id`) FROM `browse_criteria`; @@ -416,3 +416,8 @@ INSERT INTO `zseq_browse_criteria` SELECT MAX(`id`) FROM `browse_criteria`;
416 416
417 ALTER TABLE `folders` ADD `permission_folder_id` INT; 417 ALTER TABLE `folders` ADD `permission_folder_id` INT;
418 ALTER TABLE `folders` ADD INDEX ( `permission_folder_id` ) ; 418 ALTER TABLE `folders` ADD INDEX ( `permission_folder_id` ) ;
  419 +
  420 +ALTER TABLE `documents` ADD `created` DATETIME NOT NULL ;
  421 +ALTER TABLE `documents` ADD INDEX ( `created` ) ;
  422 +
  423 +UPDATE documents AS D, document_transactions AS T SET D.created = T.datetime WHERE T.document_id = D.id AND T.transaction_id = 1;