Commit ad3d0da6bd8c1991c15d28a8219ff4981af16dc8

Authored by Michael Joseph
1 parent 1503b834

fixed #2443

added move document confirmation page


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2068 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentBL.php
@@ -25,74 +25,83 @@ if (checkSession()) { @@ -25,74 +25,83 @@ if (checkSession()) {
25 25
26 if (isset($fDocumentID) && isset($fFolderID)) { 26 if (isset($fDocumentID) && isset($fFolderID)) {
27 if (isset($fForMove)) { 27 if (isset($fForMove)) {
28 - //we're trying to move a document  
29 - $oDocument = & Document::get($fDocumentID);  
30 - $iOldFolderID = $oDocument->getFolderID();  
31 - if (Permission::userHasDocumentWritePermission($fDocumentID) && Permission::userHasFolderWritePermission($fFolderID)) {  
32 - //if the user has both document and folder write permissions  
33 - //get the old document path  
34 - $sOldDocumentFileSystemPath = Folder::getFolderPath($iOldFolderID) . $oDocument->getFileName();  
35 - //put the document in the new folder  
36 - $oDocument->setFolderID($fFolderID);  
37 - if ($oDocument->update(true)) {  
38 - //get the new document path  
39 - $sNewDocumentFileSystemPath = Folder::getFolderPath($oDocument->getFolderID()) . $oDocument->getFileName();  
40 - //move the document on the file system  
41 - if (PhysicalDocumentManager::move($sOldDocumentFileSystemPath, $sNewDocumentFileSystemPath)) {  
42 -  
43 - // fire subscription alerts for the moved document (and the folder its in)  
44 - $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("MovedDocument"),  
45 - SubscriptionConstants::subscriptionType("DocumentSubscription"),  
46 - array( "folderID" => $iOldFolderID,  
47 - "modifiedDocumentName" => $oDocument->getName(),  
48 - "oldFolderName" => Folder::getFolderName($iOldFolderID),  
49 - "newFolderName" => Folder::getFolderName($fFolderID) ));  
50 - $default->log->info("moveDocumentBL.php fired $count subscription alerts for moved document " . $oDocument->getName());  
51 -  
52 - // fire folder subscriptions for the destination folder  
53 - $count = SubscriptionEngine::fireSubscription($oDocument->getFolderID(), SubscriptionConstants::subscriptionAlertType("MovedDocument"),  
54 - SubscriptionConstants::subscriptionType("FolderSubscription"),  
55 - array( "modifiedDocumentName" => $oDocument->getName(),  
56 - "oldFolderName" => Folder::getFolderName($iOldFolderID),  
57 - "newFolderName" => Folder::getFolderName($fFolderID) ));  
58 - $default->log->info("moveDocumentBL.php fired $count (folderID=$fFolderID) folder subscription alerts for moved document " . $oDocument->getName());  
59 -  
60 -  
61 - //redirect to the view path  
62 - redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); 28 + if ($fConfirmed) {
  29 + //we're trying to move a document
  30 + $oDocument = & Document::get($fDocumentID);
  31 + $iOldFolderID = $oDocument->getFolderID();
  32 + if (Permission::userHasDocumentWritePermission($fDocumentID) && Permission::userHasFolderWritePermission($fFolderID)) {
  33 + //if the user has both document and folder write permissions
  34 + //get the old document path
  35 + $sOldDocumentFileSystemPath = Folder::getFolderPath($iOldFolderID) . $oDocument->getFileName();
  36 + //put the document in the new folder
  37 + $oDocument->setFolderID($fFolderID);
  38 + if ($oDocument->update(true)) {
  39 + //get the new document path
  40 + $sNewDocumentFileSystemPath = Folder::getFolderPath($oDocument->getFolderID()) . $oDocument->getFileName();
  41 + //move the document on the file system
  42 + if (PhysicalDocumentManager::move($sOldDocumentFileSystemPath, $sNewDocumentFileSystemPath)) {
  43 +
  44 + // fire subscription alerts for the moved document (and the folder its in)
  45 + $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("MovedDocument"),
  46 + SubscriptionConstants::subscriptionType("DocumentSubscription"),
  47 + array( "folderID" => $iOldFolderID,
  48 + "modifiedDocumentName" => $oDocument->getName(),
  49 + "oldFolderName" => Folder::getFolderName($iOldFolderID),
  50 + "newFolderName" => Folder::getFolderName($fFolderID) ));
  51 + $default->log->info("moveDocumentBL.php fired $count subscription alerts for moved document " . $oDocument->getName());
  52 +
  53 + // fire folder subscriptions for the destination folder
  54 + $count = SubscriptionEngine::fireSubscription($oDocument->getFolderID(), SubscriptionConstants::subscriptionAlertType("MovedDocument"),
  55 + SubscriptionConstants::subscriptionType("FolderSubscription"),
  56 + array( "modifiedDocumentName" => $oDocument->getName(),
  57 + "oldFolderName" => Folder::getFolderName($iOldFolderID),
  58 + "newFolderName" => Folder::getFolderName($fFolderID) ));
  59 + $default->log->info("moveDocumentBL.php fired $count (folderID=$fFolderID) folder subscription alerts for moved document " . $oDocument->getName());
  60 +
  61 +
  62 + //redirect to the view path
  63 + redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID");
  64 + } else {
  65 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  66 + //we couldn't move the document on the file system
  67 + //so reset the database values
  68 + $oDocument->setFolderID($iOldFolderID);
  69 + $oDocument->update();
  70 + $oPatternCustom = & new PatternCustom();
  71 + $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID));
  72 + $main->setCentralPayload($oPatternCustom);
  73 + $main->setErrorMessage("Could not move document on file system");
  74 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1");
  75 + $main->render();
  76 + }
63 } else { 77 } else {
64 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 78 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
65 - //we couldn't move the document on the file system  
66 - //so reset the database values  
67 - $oDocument->setFolderID($iOldFolderID);  
68 - $oDocument->update(); 79 + //had a problem with the database
69 $oPatternCustom = & new PatternCustom(); 80 $oPatternCustom = & new PatternCustom();
70 $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID)); 81 $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID));
71 $main->setCentralPayload($oPatternCustom); 82 $main->setCentralPayload($oPatternCustom);
72 - $main->setErrorMessage("Could not move document on file system");  
73 - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1"); 83 + $main->setErrorMessage("Could not update document in database");
  84 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID");
74 $main->render(); 85 $main->render();
75 } 86 }
76 } else { 87 } else {
77 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 88 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
78 - //had a problem with the database  
79 $oPatternCustom = & new PatternCustom(); 89 $oPatternCustom = & new PatternCustom();
80 $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID)); 90 $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID));
81 $main->setCentralPayload($oPatternCustom); 91 $main->setCentralPayload($oPatternCustom);
82 - $main->setErrorMessage("Could not update document in database");  
83 $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID"); 92 $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID");
  93 + $main->setErrorMessage("You do not have rights to move this document");
84 $main->render(); 94 $main->render();
85 } 95 }
86 } else { 96 } else {
  97 + // display confirmation page
87 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 98 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
88 $oPatternCustom = & new PatternCustom(); 99 $oPatternCustom = & new PatternCustom();
89 - $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentID)); 100 + $oPatternCustom->setHtml(getConfirmationPage($fFolderID, $fDocumentID));
90 $main->setCentralPayload($oPatternCustom); 101 $main->setCentralPayload($oPatternCustom);
91 $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID"); 102 $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID");
92 - $main->setErrorMessage("You do not have rights to move this document");  
93 - $main->render();  
94 - }  
95 - 103 + $main->render();
  104 + }
96 } else { 105 } else {
97 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 106 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
98 $oPatternCustom = & new PatternCustom(); 107 $oPatternCustom = & new PatternCustom();
presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentUI.inc
1 <?php 1 <?php
2 2
3 -/*function renderHeading($sHeading) {  
4 - global $default;  
5 - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));  
6 - $sColor = $default->siteMap->getSectionColour($sSectionName, "th");  
7 - $sToRender = "<table border=\"0\" width=\"100%\">\n";  
8 - $sToRender .= "<tr align=\"left\"><th class=\"sectionHeading\" bgcolor=\"$sColor\">$sHeading</th></tr>\n";  
9 - $sToRender .= "<tr/>\n";  
10 - $sToRender .= "<tr/>\n";  
11 - $sToRender .= "</table>\n";  
12 - return $sToRender;  
13 -}*/ 3 +function getConfirmationPage($iFolderID, $iDocumentID) {
  4 + global $default;
  5 + $sToRender = renderHeading("Move Document");
  6 + $sToRender .= "<table>\n";
  7 + $sToRender .= "<tr>\n<td>Are you sure you want to move </td></tr>";
  8 + $sToRender .= "<tr><td><strong>" . Document::getDocumentDisplayPath($iDocumentID) . "</strong> to </td></tr>\n";
  9 + $sToRender .= "<tr><td><strong>" . Folder::getFolderDisplayPath($iFolderID) . " > " . Document::getDocumentName($iDocumentID) . "</strong></td>\n";
  10 + $sToRender .= "</tr>\n";
  11 + $sToRender .= "<tr><td><a href=\"$default->rootUrl/control.php?action=moveDocument&fDocumentID=$iDocumentID&fFolderID=$iFolderID&fForMove=1&fConfirmed=1\"><img src=\"$default->graphicsUrl/widgets/move.gif\" border=\"0\"/></a>&nbsp;<a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $iDocumentID . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a></td></tr>\n";
  12 + $sToRender .= "</table>\n";
  13 + return $sToRender;
  14 +}
  15 +
14 16
15 function getPage($iFolderID, $iDocumentID) { 17 function getPage($iFolderID, $iDocumentID) {
16 global $default; 18 global $default;