Commit 5ff69c492f2096eda4176ccd7f37bfd4e7de420a
1 parent
e04c496c
Added the ability to specify the unit when creating a group.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2921 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
55 additions
and
27 deletions
presentation/lookAndFeel/knowledgeTree/administration/groupmanagement/addGroupBL.php
| @@ -28,6 +28,7 @@ | @@ -28,6 +28,7 @@ | ||
| 28 | require_once("../../../../../config/dmsDefaults.php"); | 28 | require_once("../../../../../config/dmsDefaults.php"); |
| 29 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); | 29 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); |
| 30 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc"); | 30 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc"); |
| 31 | +require_once("$default->fileSystemRoot/lib/groups/Group.inc"); | ||
| 31 | require_once("$default->fileSystemRoot/lib/groups/GroupUnitLink.inc"); | 32 | require_once("$default->fileSystemRoot/lib/groups/GroupUnitLink.inc"); |
| 32 | require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | 33 | require_once("$default->fileSystemRoot/lib/security/Permission.inc"); |
| 33 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | 34 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); |
| @@ -41,9 +42,28 @@ if (checkSession()) { | @@ -41,9 +42,28 @@ if (checkSession()) { | ||
| 41 | 42 | ||
| 42 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 43 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 43 | $oPatternCustom = & new PatternCustom(); | 44 | $oPatternCustom = & new PatternCustom(); |
| 44 | - $oPatternCustom->setHtml(getPage()); | 45 | + if (isset($fGroupName) && isset($fUnitID)) { |
| 46 | + // add new group | ||
| 47 | + $oGroup = new Group($fGroupName); | ||
| 48 | + if($oGroup->create()) { | ||
| 49 | + // now set the group's unit | ||
| 50 | + $default->log->info("set group (id=" . $oGroup->getID() . ") to unit id=$fUnitID"); | ||
| 51 | + $oGroupUnit = new GroupUnitLink($oGroup->getID(), $fUnitID); | ||
| 52 | + if ($oGroupUnit->create()) { | ||
| 53 | + // redirect to list page | ||
| 54 | + controllerRedirect("listGroups"); | ||
| 55 | + } else { | ||
| 56 | + $oPatternCustom->setHtml(statusPage("Add A New Group", "Addition Unsuccessful!", "There was an error associating the new group with the specified unit.", "addGroup")); | ||
| 57 | + } | ||
| 58 | + } else { | ||
| 59 | + $oPatternCustom->setHtml(statusPage("Add A New Group", "Addition Unsuccessful!", "There was an error creating the new group (Check that a group with this name doesn't already exist).", "addGroup")); | ||
| 60 | + } | ||
| 61 | + } else { | ||
| 62 | + // display form | ||
| 63 | + $oPatternCustom->setHtml(getPage()); | ||
| 64 | + } | ||
| 45 | $main->setCentralPayload($oPatternCustom); | 65 | $main->setCentralPayload($oPatternCustom); |
| 46 | - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/create.php?fRedirectURL=".urlencode("$default->rootUrl/control.php?action=editGroup&fFromCreate=1&fGroupID=")); | 66 | + $main->setFormAction($_SERVER["PHP_SELF"]); |
| 47 | $main->setHasRequiredFields(true); | 67 | $main->setHasRequiredFields(true); |
| 48 | $main->render(); | 68 | $main->render(); |
| 49 | } | 69 | } |
presentation/lookAndFeel/knowledgeTree/administration/groupmanagement/addGroupUI.inc
| @@ -25,38 +25,46 @@ | @@ -25,38 +25,46 @@ | ||
| 25 | * @package administration.groupmanagement | 25 | * @package administration.groupmanagement |
| 26 | */ | 26 | */ |
| 27 | 27 | ||
| 28 | -// get add pages | 28 | +/** |
| 29 | + * Builds the group addition form | ||
| 30 | + */ | ||
| 29 | function getPage() { | 31 | function getPage() { |
| 30 | - | ||
| 31 | global $default; | 32 | global $default; |
| 32 | - $aDisplayRowNames = array("Group Name:"); | ||
| 33 | - $aParameterNumbers = array(0); | ||
| 34 | - $aDisplayColumnTypes = array(1); | ||
| 35 | - $aRequired = array(1); | ||
| 36 | - | ||
| 37 | - // create a text field that is required | ||
| 38 | - $oPatternCreate = & new PatternCreate("Group", "groups/Group.inc", $aDisplayRowNames, $aParameterNumbers, $aDisplayColumnTypes, $aRequired); | ||
| 39 | - $oPatternCreate->setUniqueName("group"); | ||
| 40 | - | ||
| 41 | - $sToRender .= renderHeading("Add Group"); | ||
| 42 | - | 33 | + $sToRender .= renderHeading("Add A New Group"); |
| 43 | $sToRender .= "<table>\n"; | 34 | $sToRender .= "<table>\n"; |
| 44 | - $sToRender .= "<tr><td>Add a New Group to the System</td></tr>\n"; | ||
| 45 | - $sToRender .= "<tr></tr>\n"; | ||
| 46 | - $sToRender .= "<tr>\n"; | ||
| 47 | - $sToRender .= "<td>" . $oPatternCreate->render() . "</td>\n"; | ||
| 48 | - $sToRender .= "</tr>\n"; | ||
| 49 | - $sToRender .= "<tr>\n"; | ||
| 50 | - $sToRender .= "</tr>\n"; | ||
| 51 | $sToRender .= "<tr>\n"; | 35 | $sToRender .= "<tr>\n"; |
| 36 | + $sToRender .= "<td>Group Name:</td>\n"; | ||
| 37 | + $sToRender .= "<td><input size = \"40\" type=\"text\" name=\"fGroupName\" \"> </td>\n"; | ||
| 52 | $sToRender .= "</tr>\n"; | 38 | $sToRender .= "</tr>\n"; |
| 39 | + $sToRender .= "<tr/>\n"; | ||
| 40 | + $sToRender .= "<tr><td><b>Unit</b></td><td>" . getUnitListBox() . "</td></tr>\n"; | ||
| 53 | $sToRender .= "<td align=\"right\"><input type=\"image\" src=\"$default->graphicsUrl/widgets/add.gif\" value=\"Submit\" border=\"0\"/>"; | 41 | $sToRender .= "<td align=\"right\"><input type=\"image\" src=\"$default->graphicsUrl/widgets/add.gif\" value=\"Submit\" border=\"0\"/>"; |
| 54 | $sToRender .= getCancelButton("listGroups") . "</td>\n"; | 42 | $sToRender .= getCancelButton("listGroups") . "</td>\n"; |
| 55 | - $sToRender .= "</table>\n"; | ||
| 56 | - | 43 | + $sToRender .= "</table>\n"; |
| 57 | return $sToRender; | 44 | return $sToRender; |
| 58 | - | ||
| 59 | - | ||
| 60 | - | 45 | +} |
| 46 | + | ||
| 47 | +/** | ||
| 48 | + * Builds the unit selection list box | ||
| 49 | + */ | ||
| 50 | +function getUnitListBox() { | ||
| 51 | + global $default; | ||
| 52 | + if (Permission::userIsSystemAdministrator()) { | ||
| 53 | + // if this is the system administrator, show all the units | ||
| 54 | + $oPatternListBox = & new PatternListBox($default->units_table, "name", "id", "fUnitID"); | ||
| 55 | + } else if (Permission::userIsUnitAdministrator()) { | ||
| 56 | + // else if this is a unit administrator, only display the units you're an administrator for | ||
| 57 | + $oPatternListBox = & new PatternListBox($default->units_table, "name", "id", "fUnitID"); | ||
| 58 | + $oPatternListBox->setWhereClause("ST.id in (" . implode(",", User::getUnitIDs($_SESSION["userID"])) . ")"); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + // javascript validation | ||
| 62 | + $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | ||
| 63 | + $sToRender .= "function validateForm(theForm) {\n"; | ||
| 64 | + $sToRender .= "\tif (!(validRequired(theForm.fUnitID, 'Initial Unit'))) {\n"; | ||
| 65 | + $sToRender .= "\t\treturn false;\n\t}\n"; | ||
| 66 | + $sToRender .= "return true;\n}\n"; | ||
| 67 | + $sToRender .= "//-->\n</script>\n\n"; | ||
| 68 | + return $oPatternListBox->render() . $sToRender; | ||
| 61 | } | 69 | } |
| 62 | ?> | 70 | ?> |
| 63 | \ No newline at end of file | 71 | \ No newline at end of file |