Skip to content

Commit

Permalink
Better word break with long logs; wrapping some controller methods in…
Browse files Browse the repository at this point in the history
… validateAction where it was missing
  • Loading branch information
aembler committed Nov 9, 2023
1 parent c88ddd1 commit 747d5bf
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 73 deletions.
71 changes: 38 additions & 33 deletions concrete/controllers/dialog/event/delete.php
Original file line number Diff line number Diff line change
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
83 changes: 46 additions & 37 deletions concrete/controllers/dialog/event/delete_occurrence.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,46 +40,55 @@ public function __construct()

public function submit()
{
$occurrence = $this->eventOccurrenceService->getByID($this->request->request->get('versionOccurrenceID'));
$e = \Core::make('error');
if (!$occurrence) {
$e->add(t('Invalid occurrence.'));
}
if (!$this->canAccess()) {
$e->add(t('Access Denied.'));
}
if ($this->validateAction()) {
$occurrence = $this->eventOccurrenceService->getByID($this->request->request->get('versionOccurrenceID'));
$e = \Core::make('error');
if (!$occurrence) {
$e->add(t('Invalid occurrence.'));
}
if (!$this->canAccess()) {
$e->add(t('Access Denied.'));
}

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

if (!$e->has()) {
$u = $this->app->make(User::class);
$eventVersion = $this->eventService->getVersionToModify($occurrence->getEvent(), $u);
$this->eventService->addEventVersion($eventVersion->getEvent(), $eventVersion->getEvent()->getCalendar(), $eventVersion);
$this->eventOccurrenceService->delete($eventVersion, $occurrence->getOccurrence());

$pkr = new ApproveCalendarEventRequest();
$pkr->setCalendarEventVersionID($eventVersion->getID());
$pkr->setRequesterUserID($u->getUserID());
$response = $pkr->trigger();
if ($response instanceof Response) {
$this->flash('success', t('Event occurrence removed.'));
} else {
$this->flash('success', t('Event occurrence removal requested. This must be approved before it is fully removed.'));
$r = new EditResponse($e);
$year = date('Y', $occurrence->getStart());
$month = date('m', $occurrence->getStart());
$r->setRedirectURL(
\URL::to(
$this->preferences->getPreferredViewPath(),
'view',
$occurrence->getEvent()->getCalendar()->getID(),
$year,
$month
)
);

if (!$e->has()) {
$u = $this->app->make(User::class);
$eventVersion = $this->eventService->getVersionToModify($occurrence->getEvent(), $u);
$this->eventService->addEventVersion(
$eventVersion->getEvent(),
$eventVersion->getEvent()->getCalendar(),
$eventVersion
);
$this->eventOccurrenceService->delete($eventVersion, $occurrence->getOccurrence());

$pkr = new ApproveCalendarEventRequest();
$pkr->setCalendarEventVersionID($eventVersion->getID());
$pkr->setRequesterUserID($u->getUserID());
$response = $pkr->trigger();
if ($response instanceof Response) {
$this->flash('success', t('Event occurrence removed.'));
} else {
$this->flash(
'success',
t('Event occurrence removal requested. This must be approved before it is fully removed.')
);
}
}
}

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


Expand Down
2 changes: 1 addition & 1 deletion concrete/controllers/dialog/file/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function view($fID)

public function submit($fID)
{
if ($this->canAccess()) {
if ($this->validateAction()) {
$file = File::getByID($this->request->attributes->get('fID'));
$file->delete();

Expand Down
2 changes: 1 addition & 1 deletion concrete/controllers/dialog/logs/delete_all.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function submit()
/** @var EditResponse $editResponse */
$editResponse = new EditResponse();

if ($this->canAccess()) {
if ($this->validateAction()) {
/** @var Connection $db */
$db = $this->app->make(Connection::class);

Expand Down
5 changes: 4 additions & 1 deletion concrete/single_pages/dashboard/reports/logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ class="btn btn-secondary dropdown-toggle dropdown-toggle-split"

<?php foreach ($item->getColumns() as $column) { ?>
<?php /** @var ItemColumn $column */ ?>
<td>
<td <?php if ($column->getColumn() instanceof
\Concrete\Core\Logging\Search\ColumnSet\Column\MessageColumn) { ?>
class="text-break"
<?php } ?>>
<?php echo $column->getColumnValue(); ?>
</td>
<?php } ?>
Expand Down

0 comments on commit 747d5bf

Please sign in to comment.