Commit 4018929d173e2b6d3f9aafcdfffcb6c981eedb3d

Authored by michael
1 parent 81b55fa1

updated phpdoc

changed to use div switching
added folder exists error handling


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2186 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/foldermanagement/editBL.php
1 <?php 1 <?php
2 /** 2 /**
3 -* Business logic used to edit folder properties  
4 -*  
5 -* Expected form variables:  
6 -* o $fFolderID - primary key of folder user is currently browsing  
7 -*  
8 -* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa  
9 -* @date 2 February 2003  
10 -* @package presentation.lookAndFeel.knowledgeTree.foldermanagement  
11 -*  
12 -*/ 3 + * $Id$
  4 + *
  5 + * Business logic used to edit folder properties
  6 + *
  7 + * Expected form variables:
  8 + * o $fFolderID - primary key of folder user is currently browsing
  9 + *
  10 + * Licensed under the GNU GPL. For full terms see the file DOCS/COPYING.
  11 + *
  12 + * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
  13 + * @date 2 February 2003
  14 + * @package presentation.lookAndFeel.knowledgeTree.foldermanagement
  15 + */
13 16
14 require_once("../../../../config/dmsDefaults.php"); 17 require_once("../../../../config/dmsDefaults.php");
15 18
@@ -25,101 +28,121 @@ if (checkSession()) { @@ -25,101 +28,121 @@ if (checkSession()) {
25 require_once("$default->fileSystemRoot/presentation/Html.inc"); 28 require_once("$default->fileSystemRoot/presentation/Html.inc");
26 29
27 if (isset($fFolderID)) { 30 if (isset($fFolderID)) {
28 - //if the user can edit the folder  
29 - if (Permission::userHasFolderWritePermission($fFolderID)) {  
30 - if (isset($fForUpdate)) {  
31 - //user is updating folder data  
32 - $oFolder = Folder::get($fFolderID);  
33 - $oFolder->setDescription($fDescription);  
34 - if (isset($fIsPublic)) {  
35 - $oFolder->setIsPublic(true);  
36 - } else {  
37 - $oFolder->setIsPublic(false);  
38 - }  
39 - $bSuccessfulUpdate = false;  
40 - if (isset($fFolderName) && strcmp($oFolder->getName(), $fFolderName) != 0) {  
41 - //folder name has changed, update the full_path  
42 - $sOldName = $oFolder->getName();  
43 - $sOldPath = $default->documentRoot . "/" . $oFolder->getFullPath() . "/" . $oFolder->getName();  
44 - $oFolder->setName($fFolderName);  
45 - if ($oFolder->update(true)) {  
46 - $bSuccessfulUpdate = true;  
47 - if (!PhysicalFolderManagement::renameFolder($sOldPath, $default->documentRoot . "/" . $oFolder->getFullPath() . "/" . $oFolder->getName())) {  
48 - //reverse the database changes if the physical rename failed  
49 - $oFolder->setName($sOldName);  
50 - $oFolder->update(true);  
51 - $bSuccessfulUpdate = false;  
52 - } 31 + $oFolder = Folder::get($fFolderID);
  32 + if ($oFolder) {
  33 + //if the user can edit the folder
  34 + if (Permission::userHasFolderWritePermission($fFolderID)) {
  35 + if (isset($fForUpdate)) {
  36 + //user is updating folder data
  37 + $oFolder = Folder::get($fFolderID);
  38 + $oFolder->setDescription($fDescription);
  39 + if (isset($fIsPublic)) {
  40 + $oFolder->setIsPublic(true);
  41 + } else {
  42 + $oFolder->setIsPublic(false);
53 } 43 }
54 - } else {  
55 - $bSuccessfulUpdate = $oFolder->update();  
56 - }  
57 - if ($bSuccessfulUpdate) {  
58 - $oPatternCustom = & new PatternCustom();  
59 - $oPatternCustom->setHtml(getPage($fFolderID));  
60 - $main->setCentralPayload($oPatternCustom);  
61 - $main->setHasRequiredFields(true);  
62 - $main->setErrorMessage("Folder successfully updated");  
63 - $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));  
64 - $main->render();  
65 - } else {  
66 - $oPatternCustom = & new PatternCustom();  
67 - $oPatternCustom->setHtml(getPage($fFolderID));  
68 - $main->setErrorMessage("An error occured while updating this folder");  
69 - $main->setCentralPayload($oPatternCustom);  
70 - $main->setHasRequiredFields(true);  
71 - $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));  
72 - $main->render();  
73 - }  
74 - } else if (isset($fCollaborationEdit)) {  
75 - //user attempted to edit the folder collaboration process but could not because there is  
76 - //a document currently in this process  
77 - $oPatternCustom = & new PatternCustom();  
78 - $oPatternCustom->setHtml(getPage($fFolderID, true));  
79 - $main->setErrorMessage("You cannot edit this folder collaboration process as a document is currently undergoing this collaboration process");  
80 - $main->setCentralPayload($oPatternCustom);  
81 - $main->setHasRequiredFields(true);  
82 - $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));  
83 - $main->render();  
84 - } else if (isset($fCollaborationDelete)) {  
85 - //user attempted to delete the folder collaboration process but could not because there is  
86 - //a document currently in this process  
87 - $oPatternCustom = & new PatternCustom();  
88 - $oPatternCustom->setHtml(getPage($fFolderID, true));  
89 - $main->setErrorMessage("You cannot delete this folder collaboration process as a document is currently undergoing this collaboration process");  
90 - $main->setCentralPayload($oPatternCustom);  
91 - $main->setHasRequiredFields(true);  
92 - $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));  
93 - $main->render();  
94 - } else {  
95 - $oPatternCustom = & new PatternCustom();  
96 - // does this folder have a document in it that has started collaboration?  
97 - $bCollaboration = Folder::hasDocumentInCollaboration($fFolderID);  
98 -  
99 - $oPatternCustom->setHtml(getPage($fFolderID, $bCollaboration));  
100 - $main->setCentralPayload($oPatternCustom);  
101 - $main->setHasRequiredFields(true);  
102 - $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));  
103 - $main->render();  
104 - }  
105 - } else {  
106 - //user does not have write permission for this folder,  
107 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
108 - $oPatternCustom = & new PatternCustom();  
109 - $oPatternCustom->setHtml("");  
110 - $main->setCentralPayload($oPatternCustom);  
111 - $main->setErrorMessage("You do not have permission to edit this folder");  
112 - $main->render();  
113 - } 44 + $bSuccessfulUpdate = false;
  45 + if (isset($fFolderName) && strcmp($oFolder->getName(), $fFolderName) != 0) {
  46 + //folder name has changed, update the full_path
  47 + $sOldName = $oFolder->getName();
  48 + $sOldPath = $default->documentRoot . "/" . $oFolder->getFullPath() . "/" . $oFolder->getName();
  49 + $oFolder->setName($fFolderName);
  50 + if ($oFolder->update(true)) {
  51 + $bSuccessfulUpdate = true;
  52 + if (!PhysicalFolderManagement::renameFolder($sOldPath, $default->documentRoot . "/" . $oFolder->getFullPath() . "/" . $oFolder->getName())) {
  53 + //reverse the database changes if the physical rename failed
  54 + $oFolder->setName($sOldName);
  55 + $oFolder->update(true);
  56 + $bSuccessfulUpdate = false;
  57 + }
  58 + }
  59 + } else {
  60 + $bSuccessfulUpdate = $oFolder->update();
  61 + }
  62 + if ($bSuccessfulUpdate) {
  63 + $oPatternCustom = & new PatternCustom();
  64 + $oPatternCustom->setHtml(getPage($fFolderID, "Folder successfully updated"));
  65 + $main->setDHTMLScrolling(false);
  66 + $main->setOnLoadJavaScript("switchDiv('folderData', 'folder')");
  67 +
  68 + $main->setCentralPayload($oPatternCustom);
  69 + $main->setHasRequiredFields(true);
  70 + $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
  71 + $main->render();
  72 + } else {
  73 + $oPatternCustom = & new PatternCustom();
  74 + $main->setDHTMLScrolling(false);
  75 + $main->setOnLoadJavaScript("switchDiv('folderData', 'folder')");
  76 +
  77 + $oPatternCustom->setHtml(getPage($fFolderID, "An error occured while updating this folder"));
  78 + $main->setCentralPayload($oPatternCustom);
  79 + $main->setHasRequiredFields(true);
  80 + $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
  81 + $main->render();
  82 + }
  83 + } else if (isset($fCollaborationEdit)) {
  84 + //user attempted to edit the folder collaboration process but could not because there is
  85 + //a document currently in this process
  86 + $oPatternCustom = & new PatternCustom();
  87 + $main->setDHTMLScrolling(false);
  88 + $main->setOnLoadJavaScript("switchDiv('folderData', 'folder')");
  89 +
  90 + $oPatternCustom->setHtml(getPage($fFolderID, "You cannot edit this folder collaboration process as a document is currently undergoing this collaboration process", true));
  91 + $main->setCentralPayload($oPatternCustom);
  92 + $main->setHasRequiredFields(true);
  93 + $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
  94 + $main->render();
  95 + } else if (isset($fCollaborationDelete)) {
  96 + //user attempted to delete the folder collaboration process but could not because there is
  97 + //a document currently in this process
  98 + $oPatternCustom = & new PatternCustom();
  99 + $main->setDHTMLScrolling(false);
  100 + $main->setOnLoadJavaScript("switchDiv('folderData', 'folder')");
  101 +
  102 + $oPatternCustom->setHtml(getPage($fFolderID, "You cannot delete this folder collaboration process as a document is currently undergoing this collaboration process", true));
  103 + $main->setCentralPayload($oPatternCustom);
  104 + $main->setHasRequiredFields(true);
  105 + $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
  106 + $main->render();
  107 + } else {
  108 + $oPatternCustom = & new PatternCustom();
  109 + // does this folder have a document in it that has started collaboration?
  110 + $bCollaboration = Folder::hasDocumentInCollaboration($fFolderID);
  111 + $main->setDHTMLScrolling(false);
  112 + $main->setOnLoadJavaScript("switchDiv('folderData', 'folder')");
  113 +
  114 + $oPatternCustom->setHtml(getPage($fFolderID, $bCollaboration));
  115 + $main->setCentralPayload($oPatternCustom);
  116 + $main->setHasRequiredFields(true);
  117 + $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
  118 + $main->render();
  119 + }
  120 + } else {
  121 + //user does not have write permission for this folder,
  122 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  123 + $oPatternCustom = & new PatternCustom();
  124 + $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n");
  125 + $main->setCentralPayload($oPatternCustom);
  126 + $main->setErrorMessage("You do not have permission to edit this folder");
  127 + $main->render();
  128 + }
  129 + } else {
  130 + // folder doesn't exist
  131 + $oPatternCustom = & new PatternCustom();
  132 + $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n");
  133 + $main->setCentralPayload($oPatternCustom);
  134 + $main->setErrorMessage("The folder you're trying to modify does not exist in the DMS");
  135 + $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
  136 + $main->render();
  137 + }
114 } else { 138 } else {
115 //else display an error message 139 //else display an error message
116 $oPatternCustom = & new PatternCustom(); 140 $oPatternCustom = & new PatternCustom();
117 - $oPatternCustom->setHtml(""); 141 + $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n");
118 $main->setCentralPayload($oPatternCustom); 142 $main->setCentralPayload($oPatternCustom);
119 $main->setErrorMessage("No folder currently selected"); 143 $main->setErrorMessage("No folder currently selected");
120 $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID")); 144 $main->setFormAction("../store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
121 $main->render(); 145 $main->render();
122 } 146 }
123 } 147 }
124 -  
125 -?> 148 +?>
126 \ No newline at end of file 149 \ No newline at end of file
presentation/lookAndFeel/knowledgeTree/foldermanagement/editUI.inc
@@ -19,7 +19,7 @@ function getFolderPath($iFolderID) { @@ -19,7 +19,7 @@ function getFolderPath($iFolderID) {
19 return "<table border=\"0\" width=\"610\"><tr><td bgcolor=\"$sTDBGColour\">" . displayFolderPathLink(Folder::getFolderPathAsArray($iFolderID), Folder::getFolderPathNamesAsArray($iFolderID), "$default->rootUrl/control.php?action=browse") . "</td></tr></table>\n"; 19 return "<table border=\"0\" width=\"610\"><tr><td bgcolor=\"$sTDBGColour\">" . displayFolderPathLink(Folder::getFolderPathAsArray($iFolderID), Folder::getFolderPathNamesAsArray($iFolderID), "$default->rootUrl/control.php?action=browse") . "</td></tr></table>\n";
20 } 20 }
21 21
22 -function getFolderData($iFolderID, $sDivName) { 22 +function getFolderData($iFolderID, $sDivName, $sStatusMessage = "") {
23 global $default; 23 global $default;
24 $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); 24 $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
25 $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); 25 $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");
@@ -29,7 +29,10 @@ function getFolderData($iFolderID, $sDivName) { @@ -29,7 +29,10 @@ function getFolderData($iFolderID, $sDivName) {
29 29
30 $sql = $default->db; 30 $sql = $default->db;
31 $sql->query($sQuery); 31 $sql->query($sQuery);
32 - $sToRender = "<table>\n"; 32 + if ($sStatusMessage) {
  33 + $sToRender .= "<font color=\"red\">$sStatusMessage</font>";
  34 + }
  35 + $sToRender .= "<table>\n";
33 $sToRender .= "<caption><strong>Folder Data</strong></caption>"; 36 $sToRender .= "<caption><strong>Folder Data</strong></caption>";
34 if ($sql->next_record()) { 37 if ($sql->next_record()) {
35 $sToRender .= "<tr>\n"; 38 $sToRender .= "<tr>\n";
@@ -158,7 +161,7 @@ function renderFolderSection($sHeading) { @@ -158,7 +161,7 @@ function renderFolderSection($sHeading) {
158 return "<tr bgcolor=\"" . getColour($iColour) . "\"><td width=\"100%\">$sHeading</td></tr>\n"; 161 return "<tr bgcolor=\"" . getColour($iColour) . "\"><td width=\"100%\">$sHeading</td></tr>\n";
159 } 162 }
160 163
161 -function getPage($iFolderID, $bCollaboration = false) { 164 +function getPage($iFolderID, $sStatusMessage = "", $bCollaboration = false) {
162 global $default; 165 global $default;
163 166
164 if ( $default->browser == "ie" ) { 167 if ( $default->browser == "ie" ) {
@@ -177,7 +180,7 @@ function getPage($iFolderID, $bCollaboration = false) { @@ -177,7 +180,7 @@ function getPage($iFolderID, $bCollaboration = false) {
177 $sToRender .= "</table>"; 180 $sToRender .= "</table>";
178 $sToRender .= "</div>"; 181 $sToRender .= "</div>";
179 182
180 - $sToRender .= getFolderData($iFolderID, "folderData"); 183 + $sToRender .= getFolderData($iFolderID, "folderData", $sStatusMessage);
181 $sToRender .= getFolderRouting($iFolderID, "folderRouting", $bCollaboration); 184 $sToRender .= getFolderRouting($iFolderID, "folderRouting", $bCollaboration);
182 $sToRender .= getFolderDocTypes($iFolderID, "documentTypes"); 185 $sToRender .= getFolderDocTypes($iFolderID, "documentTypes");
183 $sToRender .= getFolderGroupAccess($iFolderID, "folderPermissions"); 186 $sToRender .= getFolderGroupAccess($iFolderID, "folderPermissions");