modx->getOption('agenda.core_path', null, $this->modx->getOption('core_path') . 'components/agenda/'); $this->agenda = $this->modx->getService('agenda', 'Agenda', $corePath . 'model/agenda/', [ 'core_path' => $corePath ]); $this->cursus = &$this->agenda->cursus; $eventId = $this->scriptProperties['id']; $className = $this->scriptProperties['className']; if (!$this->modx->loadClass('agenda.AgendaEvents', $this->agenda->getOption('modelPath'))) { $this->modx->log(xPDO::LOG_LEVEL_ERROR, 'Could not load AgendaEvents class!', '', 'OnAgendaBeforeRemove'); return; } if (!$this->modx->loadClass('agenda.AgendaEventDates', $this->agenda->getOption('modelPath'))) { $this->modx->log(xPDO::LOG_LEVEL_ERROR, 'Could not load AgendaEventDates class!', '', 'OnAgendaBeforeRemove'); return; } if ($eventId) { if ($className == 'AgendaEvents') { $c = $this->modx->newQuery('CursusEventParticipants'); $c->leftJoin('AgendaEventDates', 'AgendaEventDates', 'CursusEventParticipants.event_id = AgendaEventDates.id'); $c->where(['AgendaEventDates.event_id' => $eventId]); $count = $this->modx->getCount('CursusEventParticipants', $c); if ($count > 0) { $this->modx->event->_output = 'There are already repeating events booked for this event. Therefore, it is not possible to delete the event.'; } } if ($className == 'AgendaEventDates') { $participants = $this->modx->getObject('CursusEventParticipants', ['event_id' => $eventId]); if ($participants) { $this->modx->event->_output = 'The event repeat has already been booked. Therefore, it is not possible to delete it.'; } } } } }