Skip to content

Commit

Permalink
Fix previous route on admin/event-plannings
Browse files Browse the repository at this point in the history
  • Loading branch information
catdesu committed May 2, 2024
1 parent b41008e commit ee2665d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
3 changes: 2 additions & 1 deletion orif/timbreuse/Controllers/EventPlannings.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ public function initController(
*/
#[\Override]
public function index(?int $timUserId = null) : string {
session()->remove('event_previous_url');

$data['title'] = lang('tim_lang.event_plannings_list');
$data['list_title'] = ucfirst(lang('tim_lang.event_plannings_list'));
$data['isVisible'] = true;
$data['route'] = '';

$data['columns'] = [
'group_or_user_name' => ucfirst(lang('tim_lang.group_or_user_name')),
Expand Down
27 changes: 13 additions & 14 deletions orif/timbreuse/Controllers/PersonalEventPlannings.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function initController(
* @return string
*/
public function index(?int $timUserId = null) : string|RedirectResponse {
session()->remove('event_previous_url');
$isAdminView = $_SESSION['user_access'] === config('\User\Config\UserConfig')->access_lvl_admin;
$eventPlannigRoute = ($isAdminView ? 'admin/' : '') . 'event-plannings/';

Expand Down Expand Up @@ -121,7 +122,7 @@ public function createPersonal(?int $userId = null) : string|RedirectResponse {
'Timbreuse\Views\eventPlannings\get_event_series_form'
];
$isAdminView = url_is('*admin*');
$route = $this->getPreviousRoute($isAdminView, $userId);
$route = $this->getPreviousRoute();

$eventTypes = $this->eventTypesModel->where('is_personal_event_type', true)->findAll();

Expand Down Expand Up @@ -273,7 +274,7 @@ public function updatePersonal(int $id, ?int $userId = 0) : string|RedirectRespo

$user = $this->userSyncModel->find($userId);

$route = $this->getPreviousRoute($isAdminView, $user['id_user'] ?? null);
$route = $this->getPreviousRoute();


$data = [
Expand Down Expand Up @@ -384,7 +385,7 @@ public function delete(int $id, int $action = 0) : string|RedirectResponse {
$userId = $eventPlanning['fk_user_sync_id'];
}

$route = $this->getPreviousRoute($isAdminView, $userId);
$route = $this->getPreviousRoute();

if (!((int)$eventPlanning['fk_user_sync_id'] == $this->getConnectedTimuserId()
|| $isUserAdmin)) {
Expand Down Expand Up @@ -504,20 +505,18 @@ protected function getConnectedTimuserId() : int|null {
* @param ?int $userId
* @return string
*/
public function getPreviousRoute(bool $isAdminView, ?int $userId = null) : string {
$route = '';

if ($isAdminView) {
$route .= 'admin/';
}
public function getPreviousRoute() : string {
$isAdminView = url_is('*admin*');

$route .= 'event-plannings/';
if (!$isAdminView) {
return base_url('event-plannings');
} else if (isset($_SESSION['event_previous_url'])) {
return $_SESSION['event_previous_url'];
} else {
$_SESSION['event_previous_url'] = $_SESSION['_ci_previous_url'];

if (!$isAdminView && !is_null($userId)) {
$route .= $userId;
return $_SESSION['event_previous_url'];
}

return $route;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<?= form_open(current_url()) ?>
<div class="row mb-3 mt-3">
<div class="col text-right">
<a class="btn btn-secondary" href="<?= base_url($returnRoute); ?>"><?= lang('common_lang.btn_cancel'); ?></a>
<a class="btn btn-secondary" href="<?= $returnRoute; ?>"><?= lang('common_lang.btn_cancel'); ?></a>
<?= form_submit($btnOccurrence, lang("tim_lang.$btnOccurrence"), ['class' => 'btn btn-primary']); ?>
<?= form_submit($btnSerie, lang("tim_lang.$btnSerie"), ['class' => 'btn btn-primary']); ?>
</div>
Expand Down
2 changes: 1 addition & 1 deletion orif/timbreuse/Views/eventPlannings/confirm_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<h4><?= lang('user_lang.what_to_do') ?></h4>
</div>
<div class="text-right">
<a href="<?= base_url($route); ?>" class="btn btn-secondary">
<a href="<?= $route; ?>" class="btn btn-secondary">
<?= lang('common_lang.btn_cancel'); ?>
</a>
<button class="btn btn-danger" data-toggle="modal" data-target="#confirmDeleteEventType">
Expand Down
2 changes: 1 addition & 1 deletion orif/timbreuse/Views/eventPlannings/personal/save_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<!-- FORM BUTTONS -->
<div class="row mb-3 mt-3">
<div class="col text-right">
<a class="btn btn-secondary" href="<?= base_url($route); ?>"><?= lang('common_lang.btn_cancel'); ?></a>
<a class="btn btn-secondary" href="<?= $route; ?>"><?= lang('common_lang.btn_cancel'); ?></a>
<?= form_submit('save', lang('common_lang.btn_save'), ['class' => 'btn btn-primary']); ?>
</div>
</div>
Expand Down

0 comments on commit ee2665d

Please sign in to comment.