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 | 94 | function getImmutable() { return $this->_oDocumentCore->getImmutable(); } |
| 95 | 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 | 104 | // Document Metadata Items |
| 98 | 105 | |
| 99 | 106 | function getDocumentTypeID() { return $this->_oDocumentMetadataVersion->getDocumentTypeId(); } |
| ... | ... | @@ -443,6 +450,8 @@ class Document { |
| 443 | 450 | "Modified", |
| 444 | 451 | "FolderId", |
| 445 | 452 | "StatusId", |
| 453 | + "RestoreFolderId", | |
| 454 | + "RestoreFolderPath", | |
| 446 | 455 | ); |
| 447 | 456 | |
| 448 | 457 | $aCore = array(); | ... | ... |
lib/documentmanagement/documentcore.inc.php
| ... | ... | @@ -67,6 +67,9 @@ class KTDocumentCore extends KTEntity { |
| 67 | 67 | |
| 68 | 68 | var $bIsCheckedOut; |
| 69 | 69 | var $iCheckedOutUserId; |
| 70 | + | |
| 71 | + var $iRestoreFolderId; | |
| 72 | + var $sRestoreFolderPath; | |
| 70 | 73 | |
| 71 | 74 | var $_aFieldToSelect = array( |
| 72 | 75 | "iId" => "id", |
| ... | ... | @@ -95,6 +98,10 @@ class KTDocumentCore extends KTEntity { |
| 95 | 98 | "iPermissionObjectId" => 'permission_object_id', |
| 96 | 99 | "iPermissionLookupId" => 'permission_lookup_id', |
| 97 | 100 | "iOwnerId" => 'owner_id', |
| 101 | + | |
| 102 | + // restore-related | |
| 103 | + 'iRestoreFolderId' => 'restore_folder_id', | |
| 104 | + 'sRestoreFolderPath' => 'restore_folder_path', | |
| 98 | 105 | ); |
| 99 | 106 | |
| 100 | 107 | function KTDocument() { |
| ... | ... | @@ -136,6 +143,12 @@ class KTDocumentCore extends KTEntity { |
| 136 | 143 | |
| 137 | 144 | function getImmutable() { return $this->bImmutable; } |
| 138 | 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 | 154 | // {{{ getParentId |
| ... | ... | @@ -234,7 +247,9 @@ class KTDocumentCore extends KTEntity { |
| 234 | 247 | |
| 235 | 248 | // {{{ update |
| 236 | 249 | function update($bPathMove = false) { |
| 250 | + //var_dump($this); exit(0); | |
| 237 | 251 | $res = parent::update(); |
| 252 | + | |
| 238 | 253 | if (($res === true) && ($bPathMove === true)) { |
| 239 | 254 | KTPermissionUtil::updatePermissionLookup($this); |
| 240 | 255 | } | ... | ... |
lib/documentmanagement/documentutil.inc.php
| ... | ... | @@ -621,7 +621,9 @@ class KTDocumentUtil { |
| 621 | 621 | // {{{ delete |
| 622 | 622 | function delete($oDocument, $sReason, $iDestFolderId = null) { |
| 623 | 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 | 627 | $oStorageManager =& KTStorageManagerUtil::getSingleton(); |
| 626 | 628 | |
| 627 | 629 | global $default; |
| ... | ... | @@ -629,24 +631,34 @@ class KTDocumentUtil { |
| 629 | 631 | if (count(trim($sReason)) == 0) { |
| 630 | 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 | 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 | 650 | DBUtil::startTransaction(); |
| 644 | 651 | |
| 645 | - // flip the status id | |
| 652 | + // flip the status id | |
| 646 | 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 | 660 | $res = $oDocument->update(); |
| 661 | + | |
| 650 | 662 | if (PEAR::isError($res) || ($res == false)) { |
| 651 | 663 | DBUtil::rollback(); |
| 652 | 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 | 198 | $oStorage =& KTStorageManagerUtil::getSingleton(); |
| 199 | 199 | |
| 200 | 200 | foreach ($aDocuments as $oDoc) { |
| 201 | - $oFolder = Folder::get($oDoc->getFolderID()); | |
| 201 | + $oFolder = Folder::get($oDoc->getRestoreFolderId()); | |
| 202 | 202 | if (PEAR::isError($oFolder)) { $oDoc->setFolderId(1); $oDoc->update(); } // move to root if parent no longer exists. |
| 203 | 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 | 205 | $oDoc->setStatusId(LIVE); |
| 206 | 206 | $res = $oDoc->update(); |
| 207 | 207 | if (PEAR::isError($res) || ($res == false)) { |
| ... | ... | @@ -233,6 +233,21 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; |
| 233 | 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 | 23 | <tr> |
| 24 | 24 | <th style="width:2em"><input type="checkbox" onclick="toggleSelectFor(this, 'selected_docs')" title="toggle all"/></th> |
| 25 | 25 | <th>{i18n}Document Name{/i18n}</th> |
| 26 | - <th>{i18n}Document Path{/i18n}</th> | |
| 26 | +{* <th>{i18n}Document Path{/i18n}</th> *} | |
| 27 | 27 | <th>{i18n}Last Modification{/i18n}</th> |
| 28 | 28 | <th>{i18n}Deletion Comment{/i18n}</th> |
| 29 | 29 | </tr> |
| ... | ... | @@ -33,7 +33,7 @@ can <strong>restore</strong> them as necessary.{/i18n}</p> |
| 33 | 33 | <tr> |
| 34 | 34 | <td><input type="checkbox" name="selected_docs[]" value="{$oDoc->getId()}"/></td> |
| 35 | 35 | <td>{$oDoc->getName()}</td> |
| 36 | - <td>{getCrumbStringForDocument document=$oDoc}</td> | |
| 36 | +{* <td>{getCrumbStringForDocument document=$oDoc}</td> *} | |
| 37 | 37 | <td>{$oDoc->getLastModifiedDate()}</td> |
| 38 | 38 | <td>{$oDoc->getLastDeletionComment()}</td> |
| 39 | 39 | </tr> | ... | ... |
templates/ktcore/document/admin/restoreconfirmlist.smarty
| ... | ... | @@ -14,12 +14,14 @@ confirm that you want to restore these documents.{/i18n}</p></div> |
| 14 | 14 | <tr> |
| 15 | 15 | |
| 16 | 16 | <th>{i18n}Document Name{/i18n}</th> |
| 17 | + <th>{i18n}Restore To{/i18n}</th> | |
| 17 | 18 | </tr> |
| 18 | 19 | </thead> |
| 19 | 20 | <tbody> |
| 20 | 21 | {foreach item=oDoc from=$documents} |
| 21 | 22 | <tr> |
| 22 | 23 | <td>{$oDoc->getName()}<input type="hidden" name="selected_docs[]" value="{$oDoc->getId()}" /></td> |
| 24 | + <td>{$context->getRestoreLocationFor($oDoc)}</td> | |
| 23 | 25 | </tr> |
| 24 | 26 | {/foreach} |
| 25 | 27 | </tbody> | ... | ... |