Commit ae531c51 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1722855: Add usrleavesgroup event trigger"

parents 671e977e c270263c
......@@ -5554,6 +5554,7 @@ function xmldb_core_upgrade($oldversion=0) {
}
if ($oldversion < 2018010300) {
log_debug('Anonymising remaining deleted user data');
$sql = "UPDATE {usr}
SET username = CONCAT(MD5(username), 1000000 + id),
email = CONCAT(MD5(email), 1000000 + id)
......@@ -5561,5 +5562,13 @@ function xmldb_core_upgrade($oldversion=0) {
execute_sql($sql);
}
if ($oldversion < 2018010400) {
log_debug('Adding new event type "userleavesgroup"');
$event = (object)array(
'name' => 'userleavesgroup'
);
ensure_record_exists('event_type', $event, $event);
}
return $status;
}
......@@ -1074,6 +1074,11 @@ function group_remove_user($groupid, $userid=null, $force=false) {
if (!$force && !group_user_can_leave($groupid, $userid)) {
throw new AccessDeniedException(get_string('usercantleavegroup', 'group'));
}
$data = new StdClass;
$data->user = $userid;
$data->group = $groupid;
$data->role = get_field('group_member', 'role', 'group', $groupid, 'member', $userid);
handle_event('userleavesgroup', $data);
delete_records('group_member', 'group', $groupid, 'member', $userid);
global $USER;
......
......@@ -871,6 +871,7 @@ function core_install_firstcoredata_defaults() {
'deactivateuser',
'activateuser',
'userjoinsgroup',
'userleavesgroup',
'saveartefact',
'deleteartefact',
'deleteartefacts',
......
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2018010300;
$config->version = 2018010400;
$config->series = '18.04';
$config->release = '18.04dev';
$config->minupgradefrom = 2015030409;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment