From a569ce88a552f043865e13c5cde8e23193e81d59 Mon Sep 17 00:00:00 2001 From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> Date: Mon, 26 Aug 2024 13:38:37 +0000 Subject: [PATCH] add action to clone an irregular date, fixes #3275 Closes #3275 Merge request studip/studip!3324 --- app/controllers/course/timesrooms.php | 27 +++++++++++++++++++++++ app/views/course/timesrooms/_cycleRow.php | 7 ++++++ 2 files changed, 34 insertions(+) diff --git a/app/controllers/course/timesrooms.php b/app/controllers/course/timesrooms.php index 4788eee05e0..129a0610ca7 100644 --- a/app/controllers/course/timesrooms.php +++ b/app/controllers/course/timesrooms.php @@ -363,6 +363,33 @@ class Course_TimesroomsController extends AuthenticatedController } + /** + * Clone an existing date + * + * @param $termin_id + */ + public function cloneDate_action($termin_id) + { + $date = CourseDate::find($termin_id); + + if ($date) { + $termin = CourseDate::build($date); + $termin->setId($termin->getNewId()); + + $termin->dozenten = $date->dozenten; + $termin->statusgruppen = $date->statusgruppen; + $termin->store(); + + PageLayout::postSuccess(sprintf( + _('Der Termin "%s" wurde dupliziert.'), + htmlReady($termin->getFullName()) + )); + } + + $this->redirect('course/timesrooms/index'); + } + + /** * Save date-information * diff --git a/app/views/course/timesrooms/_cycleRow.php b/app/views/course/timesrooms/_cycleRow.php index 5a5f60b15dc..ce286ed76e5 100644 --- a/app/views/course/timesrooms/_cycleRow.php +++ b/app/views/course/timesrooms/_cycleRow.php @@ -126,6 +126,13 @@ $is_exTermin = $termin instanceof CourseExDate; Icon::create('edit'), ['data-dialog' => ''] ) ?> + <? if (!$termin->metadate_id): ?> + <? $actionMenu->addLink( + $controller->url_for('course/timesrooms/cloneDate/' . $termin->id, $linkAttributes), + _('Termin duplizieren'), + Icon::create('copy') + ) ?> + <? endif ?> <? $actionMenu ->conditionAll(Config::get()->RESOURCES_ENABLE && Config::get()->RESOURCES_ALLOW_ROOM_REQUESTS) ->condition((bool) $room_request) -- GitLab