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