Commit dea8b606351a575069d47cfb69e94fd6766412a3

Authored by Neil Blakey-Milner
1 parent f528ba0a

Fix the multi-document move functionality.

Submitted by:	William Hawkins (williamhawkins)
SF Tracker:	1230598


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3401 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentBL.php
... ... @@ -27,7 +27,7 @@
27 27  
28 28 require_once("../../../../config/dmsDefaults.php");
29 29  
30   -KTUtil::extractGPC('fConfirmed', 'fDocumentIDs', 'fFolderID', 'fForMove');
  30 +KTUtil::extractGPC('fConfirmed', 'fDocumentIDs', 'fFolderID', 'fForMove', 'fRememberDocumentID');
31 31  
32 32 require_once("$default->fileSystemRoot/lib/security/Permission.inc");
33 33  
... ... @@ -50,6 +50,15 @@ require_once("$default->fileSystemRoot/presentation/Html.inc");
50 50 $aUnmovedDocs = array();
51 51  
52 52 if (checkSession()) {
  53 +
  54 + if (isset($fRememberDocumentID)) {
  55 + $fDocumentIDs = $_SESSION['documents'][$fRememberDocumentID];
  56 + } else {
  57 + $sUniqueID = KTUtil::randomString();
  58 + $_SESSION["documents"][$sUniqueID] = $fDocumentIDs;
  59 + $fRememberDocumentID = $sUniqueID;
  60 + }
  61 +
53 62  
54 63 if (isset($fDocumentIDs) && isset($fFolderID)) {
55 64 if (isset($fForMove)) {
... ... @@ -167,28 +176,28 @@ if (checkSession()) {
167 176 $sNewDocumentFileSystemPath = Folder::getFolderPath($fFolderID) . $oDocument->getFileName();
168 177 if (!file_exists($sNewDocumentFileSystemPath)) {
169 178 // display confirmation page
170   - $oPatternCustom->setHtml(getConfirmationPage($fFolderID, $fDocumentIDs));
  179 + $oPatternCustom->setHtml(getConfirmationPage($fFolderID, $fRememberDocumentID));
171 180 } else {
172 181 // filename collision
173   - $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentIDs, _("This folder already contains a document of the same name.") . " " . _("Please choose another directory")));
  182 + $oPatternCustom->setHtml(getPage($fFolderID, $fRememberDocumentID, _("This folder already contains a document of the same name.") . " " . _("Please choose another directory")));
174 183 break;
175 184 }
176 185 } else {
177 186 // the right document type isn't mapped
178   - $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentIDs, _("You can't move the document to this folder because it cannot store the document type of your document.") . " " . _("Please choose another directory")));
  187 + $oPatternCustom->setHtml(getPage($fFolderID, $fRememberDocumentID, _("You can't move the document to this folder because it cannot store the document type of your document.") . " " . _("Please choose another directory")));
179 188 break;
180 189 }
181 190 }
182   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID");
  191 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fRememberDocumentID=$fRememberDocumentID&fFolderID=$fFolderID");
183 192 $main->setCentralPayload($oPatternCustom);
184 193 $main->render();
185 194 }
186 195 } else { // (isset($fForMove))
187 196 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
188 197 $oPatternCustom = & new PatternCustom();
189   - $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentIDs));
  198 + $oPatternCustom->setHtml(getPage($fFolderID, $fRememberDocumentID));
190 199 $main->setCentralPayload($oPatternCustom);
191   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fDocumentID=$fDocumentID&fFolderID=$fFolderID");
  200 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForMove=1&fRememberDocumentID=$fRememberDocumentID&fFolderID=$fFolderID");
192 201 $main->render();
193 202 }
194 203 } else { // (isset($fDocumentIDs) && isset($fFolderID))
... ...
presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentUI.inc
... ... @@ -25,8 +25,10 @@
25 25 * @package documentmanagement
26 26 */
27 27  
28   -function getConfirmationPage($iFolderID, $iDocumentIDs) {
  28 +function getConfirmationPage($iFolderID, $sRememberDocumentID) {
29 29 global $default;
  30 + $iDocumentIDs = $_SESSION['documents'][$sRememberDocumentID];
  31 +
30 32 $sToRender = renderHeading(_("Move Document"));
31 33 $sToRender .= "<table>\n";
32 34 $sToRender .= "<tr>\n<td>" . _("Are you sure you want to move") . ": </td></tr>";
... ... @@ -37,8 +39,8 @@ function getConfirmationPage($iFolderID, $iDocumentIDs) {
37 39  
38 40 $sToRender .= "<tr><td><strong>" . $oDocument->getDisplayPath() . "</strong> <td>&nbsp;" . _("to") . "&nbsp;</td> </td>\n";
39 41 $sToRender .= "<td><strong>" . Folder::getFolderDisplayPath($iFolderID) . " > " . $oDocument->getFileName() . "</strong></td>\n";
40   - $sQueryString .= "fDocumentIDs[]=$iDocumentIDs[$i]&";
41 42 }
  43 + $sQueryString .= "fRememberDocumentID=$sRememberDocumentID&";
42 44  
43 45 $sToRender .= "</tr>\n";
44 46 $sToRender .= "<tr><td><a href=\"$default->rootUrl/control.php?action=moveDocument&" . $sQueryString .
... ... @@ -53,8 +55,10 @@ function getConfirmationPage($iFolderID, $iDocumentIDs) {
53 55 }
54 56  
55 57  
56   -function getPage($iFolderID, $iDocumentIDs, $sErrorMessage = "") {
  58 +function getPage($iFolderID, $sRememberDocumentID, $sErrorMessage = "") {
57 59 global $default;
  60 + $iDocumentIDs = $_SESSION['documents'][$sRememberDocumentID];
  61 +
58 62 $sToRender = renderHeading(_("Move Document"));
59 63 $sToRender .= "<table>\n";
60 64 if ($sErrorMessage) {
... ... @@ -65,8 +69,8 @@ function getPage($iFolderID, $iDocumentIDs, $sErrorMessage = &quot;&quot;) {
65 69 for ($i = 0; $i < count($iDocumentIDs); $i++) {
66 70 $sToRender .= "<tr>\n";
67 71 $sToRender .= "<td>&nbsp;&nbsp;'" . Document::getDocumentDisplayPath($iDocumentIDs[$i]) . "'</td>\n";
68   - $sQueryString .= "fDocumentIDs[]=$iDocumentIDs[$i]&";
69 72 }
  73 + $sQueryString .= "fRememberDocumentID=$sRememberDocumentID&";
70 74  
71 75 $sToRender .= "<tr><td>" . _("To Folder") . ":</td></tr>";
72 76 $sToRender .= "<tr>\n";
... ...