diff --git a/app/controllers/course/timesrooms.php b/app/controllers/course/timesrooms.php index 68acb2ac65017f929b8df98dd251848656f5b773..39a6fb6c3ae1428e490d488fece096e52d28828c 100644 --- a/app/controllers/course/timesrooms.php +++ b/app/controllers/course/timesrooms.php @@ -1354,7 +1354,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 @@ -1362,7 +1362,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(); @@ -1378,12 +1377,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 9930f23eee53575d5385f0d0b62ba3917cc7f44b..2adf5e1c71398c58f1abd6eb1828fba627e0dcdf 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); }