Commit e29fdadfac1bd841dbe71ec410636c97d7761a47
1 parent
d033d781
partial fix for KTS-484.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5715 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
8 changed files
with
71 additions
and
15 deletions
docs/VERSION.txt
lib/documentmanagement/Document.inc
| @@ -94,6 +94,13 @@ class Document { | @@ -94,6 +94,13 @@ class Document { | ||
| 94 | function getImmutable() { return $this->_oDocumentCore->getImmutable(); } | 94 | function getImmutable() { return $this->_oDocumentCore->getImmutable(); } |
| 95 | function setImmutable($mValue) { $this->_oDocumentCore->setImmutable($mValue); } | 95 | function setImmutable($mValue) { $this->_oDocumentCore->setImmutable($mValue); } |
| 96 | 96 | ||
| 97 | + function getRestoreFolderId() { return $this->_oDocumentCore->getRestoreFolderId(); } | ||
| 98 | + function setRestoreFolderId($iValue) { $this->_oDocumentCore->setRestoreFolderId($iValue); } | ||
| 99 | + | ||
| 100 | + function getRestoreFolderPath() { return $this->_oDocumentCore->getRestoreFolderPath(); } | ||
| 101 | + function setRestoreFolderPath($sValue) { $this->_oDocumentCore->setRestoreFolderPath($sValue); } | ||
| 102 | + | ||
| 103 | + | ||
| 97 | // Document Metadata Items | 104 | // Document Metadata Items |
| 98 | 105 | ||
| 99 | function getDocumentTypeID() { return $this->_oDocumentMetadataVersion->getDocumentTypeId(); } | 106 | function getDocumentTypeID() { return $this->_oDocumentMetadataVersion->getDocumentTypeId(); } |
| @@ -443,6 +450,8 @@ class Document { | @@ -443,6 +450,8 @@ class Document { | ||
| 443 | "Modified", | 450 | "Modified", |
| 444 | "FolderId", | 451 | "FolderId", |
| 445 | "StatusId", | 452 | "StatusId", |
| 453 | + "RestoreFolderId", | ||
| 454 | + "RestoreFolderPath", | ||
| 446 | ); | 455 | ); |
| 447 | 456 | ||
| 448 | $aCore = array(); | 457 | $aCore = array(); |
lib/documentmanagement/documentcore.inc.php
| @@ -67,6 +67,9 @@ class KTDocumentCore extends KTEntity { | @@ -67,6 +67,9 @@ class KTDocumentCore extends KTEntity { | ||
| 67 | 67 | ||
| 68 | var $bIsCheckedOut; | 68 | var $bIsCheckedOut; |
| 69 | var $iCheckedOutUserId; | 69 | var $iCheckedOutUserId; |
| 70 | + | ||
| 71 | + var $iRestoreFolderId; | ||
| 72 | + var $sRestoreFolderPath; | ||
| 70 | 73 | ||
| 71 | var $_aFieldToSelect = array( | 74 | var $_aFieldToSelect = array( |
| 72 | "iId" => "id", | 75 | "iId" => "id", |
| @@ -95,6 +98,10 @@ class KTDocumentCore extends KTEntity { | @@ -95,6 +98,10 @@ class KTDocumentCore extends KTEntity { | ||
| 95 | "iPermissionObjectId" => 'permission_object_id', | 98 | "iPermissionObjectId" => 'permission_object_id', |
| 96 | "iPermissionLookupId" => 'permission_lookup_id', | 99 | "iPermissionLookupId" => 'permission_lookup_id', |
| 97 | "iOwnerId" => 'owner_id', | 100 | "iOwnerId" => 'owner_id', |
| 101 | + | ||
| 102 | + // restore-related | ||
| 103 | + 'iRestoreFolderId' => 'restore_folder_id', | ||
| 104 | + 'sRestoreFolderPath' => 'restore_folder_path', | ||
| 98 | ); | 105 | ); |
| 99 | 106 | ||
| 100 | function KTDocument() { | 107 | function KTDocument() { |
| @@ -136,6 +143,12 @@ class KTDocumentCore extends KTEntity { | @@ -136,6 +143,12 @@ class KTDocumentCore extends KTEntity { | ||
| 136 | 143 | ||
| 137 | function getImmutable() { return $this->bImmutable; } | 144 | function getImmutable() { return $this->bImmutable; } |
| 138 | function setImmutable($mValue) { $this->bImmutable = $mValue; } | 145 | function setImmutable($mValue) { $this->bImmutable = $mValue; } |
| 146 | + | ||
| 147 | + function getRestoreFolderId() { return $this->iRestoreFolderId; } | ||
| 148 | + function setRestoreFolderId($iValue) { $this->iRestoreFolderId = $iValue; } | ||
| 149 | + | ||
| 150 | + function getRestoreFolderPath() { return $this->sRestoreFolderPath; } | ||
| 151 | + function setRestoreFolderPath($sValue) { $this->sRestoreFolderPath = $sValue; } | ||
| 139 | // }}} | 152 | // }}} |
| 140 | 153 | ||
| 141 | // {{{ getParentId | 154 | // {{{ getParentId |
| @@ -234,7 +247,9 @@ class KTDocumentCore extends KTEntity { | @@ -234,7 +247,9 @@ class KTDocumentCore extends KTEntity { | ||
| 234 | 247 | ||
| 235 | // {{{ update | 248 | // {{{ update |
| 236 | function update($bPathMove = false) { | 249 | function update($bPathMove = false) { |
| 250 | + //var_dump($this); exit(0); | ||
| 237 | $res = parent::update(); | 251 | $res = parent::update(); |
| 252 | + | ||
| 238 | if (($res === true) && ($bPathMove === true)) { | 253 | if (($res === true) && ($bPathMove === true)) { |
| 239 | KTPermissionUtil::updatePermissionLookup($this); | 254 | KTPermissionUtil::updatePermissionLookup($this); |
| 240 | } | 255 | } |
lib/documentmanagement/documentutil.inc.php
| @@ -621,7 +621,9 @@ class KTDocumentUtil { | @@ -621,7 +621,9 @@ class KTDocumentUtil { | ||
| 621 | // {{{ delete | 621 | // {{{ delete |
| 622 | function delete($oDocument, $sReason, $iDestFolderId = null) { | 622 | function delete($oDocument, $sReason, $iDestFolderId = null) { |
| 623 | $oDocument =& KTUtil::getObject('Document', $oDocument); | 623 | $oDocument =& KTUtil::getObject('Document', $oDocument); |
| 624 | - if (is_null($iDestFolderId)) { $iDestFolderId = $oDocument->getFolderID(); } | 624 | + if (is_null($iDestFolderId)) { |
| 625 | + $iDestFolderId = $oDocument->getFolderID(); | ||
| 626 | + } | ||
| 625 | $oStorageManager =& KTStorageManagerUtil::getSingleton(); | 627 | $oStorageManager =& KTStorageManagerUtil::getSingleton(); |
| 626 | 628 | ||
| 627 | global $default; | 629 | global $default; |
| @@ -629,24 +631,34 @@ class KTDocumentUtil { | @@ -629,24 +631,34 @@ class KTDocumentUtil { | ||
| 629 | if (count(trim($sReason)) == 0) { | 631 | if (count(trim($sReason)) == 0) { |
| 630 | return PEAR::raiseError('Deletion requires a reason'); | 632 | return PEAR::raiseError('Deletion requires a reason'); |
| 631 | } | 633 | } |
| 632 | - if (PEAR::isError($oDocument) || ($oDocument == false)) { return PEAR::raiseError('Invalid document object.'); } | ||
| 633 | 634 | ||
| 634 | - if ($oDocument->getIsCheckedOut() == true) { return PEAR::raiseError(sprintf(_kt('The document is checked out and cannot be deleted: %s'), $oDocument->getName())); } | 635 | + if (PEAR::isError($oDocument) || ($oDocument == false)) { |
| 636 | + return PEAR::raiseError('Invalid document object.'); | ||
| 637 | + } | ||
| 638 | + | ||
| 639 | + if ($oDocument->getIsCheckedOut() == true) { | ||
| 640 | + return PEAR::raiseError(sprintf(_kt('The document is checked out and cannot be deleted: %s'), $oDocument->getName())); | ||
| 641 | + } | ||
| 635 | 642 | ||
| 636 | // IF we're deleted ... | 643 | // IF we're deleted ... |
| 637 | - if ($oDocument->getStatusID() == DELETED) { return true; } | ||
| 638 | - | ||
| 639 | - | ||
| 640 | - $oOrigFolder = Folder::get($oDocument->getFolderId()); | ||
| 641 | - | 644 | + if ($oDocument->getStatusID() == DELETED) { |
| 645 | + return true; | ||
| 646 | + } | ||
| 642 | 647 | ||
| 648 | + $oOrigFolder = Folder::get($oDocument->getFolderId()); | ||
| 649 | + | ||
| 643 | DBUtil::startTransaction(); | 650 | DBUtil::startTransaction(); |
| 644 | 651 | ||
| 645 | - // flip the status id | 652 | + // flip the status id |
| 646 | $oDocument->setStatusID(DELETED); | 653 | $oDocument->setStatusID(DELETED); |
| 647 | - $oDocument->setFolderID($iDestFolderId); // try to keep it in _this_ folder, otherwise move to root. | 654 | + |
| 655 | + // $iDestFolderId is DEPRECATED. | ||
| 656 | + $oDocument->setFolderID(null); | ||
| 657 | + $oDocument->setRestoreFolderId($oOrigFolder->getId()); | ||
| 658 | + $oDocument->setRestoreFolderPath(Folder::generateFolderIDs($oOrigFolder->getId())); | ||
| 648 | 659 | ||
| 649 | $res = $oDocument->update(); | 660 | $res = $oDocument->update(); |
| 661 | + | ||
| 650 | if (PEAR::isError($res) || ($res == false)) { | 662 | if (PEAR::isError($res) || ($res == false)) { |
| 651 | DBUtil::rollback(); | 663 | DBUtil::rollback(); |
| 652 | return PEAR::raiseError(_kt("There was a problem deleting the document from the database.")); | 664 | return PEAR::raiseError(_kt("There was a problem deleting the document from the database.")); |
plugins/ktcore/admin/deletedDocuments.php
| @@ -198,10 +198,10 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | @@ -198,10 +198,10 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | ||
| 198 | $oStorage =& KTStorageManagerUtil::getSingleton(); | 198 | $oStorage =& KTStorageManagerUtil::getSingleton(); |
| 199 | 199 | ||
| 200 | foreach ($aDocuments as $oDoc) { | 200 | foreach ($aDocuments as $oDoc) { |
| 201 | - $oFolder = Folder::get($oDoc->getFolderID()); | 201 | + $oFolder = Folder::get($oDoc->getRestoreFolderId()); |
| 202 | if (PEAR::isError($oFolder)) { $oDoc->setFolderId(1); $oDoc->update(); } // move to root if parent no longer exists. | 202 | if (PEAR::isError($oFolder)) { $oDoc->setFolderId(1); $oDoc->update(); } // move to root if parent no longer exists. |
| 203 | if ($oStorage->restore($oDoc)) { | 203 | if ($oStorage->restore($oDoc)) { |
| 204 | - $oDoc = Document::get($oDoc->getId()); // storage path has changed for most recent object... | 204 | + $oDoc = Document::get($oDoc->getId()); // storage path has changed for most recent object... |
| 205 | $oDoc->setStatusId(LIVE); | 205 | $oDoc->setStatusId(LIVE); |
| 206 | $res = $oDoc->update(); | 206 | $res = $oDoc->update(); |
| 207 | if (PEAR::isError($res) || ($res == false)) { | 207 | if (PEAR::isError($res) || ($res == false)) { |
| @@ -233,6 +233,21 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | @@ -233,6 +233,21 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | ||
| 233 | $this->successRedirectToMain($msg); | 233 | $this->successRedirectToMain($msg); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | + function getRestoreLocationFor($oDocument) { | ||
| 237 | + $iFolderId = $oDocument->getRestoreFolderId(); | ||
| 238 | + $oFolder = Folder::get($iFolderId); | ||
| 239 | + | ||
| 240 | + if (PEAR::isError($oFolder)) { | ||
| 241 | + return _kt('Original folder no longer exists. Document will be restored in the root folder.'); | ||
| 242 | + } else { | ||
| 243 | + $aCrumbs = KTBrowseUtil::breadcrumbsForFolder($oFolder); | ||
| 244 | + $aParts = array(); | ||
| 245 | + foreach ($aCrumbs as $aInfo) { | ||
| 246 | + $aParts[] = $aInfo['name']; | ||
| 247 | + } | ||
| 248 | + return implode(' » ', $aParts); | ||
| 249 | + } | ||
| 250 | + } | ||
| 236 | } | 251 | } |
| 237 | 252 | ||
| 238 | ?> | 253 | ?> |
sql/mysql/upgrade/3.0.3.6/document-restore.sql
0 → 100644
templates/ktcore/document/admin/deletedlist.smarty
| @@ -23,7 +23,7 @@ can <strong>restore</strong> them as necessary.{/i18n}</p> | @@ -23,7 +23,7 @@ can <strong>restore</strong> them as necessary.{/i18n}</p> | ||
| 23 | <tr> | 23 | <tr> |
| 24 | <th style="width:2em"><input type="checkbox" onclick="toggleSelectFor(this, 'selected_docs')" title="toggle all"/></th> | 24 | <th style="width:2em"><input type="checkbox" onclick="toggleSelectFor(this, 'selected_docs')" title="toggle all"/></th> |
| 25 | <th>{i18n}Document Name{/i18n}</th> | 25 | <th>{i18n}Document Name{/i18n}</th> |
| 26 | - <th>{i18n}Document Path{/i18n}</th> | 26 | +{* <th>{i18n}Document Path{/i18n}</th> *} |
| 27 | <th>{i18n}Last Modification{/i18n}</th> | 27 | <th>{i18n}Last Modification{/i18n}</th> |
| 28 | <th>{i18n}Deletion Comment{/i18n}</th> | 28 | <th>{i18n}Deletion Comment{/i18n}</th> |
| 29 | </tr> | 29 | </tr> |
| @@ -33,7 +33,7 @@ can <strong>restore</strong> them as necessary.{/i18n}</p> | @@ -33,7 +33,7 @@ can <strong>restore</strong> them as necessary.{/i18n}</p> | ||
| 33 | <tr> | 33 | <tr> |
| 34 | <td><input type="checkbox" name="selected_docs[]" value="{$oDoc->getId()}"/></td> | 34 | <td><input type="checkbox" name="selected_docs[]" value="{$oDoc->getId()}"/></td> |
| 35 | <td>{$oDoc->getName()}</td> | 35 | <td>{$oDoc->getName()}</td> |
| 36 | - <td>{getCrumbStringForDocument document=$oDoc}</td> | 36 | +{* <td>{getCrumbStringForDocument document=$oDoc}</td> *} |
| 37 | <td>{$oDoc->getLastModifiedDate()}</td> | 37 | <td>{$oDoc->getLastModifiedDate()}</td> |
| 38 | <td>{$oDoc->getLastDeletionComment()}</td> | 38 | <td>{$oDoc->getLastDeletionComment()}</td> |
| 39 | </tr> | 39 | </tr> |
templates/ktcore/document/admin/restoreconfirmlist.smarty
| @@ -14,12 +14,14 @@ confirm that you want to restore these documents.{/i18n}</p></div> | @@ -14,12 +14,14 @@ confirm that you want to restore these documents.{/i18n}</p></div> | ||
| 14 | <tr> | 14 | <tr> |
| 15 | 15 | ||
| 16 | <th>{i18n}Document Name{/i18n}</th> | 16 | <th>{i18n}Document Name{/i18n}</th> |
| 17 | + <th>{i18n}Restore To{/i18n}</th> | ||
| 17 | </tr> | 18 | </tr> |
| 18 | </thead> | 19 | </thead> |
| 19 | <tbody> | 20 | <tbody> |
| 20 | {foreach item=oDoc from=$documents} | 21 | {foreach item=oDoc from=$documents} |
| 21 | <tr> | 22 | <tr> |
| 22 | <td>{$oDoc->getName()}<input type="hidden" name="selected_docs[]" value="{$oDoc->getId()}" /></td> | 23 | <td>{$oDoc->getName()}<input type="hidden" name="selected_docs[]" value="{$oDoc->getId()}" /></td> |
| 24 | + <td>{$context->getRestoreLocationFor($oDoc)}</td> | ||
| 23 | </tr> | 25 | </tr> |
| 24 | {/foreach} | 26 | {/foreach} |
| 25 | </tbody> | 27 | </tbody> |