diff --git a/app/controllers/course/timesrooms.php b/app/controllers/course/timesrooms.php index b2ca347166cb77d3efb120df98e85abe584d7304..18792bb626aba9b8d65540dd368f69737d439c21 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 9060797f8c3dc8864816330a567daa88b75b5327..91c357934069f01e2a11b3f540ceecfaa2940042 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); }