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