MDL-45991 groups: Auto-create groups with ungrouped users only
When using auto-create groups, sometimes it is needed to only create
groups with users that are not already inside a course group. This
patch creates a checkbox that will ignore users that are in already
existing groups. It alters the groups_get_potential_members function so
that the eligible users are retrieved entirely though sql.
This combines the following changes:
* Event for group member added
* Event for group member removed
* Event for group created
* Event for grouping created
* Event for group updated
* Event for grouping updated
* Event for group deleted
* Event for grouping deleted
* Adding tests for deleting functions
* Bulk remove of members uses low-level API
The reason for this is that a bulk event has no value from a logging
perspective as it is not granular. So now, the API is a bit slower,
but the information the events contain makes sense, beside this is
not (and should not be) used very often.
The reason why the events_trigger_legacy() is kept is because we
cannot create a new event for this, as we don't encourage developers
to created bulk events, for the reasons mentioned above.
I removed the call that gets the user record from the function
groups_remove_member() as it was not required and only appeared
to check if the user existed. It appears to be safe not to do
this check as nothing would fail down the line.
* Bulk unassign of groupings uses low-level API
As the previous commit, we keep the legacy event for now as it would
be wrong to create a new event to replace it.
Also, the code has been changed to call the low-level API to unassign
groups from groupins, even though at the moment there are no
events for that function.
* Bulk deletion of groups uses low-level API
Again, we keep the legacy event because replacing it would force
us to create a new event that does not make sense. See MDL-41312.
* Bulk deleting of groupings uses low-level API
* Asserting legacy event name in unit tests
* Minor SQL query and code improvements
GD PHP extension is now required. Add-ons need to remove $CFG->gdversion tests. The worst case regression is that add-on will think GD is not available.
This patch includes following changes and new features:
* Group sync in enrol_cohort plugin.
* Option for editing of role in existing cohort sync instance.
* Group memberships are now restored after enrolments.
* New enrol method for restore of protected group membership.
* New component callback 'restore_group_member' for restore of general plugin group membership.
* New component callback 'restore_role_assignment' for restore of general plugin role assignments.
* Implemented group membership protection in enrolment UI.
* Other minor fixes and cleanup.
Notes:
* The YUI base enrolment page is not reimplemented yet - see MDL-35618.
This commit coverts everything in the codebase to use the new
users_order_by_sql function when sorting lists of users. More details in
the bug.
Note that this does not change places where users are displayed in a
sortable table, and the sort order comes from the table.
New keep roles/enrolments and groups/groupings options, notification CSS fixed, standardised notification texts, added missing delete of module blocks, fixed file deleting and some other minor issues.
Please forgive me if I have missed converting any output statements. If you do find an output statement that is not formatting correctly please refere to the table I added to this bug in regards to how it should be formatted.