/* ------------------------------------ Build the SQL statement to populate the list ---------------------------*/
$objGroupList = new clsGroupList();
$order = $objConfig->Get("Group_SortOrder");
$objGroupList->Clear();
$sql = "SELECT ResourceId, g.name as Name, ELT(g.Personal+1,'Group ','User ') as UserGroup FROM ".GetTablePrefix()."Permissions as p ";
$sql .="LEFT JOIN ".GetTablePrefix()."PortalGroup as g ON p.GroupId=g.GroupId WHERE (p.CatId=".(int)$c->Get("CategoryId").") AND (g.Personal = 0) GROUP BY Name";
//$sql = "SELECT GroupId, count(*) as PermCount FROM ".GetTablePrefix()."Permissions WHERE CatId=".$c->Get("CategoryId")." GROUP BY GroupId";
// You have to sign the code to enable this or allow the action in about:config by changing user_pref("signed.applets.codebase_principal_support", true);
function TableCount($TableName, $where="",$JoinCats=1)
{
$db = &GetADODBConnection();
if(!$JoinCats)
{
$sql = "SELECT count(*) as TableCount FROM $TableName";
}
else
$sql = "SELECT count(*) as TableCount FROM $TableName INNER JOIN ".GetTablePrefix()."CategoryItems ON ".GetTablePrefix()."CategoryItems.ItemResourceId=$TableName.ResourceId";
if(strlen($where)>0)
$sql .= " WHERE ".$where;
$rs = $db->Execute($sql);
// echo "SQL TABLE COUNT: ".$sql."<br>\n";
$res = $rs->fields["TableCount"];
return $res;
}
Function QueryCount($sql)
{
$sql = preg_replace('/SELECT(.*)FROM[ \n\r](.*)/is','SELECT COUNT(*) AS TableCount FROM $2', $sql);