| @@ 182-197 (lines=16) @@ | ||
| 179 | * |
|
| 180 | * Returns a list with all groups |
|
| 181 | */ |
|
| 182 | public function getGroups($search = '', $limit = null, $offset = null) { |
|
| 183 | $parameters = []; |
|
| 184 | $searchLike = ''; |
|
| 185 | if ($search !== '') { |
|
| 186 | $parameters[] = '%' . $search . '%'; |
|
| 187 | $searchLike = ' WHERE LOWER(`gid`) LIKE LOWER(?)'; |
|
| 188 | } |
|
| 189 | ||
| 190 | $stmt = OC_DB::prepare('SELECT `gid` FROM `*PREFIX*groups`' . $searchLike . ' ORDER BY `gid` ASC', $limit, $offset); |
|
| 191 | $result = $stmt->execute($parameters); |
|
| 192 | $groups = array(); |
|
| 193 | while ($row = $result->fetchRow()) { |
|
| 194 | $groups[] = $row['gid']; |
|
| 195 | } |
|
| 196 | return $groups; |
|
| 197 | } |
|
| 198 | ||
| 199 | /** |
|
| 200 | * check if a group exists |
|
| @@ 221-238 (lines=18) @@ | ||
| 218 | * @param int $offset |
|
| 219 | * @return array an array of user ids |
|
| 220 | */ |
|
| 221 | public function usersInGroup($gid, $search = '', $limit = null, $offset = null) { |
|
| 222 | $parameters = [$gid]; |
|
| 223 | $searchLike = ''; |
|
| 224 | if ($search !== '') { |
|
| 225 | $parameters[] = '%' . $this->escapeLikeParameter($search) . '%'; |
|
| 226 | $searchLike = ' AND `uid` LIKE ?'; |
|
| 227 | } |
|
| 228 | ||
| 229 | $stmt = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*group_user` WHERE `gid` = ?' . $searchLike . ' ORDER BY `uid` ASC', |
|
| 230 | $limit, |
|
| 231 | $offset); |
|
| 232 | $result = $stmt->execute($parameters); |
|
| 233 | $users = array(); |
|
| 234 | while ($row = $result->fetchRow()) { |
|
| 235 | $users[] = $row['uid']; |
|
| 236 | } |
|
| 237 | return $users; |
|
| 238 | } |
|
| 239 | ||
| 240 | /** |
|
| 241 | * get the number of all users matching the search string in a group |
|
| @@ 245-260 (lines=16) @@ | ||
| 242 | * @param null|int $offset |
|
| 243 | * @return string[] an array of all uids |
|
| 244 | */ |
|
| 245 | public function getUsers($search = '', $limit = null, $offset = null) { |
|
| 246 | $parameters = []; |
|
| 247 | $searchLike = ''; |
|
| 248 | if ($search !== '') { |
|
| 249 | $parameters[] = '%' . $search . '%'; |
|
| 250 | $searchLike = ' WHERE LOWER(`uid`) LIKE LOWER(?)'; |
|
| 251 | } |
|
| 252 | ||
| 253 | $query = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY `uid` ASC', $limit, $offset); |
|
| 254 | $result = $query->execute($parameters); |
|
| 255 | $users = array(); |
|
| 256 | while ($row = $result->fetchRow()) { |
|
| 257 | $users[] = $row['uid']; |
|
| 258 | } |
|
| 259 | return $users; |
|
| 260 | } |
|
| 261 | ||
| 262 | /** |
|
| 263 | * check if a user exists |
|