Commit 73bcad72e5029ba2a28c9020070b994238ea24cb
1 parent
6eb22dd1
(#2808) added checks for users mapped to groups
and units mapped to groups incorporated statusPage method (need to refactor this) tidied and reformatted git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2439 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
26 additions
and
77 deletions
presentation/lookAndFeel/knowledgeTree/administration/groupmanagement/removeGroupBL.php
| ... | ... | @@ -23,33 +23,33 @@ if (checkSession()) { |
| 23 | 23 | require_once("$default->fileSystemRoot/presentation/Html.inc"); |
| 24 | 24 | |
| 25 | 25 | $oPatternCustom = & new PatternCustom(); |
| 26 | - | |
| 27 | - // get main page | |
| 26 | + | |
| 28 | 27 | if (isset($fGroupID)) { |
| 29 | - | |
| 30 | - $oPatternCustom->setHtml(getDeletePage($fGroupID)); | |
| 31 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForDelete=1"); | |
| 32 | - | |
| 33 | - // get delete page | |
| 34 | - } else { | |
| 35 | - $oPatternCustom->setHtml(getDeletePage(null)); | |
| 36 | - $main->setFormAction($_SERVER["PHP_SELF"]); | |
| 37 | - } | |
| 38 | - | |
| 39 | - // if delete entry | |
| 40 | - if (isset($fForDelete)) { | |
| 41 | - $oGroup = Group::get($fGroupID); | |
| 42 | - $oGroup->setName($fGroupName); | |
| 43 | - | |
| 44 | - if ($oGroup->delete()) { | |
| 45 | - $oPatternCustom->setHtml(getDeleteSuccessPage()); | |
| 46 | - | |
| 28 | + $oGroup = Group::get($fGroupID); | |
| 29 | + if (!$oGroup->hasUsers()) { | |
| 30 | + if (!$oGroup->hasUnit()) { | |
| 31 | + if (isset($fForDelete)) { | |
| 32 | + if ($oGroup->delete()) { | |
| 33 | + // FIXME: refactor getStatusPage in Html.inc | |
| 34 | + $oPatternCustom->setHtml(statusPage("Remove Group", "Group successfully removed!", "listGroups")); | |
| 35 | + } else { | |
| 36 | + $oPatternCustom->setHtml(statusPage("Remove Group", "Group deletion failed!", "listGroups", "There was an error deleting this group. Please try again later.")); | |
| 37 | + } | |
| 38 | + } else { | |
| 39 | + $oPatternCustom->setHtml(getDeletePage($fGroupID)); | |
| 40 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForDelete=1"); | |
| 41 | + } | |
| 42 | + } else { | |
| 43 | + $oPatternCustom->setHtml(statusPage("Remove Group", "This group is in a unit!", "listGroups", "This group can not be deleted because it belongs to a unit.")); | |
| 44 | + } | |
| 47 | 45 | } else { |
| 48 | - $oPatternCustom->setHtml(getDeleteFailPage()); | |
| 46 | + $oPatternCustom->setHtml(statusPage("Remove Group", "This group has users!", "listGroups", "This group can not be deleted because there are still users in it.")); | |
| 49 | 47 | } |
| 48 | + } else { | |
| 49 | + $oPatternCustom->setHtml(statusPage("Remove Group", "No group was selected for deletion", "listGroups")); | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $main->setCentralPayload($oPatternCustom); |
| 53 | 53 | $main->render(); |
| 54 | 54 | } |
| 55 | 55 | -?> |
| 56 | +?> | |
| 56 | 57 | \ No newline at end of file | ... | ... |
presentation/lookAndFeel/knowledgeTree/administration/groupmanagement/removeGroupUI.inc
| ... | ... | @@ -39,53 +39,8 @@ function getDeletePage($iGroupID) { |
| 39 | 39 | $sToRender .= "</tr>\n"; |
| 40 | 40 | $sToRender .= getDeleteButton($oGroup); |
| 41 | 41 | $sToRender .= "</table>\n"; |
| 42 | - | |
| 43 | - | |
| 44 | - return $sToRender; | |
| 45 | -} | |
| 46 | - | |
| 47 | -// get successfully deletion page | |
| 48 | -function getDeleteSuccessPage() { | |
| 49 | - | |
| 50 | -global $default; | |
| 51 | - | |
| 52 | -$sToRender .= renderHeading("Remove Group"); | |
| 53 | -$sToRender .= "<table>\n"; | |
| 54 | -$sToRender .= "<tr>\n"; | |
| 55 | -$sToRender .= "<td><b>Group SuccessFully Removed!</b></td>\n"; | |
| 56 | -$sToRender .= "</tr>\n"; | |
| 57 | -$sToRender .= "<tr></tr>\n"; | |
| 58 | -$sToRender .= "<tr></tr>\n"; | |
| 59 | -$sToRender .= "<tr></tr>\n"; | |
| 60 | -$sToRender .= "<tr></tr>\n"; | |
| 61 | -$sToRender .= "<tr>\n"; | |
| 62 | -$sToRender .= "<td align = right><a href=\"$default->rootUrl/control.php?action=listGroups\"><img src =\"$default->graphicsUrl/widgets/back.gif\" border = \"0\" /></a></td>\n"; | |
| 63 | -$sToRender .= "</tr>\n"; | |
| 64 | -$sToRender .= "</table>\n"; | |
| 65 | - | |
| 66 | -return $sToRender; | |
| 67 | -} | |
| 68 | - | |
| 69 | -// get deletion failed page | |
| 70 | -function getDeleteFailPage() { | |
| 71 | - | |
| 72 | -global $default; | |
| 73 | 42 | |
| 74 | -$sToRender .= renderHeading("Remove Group"); | |
| 75 | -$sToRender .= "<table>\n"; | |
| 76 | -$sToRender .= "<tr>\n"; | |
| 77 | -$sToRender .= "<td><b>Deletion Failed!</b></td>\n"; | |
| 78 | -$sToRender .= "</tr>\n"; | |
| 79 | -$sToRender .= "<tr></tr>\n"; | |
| 80 | -$sToRender .= "<tr></tr>\n"; | |
| 81 | -$sToRender .= "<tr><td>Please Ensure that The Group has been Removed from any Unit it belongs to</td></tr>\n"; | |
| 82 | -$sToRender .= "<tr></tr>\n"; | |
| 83 | -$sToRender .= "<tr></tr>\n"; | |
| 84 | -$sToRender .= "</tr>\n"; | |
| 85 | -$sToRender .= "<tr><td align = right><a href=\"$default->rootUrl/control.php?action=listGroups\"><img src =\"$default->graphicsUrl/widgets/back.gif\" border = \"0\" /></a></td></tr>\n"; | |
| 86 | -$sToRender .= "</table>\n"; | |
| 87 | - | |
| 88 | -return $sToRender; | |
| 43 | + return $sToRender; | |
| 89 | 44 | } |
| 90 | 45 | |
| 91 | 46 | // show listbox...or the text name |
| ... | ... | @@ -100,26 +55,20 @@ function getGroupDisplay($oGroup) { |
| 100 | 55 | return "<input type=\"hidden\" name=\"fGroupID\" value=\"" . $oGroup->iId . "\">\n" . |
| 101 | 56 | "<b>" . $oGroup->getName() . "</b>"; |
| 102 | 57 | } |
| 103 | - | |
| 104 | 58 | } |
| 105 | 59 | |
| 106 | 60 | // show check box |
| 107 | 61 | function getUnitAdminCheckBox($oGroup) { |
| 108 | - if (!isset($oGroup)) { | |
| 109 | - return ""; | |
| 110 | - } else { | |
| 62 | + if (isset($oGroup)) { | |
| 111 | 63 | return "Unit Administrator: <input disabled=\"true\" type=\"checkbox\" name=\"fGroupUnitAdmin\" " . ($oGroup->getUnitAdmin() ? "CHECKED " : " ") . " />"; |
| 112 | 64 | } |
| 113 | 65 | } |
| 114 | 66 | |
| 115 | 67 | // show text box |
| 116 | 68 | function getSysAdminCheckBox($oGroup) { |
| 117 | - if (!isset($oGroup)) { | |
| 118 | - return ""; | |
| 119 | - } else { | |
| 69 | + if (isset($oGroup)) { | |
| 120 | 70 | return "System Administrator: <input disabled=\"true\" type=\"checkbox\" name=\"fGroupSysAdmin\" " . ($oGroup->getSysAdmin() ? "CHECKED " : " ") . " />"; |
| 121 | 71 | } |
| 122 | - | |
| 123 | 72 | } |
| 124 | 73 | |
| 125 | 74 | // show delete button |
| ... | ... | @@ -130,4 +79,4 @@ function getDeleteButton($oGroup) { |
| 130 | 79 | "<td align = right><a href=\"$default->rootUrl/control.php?action=listGroups\"><img src =\"$default->graphicsUrl/widgets/cancel.gif\" border = \"0\" /></a></td>\n"; |
| 131 | 80 | } |
| 132 | 81 | } |
| 133 | 82 | -?> |
| 83 | +?> | |
| 134 | 84 | \ No newline at end of file | ... | ... |