units_table, "name", "id", "fUnitID"); $oPatternListBox->setPostBackOnChange(true); if ($iUnitID != 0) { $oPatternListBox->setSelectedValue($iUnitID); } return "
Filter By Unit " . $oPatternListBox->render() . "
"; } } function getGroups($aUnitIDs) { global $default; $sQuery = "SELECT GL.id AS groupID, UL.name AS UnitNameB4, GL.name AS name, 'Edit' , 'Delete', 'Edit Unit', " . "CASE WHEN UL.name IS NULL THEN 'No Unit Assigned' ELSE UL.name END AS UnitName " . "FROM ($default->groups_table GL LEFT JOIN $default->groups_units_table GUL ON GL.id = GUL.group_id) " . "LEFT JOIN $default->units_table UL ON UL.id = GUL.unit_id "; // #2978 don't display system admin groups if you're not a sys admin // filter by unit $sUnitIDs = implode(",", $aUnitIDs); if ($sUnitIDs <> "") { $sWhereClause = "WHERE GUL.unit_id IN (" . $sUnitIDs . ") "; } // #2978 don't display sys admin groups if you're not a sysadmin if (!Permission::userIsSystemAdministrator()) { $sRestrictGroups = " GL.is_sys_admin = 0 "; if (strlen($sWhereClause) > 0) { $sWhereClause .= " AND $sRestrictGroups"; } else { $sWhereClause = "WHERE $sRestrictGroups"; } } $sQuery .= $sWhereClause . "ORDER BY GL.name"; $default->log->info("groupQuery: $sQuery"); $aColumns = array("name", "UnitName", "Edit", "Delete", "Edit Unit"); $aColumnNames = array( "Name", "Unit Name", "Edit", "Delete", "Edit Unit"); $aColumnTypes = array(1,1,3,3,3); $aDBColumnArray = array("groupID"); $aQueryStringVariableNames = array("fGroupID"); $aHyperLinkURL = array( 2=> "$default->rootUrl/control.php?action=editGroup", 3=> "$default->rootUrl/control.php?action=removeGroup", 4=> "$default->rootUrl/control.php?action=editGroupUnit"); $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames); $oSearchResults->setDisplayColumnHeadings(true); return $oSearchResults->render() ; } function getPage($aUnitIDs) { global $default; $sToRender .= renderHeading("Group Management"); $sToRender .= getAddLink("addGroup", "Add A Group"); $sToRender .= getUnitDisplay($aUnitIDs[0]); $sToRender .= getGroups($aUnitIDs); return $sToRender; } ?>