Skip to content

Commit

Permalink
validateaction on event delete
Browse files Browse the repository at this point in the history
  • Loading branch information
aembler committed Nov 10, 2023
1 parent 3c7b8e6 commit c770ca0
Showing 1 changed file with 38 additions and 33 deletions.
71 changes: 38 additions & 33 deletions concrete/controllers/dialog/event/delete.php
Expand Up @@ -38,42 +38,47 @@ public function __construct()

public function submit()
{
$event = $this->eventService->getByID($_REQUEST['eventID'], EventService::EVENT_VERSION_RECENT);
$e = \Core::make('error');
if (!$event) {
$e->add(t('Invalid event.'));
}
if (!$this->canAccess()) {
$e->add(t('Access Denied.'));
}
if ($this->validateAction()) {
$event = $this->eventService->getByID($_REQUEST['eventID'], EventService::EVENT_VERSION_RECENT);
$e = \Core::make('error');
if (!$event) {
$e->add(t('Invalid event.'));
}
if (!$this->canAccess()) {
$e->add(t('Access Denied.'));
}

$r = new EditResponse($e);
$year = date('Y');
$month = date('m');
$r->setRedirectURL(
\URL::to(
$this->preferences->getPreferredViewPath(),
'view',
$event->getCalendar()->getID(),
$year,
$month
)
);

if (!$e->has()) {
$u = $this->app->make(User::class);
$pkr = new DeleteCalendarEventRequest();
$pkr->setCalendarEventVersionID($event->getRecentVersion()->getID());
$pkr->setRequesterUserID($u->getUserID());
$response = $pkr->trigger();
if ($response instanceof Response) {
$this->flash('success', t('Event deleted successfully.'));
} else {
$this->flash('success', t('Event deletion pending. This request must be approved before the event is fully removed.'));
$r = new EditResponse($e);
$year = date('Y');
$month = date('m');
$r->setRedirectURL(
\URL::to(
$this->preferences->getPreferredViewPath(),
'view',
$event->getCalendar()->getID(),
$year,
$month
)
);

if (!$e->has()) {
$u = $this->app->make(User::class);
$pkr = new DeleteCalendarEventRequest();
$pkr->setCalendarEventVersionID($event->getRecentVersion()->getID());
$pkr->setRequesterUserID($u->getUserID());
$response = $pkr->trigger();
if ($response instanceof Response) {
$this->flash('success', t('Event deleted successfully.'));
} else {
$this->flash(
'success',
t('Event deletion pending. This request must be approved before the event is fully removed.')
);
}
}
}

$r->outputJSON();
$r->outputJSON();
}
}


Expand Down

0 comments on commit c770ca0

Please sign in to comment.