@@ -101,6 +101,7 @@ class Rest extends WebService
101101 public const DELETE_USER = 'delete_user ' ;
102102 public const GET_USERS_API_KEYS = 'get_users_api_keys ' ;
103103 public const GET_USER_API_KEY = 'get_user_api_key ' ;
104+ public const GET_USER_SUB_GROUP = 'get_user_sub_group ' ;
104105
105106 public const GET_COURSES = 'get_courses ' ;
106107 public const GET_COURSES_FROM_EXTRA_FIELD = 'get_courses_from_extra_field ' ;
@@ -4076,6 +4077,8 @@ public function getGroupSubscribedSessions(int $groupId): array
40764077 /**
40774078 * Add a new user to the given group/class.
40784079 *
4080+ * @param int $groupId
4081+ * @param int $userId
40794082 * @param int $relationType (1:admin, 2:reader, etc. See GROUP_USER_PERMISSION_ constants in api.lib.php)
40804083 *
40814084 * @return array One item array containing true on success, false otherwise
@@ -4087,6 +4090,21 @@ public function addGroupSubscribedUser(int $groupId, int $userId, int $relationT
40874090 return [$ userGroup ->add_user_to_group ($ userId , $ groupId , $ relationType )];
40884091 }
40894092
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+
40904108 /**
40914109 * Add a new course to which the given group/class is subscribed.
40924110 *
0 commit comments