Commit 55b99655 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1758769: Tutor role creates group views outside group edit window"

parents fd9bee31 a6a9a12d
......@@ -183,14 +183,19 @@ function group_role_can_edit_views($group, $role) {
* the window.
* @param object $group the group to check
* @param bool $admin_always whether the admin should be OK regardless of time
* @param bool $tutor_always whether the tutor should be OK regardless of time
*/
function group_within_edit_window($group, $admin_always=true) {
function group_within_edit_window($group, $admin_always=true, $tutor_always=true) {
if (is_numeric($group)) {
$group = get_group_by_id($group, true);
}
if ($admin_always && group_user_access($group->id) == 'admin') {
return true;
return true;
}
if ($tutor_always && group_user_access($group->id) == 'tutor') {
return true;
}
$start = !empty($group->editwindowstart) ? strtotime($group->editwindowstart) : null;
......
......@@ -29,7 +29,7 @@ $group = get_record_sql(
array($USER->get('id'), $groupid)
);
if (!$group || !group_within_edit_window($group)) {
if (!$group || !group_within_edit_window($groupid)) {
throw new AccessDeniedException(get_string('cantsubmittogroup', 'view'));
}
......
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