Commit 635e2075 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Delay group invite notifications when sent in bulk


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 360c7423
......@@ -87,9 +87,11 @@ function addmembers_submit(Pieform $form, $values) {
return;
}
db_begin();
foreach ($values['users'] as $userid) {
group_invite_user($group, $userid, $USER->get('id'));
group_invite_user($group, $userid, $USER->get('id'), 'member', true);
}
db_commit();
$SESSION->add_ok_msg(get_string('invitationssent', 'group', count($values['users'])));
redirect(get_config('wwwroot') . 'group/members.php?id=' . GROUP);
......
......@@ -445,7 +445,7 @@ function group_remove_user($groupid, $userid=null, $force=false) {
* @param object $userid User to invite
* @param object $userfrom User sending the invitation
*/
function group_invite_user($group, $userid, $userfrom, $role='member') {
function group_invite_user($group, $userid, $userfrom, $role='member', $delay=null) {
$user = optional_userobj($userid);
$data = new StdClass;
......@@ -456,13 +456,14 @@ function group_invite_user($group, $userid, $userfrom, $role='member') {
ensure_record_exists('group_member_invite', $data, $data);
$lang = get_user_language($user->id);
require_once('activity.php');
activity_occurred('maharamessage', array(
$activitydata = array(
'users' => array($user->id),
'subject' => get_string_from_language($lang, 'invitetogroupsubject', 'group'),
'message' => get_string_from_language($lang, 'invitetogroupmessage', 'group', display_name($userfrom, $user), $group->name),
'url' => get_config('wwwroot') . 'group/view.php?id=' . $group->id,
'urltext' => $group->name,
));
);
activity_occurred('maharamessage', $activitydata, null, null, $delay);
}
// Pieforms for various operations on groups
......
Supports Markdown
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