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,8 +183,9 @@ 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);
}
......@@ -193,6 +194,10 @@ function group_within_edit_window($group, $admin_always=true) {
return true;
}
if ($tutor_always && group_user_access($group->id) == 'tutor') {
return true;
}
$start = !empty($group->editwindowstart) ? strtotime($group->editwindowstart) : null;
$end = !empty($group->editwindowend) ? strtotime($group->editwindowend) : null;
$now = time();
......
......@@ -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'));
}
......
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