Commit ccf441e6afb4c2be2a5bf6a20cee58c606e8fdf6

Authored by bshuttle
1 parent 5ce1ba1d

fMoveCode was lost, causing KTS-298


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4818 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 30 additions and 14 deletions
browse.php
... ... @@ -58,7 +58,7 @@ class KTMassMoveColumn extends TitleColumn {
58 58 }
59 59  
60 60 function buildFolderLink($aDataRow) {
61   - return KTUtil::addQueryStringSelf(sprintf('MoveCode=%s&fFolderId=%d&action=startMove', $this->sMoveCode, $aDataRow["folder"]->getId()));
  61 + return KTUtil::addQueryStringSelf(sprintf('fMoveCode=%s&fFolderId=%d&action=startMove', $this->sMoveCode, $aDataRow["folder"]->getId()));
62 62 }
63 63 }
64 64  
... ... @@ -294,9 +294,13 @@ class BrowseDispatcher extends KTStandardDispatcher {
294 294 $aFolderSelection = KTUtil::arrayGet($_REQUEST, 'selection_f' , array());
295 295 $aDocumentSelection = KTUtil::arrayGet($_REQUEST, 'selection_d' , array());
296 296  
  297 +
  298 +
297 299 $sMoveCode = KTUtil::randomString();
298 300 $aMoveData = array('folders' => $aFolderSelection, 'documents' => $aDocumentSelection);
299 301  
  302 + var_dump($aMoveData);
  303 +
300 304 $moves = KTUtil::arrayGet($_SESSION, 'moves', array());
301 305 $moves = (array) $moves; // ?
302 306 $moves[$sMoveCode] = $aMoveData;
... ... @@ -403,6 +407,7 @@ class BrowseDispatcher extends KTStandardDispatcher {
403 407  
404 408 $aMoveStack = $_SESSION['moves'][$move_code];
405 409  
  410 +
406 411 $oTargetFolder = Folder::get($target_folder);
407 412  
408 413 if (PEAR::isError($oTargetFolder)) {
... ... @@ -425,31 +430,42 @@ class BrowseDispatcher extends KTStandardDispatcher {
425 430 if (PEAR::isError($oDoc)) {
426 431 $this->errorRedirectToMain(_('Invalid document.'));
427 432 }
428   - $oDocumentFolder = Folder::get($oDoc->getFolderID());
429   - $oDoc->setFolderID($target_folder);
430   - if (!$oDoc->update(true)) {
431   - $this->errorRedirectTo("main", _("There was a problem updating the document's location in the database"), sprintf("fDocumentId=%d&fFolderId=%d", $this->oDocument->getId(), $this->oFolder->getId()));
  433 +
  434 + $oOriginalFolder = Folder::get($oDoc->getFolderId());
  435 + $iOriginalFolderPermissionObjectId = $oOriginalFolder->getPermissionObjectId();
  436 + $iDocumentPermissionObjectId = $oDoc->getPermissionObjectId();
  437 +
  438 + if ($iDocumentPermissionObjectId === $iOriginalFolderPermissionObjectId) {
  439 + $oDoc->setPermissionObjectId($oTargetFolder->getPermissionObjectId());
432 440 }
  441 +
  442 + //put the document in the new folder
  443 + $oDoc->setFolderID($oTargetFolder->getId());
  444 + $res = $oDoc->update(true);
  445 + if (!$res) {
  446 + $this->errorRedirectTo("move", _("There was a problem updating the document's location in the database"), sprintf("fDocumentId=%d&fFolderId=%d", $oDoc->getId(), $oTargetFolder->getId()));
  447 + }
433 448  
434   - if (!$oStorage->moveDocument($oDoc, $oDocumentFolder, $oTargetFolder)) {
435   - $oDoc->setFolderID($oDocumentFolder->getId());
  449 + //move the document on the file system
  450 + $oStorage =& KTStorageManagerUtil::getSingleton();
  451 + if (!$oStorage->moveDocument($oDoc, $oOriginalFolder, $oTargetFolder)) {
  452 + $oDoc->setFolderID($oOriginalFolder->getId());
436 453 $oDoc->update(true);
437   - errorRedirectTo("move", _("There was a problem updating the document's location in the repository storage"), sprintf("fDocumentId=%d&fFolderId=%d", $this->oDocument->getId(), $this->oFolder->getId()));
  454 + $this->errorRedirectTo("move", _("There was a problem updating the document's location in the repository storage"), sprintf("fDocumentId=%d&fFolderId=%d", $oDoc->getId(), $oTargetFolder->getId()));
438 455 }
439 456  
440 457 $sMoveMessage = sprintf("Moved from %s/%s to %s/%s: %s",
441   - $oDocumentFolder->getFullPath(),
442   - $oDocumentFolder->getName(),
  458 + $oOriginalFolder->getFullPath(),
  459 + $oOriginalFolder->getName(),
443 460 $oTargetFolder->getFullPath(),
444 461 $oTargetFolder->getName(),
445   - $sReason);
  462 + $reason);
446 463  
447 464 // create the document transaction record
448 465  
449 466 $oDocumentTransaction = & new DocumentTransaction($oDoc, $sMoveMessage, 'ktcore.transactions.move');
450   - $oDocumentTransaction->create();
451   -
452   -
  467 + $oDocumentTransaction->create();
  468 +
453 469 $this->commitTransaction();
454 470  
455 471 $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
... ...