Commit b997ff5d06915f61d2dfb0547e2b7ea097009a19
1 parent
c0cdd009
fix for KTS-571 and KTS-554
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5058 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
18 additions
and
6 deletions
lib/documentmanagement/documentutil.inc.php
| @@ -567,9 +567,9 @@ class KTDocumentUtil { | @@ -567,9 +567,9 @@ class KTDocumentUtil { | ||
| 567 | // }}} | 567 | // }}} |
| 568 | 568 | ||
| 569 | // {{{ delete | 569 | // {{{ delete |
| 570 | - function delete($oDocument, $sReason) { | 570 | + function delete($oDocument, $sReason, $iDestFolderId = null) { |
| 571 | $oDocument =& KTUtil::getObject('Document', $oDocument); | 571 | $oDocument =& KTUtil::getObject('Document', $oDocument); |
| 572 | - | 572 | + if (is_null($iDestFolderId)) { $iDestFolderId = $oDocument->getFolderID(); } |
| 573 | $oStorageManager =& KTStorageManagerUtil::getSingleton(); | 573 | $oStorageManager =& KTStorageManagerUtil::getSingleton(); |
| 574 | 574 | ||
| 575 | global $default; | 575 | global $default; |
| @@ -588,7 +588,7 @@ class KTDocumentUtil { | @@ -588,7 +588,7 @@ class KTDocumentUtil { | ||
| 588 | 588 | ||
| 589 | // flip the status id | 589 | // flip the status id |
| 590 | $oDocument->setStatusID(DELETED); | 590 | $oDocument->setStatusID(DELETED); |
| 591 | - | 591 | + $oDocument->setFolderID($iDestFolderId); // try to keep it in _this_ folder, otherwise move to root. |
| 592 | 592 | ||
| 593 | $res = $oDocument->update(); | 593 | $res = $oDocument->update(); |
| 594 | if (PEAR::isError($res) || ($res == false)) { | 594 | if (PEAR::isError($res) || ($res == false)) { |
lib/foldermanagement/folderutil.inc.php
| @@ -270,7 +270,7 @@ class KTFolderUtil { | @@ -270,7 +270,7 @@ class KTFolderUtil { | ||
| 270 | 270 | ||
| 271 | // now we can go ahead. | 271 | // now we can go ahead. |
| 272 | foreach ($aDocuments as $oDocument) { | 272 | foreach ($aDocuments as $oDocument) { |
| 273 | - $res = KTDocumentUtil::delete($oDocument, $sReason); | 273 | + $res = KTDocumentUtil::delete($oDocument, $sReason, 1); // id of destination folder = ROOT |
| 274 | if (PEAR::isError($res)) { | 274 | if (PEAR::isError($res)) { |
| 275 | DBUtil::rollback(); | 275 | DBUtil::rollback(); |
| 276 | return PEAR::raiseError(_('Delete Aborted. Unexpected failure to delete document: ') . $oDocument->getName() . $res->getMessage()); | 276 | return PEAR::raiseError(_('Delete Aborted. Unexpected failure to delete document: ') . $oDocument->getName() . $res->getMessage()); |
plugins/ktcore/admin/deletedDocuments.php
| @@ -118,6 +118,10 @@ class DeletedDocumentsDispatcher extends KTAdminDispatcher { | @@ -118,6 +118,10 @@ class DeletedDocumentsDispatcher extends KTAdminDispatcher { | ||
| 118 | $oStorage =& KTStorageManagerUtil::getSingleton(); | 118 | $oStorage =& KTStorageManagerUtil::getSingleton(); |
| 119 | 119 | ||
| 120 | foreach ($aDocuments as $oDoc) { | 120 | foreach ($aDocuments as $oDoc) { |
| 121 | + // first evaluate the folder for inconsistencies. | ||
| 122 | + $oFolder = Folder::get($oDoc->getFolderID()); | ||
| 123 | + if (PEAR::isError($oFolder)) { $oDoc->setFolderId(1); } | ||
| 124 | + | ||
| 121 | if (!$oStorage->expunge($oDoc)) { $aErrorDocuments[] = $oDoc->getDisplayPath(); } | 125 | if (!$oStorage->expunge($oDoc)) { $aErrorDocuments[] = $oDoc->getDisplayPath(); } |
| 122 | else { | 126 | else { |
| 123 | $oDocumentTransaction = & new DocumentTransaction($oDoc, "Document expunged", 'ktcore.transactions.expunge'); | 127 | $oDocumentTransaction = & new DocumentTransaction($oDoc, "Document expunged", 'ktcore.transactions.expunge'); |
| @@ -191,15 +195,23 @@ class DeletedDocumentsDispatcher extends KTAdminDispatcher { | @@ -191,15 +195,23 @@ class DeletedDocumentsDispatcher extends KTAdminDispatcher { | ||
| 191 | $oStorage =& KTStorageManagerUtil::getSingleton(); | 195 | $oStorage =& KTStorageManagerUtil::getSingleton(); |
| 192 | 196 | ||
| 193 | foreach ($aDocuments as $oDoc) { | 197 | foreach ($aDocuments as $oDoc) { |
| 194 | - $oDoc->setFolderID(1); | 198 | + $oFolder = Folder::get($oDoc->getFolderID()); |
| 199 | + if (PEAR::isError($oFolder)) { $oDoc->setFolderId(1); } // move to root if parent no longer exists. | ||
| 195 | if ($oStorage->restore($oDoc)) { | 200 | if ($oStorage->restore($oDoc)) { |
| 196 | $oDoc->setStatusId(LIVE); | 201 | $oDoc->setStatusId(LIVE); |
| 197 | $res = $oDoc->update(); | 202 | $res = $oDoc->update(); |
| 198 | if (PEAR::isError($res) || ($res == false)) { | 203 | if (PEAR::isError($res) || ($res == false)) { |
| 199 | - $oStorage->delete($oDoc); | ||
| 200 | $aErrorDocuments[] = $oDoc->getName; | 204 | $aErrorDocuments[] = $oDoc->getName; |
| 201 | continue; // skip transactions, etc. | 205 | continue; // skip transactions, etc. |
| 202 | } | 206 | } |
| 207 | + | ||
| 208 | + $res = KTPermissionUtil::updatePermissionLookup($oDoc); | ||
| 209 | + | ||
| 210 | + if (PEAR::isError($res)) { | ||
| 211 | + $aErrorDocuments[] = $oDoc->getName; | ||
| 212 | + continue; // skip transactions, etc. | ||
| 213 | + } | ||
| 214 | + | ||
| 203 | // create a doc-transaction. | 215 | // create a doc-transaction. |
| 204 | // FIXME does this warrant a transaction-type? | 216 | // FIXME does this warrant a transaction-type? |
| 205 | $oTransaction = new DocumentTransaction($oDoc, 'Restored from deleted state by ' . $this->oUser->getName(), 'ktcore.transactions.update'); | 217 | $oTransaction = new DocumentTransaction($oDoc, 'Restored from deleted state by ' . $this->oUser->getName(), 'ktcore.transactions.update'); |