Skip to content

Commit 515553e

Browse files
committed
only send notification once, when bulk scheduling
1 parent cb9af6e commit 515553e

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

controllers/course.php

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ public function schedule_action($resource_id, $termin_id)
434434

435435
$this->schedule($resource_id, $termin_id, $this->course_id);
436436

437+
$this->sendRecordingNotifications($this->course_id);
438+
437439
$this->redirect('course/scheduler?semester_filter=' . Request::option('semester_filter'));
438440
}
439441

@@ -630,6 +632,10 @@ public function bulkschedule_action()
630632
}
631633
}
632634

635+
if ($action == 'create') {
636+
$this->sendRecordingNotifications($this->course_id);
637+
}
638+
633639
$this->redirect('course/scheduler?semester_filter=' . Request::option('semester_filter'));
634640
}
635641

@@ -642,26 +648,6 @@ public function schedule($resource_id, $termin_id, $course_id)
642648
$scheduler_client = SchedulerClient::getInstance(OCConfig::getConfigIdForCourse($course_id));
643649

644650
if ($scheduler_client->scheduleEventForSeminar($course_id, $resource_id, $termin_id)) {
645-
$course = Course::find($course_id);
646-
$members = $course->members;
647-
$users = [];
648-
649-
foreach ($members as $member) {
650-
$users[] = $member->user_id;
651-
}
652-
653-
$notification = sprintf(
654-
$this->_('Die Veranstaltung "%s" wird für Sie mit Bild und Ton automatisiert aufgezeichnet.'),
655-
htmlReady($course->name)
656-
);
657-
PersonalNotifications::add(
658-
$users,
659-
$this->url_for('course/index', ['cid' => $course_id]),
660-
$notification,
661-
$course_id,
662-
Icon::create($this->plugin->getPluginUrl() . '/images/opencast-black.svg')
663-
);
664-
665651
StudipLog::log('OC_SCHEDULE_EVENT', $termin_id, $course_id);
666652

667653
PageLayout::postSuccess(
@@ -710,6 +696,29 @@ public function updateschedule($resource_id, $termin_id, $course_id)
710696
}
711697
}
712698

699+
private function sendRecordingNotifications($course_id)
700+
{
701+
$course = Course::find($course_id);
702+
$members = $course->members;
703+
$users = [];
704+
705+
foreach ($members as $member) {
706+
$users[] = $member->user_id;
707+
}
708+
709+
$notification = sprintf(
710+
$this->_('Die Veranstaltung "%s" wird für Sie mit Bild und Ton automatisiert aufgezeichnet.'),
711+
htmlReady($course->name)
712+
);
713+
PersonalNotifications::add(
714+
$users,
715+
$this->url_for('course/index', ['cid' => $course_id]),
716+
$notification,
717+
$course_id,
718+
Icon::create($this->plugin->getPluginUrl() . '/images/opencast-black.svg')
719+
);
720+
}
721+
713722
public function unschedule($resource_id, $termin_id, $course_id)
714723
{
715724
$scheduled = OCModel::checkScheduledRecording($course_id, $resource_id, $termin_id);

0 commit comments

Comments
 (0)