diff options
Diffstat (limited to 'lib/group')
-rw-r--r-- | lib/group/backend.php | 6 | ||||
-rw-r--r-- | lib/group/database.php | 22 |
2 files changed, 24 insertions, 4 deletions
diff --git a/lib/group/backend.php b/lib/group/backend.php index ebee8aacb91..43f94e7ea1a 100644 --- a/lib/group/backend.php +++ b/lib/group/backend.php @@ -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){} } diff --git a/lib/group/database.php b/lib/group/database.php index 6ca80b93985..8a9fc53d39f 100644 --- a/lib/group/database.php +++ b/lib/group/database.php @@ -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; + } } |