Commit 236b3e8b7cb6dd6d6a24f1db28d8f886de46c675

Authored by nbm
1 parent 99bb247e

Untangle nested ifs to simplify understanding of code.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3066 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/foldermanagement/editBL.php
... ... @@ -32,65 +32,79 @@ require_once("../../../../config/dmsDefaults.php");
32 32  
33 33 KTUtil::extractGPC('fCollaborationDelete', 'fCollaborationEdit', 'fFolderID', 'fShowSection');
34 34  
35   -if (checkSession()) {
36   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
37   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableListFromQuery.inc");
38   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc");
39   - require_once("editUI.inc");
40   - require_once("$default->fileSystemRoot/lib/security/Permission.inc");
41   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
42   - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
43   - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
44   - require_once("$default->fileSystemRoot/presentation/Html.inc");
45   - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  35 +if (!checkSession()) {
  36 + exit(0);
  37 +}
  38 +
  39 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
  40 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableListFromQuery.inc");
  41 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc");
  42 +require_once("editUI.inc");
  43 +require_once("$default->fileSystemRoot/lib/security/Permission.inc");
  44 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
  45 +require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
  46 +require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
  47 +require_once("$default->fileSystemRoot/presentation/Html.inc");
  48 +require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  49 +
  50 +$oPatternCustom = & new PatternCustom();
46 51  
47   - $oPatternCustom = & new PatternCustom();
48   - if (isset($fFolderID)) {
49   - $oFolder = Folder::get($fFolderID);
50   - if ($oFolder) {
51   - //if the user can edit the folder
52   - if (Permission::userHasFolderWritePermission($oFolder)) {
53   - if (isset($fCollaborationEdit)) {
54   - //user attempted to edit the folder collaboration process but could not because there is
55   - //a document currently in this process
56   - $oPatternCustom->setHtml(getStatusPage($fFolderID, _("You cannot edit this folder collaboration process as a document is currently undergoing this collaboration process")));
57   -
58   - $main->setHasRequiredFields(true);
59   - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
60   - } else if (isset($fCollaborationDelete)) {
61   - //user attempted to delete the folder collaboration process but could not because there is
62   - //a document currently in this process
63   - $oPatternCustom->setHtml(getStatusPage($fFolderID, _("You cannot delete this folder collaboration process as a document is currently undergoing this collaboration process")));
64   - $main->setHasRequiredFields(true);
65   - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
66   - } else {
67   - // does this folder have a document in it that has started collaboration?
68   - $bCollaboration = Folder::hasDocumentInCollaboration($fFolderID);
69   - $main->setDHTMLScrolling(false);
70   - $main->setOnLoadJavaScript("switchDiv('" . (isset($fShowSection) ? $fShowSection : "folderData") . "', 'folder')");
71   -
72   - $oPatternCustom->setHtml(getPage($fFolderID, "", $bCollaboration));
73   - $main->setHasRequiredFields(true);
74   - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
75   - }
76   - } else {
77   - //user does not have write permission for this folder,
78   - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n");
79   - $main->setErrorMessage(_("You do not have permission to edit this folder"));
80   - }
81   - } else {
82   - // folder doesn't exist
83   - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n");
84   - $main->setErrorMessage(_("The folder you're trying to modify does not exist in the DMS"));
85   - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
86   - }
87   - } else {
88   - //else display an error message
89   - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n");
90   - $main->setErrorMessage(_("No folder currently selected"));
91   - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
92   - }
93   - $main->setCentralPayload($oPatternCustom);
94   - $main->render();
  52 +if (!isset($fFolderID)) {
  53 + //else display an error message
  54 + $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n");
  55 + $main->setErrorMessage(_("No folder currently selected"));
  56 + $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
  57 + $main->setCentralPayload($oPatternCustom);
  58 + $main->render();
  59 + exit(0);
95 60 }
  61 +
  62 +$oFolder = Folder::get($fFolderID);
  63 +if (!$oFolder) {
  64 + // folder doesn't exist
  65 + $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n");
  66 + $main->setErrorMessage(_("The folder you're trying to modify does not exist in the DMS"));
  67 + $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
  68 + $main->setCentralPayload($oPatternCustom);
  69 + $main->render();
  70 + exit(0);
  71 +}
  72 +
  73 +//if the user can edit the folder
  74 +if (!Permission::userHasFolderWritePermission($oFolder)) {
  75 + //user does not have write permission for this folder,
  76 + $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n");
  77 + $main->setErrorMessage(_("You do not have permission to edit this folder"));
  78 + $main->setCentralPayload($oPatternCustom);
  79 + $main->render();
  80 + exit(0);
  81 +}
  82 +
  83 +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->setHtml(getStatusPage($fFolderID, _("You cannot edit this folder collaboration process as a document is currently undergoing this collaboration process")));
  87 +
  88 + $main->setHasRequiredFields(true);
  89 + $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
  90 +} else if (isset($fCollaborationDelete)) {
  91 + //user attempted to delete the folder collaboration process but could not because there is
  92 + //a document currently in this process
  93 + $oPatternCustom->setHtml(getStatusPage($fFolderID, _("You cannot delete this folder collaboration process as a document is currently undergoing this collaboration process")));
  94 + $main->setHasRequiredFields(true);
  95 + $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
  96 +} else {
  97 + // does this folder have a document in it that has started collaboration?
  98 + $bCollaboration = Folder::hasDocumentInCollaboration($fFolderID);
  99 + $main->setDHTMLScrolling(false);
  100 + $main->setOnLoadJavaScript("switchDiv('" . (isset($fShowSection) ? $fShowSection : "folderData") . "', 'folder')");
  101 +
  102 + $oPatternCustom->setHtml(getPage($fFolderID, "", $bCollaboration));
  103 + $main->setHasRequiredFields(true);
  104 + $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID"));
  105 +}
  106 +
  107 +$main->setCentralPayload($oPatternCustom);
  108 +$main->render();
  109 +
96 110 ?>
... ...