@@ -193,6 +193,49 @@ public function getUsersDetails(string $search = '', $limit = null, $offset = 0)
193193 ]);
194194 }
195195
196+ /**
197+ * @NoAdminRequired
198+ *
199+ * returns a list of users and their data based on their groupid
200+ */
201+ public function getUsersGroupDetails (string $ groupId , int $ limit = null , int $ offset = 0 ): DataResponse {
202+ $ user = $ this ->userSession ->getUser ();
203+
204+ $ isSubadminOfGroup = false ;
205+ $ group = $ this ->groupManager ->get ($ groupId );
206+ if ($ group !== null ) {
207+ $ isSubadminOfGroup = $ this ->groupManager ->getSubAdmin ()->isSubAdminofGroup ($ user , $ group );
208+ } else {
209+ throw new OCSException ('The requested group could not be found ' , \OCP \API ::RESPOND_NOT_FOUND );
210+ }
211+
212+ // Check subadmin has access to this group
213+ if ($ this ->groupManager ->isAdmin ($ user ->getUID ())
214+ || $ isSubadminOfGroup ) {
215+ $ users = $ group ->getUsers ();
216+ $ users = array_map (function ($ user ) {
217+ /** @var IUser $user */
218+ return $ user ->getUID ();
219+ }, $ users );
220+ $ users = array_slice (array_values ($ users ), $ offset , $ limit );
221+ } else {
222+ throw new OCSException ('User does not have access to specified group ' , \OCP \API ::RESPOND_UNAUTHORISED );
223+ }
224+ $ usersDetails = [];
225+ foreach ($ users as $ key => $ userId ) {
226+ $ userData = $ this ->getUserData ($ userId );
227+ // Do not insert empty entry
228+ if (!empty ($ userData )) {
229+ $ usersDetails [$ userId ] = $ userData ;
230+ }
231+ }
232+
233+ return new DataResponse ([
234+ 'users ' => $ usersDetails
235+ ]);
236+
237+ }
238+
196239 /**
197240 * @PasswordConfirmationRequired
198241 * @NoAdminRequired
0 commit comments