From 972e8b899c28a272ad74285b4f72cc90e1bb7fa8 Mon Sep 17 00:00:00 2001 From: David Siegfried <david.siegfried@uni-vechta.de> Date: Tue, 31 May 2022 10:25:01 +0000 Subject: [PATCH] use sorm-relations, refs #707 Merge request studip/studip!662 --- app/controllers/course/timesrooms.php | 9 +-------- lib/models/CourseDate.class.php | 5 +++++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controllers/course/timesrooms.php b/app/controllers/course/timesrooms.php index b2ca347166c..18792bb626a 100644 --- a/app/controllers/course/timesrooms.php +++ b/app/controllers/course/timesrooms.php @@ -1417,7 +1417,7 @@ class Course_TimesroomsController extends AuthenticatedController /** * Deletes a date. * - * @param String $termin CourseDate of the date + * @param CourseDate $termin CourseDate of the date * @param String $cancel_comment cancel mesessage (if non empty) * * @return CourseDate|CourseExDate deleted date @@ -1425,7 +1425,6 @@ class Course_TimesroomsController extends AuthenticatedController private function deleteDate($termin, $cancel_comment) { $seminar_id = $termin->range_id; - $termin_id = $termin->id; $termin_room = $termin->getRoomName(); $termin_date = $termin->getFullname(); $has_topics = $termin->topics->count(); @@ -1441,12 +1440,6 @@ class Course_TimesroomsController extends AuthenticatedController } else { if ($termin->delete()) { StudipLog::log("SEM_DELETE_SINGLEDATE", $termin->id, $seminar_id, 'appointment cancelled'); - - // delete attached resource request appointments if they exist - ResourceRequestAppointment::deleteBySQL( - "appointment_id = ?", - [$termin_id] - ); } } diff --git a/lib/models/CourseDate.class.php b/lib/models/CourseDate.class.php index 9060797f8c3..91c35793406 100644 --- a/lib/models/CourseDate.class.php +++ b/lib/models/CourseDate.class.php @@ -100,6 +100,11 @@ class CourseDate extends SimpleORMap implements PrivacyObject 'assoc_foreign_key' => 'termin_id', 'on_delete' => 'delete', ]; + $config['has_many']['resource_request_appointments'] = [ + 'class_name' => ResourceRequestAppointment::class, + 'assoc_foreign_key' => 'appointment_id', + 'on_delete' => 'delete', + ]; $config['default_values']['date_typ'] = 1; parent::configure($config); } -- GitLab