Commit 8edec41ef2f7a505c4f27f0c6204c5a0035c0bc8

Authored by nbm
1 parent bb1b2bce

Add modified user tracking to the checkin functionality.

Rename setModifiedDate to setModified, and require the user to be passed
in.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4056 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/documentutil.inc.php
@@ -90,18 +90,14 @@ class KTDocumentUtil { @@ -90,18 +90,14 @@ class KTDocumentUtil {
90 return $oDocument->update(); 90 return $oDocument->update();
91 } 91 }
92 92
93 - function setModifiedDate($oDocument) {  
94 - if (is_numeric($oDocument)) {  
95 - $oDocument =& Document::get($oDocument);  
96 - if (PEAR::isError($oDocument)) {  
97 - return $oDocument;  
98 - }  
99 - } 93 + function setModified($oDocument, $oUser) {
  94 + $oDocument =& KTUtil::getObject('Document', $oDocument);
100 $oDocument->setLastModifiedDate(getCurrentDateTime()); 95 $oDocument->setLastModifiedDate(getCurrentDateTime());
  96 + $oDocument->setModifiedUserId(KTUtil::getId($oUser));
101 return $oDocument->update(); 97 return $oDocument->update();
102 } 98 }
103 99
104 - function checkin($oDocument, $sFilename, $sCheckInComment, $sCheckInType = "minor") { 100 + function checkin($oDocument, $sFilename, $sCheckInComment, $oUser) {
105 $sBackupPath = $oDocument->getPath() . "-" . $oDocument->getMajorVersionNumber() . "." . $oDocument->getMinorVersionNumber(); 101 $sBackupPath = $oDocument->getPath() . "-" . $oDocument->getMajorVersionNumber() . "." . $oDocument->getMinorVersionNumber();
106 $bSuccess = @copy($oDocument->getPath(), $sBackupPath); 102 $bSuccess = @copy($oDocument->getPath(), $sBackupPath);
107 if ($bSuccess === false) { 103 if ($bSuccess === false) {
@@ -113,6 +109,7 @@ class KTDocumentUtil { @@ -113,6 +109,7 @@ class KTDocumentUtil {
113 } 109 }
114 110
115 $oStorage =& KTStorageManagerUtil::getSingleton(); 111 $oStorage =& KTStorageManagerUtil::getSingleton();
  112 + $iFileSize = filesize($sFilename);
116 113
117 if (!$oStorage->upload($oDocument, $sFilename)) { 114 if (!$oStorage->upload($oDocument, $sFilename)) {
118 // reinstate the backup 115 // reinstate the backup
@@ -125,17 +122,11 @@ class KTDocumentUtil { @@ -125,17 +122,11 @@ class KTDocumentUtil {
125 $oDocument->setMetadataVersion($oDocument->getMetadataVersion()+1); 122 $oDocument->setMetadataVersion($oDocument->getMetadataVersion()+1);
126 123
127 $oDocument->setLastModifiedDate(getCurrentDateTime()); 124 $oDocument->setLastModifiedDate(getCurrentDateTime());
  125 + $oDocument->setModifiedUserId($oUser->getId());
128 $oDocument->setIsCheckedOut(false); 126 $oDocument->setIsCheckedOut(false);
129 $oDocument->setCheckedOutUserID(-1); 127 $oDocument->setCheckedOutUserID(-1);
130 -  
131 - // bump the version numbers  
132 - if ($sCheckInType == "major") {  
133 - $oDocument->setMajorVersionNumber($oDocument->getMajorVersionNumber()+1);  
134 - $oDocument->setMinorVersionNumber(0);  
135 - } else if ($sCheckInType == "minor") {  
136 - $oDocument->setMinorVersionNumber($oDocument->getMinorVersionNumber()+1);  
137 - }  
138 - $oDocument->setFileSize($_FILES['fFile']['size']); 128 + $oDocument->setMinorVersionNumber($oDocument->getMinorVersionNumber()+1);
  129 + $oDocument->setFileSize($iFileSize);
139 130
140 $bSuccess = $oDocument->update(); 131 $bSuccess = $oDocument->update();
141 if ($bSuccess !== true) { 132 if ($bSuccess !== true) {