Commit ab5f71ebaf21749217ef6ebca1d39c8909af4b83

Authored by michaeljoseph
1 parent 77270a40

Added support for multiple units in group adminstration.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2906 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/groupmanagement/listGroupsBL.php
@@ -37,10 +37,10 @@ require_once("listGroupsUI.inc"); @@ -37,10 +37,10 @@ require_once("listGroupsUI.inc");
37 37
38 if (checkSession()) { 38 if (checkSession()) {
39 $oPatternCustom = & new PatternCustom(); 39 $oPatternCustom = & new PatternCustom();
40 - // #3519 unit administrators only see their unit. 40 + // #3519 unit administrators only see their units.
41 if (Permission::userIsUnitAdministrator()) { 41 if (Permission::userIsUnitAdministrator()) {
42 - $iUnitID = User::getUnitID($_SESSION["userID"]);  
43 - $oPatternCustom->setHtml(getPage($iUnitID)); 42 + $aUnitIDs = User::getUnitIDs($_SESSION["userID"]);
  43 + $oPatternCustom->setHtml(getPage($aUnitIDs));
44 } else { 44 } else {
45 $oPatternCustom->setHtml(getPage($fUnitID)); 45 $oPatternCustom->setHtml(getPage($fUnitID));
46 } 46 }
presentation/lookAndFeel/knowledgeTree/administration/groupmanagement/listGroupsUI.inc
@@ -26,13 +26,14 @@ @@ -26,13 +26,14 @@
26 */ 26 */
27 27
28 // display the listbox initially ..then just display the text 28 // display the listbox initially ..then just display the text
29 -function getUnitDisplay($iUnitID) { 29 +function getUnitDisplay($aUnitIDs) {
30 global $default; 30 global $default;
31 31
32 // #3519 only allow unit filters for system administrators 32 // #3519 only allow unit filters for system administrators
33 - // unit administrators only see their unit. 33 + // unit administrators only see their units.
34 if (Permission::userIsSystemAdministrator()) { 34 if (Permission::userIsSystemAdministrator()) {
35 - $oPatternListBox = & new PatternListBox($default->units_table, "name", "id", "fUnitID"); 35 + $oPatternListBox = & new PatternListBox($default->units_table, "name", "id", "fUnitID");
  36 + $oPatternListBox->setWhereClause("ST.unit_id IN (" . implode(",", $aUnitIDs) . ")");
36 $oPatternListBox->setPostBackOnChange(true); 37 $oPatternListBox->setPostBackOnChange(true);
37 if ($iUnitID != 0) { 38 if ($iUnitID != 0) {
38 $oPatternListBox->setSelectedValue($iUnitID); 39 $oPatternListBox->setSelectedValue($iUnitID);
@@ -41,7 +42,7 @@ function getUnitDisplay($iUnitID) { @@ -41,7 +42,7 @@ function getUnitDisplay($iUnitID) {
41 } 42 }
42 } 43 }
43 44
44 -function getGroups($fUnitID) { 45 +function getGroups($aUnitIDs) {
45 global $default; 46 global $default;
46 $sQuery = "SELECT GL.id AS groupID, UL.name AS UnitNameB4, GL.name AS name, 'Edit' , 'Delete', 'Edit Unit', " . 47 $sQuery = "SELECT GL.id AS groupID, UL.name AS UnitNameB4, GL.name AS name, 'Edit' , 'Delete', 'Edit Unit', " .
47 "CASE WHEN UL.name IS NULL THEN '<font color=darkgrey>No Unit Assigned</font>' ELSE UL.name END AS UnitName " . 48 "CASE WHEN UL.name IS NULL THEN '<font color=darkgrey>No Unit Assigned</font>' ELSE UL.name END AS UnitName " .
@@ -50,8 +51,8 @@ function getGroups($fUnitID) { @@ -50,8 +51,8 @@ function getGroups($fUnitID) {
50 51
51 // #2978 don't display system admin groups if you're not a sys admin 52 // #2978 don't display system admin groups if you're not a sys admin
52 // filter by unit 53 // filter by unit
53 - if ($fUnitID) {  
54 - $sWhereClause = "WHERE GUL.unit_id =$fUnitID "; 54 + if ($aUnitIDs) {
  55 + $sWhereClause = "WHERE GUL.unit_id IN (" . implode(",", $aUnitIDs) . ") ";
55 } 56 }
56 // #2978 don't display sys admin groups if you're not a sysadmin 57 // #2978 don't display sys admin groups if you're not a sysadmin
57 if (!Permission::userIsSystemAdministrator()) { 58 if (!Permission::userIsSystemAdministrator()) {
@@ -81,13 +82,13 @@ function getGroups($fUnitID) { @@ -81,13 +82,13 @@ function getGroups($fUnitID) {
81 return $oSearchResults->render() ; 82 return $oSearchResults->render() ;
82 } 83 }
83 84
84 -function getPage($fUnitID) { 85 +function getPage($aUnitIDs) {
85 global $default; 86 global $default;
86 $sToRender .= renderHeading("Group Management"); 87 $sToRender .= renderHeading("Group Management");
87 88
88 $sToRender .= getAddLink("addGroup", "Add A Group"); 89 $sToRender .= getAddLink("addGroup", "Add A Group");
89 - $sToRender .= getUnitDisplay($fUnitID);  
90 - $sToRender .= getGroups($fUnitID); 90 + $sToRender .= getUnitDisplay($aUnitIDs);
  91 + $sToRender .= getGroups($aUnitIDs);
91 return $sToRender; 92 return $sToRender;
92 } 93 }
93 ?> 94 ?>
94 \ No newline at end of file 95 \ No newline at end of file