Commit 087cb93d authored by Robert Lyon's avatar Robert Lyon

Bug 1760742: Error when changing a group from standard to course

When there are no blogposts made

behatnotneeded

Change-Id: I7a3b2bed818c66fd4edef188ed7ba475e54c3a4c
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 1085ec62
......@@ -706,21 +706,22 @@ function group_update($new, $create=false) {
// to the group artefacts are updated
if ($old->grouptype != $new->grouptype) {
if ($new->grouptype == 'course') {
$ids = get_records_select_array('artefact',
if ($ids = get_records_select_array('artefact',
'"group" = ' . $new->id . ' AND artefacttype IN (\'blog\', \'blogpost\')',
null, '', 'id');
$access = ($old->editroles == 'all' || $old->editroles == 'notmember');
db_begin();
foreach ($ids as $i => $artefact) {
insert_record('artefact_access_role', (object) array(
'artefact' => $artefact->id,
'role' => 'tutor',
'can_view' => 1,
'can_edit' => (int) $access,
'can_republish' => (int) $access,
));
null, '', 'id')) {
$access = ($old->editroles == 'all' || $old->editroles == 'notmember');
db_begin();
foreach ($ids as $i => $artefact) {
insert_record('artefact_access_role', (object) array(
'artefact' => $artefact->id,
'role' => 'tutor',
'can_view' => 1,
'can_edit' => (int) $access,
'can_republish' => (int) $access,
));
}
db_commit();
}
db_commit();
}
else { //grouptype = standard
$query = 'DELETE FROM {artefact_access_role}
......
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