units_table, "name", "id", "fUnitID");
$oPatternListBox->setPostBackOnChange(true);
if ($iUnitID != 0) {
$oPatternListBox->setSelectedValue($iUnitID);
}
return "
| " . _("Filter By Unit") . " | " . $oPatternListBox->render() . " |
";
}
}
function getNameDisplay($sName) {
return "";
}
function getGroups($aUnitIDs, $sName) {
global $default;
/*ok*/ $sQuery = "SELECT GL.id AS groupID, UL.name AS UnitNameB4, GL.name AS name, 'Edit' , 'Delete', 'Edit Unit', 'Edit Users', " .
"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 . ") ";
}
// filter by name
if ($sName) {
$sWhereClause = "WHERE GL.name like '%$sName%' ";
}
// #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", "Edit Users");
$aColumnNames = array(_("Name"), _("Unit Name"), _("Edit"), _("Delete"), _("Edit Unit"), _("Edit Users"));
$aColumnTypes = array(1,1,3,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",
5=> "$default->rootUrl/control.php?action=editGroupUsers");
$oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);
$oSearchResults->setDisplayColumnHeadings(true);
return $oSearchResults->render() ;
}
function getPage($aUnitIDs, $sName) {
global $default;
$sToRender .= renderHeading(_("Group Management"));
$sToRender .= getAddLink("addGroup", _("Add A Group"));
$sToRender .= getUnitDisplay($aUnitIDs[0]);
$sToRender .= getNameDisplay($sName);
$sToRender .= getGroups($aUnitIDs, $sName);
return $sToRender;
}
?>