@@ -101,6 +101,7 @@ class Rest extends WebService
101
101
public const DELETE_USER = 'delete_user ' ;
102
102
public const GET_USERS_API_KEYS = 'get_users_api_keys ' ;
103
103
public const GET_USER_API_KEY = 'get_user_api_key ' ;
104
+ public const GET_USER_SUB_GROUP = 'get_user_sub_group ' ;
104
105
105
106
public const GET_COURSES = 'get_courses ' ;
106
107
public const GET_COURSES_FROM_EXTRA_FIELD = 'get_courses_from_extra_field ' ;
@@ -4076,6 +4077,8 @@ public function getGroupSubscribedSessions(int $groupId): array
4076
4077
/**
4077
4078
* Add a new user to the given group/class.
4078
4079
*
4080
+ * @param int $groupId
4081
+ * @param int $userId
4079
4082
* @param int $relationType (1:admin, 2:reader, etc. See GROUP_USER_PERMISSION_ constants in api.lib.php)
4080
4083
*
4081
4084
* @return array One item array containing true on success, false otherwise
@@ -4087,6 +4090,21 @@ public function addGroupSubscribedUser(int $groupId, int $userId, int $relationT
4087
4090
return [$ userGroup ->add_user_to_group ($ userId , $ groupId , $ relationType )];
4088
4091
}
4089
4092
4093
+ /**
4094
+ * Get the list of group/class IDs to which the user belongs.
4095
+ *
4096
+ * @param int $userId
4097
+ *
4098
+ * @return array Array containing the group IDs like ['groups' => [1, 2, 3]]
4099
+ */
4100
+ public function getUserSubGroup (int $ userId ): array
4101
+ {
4102
+ $ userGroup = new UserGroup ();
4103
+
4104
+ $ res = $ userGroup ->get_usergroup_by_user ($ userId );
4105
+ return ['groups ' => $ res ];
4106
+ }
4107
+
4090
4108
/**
4091
4109
* Add a new course to which the given group/class is subscribed.
4092
4110
*
0 commit comments