public function getUsersCount($baseGroup = "/", $regexp = "", $filterProperty = null, $filterValue = null, $recursive = true) { // WITH PARENT // SELECT COUNT(*) FROM ajxp_users AS u, ajxp_user_rights AS r WHERE u.groupPath LIKE '/%' AND r.login=u.login AND r.repo_uuid = 'ajxp.parent_user' // WITH SPECIFIC PARENT 'username' // SELECT COUNT(*) FROM ajxp_users AS u, ajxp_user_rights AS r WHERE u.groupPath LIKE '/%' AND r.login=u.login AND r.repo_uuid = 'ajxp.parent_user' AND r.rights = 'username' // WITHOUT PARENT // SELECT COUNT(*) FROM ajxp_users AS u WHERE NOT EXISTS (SELECT * FROM ajxp_user_rights AS c WHERE c.login=u.login AND c.repo_uuid='ajxp.parent_user') $ands = array(); $select = "SELECT COUNT(*) FROM [ajxp_users] AS u WHERE %and"; if (!empty($regexp)) { $ands[] = array("[u.login] " . AJXP_Utils::regexpToLike($regexp), AJXP_Utils::cleanRegexp($regexp)); } if ($recursive) { $ands[] = array("[u.groupPath] LIKE %like~", $baseGroup); } else { $ands[] = array("[u.groupPath] = %s", $baseGroup); } $ands[] = array("NOT EXISTS (SELECT * FROM [ajxp_user_rights] AS c WHERE [c.login]=[u.login] AND [c.repo_uuid] = 'ajxp.hidden')"); if ($filterProperty !== null && $filterValue !== null) { if ($filterProperty == "parent") { $filterProperty = "ajxp.parent_user"; } else { if ($filterProperty == "admin") { $filterProperty = "ajxp.admin"; } } if ($filterValue == AJXP_FILTER_EMPTY) { $ands[] = array("NOT EXISTS (SELECT * FROM [ajxp_user_rights] AS c WHERE [c.login]=[u.login] AND [c.repo_uuid] = %s)", $filterProperty); } else { if ($filterValue == AJXP_FILTER_NOT_EMPTY) { $select = "SELECT COUNT(*) FROM [ajxp_users] AS u, [ajxp_user_rights] AS r WHERE %and"; $ands[] = array("[r.login]=[u.login]"); $ands[] = array("[r.repo_uuid] = %s", $filterProperty); } else { $select = "SELECT COUNT(*) FROM [ajxp_users] AS u, [ajxp_user_rights] AS r WHERE %and"; $ands[] = array("[r.login]=[u.login]"); $ands[] = array("[r.repo_uuid] = %s", $filterProperty); $ands[] = array("[r.rights] " . AJXP_Utils::likeToLike($filterValue), AJXP_Utils::cleanLike($filterValue)); } } } $res = dibi::query($select, $ands); return $res->fetchSingle(); }