Commit 8c81c136 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>
(cherry picked from commit 087cb93d)
parent 1d0aef8d
...@@ -706,21 +706,22 @@ function group_update($new, $create=false) { ...@@ -706,21 +706,22 @@ function group_update($new, $create=false) {
// to the group artefacts are updated // to the group artefacts are updated
if ($old->grouptype != $new->grouptype) { if ($old->grouptype != $new->grouptype) {
if ($new->grouptype == 'course') { 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\')', '"group" = ' . $new->id . ' AND artefacttype IN (\'blog\', \'blogpost\')',
null, '', 'id'); null, '', 'id')) {
$access = ($old->editroles == 'all' || $old->editroles == 'notmember'); $access = ($old->editroles == 'all' || $old->editroles == 'notmember');
db_begin(); db_begin();
foreach ($ids as $i => $artefact) { foreach ($ids as $i => $artefact) {
insert_record('artefact_access_role', (object) array( insert_record('artefact_access_role', (object) array(
'artefact' => $artefact->id, 'artefact' => $artefact->id,
'role' => 'tutor', 'role' => 'tutor',
'can_view' => 1, 'can_view' => 1,
'can_edit' => (int) $access, 'can_edit' => (int) $access,
'can_republish' => (int) $access, 'can_republish' => (int) $access,
)); ));
}
db_commit();
} }
db_commit();
} }
else { //grouptype = standard else { //grouptype = standard
$query = 'DELETE FROM {artefact_access_role} $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