forked from ZwiiCMS-Team/ZwiiCMS
protection changement module
This commit is contained in:
parent
96041f1842
commit
ef71b79225
|
@ -76,57 +76,57 @@ class page extends common {
|
|||
$this->addOutput([
|
||||
'access' => false
|
||||
]);
|
||||
} else {
|
||||
// Adresse sans le token
|
||||
$url = explode('&',$this->getUrl(2));
|
||||
// La page n'existe pas
|
||||
if($this->getData(['page', $url[0]]) === null) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'access' => false
|
||||
]);
|
||||
} // Jeton incorrect
|
||||
elseif(!isset($_GET['csrf'])) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||
'notification' => 'Jeton invalide'
|
||||
]);
|
||||
}
|
||||
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||
'notification' => 'Suppression non autorisée'
|
||||
]);
|
||||
}
|
||||
// Duplication de la page
|
||||
$pageTitle = $this->getData(['page',$url[0],'title']);
|
||||
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
|
||||
return;
|
||||
}
|
||||
// Adresse sans le token
|
||||
$url = explode('&',$this->getUrl(2));
|
||||
// La page n'existe pas
|
||||
if($this->getData(['page', $url[0]]) === null) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'access' => false
|
||||
]);
|
||||
} // Jeton incorrect
|
||||
elseif(!isset($_GET['csrf'])) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||
'notification' => 'Jeton invalide'
|
||||
]);
|
||||
}
|
||||
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||
'notification' => 'Suppression non autorisée'
|
||||
]);
|
||||
}
|
||||
// Duplication de la page
|
||||
$pageTitle = $this->getData(['page',$url[0],'title']);
|
||||
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
|
||||
$data = $this->getData([
|
||||
'page',
|
||||
$url[0]
|
||||
]);
|
||||
// Ecriture
|
||||
$this->setData (['page',$pageId,$data]);
|
||||
$notification = 'La page a été dupliquée';
|
||||
// Duplication du module présent
|
||||
if ($this->getData(['page',$url[0],'moduleId'])) {
|
||||
$data = $this->getData([
|
||||
'page',
|
||||
'module',
|
||||
$url[0]
|
||||
]);
|
||||
// Ecriture
|
||||
$this->setData (['page',$pageId,$data]);
|
||||
$notification = 'La page a été dupliquée';
|
||||
// Duplication du module présent
|
||||
if ($this->getData(['page',$url[0],'moduleId'])) {
|
||||
$data = $this->getData([
|
||||
'module',
|
||||
$url[0]
|
||||
]);
|
||||
// Ecriture
|
||||
$this->setData (['module',$pageId,$data]);
|
||||
$notification = 'La page et son module ont été dupliqués';
|
||||
}
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'page/edit/' . $pageId,
|
||||
'notification' => $notification,
|
||||
'state' => true
|
||||
]);
|
||||
$this->setData (['module',$pageId,$data]);
|
||||
$notification = 'La page et son module ont été dupliqués';
|
||||
}
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'page/edit/' . $pageId,
|
||||
'notification' => $notification,
|
||||
'state' => true
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -349,7 +349,8 @@ class page extends common {
|
|||
}
|
||||
}
|
||||
// Supprime les données du module en cas de changement de module
|
||||
if($this->getInput('pageEditModuleId') !== $this->getData(['page', $this->getUrl(2), 'moduleId'])) {
|
||||
if( !empty($this->getInput('pageEditModuleId') )
|
||||
AND $this->getInput('pageEditModuleId') !== $this->getData(['page', $this->getUrl(2), 'moduleId'])) {
|
||||
$this->deleteData(['module', $pageId]);
|
||||
}
|
||||
// Supprime l'ancienne page si l'id a changée
|
||||
|
|
|
@ -50,17 +50,17 @@ echo template::formOpen('pageEditForm');
|
|||
<div class="col4">
|
||||
<div class="row">
|
||||
<div class="col9">
|
||||
<?php echo template::hidden('pageEditModuleRedirect'); ?>
|
||||
<?php echo template::select('pageEditModuleId', $module::$moduleIds, [
|
||||
'help' => 'En cas de changement de module, les données du module précédent seront supprimées.',
|
||||
'label' => 'Module',
|
||||
'selected' => $this->getData(['page', $this->getUrl(2), 'moduleId']),
|
||||
'disabled' => !($module::$actions['delete'] < $this->getUser('group'))
|
||||
]); ?>
|
||||
<?php echo template::hidden('pageEditModuleIdOld',['value' => $this->getData(['page', $this->getUrl(2), 'moduleId'])]); ?>
|
||||
<?php echo template::hidden('pageEditModuleIdOldText',[
|
||||
'value' => array_key_exists($this->getData(['page', $this->getUrl(2), 'moduleId']),$module::$moduleNames)? $module::$moduleNames[$this->getData(['page', $this->getUrl(2), 'moduleId'])] : ucfirst($this->getData(['page', $this->getUrl(2), 'moduleId']))
|
||||
]); ?>
|
||||
<?php echo template::hidden('pageEditModuleRedirect'); ?>
|
||||
<?php echo template::select('pageEditModuleId', $listModules, [
|
||||
'help' => 'En cas de changement de module, les données du module précédent seront supprimées.',
|
||||
'label' => 'Module',
|
||||
'selected' => $this->getData(['page', $this->getUrl(2), 'moduleId'])
|
||||
]); ?>
|
||||
<!-- Confirmation de suppression e ca sd'annulation -->
|
||||
<?php echo template::hidden('pageEditModuleIdOld',['value' => $this->getData(['page', $this->getUrl(2), 'moduleId'])]); ?>
|
||||
<?php echo template::hidden('pageEditModuleIdOldText',[
|
||||
'value' => array_key_exists($this->getData(['page', $this->getUrl(2), 'moduleId']),$module::$moduleNames)? $module::$moduleNames[$this->getData(['page', $this->getUrl(2), 'moduleId'])] : ucfirst($this->getData(['page', $this->getUrl(2), 'moduleId']))
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col3 verticalAlignBottom">
|
||||
<?php echo template::button('pageEditModuleConfig', [
|
||||
|
|
Loading…
Reference in New Issue