diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentBL.php index 020e9fa..521b1ce 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentBL.php +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentBL.php @@ -25,74 +25,83 @@ if (checkSession()) { if (isset($fDocumentID) && isset($fFolderID)) { if (isset($fForMove)) { - //we're trying to move a document - $oDocument = & Document::get($fDocumentID); - $iOldFolderID = $oDocument->getFolderID(); - if (Permission::userHasDocumentWritePermission($fDocumentID) && Permission::userHasFolderWritePermission($fFolderID)) { - //if the user has both document and folder write permissions - //get the old document path - $sOldDocumentFileSystemPath = Folder::getFolderPath($iOldFolderID) . $oDocument->getFileName(); - //put the document in the new folder - $oDocument->setFolderID($fFolderID); - if ($oDocument->update(true)) { - //get the new document path - $sNewDocumentFileSystemPath = Folder::getFolderPath($oDocument->getFolderID()) . $oDocument->getFileName(); - //move the document on the file system - if (PhysicalDocumentManager::move($sOldDocumentFileSystemPath, $sNewDocumentFileSystemPath)) { - - // fire subscription alerts for the moved document (and the folder its in) - $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("MovedDocument"), - SubscriptionConstants::subscriptionType("DocumentSubscription"), - array( "folderID" => $iOldFolderID, - "modifiedDocumentName" => $oDocument->getName(), - "oldFolderName" => Folder::getFolderName($iOldFolderID), - "newFolderName" => Folder::getFolderName($fFolderID) )); - $default->log->info("moveDocumentBL.php fired $count subscription alerts for moved document " . $oDocument->getName()); - - // fire folder subscriptions for the destination folder - $count = SubscriptionEngine::fireSubscription($oDocument->getFolderID(), SubscriptionConstants::subscriptionAlertType("MovedDocument"), - SubscriptionConstants::subscriptionType("FolderSubscription"), - array( "modifiedDocumentName" => $oDocument->getName(), - "oldFolderName" => Folder::getFolderName($iOldFolderID), - "newFolderName" => Folder::getFolderName($fFolderID) )); - $default->log->info("moveDocumentBL.php fired $count (folderID=$fFolderID) folder subscription alerts for moved document " . $oDocument->getName()); - - - //redirect to the view path - redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); + if ($fConfirmed) { + //we're trying to move a document + $oDocument = & Document::get($fDocumentID); + $iOldFolderID = $oDocument->getFolderID(); + if (Permission::userHasDocumentWritePermission($fDocumentID) && Permission::userHasFolderWritePermission($fFolderID)) { + //if the user has both document and folder write permissions + //get the old document path + $sOldDocumentFileSystemPath = Folder::getFolderPath($iOldFolderID) . $oDocument->getFileName(); + //put the document in the new folder + $oDocument->setFolderID($fFolderID); + if ($oDocument->update(true)) { + //get the new document path + $sNewDocumentFileSystemPath = Folder::getFolderPath($oDocument->getFolderID()) . $oDocument->getFileName(); + //move the document on the file system + if (PhysicalDocumentManager::move($sOldDocumentFileSystemPath, $sNewDocumentFileSystemPath)) { + + // fire subscription alerts for the moved document (and the folder its in) + $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("MovedDocument"), + SubscriptionConstants::subscriptionType("DocumentSubscription"), + array( "folderID" => $iOldFolderID, + "modifiedDocumentName" => $oDocument->getName(), + "oldFolderName" => Folder::getFolderName($iOldFolderID), + "newFolderName" => Folder::getFolderName($fFolderID) )); + $default->log->info("moveDocumentBL.php fired $count subscription alerts for moved document " . $oDocument->getName()); + + // fire folder subscriptions for the destination folder + $count = SubscriptionEngine::fireSubscription($oDocument->getFolderID(), SubscriptionConstants::subscriptionAlertType("MovedDocument"), + SubscriptionConstants::subscriptionType("FolderSubscription"), + array( "modifiedDocumentName" => $oDocument->getName(), + "oldFolderName" => Folder::getFolderName($iOldFolderID), + "newFolderName" => Folder::getFolderName($fFolderID) )); + $default->log->info("moveDocumentBL.php fired $count (folderID=$fFolderID) folder subscription alerts for moved document " . $oDocument->getName()); + + + //redirect to the view path + redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); + } else { + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); + //we couldn't move the document on the file system + //so reset the database values + $oDocument->setFolderID($iOldFolderID); + $oDocument->update(); + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID)); + $main->setCentralPayload($oPatternCustom); + $main->setErrorMessage("Could not move document on file system"); + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1"); + $main->render(); + } } else { require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - //we couldn't move the document on the file system - //so reset the database values - $oDocument->setFolderID($iOldFolderID); - $oDocument->update(); + //had a problem with the database $oPatternCustom = & new PatternCustom(); $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID)); $main->setCentralPayload($oPatternCustom); - $main->setErrorMessage("Could not move document on file system"); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1"); + $main->setErrorMessage("Could not update document in database"); + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID"); $main->render(); } } else { require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - //had a problem with the database $oPatternCustom = & new PatternCustom(); $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID)); $main->setCentralPayload($oPatternCustom); - $main->setErrorMessage("Could not update document in database"); $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID"); + $main->setErrorMessage("You do not have rights to move this document"); $main->render(); } } else { + // display confirmation page require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID)); + $oPatternCustom->setHtml(getConfirmationPage($fFolderID, $fDocumentID)); $main->setCentralPayload($oPatternCustom); $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID"); - $main->setErrorMessage("You do not have rights to move this document"); - $main->render(); - } - + $main->render(); + } } else { require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); $oPatternCustom = & new PatternCustom(); diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentUI.inc index d1eb726..c318fd6 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentUI.inc @@ -1,16 +1,18 @@ siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sColor = $default->siteMap->getSectionColour($sSectionName, "th"); - $sToRender = "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "\n"; - $sToRender .= "
$sHeading
\n"; - return $sToRender; -}*/ +function getConfirmationPage($iFolderID, $iDocumentID) { + global $default; + $sToRender = renderHeading("Move Document"); + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "
Are you sure you want to move
" . Document::getDocumentDisplayPath($iDocumentID) . " to
" . Folder::getFolderDisplayPath($iFolderID) . " > " . Document::getDocumentName($iDocumentID) . "
rootUrl/control.php?action=moveDocument&fDocumentID=$iDocumentID&fFolderID=$iFolderID&fForMove=1&fConfirmed=1\">graphicsUrl/widgets/move.gif\" border=\"0\"/> rootUrl/control.php?action=viewDocument&fDocumentID=" . $iDocumentID . "\">graphicsUrl/widgets/cancel.gif\" border=\"0\">
\n"; + return $sToRender; +} + function getPage($iFolderID, $iDocumentID) { global $default;