Fix bugs pages

This commit is contained in:
Fred Tempez 2023-07-03 19:49:39 +02:00
parent 2cabb31734
commit 38ed0dc1aa
1 changed files with 81 additions and 79 deletions

View File

@ -74,19 +74,15 @@ class page extends common
// Adresse sans le token // Adresse sans le token
$page = $this->getUrl(2); $page = $this->getUrl(2);
// La page n'existe pas // La page n'existe pas
if ($this->getData(['page', $page]) === null) { if (
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true ||
$this->getData(['page', $page]) === null
) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
]); ]);
} // Action interdite } else {
elseif ($this->checkCSRF()) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $page,
'notification' => helper::translate('Jeton invalide')
]);
}
// Duplication de la page // Duplication de la page
$pageTitle = $this->getData(['page', $page, 'title']); $pageTitle = $this->getData(['page', $page, 'title']);
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page'])); $pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
@ -101,14 +97,11 @@ class page extends common
$notification = helper::translate('Page dupliquée'); $notification = helper::translate('Page dupliquée');
// Duplication du module présent // Duplication du module présent
if ($this->getData(['page', $page, 'moduleId'])) { if ($this->getData(['page', $page, 'moduleId'])) {
$data = $this->getData([ $data = $this->getData(['module', $page]);
'module',
$page
]);
// Ecriture
$this->setData(['module', $pageId, $data]); $this->setData(['module', $pageId, $data]);
$notification = helper::translate('Page et module dupliqués'); $notification = helper::translate('Page et module dupliqués');
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $pageId, 'redirect' => helper::baseUrl() . 'page/edit/' . $pageId,
@ -116,6 +109,7 @@ class page extends common
'state' => true 'state' => true
]); ]);
} }
}
/** /**
@ -123,6 +117,12 @@ class page extends common
*/ */
public function add() public function add()
{ {
if ($this->getUser('permission', __CLASS__, __FUNCTION__) !== true) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
} else {
$pageTitle = 'Nouvelle page'; $pageTitle = 'Nouvelle page';
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page'])); $pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
$this->setData([ $this->setData([
@ -174,6 +174,8 @@ class page extends common
]); ]);
} }
}
/** /**
* Suppression * Suppression
*/ */