Commit 3e5b7503 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

When requesting group membership, send request message to all group admins

parent 407a9712
......@@ -85,19 +85,23 @@ function requestjoingroup_submit(Pieform $form, $values) {
'reason' => isset($values['reason']) ? $values['reason'] : null
)
);
$ownerlang = get_user_language($group->owner);
if (isset($values['reason']) && $values['reason'] != '') {
$message = get_string_from_language($ownerlang, 'grouprequestmessagereason', 'group', display_name($USER, get_record('usr', 'id', $group->owner)), $group->name, $values['reason']);
}
else {
$message = get_string_from_language($ownerlang, 'grouprequestmessage', 'group', display_name($USER, get_record('usr', 'id', $group->owner)), $group->name);
}
// Send request to all group admins
require_once('activity.php');
activity_occurred('maharamessage',
array('users' => array($group->owner),
'subject' => get_string_from_language($ownerlang, 'grouprequestsubject', 'group'),
'message' => $message,
'url' => get_config('wwwroot') . 'group/view.php?id=' . $group->id));
$groupadmins = get_column('group_member', 'member', 'group', $group->id, 'role', 'admin');
foreach ($groupadmins as $groupadmin) {
$adminlang = get_user_language($groupadmin);
if (isset($values['reason']) && $values['reason'] != '') {
$message = get_string_from_language($adminlang, 'grouprequestmessagereason', 'group', display_name($USER, get_record('usr', 'id', $groupadmin)), $group->name, $values['reason']);
}
else {
$message = get_string_from_language($adminlang, 'grouprequestmessage', 'group', display_name($USER, get_record('usr', 'id', $groupadmin)), $group->name);
}
activity_occurred('maharamessage', array(
'users' => array($groupadmin),
'subject' => get_string_from_language($adminlang, 'grouprequestsubject', 'group'),
'message' => $message,
'url' => get_config('wwwroot') . 'group/view.php?id=' . $group->id));
}
$SESSION->add_ok_msg(get_string('grouprequestsent', 'group'));
redirect($values['returnto'] == 'find' ? '/group/find.php' : '/group/mygroups.php');
}
......
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