Commit 20c82d27 authored by Richard Mansfield's avatar Richard Mansfield

Add internal admin notifications for new institutional admins

parent 549cd6d6
......@@ -305,6 +305,9 @@ function edituser_institution_submit(Pieform $form, $values) {
db_begin();
delete_records('usr_institution', 'usr', $user->id, 'institution', $i->institution);
insert_record('usr_institution', $newuser);
if ($newuser->admin) {
activity_add_admin_defaults(array($user->id));
}
handle_event('updateuser', $user->id);
db_commit();
break;
......
......@@ -88,6 +88,7 @@ function adminusers_submit(Pieform $form, $values) {
SET admin = 1
WHERE usr IN (' . join(',', $values['users']) . ') AND institution = ' . db_quote($inst));
}
activity_add_admin_defaults($values['users']);
db_commit();
$SESSION->add_ok_msg(get_string('adminusersupdated', 'admin'));
redirect('/admin/users/institutionadmins.php?institution=' . $inst);
......
......@@ -425,6 +425,22 @@ function activity_set_defaults($user_id) {
}
function activity_add_admin_defaults($userids) {
$activitytypes = get_records_array('activity_type', 'admin', 1);
foreach ($activitytypes as $type) {
foreach ($userids as $id) {
if (!record_exists('usr_activity_preference', 'usr', $id, 'activity', $type->name)) {
insert_record('usr_activity_preference', (object)array(
'usr' => $id,
'activity' => $type->name,
'method' => 'internal',
));
}
}
}
}
function activity_process_queue() {
db_begin();
......
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