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 67 var $sParentFolderIDs;
68 68 /** forward slash deliminated path from file system root */
69 69 var $sFullPath;
  70 + /** date the document was created */
  71 + var $dCreated;
70 72  
71 73 /**
72 74 * Document class constructor
... ... @@ -172,6 +174,10 @@ class Document extends KTEntity {
172 174 $this->dModified = $dNewValue;
173 175 }
174 176  
  177 + function getCreatedDateTime() {
  178 + return $this->dCreated;
  179 + }
  180 +
175 181 /** get the document description */
176 182 function getDescription() {
177 183 return $this->sDescription;
... ... @@ -352,6 +358,7 @@ class Document extends KTEntity {
352 358 'parent_folder_ids' => $this->sParentFolderIDs,
353 359 'full_path' => $this->sFullPath,
354 360 'status_id' => $this->iStatusID,
  361 + 'created' => $this->dCreated,
355 362 );
356 363 }
357 364  
... ... @@ -367,6 +374,7 @@ class Document extends KTEntity {
367 374 * @return boolean true on successful insert, false otherwise
368 375 */
369 376 function create() {
  377 + $this->dCreated = getCurrentDateTime();
370 378 $res = parent::create();
371 379  
372 380 if ($res === true) {
... ... @@ -487,6 +495,7 @@ class Document extends KTEntity {
487 495 $oDocument->setMinorVersionNumber($sql->f("minor_version"));
488 496 $oDocument->setIsCheckedOut($sql->f("is_checked_out"));
489 497 $oDocument->setLastModifiedDate($sql->f("modified"));
  498 + $oDocument->dCreated = $sql->f("created");
490 499 $oDocument->sParentFolderIDs = $sql->f("parent_folder_ids");
491 500 $oDocument->sFullPath = $sql->f("full_path");
492 501 $oDocument->setCheckedOutUserID($sql->f("checked_out_user_id"));
... ...
sql/mysql/install/tables.sql
... ... @@ -329,12 +329,14 @@ CREATE TABLE documents (
329 329 full_path text,
330 330 checked_out_user_id int(11) default NULL,
331 331 status_id int(11) default NULL,
  332 + created datetime NOT NULL default '0000-00-00 00:00:00',
332 333 UNIQUE KEY id (id),
333 334 KEY fk_document_type_id (document_type_id),
334 335 KEY fk_creator_id (creator_id),
335 336 KEY fk_folder_id (folder_id),
336 337 KEY fk_checked_out_user_id (checked_out_user_id),
337 338 KEY fk_status_id (status_id)
  339 + KEY created (created)
338 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 416  
417 417 ALTER TABLE `folders` ADD `permission_folder_id` INT;
418 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;
... ...