Implement ISearchableGroupBackend

Signed-off-by: Claus-Justus Heine <himself@claus-justus-heine.de>
This commit is contained in:
Claus-Justus Heine
2023-08-22 12:35:26 +02:00
parent 662b849ed9
commit 7da80d207a
5 changed files with 115 additions and 12 deletions

View File

@@ -223,6 +223,27 @@ class DataQuery
return $result->fetchFirstColumn();
}
/**
* Fetch values from all columns which the given query returns.
*
* @param string $queryName The query to execute.
* @param array $params The query parameters to bind.
* @param int $limit Results limit. Defaults to -1 (no limit).
* @param int $offset Results offset. Defaults to 0.
*
* @return array|bool Queried column or FALSE on failure.
*/
public function queryColumns(
$queryName, $params = [], $limit = -1, $offset = 0
) {
$result = $this->execQuery($queryName, $params, $limit, $offset);
if ($result === false) {
return false;
}
return $result->fetchAll();
}
/**
* Fetch entity returned by the given query.
*

View File

@@ -154,14 +154,23 @@ class QueryProvider implements \ArrayAccess
"FROM $group g " .
"WHERE g.$gGID = :$gidParam",
Query::FIND_GROUP_USERS =>
"SELECT DISTINCT ug.$ugUID AS uid " .
"FROM $userGroup ug " .
"LEFT JOIN $user u ON u.$uUID = ug.$ugUID " .
Query::FIND_GROUP_UIDS =>
"SELECT DISTINCT u.$uUID AS uid " .
"FROM $user u " .
"LEFT JOIN $userGroup ug ON u.$uUID = ug.$ugUID " .
"WHERE ug.$ugGID LIKE :$gidParam " .
"AND ug.$ugUID LIKE :$searchParam " .
"AND u.$uUID LIKE :$searchParam " .
(empty($uDisabled) ? "" : "AND NOT u.$uDisabled ") .
"ORDER BY ug.$ugUID",
"ORDER BY u.$uUID",
Query::FIND_GROUP_USERS =>
"SELECT DISTINCT u.$uUID AS uid, u.$uName AS name " .
"FROM $user u " .
"LEFT JOIN $userGroup ug ON u.$uUID = ug.$ugUID " .
"WHERE ug.$ugGID LIKE :$gidParam " .
"AND u.$uUID LIKE :$searchParam " .
(empty($uDisabled) ? "" : "AND NOT u.$uDisabled ") .
"ORDER BY u.$uUID",
Query::FIND_GROUPS =>
"SELECT $groupColumns " .