Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
bfd72501
Commit
bfd72501
authored
13 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
add OC_Group::usersInGroup() to get a list of all users in a group
parent
110f96df
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/group.php
+8
-0
8 additions, 0 deletions
lib/group.php
lib/group/backend.php
+6
-0
6 additions, 0 deletions
lib/group/backend.php
lib/group/database.php
+18
-4
18 additions, 4 deletions
lib/group/database.php
with
32 additions
and
4 deletions
lib/group.php
+
8
−
0
View file @
bfd72501
...
...
@@ -243,4 +243,12 @@ class OC_Group {
public
static
function
groupExists
(
$gid
){
return
in_array
(
$gid
,
self
::
getGroups
());
}
/**
* @brief get a list of all users in a group
* @returns array with user ids
*/
public
static
function
usersInGroup
(
$gid
){
return
self
::
$_backend
->
usersInGroup
();
}
}
This diff is collapsed.
Click to expand it.
lib/group/backend.php
+
6
−
0
View file @
bfd72501
...
...
@@ -93,4 +93,10 @@ abstract class OC_Group_Backend {
* Returns a list with all groups
*/
public
static
function
getGroups
(){}
/**
* @brief get a list of all users in a group
* @returns array with user ids
*/
public
static
function
usersInGroup
(
$gid
){}
}
This diff is collapsed.
Click to expand it.
lib/group/database.php
+
18
−
4
View file @
bfd72501
...
...
@@ -53,7 +53,7 @@ class OC_Group_Database extends OC_Group_Backend {
*/
public
static
function
createGroup
(
$gid
){
// Check for existence
$query
=
OC_DB
::
prepare
(
"SELECT
*
FROM `*PREFIX*groups` WHERE gid = ?"
);
$query
=
OC_DB
::
prepare
(
"SELECT
gid
FROM `*PREFIX*groups` WHERE gid = ?"
);
$result
=
$query
->
execute
(
array
(
$gid
));
if
(
$result
->
numRows
()
>
0
){
...
...
@@ -98,7 +98,7 @@ class OC_Group_Database extends OC_Group_Backend {
*/
public
static
function
inGroup
(
$uid
,
$gid
){
// check
$query
=
OC_DB
::
prepare
(
"SELECT
*
FROM `*PREFIX*group_user` WHERE gid = ? AND uid = ?"
);
$query
=
OC_DB
::
prepare
(
"SELECT
uid
FROM `*PREFIX*group_user` WHERE gid = ? AND uid = ?"
);
$result
=
$query
->
execute
(
array
(
$gid
,
$uid
));
return
$result
->
numRows
()
>
0
?
true
:
false
;
...
...
@@ -146,7 +146,7 @@ class OC_Group_Database extends OC_Group_Backend {
*/
public
static
function
getUserGroups
(
$uid
){
// No magic!
$query
=
OC_DB
::
prepare
(
"SELECT
*
FROM `*PREFIX*group_user` WHERE uid = ?"
);
$query
=
OC_DB
::
prepare
(
"SELECT
gid
FROM `*PREFIX*group_user` WHERE uid = ?"
);
$result
=
$query
->
execute
(
array
(
$uid
));
$groups
=
array
();
...
...
@@ -164,7 +164,7 @@ class OC_Group_Database extends OC_Group_Backend {
* Returns a list with all groups
*/
public
static
function
getGroups
(){
$query
=
OC_DB
::
prepare
(
"SELECT
*
FROM `*PREFIX*groups`"
);
$query
=
OC_DB
::
prepare
(
"SELECT
gid
FROM `*PREFIX*groups`"
);
$result
=
$query
->
execute
();
$groups
=
array
();
...
...
@@ -174,4 +174,18 @@ class OC_Group_Database extends OC_Group_Backend {
return
$groups
;
}
/**
* @brief get a list of all users in a group
* @returns array with user ids
*/
public
static
function
usersInGroup
(
$gid
){
$query
=
OC_DB
::
prepare
(
'SELECT uid FROM *PREFIX*group_user WHERE gid=?'
);
$users
=
array
();
$result
=
$query
->
execute
(
array
(
$gid
));
while
(
$row
=
$result
->
fetchRow
()){
$users
[]
=
$row
[
'uid'
];
}
return
$users
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment