Opened 5 years ago
Closed 4 years ago
#355 closed Defect (fixed)
The "addtogroup" action for groups does not function properly - Fix included
| Reported by: | jade22 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Core | Version: | 1.0 |
| Severity: | minor | Keywords: | group invite, join group |
| Cc: | brettp | Difficulty: |
Description
When a user 'requests membership' to a group, the group_join_request(GJR) metadata is added to that users entity.
A user can request to be added to more than one group, giving that user multiple GJR metadata. So a user can have either 1 GJR metadata, or several GJR metadata.
The "add to group" action found at: /mod/groups/actions/addtogroup.php does a good job of looping through multiple GJR metadata in order to find the one that equals the current group the group owner is attempting to add the user to. But it does not function as it should if the user has only one GJR metadata. The function is expecting an array to loop through, if $requests is not an array, the user is not added to the group and instead receives an "invite" invitation.
The other problem is when a user does have multiple GJR metadata, the foreach loop should break as soon as the appropriate metadata is found. This ensures a proper system_message display. Otherwise whatever outcome the last element in the loop has will determine the system_message.
Attachments (1)
Change History (2)
Changed 5 years ago by jade22
comment:1 Changed 4 years ago by cash
- Resolution set to fixed
- Status changed from new to closed
This has been fixed: groups membership requests are now handled through a relationship and there is a simple check in the action: check_entity_relationship($user->guid, 'membership_request', $group->guid)
I also checked functionality as a sanity check and it worked as expected.

updated addtogroup.php file with commented fixes