Commit fc447de4 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie

Add a user to a community as a tutor if they're staff and the community

is controlled.
parent 5623f2b9
......@@ -98,7 +98,7 @@ function createcommunity_submit(Pieform $form, $values) {
$now = db_format_timestamp(time());
insert_record(
$id = insert_record(
'community',
(object) array(
'name' => $values['name'],
......@@ -107,9 +107,25 @@ function createcommunity_submit(Pieform $form, $values) {
'owner' => $USER->get('id'),
'ctime' => $now,
'mtime' => $now,
)
),
'id',
true
);
// If the user is a staff member, they should be added as a tutor automatically
if ($values['membershiptype'] == 'controlled' && $USER->get('staff')) {
log_debug('Adding staff user to community');
insert_record(
'community_member',
(object) array(
'community' => $id,
'member' => $USER->get('id'),
'ctime' => $now,
'tutor' => 1
)
);
}
$SESSION->add_ok_msg(get_string('communitysaved'));
db_commit();
......
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