Commit 2fd5f2e4b234cab451715ce5fef54ad3d455e481
1 parent
fd5af8dc
Added triggers after the expunge has completed to do a bulk action on all expunged documents.
PT: 2100328 Committed by: Megan Watson
Showing
1 changed file
with
78 additions
and
64 deletions
plugins/ktcore/admin/deletedDocuments.php
| @@ -5,32 +5,32 @@ | @@ -5,32 +5,32 @@ | ||
| 5 | * KnowledgeTree Community Edition | 5 | * KnowledgeTree Community Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2008, 2009 KnowledgeTree Inc. | 7 | * Copyright (C) 2008, 2009 KnowledgeTree Inc. |
| 8 | - * | ||
| 9 | - * | 8 | + * |
| 9 | + * | ||
| 10 | * This program is free software; you can redistribute it and/or modify it under | 10 | * This program is free software; you can redistribute it and/or modify it under |
| 11 | * the terms of the GNU General Public License version 3 as published by the | 11 | * the terms of the GNU General Public License version 3 as published by the |
| 12 | * Free Software Foundation. | 12 | * Free Software Foundation. |
| 13 | - * | 13 | + * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT | 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 17 | * details. | 17 | * details. |
| 18 | - * | 18 | + * |
| 19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | - * | ||
| 22 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | 21 | + * |
| 22 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 23 | * California 94120-7775, or email info@knowledgetree.com. | 23 | * California 94120-7775, or email info@knowledgetree.com. |
| 24 | - * | 24 | + * |
| 25 | * The interactive user interfaces in modified source and object code versions | 25 | * The interactive user interfaces in modified source and object code versions |
| 26 | * of this program must display Appropriate Legal Notices, as required under | 26 | * of this program must display Appropriate Legal Notices, as required under |
| 27 | * Section 5 of the GNU General Public License version 3. | 27 | * Section 5 of the GNU General Public License version 3. |
| 28 | - * | 28 | + * |
| 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 30 | * these Appropriate Legal Notices must retain the display of the "Powered by | 30 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 31 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 31 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | 33 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 34 | * copyright notice. | 34 | * copyright notice. |
| 35 | * Contributor( s): ______________________________________ | 35 | * Contributor( s): ______________________________________ |
| 36 | * | 36 | * |
| @@ -51,9 +51,9 @@ class DeletedDocumentsDispatcher extends KTAdminDispatcher { | @@ -51,9 +51,9 @@ class DeletedDocumentsDispatcher extends KTAdminDispatcher { | ||
| 51 | var $sHelpPage = 'ktcore/admin/deleted documents.html'; | 51 | var $sHelpPage = 'ktcore/admin/deleted documents.html'; |
| 52 | function do_main () { | 52 | function do_main () { |
| 53 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Deleted Documents')); | 53 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Deleted Documents')); |
| 54 | - | 54 | + |
| 55 | $this->oPage->setBreadcrumbDetails(_kt('view')); | 55 | $this->oPage->setBreadcrumbDetails(_kt('view')); |
| 56 | - | 56 | + |
| 57 | $aDocuments =& Document::getList('status_id=' . DELETED); | 57 | $aDocuments =& Document::getList('status_id=' . DELETED); |
| 58 | 58 | ||
| 59 | if(!empty($aDocuments)){ | 59 | if(!empty($aDocuments)){ |
| @@ -72,12 +72,12 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | @@ -72,12 +72,12 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | ||
| 72 | }else{ | 72 | }else{ |
| 73 | $limit = 9; | 73 | $limit = 9; |
| 74 | } | 74 | } |
| 75 | - | 75 | + |
| 76 | for($i = 0; $i <= $limit; $i++){ | 76 | for($i = 0; $i <= $limit; $i++){ |
| 77 | $aDocumentsList[] = $aDocuments[$i]; | 77 | $aDocumentsList[] = $aDocuments[$i]; |
| 78 | } | 78 | } |
| 79 | } | 79 | } |
| 80 | - | 80 | + |
| 81 | $oTemplating =& KTTemplating::getSingleton(); | 81 | $oTemplating =& KTTemplating::getSingleton(); |
| 82 | $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/deletedlist'); | 82 | $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/deletedlist'); |
| 83 | $oTemplate->setData(array( | 83 | $oTemplate->setData(array( |
| @@ -90,7 +90,7 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | @@ -90,7 +90,7 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | ||
| 90 | )); | 90 | )); |
| 91 | return $oTemplate; | 91 | return $oTemplate; |
| 92 | } | 92 | } |
| 93 | - | 93 | + |
| 94 | function do_branchConfirm() { | 94 | function do_branchConfirm() { |
| 95 | $submit = KTUtil::arrayGet($_REQUEST, 'submit' , array()); | 95 | $submit = KTUtil::arrayGet($_REQUEST, 'submit' , array()); |
| 96 | if (array_key_exists('expunge',$submit)) { | 96 | if (array_key_exists('expunge',$submit)) { |
| @@ -104,33 +104,33 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | @@ -104,33 +104,33 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | ||
| 104 | } | 104 | } |
| 105 | $this->errorRedirectToMain(_kt('No action specified.')); | 105 | $this->errorRedirectToMain(_kt('No action specified.')); |
| 106 | } | 106 | } |
| 107 | - | 107 | + |
| 108 | function do_confirm_expunge($all = false) { | 108 | function do_confirm_expunge($all = false) { |
| 109 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Deleted Documents')); | 109 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Deleted Documents')); |
| 110 | - | 110 | + |
| 111 | $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array()); | 111 | $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array()); |
| 112 | $full_docs = KTUtil::arrayGet($_REQUEST, 'docIds', array()); | 112 | $full_docs = KTUtil::arrayGet($_REQUEST, 'docIds', array()); |
| 113 | - | 113 | + |
| 114 | if($all == true){ | 114 | if($all == true){ |
| 115 | $selected_docs = $full_docs; | 115 | $selected_docs = $full_docs; |
| 116 | } | 116 | } |
| 117 | - | 117 | + |
| 118 | $this->oPage->setTitle(sprintf(_kt('Confirm Expunge of %d documents'), count($selected_docs))); | 118 | $this->oPage->setTitle(sprintf(_kt('Confirm Expunge of %d documents'), count($selected_docs))); |
| 119 | - | 119 | + |
| 120 | $this->oPage->setBreadcrumbDetails(sprintf(_kt('confirm expunge of %d documents'), count($selected_docs))); | 120 | $this->oPage->setBreadcrumbDetails(sprintf(_kt('confirm expunge of %d documents'), count($selected_docs))); |
| 121 | - | 121 | + |
| 122 | $aDocuments = array(); | 122 | $aDocuments = array(); |
| 123 | foreach ($selected_docs as $doc_id) { | 123 | foreach ($selected_docs as $doc_id) { |
| 124 | $oDoc =& Document::get($doc_id); | 124 | $oDoc =& Document::get($doc_id); |
| 125 | - if (PEAR::isError($oDoc) || ($oDoc === false)) { | 125 | + if (PEAR::isError($oDoc) || ($oDoc === false)) { |
| 126 | $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting expunge')); | 126 | $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting expunge')); |
| 127 | } else if ($oDoc->getStatusId() != DELETED) { | 127 | } else if ($oDoc->getStatusId() != DELETED) { |
| 128 | $this->errorRedirectToMain(sprintf(_kt('%s is not a deleted document. Aborting expunge'), $oDoc->getName())); | 128 | $this->errorRedirectToMain(sprintf(_kt('%s is not a deleted document. Aborting expunge'), $oDoc->getName())); |
| 129 | } | 129 | } |
| 130 | $aDocuments[] = $oDoc; | 130 | $aDocuments[] = $oDoc; |
| 131 | } | 131 | } |
| 132 | - | ||
| 133 | - | 132 | + |
| 133 | + | ||
| 134 | $oTemplating =& KTTemplating::getSingleton(); | 134 | $oTemplating =& KTTemplating::getSingleton(); |
| 135 | $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/expungeconfirmlist'); | 135 | $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/expungeconfirmlist'); |
| 136 | $oTemplate->setData(array( | 136 | $oTemplate->setData(array( |
| @@ -140,47 +140,49 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | @@ -140,47 +140,49 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | ||
| 140 | return $oTemplate; | 140 | return $oTemplate; |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | - function do_finish_expunge() { | ||
| 144 | - $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array()); | ||
| 145 | - | 143 | + function do_finish_expunge() { |
| 144 | + $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array()); | ||
| 145 | + | ||
| 146 | $aDocuments = array(); | 146 | $aDocuments = array(); |
| 147 | foreach ($selected_docs as $doc_id) { | 147 | foreach ($selected_docs as $doc_id) { |
| 148 | $oDoc =& Document::get($doc_id); | 148 | $oDoc =& Document::get($doc_id); |
| 149 | - if (PEAR::isError($oDoc) || ($oDoc === false)) { | 149 | + if (PEAR::isError($oDoc) || ($oDoc === false)) { |
| 150 | $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting expunge')); | 150 | $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting expunge')); |
| 151 | } else if ($oDoc->getStatusId() != DELETED) { | 151 | } else if ($oDoc->getStatusId() != DELETED) { |
| 152 | $this->errorRedirectToMain(sprintf(_kt('%s is not a deleted document. Aborting expunge'), $oDoc->getName())); | 152 | $this->errorRedirectToMain(sprintf(_kt('%s is not a deleted document. Aborting expunge'), $oDoc->getName())); |
| 153 | } | 153 | } |
| 154 | $aDocuments[] = $oDoc; | 154 | $aDocuments[] = $oDoc; |
| 155 | } | 155 | } |
| 156 | - | 156 | + |
| 157 | $this->startTransaction(); | 157 | $this->startTransaction(); |
| 158 | $aErrorDocuments = array(); | 158 | $aErrorDocuments = array(); |
| 159 | - $aSuccessDocuments = array(); | 159 | + $aSuccessDocuments = array(); |
| 160 | + $aDeletedDocs = array(); | ||
| 160 | 161 | ||
| 161 | $oStorage =& KTStorageManagerUtil::getSingleton(); | 162 | $oStorage =& KTStorageManagerUtil::getSingleton(); |
| 163 | + $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); | ||
| 162 | 164 | ||
| 163 | foreach ($aDocuments as $oDoc) { | 165 | foreach ($aDocuments as $oDoc) { |
| 164 | // first evaluate the folder for inconsistencies. | 166 | // first evaluate the folder for inconsistencies. |
| 165 | $oFolder = Folder::get($oDoc->getFolderID()); | 167 | $oFolder = Folder::get($oDoc->getFolderID()); |
| 166 | if (PEAR::isError($oFolder)) { $oDoc->setFolderId(1); $oDoc->update(); } | 168 | if (PEAR::isError($oFolder)) { $oDoc->setFolderId(1); $oDoc->update(); } |
| 167 | - | 169 | + |
| 168 | if (!$oStorage->expunge($oDoc)) { $aErrorDocuments[] = $oDoc->getDisplayPath(); } | 170 | if (!$oStorage->expunge($oDoc)) { $aErrorDocuments[] = $oDoc->getDisplayPath(); } |
| 169 | else { | 171 | else { |
| 170 | $oDocumentTransaction = & new DocumentTransaction($oDoc, _kt('Document expunged'), 'ktcore.transactions.expunge'); | 172 | $oDocumentTransaction = & new DocumentTransaction($oDoc, _kt('Document expunged'), 'ktcore.transactions.expunge'); |
| 171 | $oDocumentTransaction->create(); | 173 | $oDocumentTransaction->create(); |
| 172 | - | 174 | + |
| 173 | // delete this from the db now | 175 | // delete this from the db now |
| 174 | if (!$oDoc->delete()) { | 176 | if (!$oDoc->delete()) { |
| 175 | - $aErrorDocuments[] = $oDoc->getId(); | 177 | + $aErrorDocuments[] = $oDoc->getId(); |
| 176 | } else { | 178 | } else { |
| 177 | // removed succesfully | 179 | // removed succesfully |
| 178 | $aSuccessDocuments[] = $oDoc->getDisplayPath(); | 180 | $aSuccessDocuments[] = $oDoc->getDisplayPath(); |
| 179 | - | 181 | + $aDeletedDocs[] = $oDoc->getId(); |
| 182 | + | ||
| 180 | // remove any document data | 183 | // remove any document data |
| 181 | $oDoc->cleanupDocumentData($oDoc->getId()); // silly - why the redundancy? | 184 | $oDoc->cleanupDocumentData($oDoc->getId()); // silly - why the redundancy? |
| 182 | - | ||
| 183 | - $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); | 185 | + |
| 184 | $aTriggers = $oKTTriggerRegistry->getTriggers('expunge', 'finalised'); | 186 | $aTriggers = $oKTTriggerRegistry->getTriggers('expunge', 'finalised'); |
| 185 | foreach ($aTriggers as $aTrigger) { | 187 | foreach ($aTriggers as $aTrigger) { |
| 186 | $sTrigger = $aTrigger[0]; | 188 | $sTrigger = $aTrigger[0]; |
| @@ -189,38 +191,50 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | @@ -189,38 +191,50 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | ||
| 189 | 'document' => $oDoc, | 191 | 'document' => $oDoc, |
| 190 | ); | 192 | ); |
| 191 | $oTrigger->setInfo($aInfo); | 193 | $oTrigger->setInfo($aInfo); |
| 192 | - $ret = $oTrigger->finalised(); | 194 | + $ret = $oTrigger->finalised(); |
| 193 | } | 195 | } |
| 194 | } | 196 | } |
| 195 | } | 197 | } |
| 196 | } | 198 | } |
| 197 | $this->commitTransaction(); | 199 | $this->commitTransaction(); |
| 200 | + | ||
| 201 | + $aTriggers = $oKTTriggerRegistry->getTriggers('expunge', 'postValidate'); | ||
| 202 | + foreach ($aTriggers as $aTrigger) { | ||
| 203 | + $sTrigger = $aTrigger[0]; | ||
| 204 | + $oTrigger = new $sTrigger; | ||
| 205 | + $aInfo = array( | ||
| 206 | + 'documents' => $aDeletedDocs, | ||
| 207 | + ); | ||
| 208 | + $oTrigger->setInfo($aInfo); | ||
| 209 | + $ret = $oTrigger->postValidate(); | ||
| 210 | + } | ||
| 211 | + | ||
| 198 | $msg = sprintf(_kt('%d documents expunged.'), count($aSuccessDocuments)); | 212 | $msg = sprintf(_kt('%d documents expunged.'), count($aSuccessDocuments)); |
| 199 | if (count($aErrorDocuments) != 0) { $msg .= _kt('Failed to expunge') . ': ' . join(', ', $aErrorDocuments); } | 213 | if (count($aErrorDocuments) != 0) { $msg .= _kt('Failed to expunge') . ': ' . join(', ', $aErrorDocuments); } |
| 200 | $this->successRedirectToMain($msg); | 214 | $this->successRedirectToMain($msg); |
| 201 | } | 215 | } |
| 202 | - | 216 | + |
| 203 | function do_confirm_restore() { | 217 | function do_confirm_restore() { |
| 204 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Deleted Documents')); | 218 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Deleted Documents')); |
| 205 | - | ||
| 206 | - $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array()); | ||
| 207 | - | 219 | + |
| 220 | + $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array()); | ||
| 221 | + | ||
| 208 | $this->oPage->setTitle(sprintf(_kt('Confirm Restore of %d documents'), count($selected_docs))); | 222 | $this->oPage->setTitle(sprintf(_kt('Confirm Restore of %d documents'), count($selected_docs))); |
| 209 | - | 223 | + |
| 210 | $this->oPage->setBreadcrumbDetails(sprintf(_kt('Confirm Restore of %d documents'), count($selected_docs))); | 224 | $this->oPage->setBreadcrumbDetails(sprintf(_kt('Confirm Restore of %d documents'), count($selected_docs))); |
| 211 | - | 225 | + |
| 212 | $aDocuments = array(); | 226 | $aDocuments = array(); |
| 213 | foreach ($selected_docs as $doc_id) { | 227 | foreach ($selected_docs as $doc_id) { |
| 214 | $oDoc =& Document::get($doc_id); | 228 | $oDoc =& Document::get($doc_id); |
| 215 | - if (PEAR::isError($oDoc) || ($oDoc === false)) { | 229 | + if (PEAR::isError($oDoc) || ($oDoc === false)) { |
| 216 | $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting expunge')); | 230 | $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting expunge')); |
| 217 | } else if ($oDoc->getStatusId() != DELETED) { | 231 | } else if ($oDoc->getStatusId() != DELETED) { |
| 218 | $this->errorRedirectToMain(sprintf(_kt('%s is not a deleted document. Aborting expunge'), $oDoc->getName())); | 232 | $this->errorRedirectToMain(sprintf(_kt('%s is not a deleted document. Aborting expunge'), $oDoc->getName())); |
| 219 | } | 233 | } |
| 220 | $aDocuments[] = $oDoc; | 234 | $aDocuments[] = $oDoc; |
| 221 | } | 235 | } |
| 222 | - | ||
| 223 | - | 236 | + |
| 237 | + | ||
| 224 | $oTemplating =& KTTemplating::getSingleton(); | 238 | $oTemplating =& KTTemplating::getSingleton(); |
| 225 | $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/restoreconfirmlist'); | 239 | $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/restoreconfirmlist'); |
| 226 | $oTemplate->setData(array( | 240 | $oTemplate->setData(array( |
| @@ -230,36 +244,36 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | @@ -230,36 +244,36 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | ||
| 230 | return $oTemplate; | 244 | return $oTemplate; |
| 231 | } | 245 | } |
| 232 | 246 | ||
| 233 | - function do_finish_restore() { | ||
| 234 | - $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array()); | ||
| 235 | - | 247 | + function do_finish_restore() { |
| 248 | + $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array()); | ||
| 249 | + | ||
| 236 | $aDocuments = array(); | 250 | $aDocuments = array(); |
| 237 | foreach ($selected_docs as $doc_id) { | 251 | foreach ($selected_docs as $doc_id) { |
| 238 | $oDoc =& Document::get($doc_id); | 252 | $oDoc =& Document::get($doc_id); |
| 239 | - if (PEAR::isError($oDoc) || ($oDoc === false)) { | 253 | + if (PEAR::isError($oDoc) || ($oDoc === false)) { |
| 240 | $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting restore')); | 254 | $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting restore')); |
| 241 | } else if ($oDoc->getStatusId() != DELETED) { | 255 | } else if ($oDoc->getStatusId() != DELETED) { |
| 242 | $this->errorRedirectToMain(sprintf(_kt('%s is not a deleted document. Aborting restore'), $oDoc->getName())); | 256 | $this->errorRedirectToMain(sprintf(_kt('%s is not a deleted document. Aborting restore'), $oDoc->getName())); |
| 243 | } | 257 | } |
| 244 | $aDocuments[] = $oDoc; | 258 | $aDocuments[] = $oDoc; |
| 245 | } | 259 | } |
| 246 | - | 260 | + |
| 247 | $this->startTransaction(); | 261 | $this->startTransaction(); |
| 248 | $aErrorDocuments = array(); | 262 | $aErrorDocuments = array(); |
| 249 | - $aSuccessDocuments = array(); | 263 | + $aSuccessDocuments = array(); |
| 250 | 264 | ||
| 251 | $oStorage =& KTStorageManagerUtil::getSingleton(); | 265 | $oStorage =& KTStorageManagerUtil::getSingleton(); |
| 252 | 266 | ||
| 253 | foreach ($aDocuments as $oDoc) { | 267 | foreach ($aDocuments as $oDoc) { |
| 254 | $oFolder = Folder::get($oDoc->getRestoreFolderId()); | 268 | $oFolder = Folder::get($oDoc->getRestoreFolderId()); |
| 255 | // move to root if parent no longer exists. | 269 | // move to root if parent no longer exists. |
| 256 | - if (PEAR::isError($oFolder)) { | ||
| 257 | - $oDoc->setFolderId(1); | 270 | + if (PEAR::isError($oFolder)) { |
| 271 | + $oDoc->setFolderId(1); | ||
| 258 | $oFolder = Folder::get(1); | 272 | $oFolder = Folder::get(1); |
| 259 | - } else { | 273 | + } else { |
| 260 | $oDoc->setFolderId($oDoc->getRestoreFolderId()); | 274 | $oDoc->setFolderId($oDoc->getRestoreFolderId()); |
| 261 | } | 275 | } |
| 262 | - | 276 | + |
| 263 | if ($oStorage->restore($oDoc)) { | 277 | if ($oStorage->restore($oDoc)) { |
| 264 | $oDoc = Document::get($oDoc->getId()); // storage path has changed for most recent object... | 278 | $oDoc = Document::get($oDoc->getId()); // storage path has changed for most recent object... |
| 265 | $oDoc->setStatusId(LIVE); | 279 | $oDoc->setStatusId(LIVE); |
| @@ -269,14 +283,14 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | @@ -269,14 +283,14 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | ||
| 269 | $aErrorDocuments[] = $oDoc->getName(); | 283 | $aErrorDocuments[] = $oDoc->getName(); |
| 270 | continue; // skip transactions, etc. | 284 | continue; // skip transactions, etc. |
| 271 | } | 285 | } |
| 272 | - | 286 | + |
| 273 | $res = KTPermissionUtil::updatePermissionLookup($oDoc); | 287 | $res = KTPermissionUtil::updatePermissionLookup($oDoc); |
| 274 | - | 288 | + |
| 275 | if (PEAR::isError($res)) { | 289 | if (PEAR::isError($res)) { |
| 276 | $aErrorDocuments[] = $oDoc->getName(); | 290 | $aErrorDocuments[] = $oDoc->getName(); |
| 277 | continue; // skip transactions, etc. | 291 | continue; // skip transactions, etc. |
| 278 | } | 292 | } |
| 279 | - | 293 | + |
| 280 | // create a doc-transaction. | 294 | // create a doc-transaction. |
| 281 | // FIXME does this warrant a transaction-type? | 295 | // FIXME does this warrant a transaction-type? |
| 282 | $oTransaction = new DocumentTransaction($oDoc, sprintf(_kt("Restored from deleted state by %s"), $this->oUser->getName()), 'ktcore.transactions.update'); | 296 | $oTransaction = new DocumentTransaction($oDoc, sprintf(_kt("Restored from deleted state by %s"), $this->oUser->getName()), 'ktcore.transactions.update'); |
| @@ -293,14 +307,14 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | @@ -293,14 +307,14 @@ var $sHelpPage = 'ktcore/admin/deleted documents.html'; | ||
| 293 | $msg = sprintf(_kt('%d documents restored.'), count($aSuccessDocuments)); | 307 | $msg = sprintf(_kt('%d documents restored.'), count($aSuccessDocuments)); |
| 294 | if (count($aErrorDocuments) != 0) { $msg .= _kt('Failed to restore') . ': ' . join(', ', $aErrorDocuments); } | 308 | if (count($aErrorDocuments) != 0) { $msg .= _kt('Failed to restore') . ': ' . join(', ', $aErrorDocuments); } |
| 295 | $this->successRedirectToMain($msg); | 309 | $this->successRedirectToMain($msg); |
| 296 | - } | ||
| 297 | - | 310 | + } |
| 311 | + | ||
| 298 | function getRestoreLocationFor($oDocument) { | 312 | function getRestoreLocationFor($oDocument) { |
| 299 | - $iFolderId = $oDocument->getRestoreFolderId(); | 313 | + $iFolderId = $oDocument->getRestoreFolderId(); |
| 300 | $oFolder = Folder::get($iFolderId); | 314 | $oFolder = Folder::get($iFolderId); |
| 301 | - | 315 | + |
| 302 | if (PEAR::isError($oFolder)) { | 316 | if (PEAR::isError($oFolder)) { |
| 303 | - return _kt('Original folder no longer exists. Document will be restored in the root folder.'); | 317 | + return _kt('Original folder no longer exists. Document will be restored in the root folder.'); |
| 304 | } else { | 318 | } else { |
| 305 | $aCrumbs = KTBrowseUtil::breadcrumbsForFolder($oFolder); | 319 | $aCrumbs = KTBrowseUtil::breadcrumbsForFolder($oFolder); |
| 306 | $aParts = array(); | 320 | $aParts = array(); |