Skip to content
Snippets Groups Projects
Commit c2f2798e authored by Moritz Strohm's avatar Moritz Strohm Committed by Elmar Ludwig
Browse files

do not remove assigned course dates when bulk-updating course groups, closes #1427

Closes #1427

Merge request studip/studip!890
parent a97f45d0
No related branches found
No related tags found
No related merge requests found
...@@ -1112,11 +1112,17 @@ class Course_StatusgroupsController extends AuthenticatedController ...@@ -1112,11 +1112,17 @@ class Course_StatusgroupsController extends AuthenticatedController
$groups = Statusgruppen::findMany(Request::getArray('groups')); $groups = Statusgruppen::findMany(Request::getArray('groups'));
foreach ($groups as $g) { foreach ($groups as $g) {
Statusgruppen::createOrUpdate($g->id, $g->name, Statusgruppen::createOrUpdate(
$g->position, $this->course_id, $g->id,
$g->name,
$g->position,
$this->course_id,
Request::int('size', 0), Request::int('size', 0),
$g->selfassign, $g->selfassign_start, $g->selfassign_end, $g->selfassign,
false); $g->selfassign_start,
$g->selfassign_end,
false
);
} }
PageLayout::postSuccess(_('Die Einstellungen der ausgewählten Gruppen wurden gespeichert.')); PageLayout::postSuccess(_('Die Einstellungen der ausgewählten Gruppen wurden gespeichert.'));
$this->relocate('course/statusgroups'); $this->relocate('course/statusgroups');
......
...@@ -109,15 +109,16 @@ class Statusgruppen extends SimpleORMap implements PrivacyObject ...@@ -109,15 +109,16 @@ class Statusgruppen extends SimpleORMap implements PrivacyObject
/** /**
* Creates or updates a statusgroup. * Creates or updates a statusgroup.
* *
* @param string $id ID of an existing group or empty if new group * @param string $id ID of an existing group or empty if new group
* @param string $name group name * @param string $name group name
* @param int $position position or null if automatic position after other groups * @param int $position position or null if automatic position after other groups
* @param string $range_id ID of the object this group belongs to * @param string $range_id ID of the object this group belongs to
* @param int $size max number of members or 0 if unlimited * @param int $size max number of members or 0 if unlimited
* @param int $selfassign may users join this group by themselves? * @param int $selfassign may users join this group by themselves?
* @param int $selfassign_start group joining is possible starting at ... * @param int $selfassign_start group joining is possible starting at ...
* @param int $makefolder create a document folder assigned to this group? * @param int $makefolder create a document folder assigned to this group?
* @param array $dates dates assigned to this group * @param array|null $dates dates assigned to this group. Defaults to null which means already assigned
* dates are not changed.
* @return Statusgruppen The saved statusgroup. * @return Statusgruppen The saved statusgroup.
* @throws Exception * @throws Exception
*/ */
...@@ -131,7 +132,7 @@ class Statusgruppen extends SimpleORMap implements PrivacyObject ...@@ -131,7 +132,7 @@ class Statusgruppen extends SimpleORMap implements PrivacyObject
$selfassign_start, $selfassign_start,
$selfassign_end, $selfassign_end,
$makefolder, $makefolder,
$dates = [] $dates = null
) )
{ {
$group = new Statusgruppen($id); $group = new Statusgruppen($id);
...@@ -145,10 +146,8 @@ class Statusgruppen extends SimpleORMap implements PrivacyObject ...@@ -145,10 +146,8 @@ class Statusgruppen extends SimpleORMap implements PrivacyObject
$group->selfassign_end = $selfassign ? $selfassign_end : 0; $group->selfassign_end = $selfassign ? $selfassign_end : 0;
// Set assigned dates. // Set assigned dates.
if ($dates) { if (isset($dates)) {
$group->dates = CourseDate::findMany($dates); $group->dates = CourseDate::findMany($dates);
} else {
$group->dates = [];
} }
$group->store(); $group->store();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment