Modif Sylvain

This commit is contained in:
Fred Tempez 2020-10-11 18:42:54 +02:00
parent ef71b79225
commit 87d2e22577
12 changed files with 324 additions and 354 deletions

6
.gitignore vendored
View File

@ -36,9 +36,3 @@ site/data/journal.log
.DS_Store .DS_Store
site/.DS_Store site/.DS_Store
site/file/.DS_Store site/file/.DS_Store
site/tmp/5f7f5e998762c.png
site/tmp/5f7f5e9987628.png
site/tmp/5f7f5ea3e983b.png
site/tmp/5f7f5ea3e9837.png
site/tmp/5f7f5ea20d5eb.png
site/tmp/5f7f5ea20d5ee.png

View File

@ -64,7 +64,7 @@ class template {
$html = '<div class="captcha" id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">'; $html = '<div class="captcha" id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Label // Label
$html .= self::label($attributes['id'], $html .= self::label($attributes['id'],
'<img src="' . helper::baseUrl(false) . 'site/tmp/' . $firstLetter . '.png" />' . template::ico('plus') . '<img class="captchaNumber" src="' . helper::baseUrl(false) . 'site/tmp/' . $secondLetter . '.png" /> en chiffres ?', [ '<img src="' . helper::baseUrl(false) . 'site/tmp/' . $firstLetter . '.png" />' . template::ico('plus') . '<img class="captchaNumber" src="' . helper::baseUrl(false) . 'site/tmp/' . $secondLetter . '.png" /> en chiffres ?', [
'help' => $attributes['help'] 'help' => $attributes['help']
]); ]);
// Notice // Notice

View File

@ -1797,6 +1797,8 @@ class core extends common {
} }
// Check l'accès à la page // Check l'accès à la page
$access = null; $access = null;
$accessInfo['userName'] = '';
$accessInfo['pageId'] = '';
if($this->getData(['page', $this->getUrl(0)]) !== null) { if($this->getData(['page', $this->getUrl(0)]) !== null) {
if( if(
$this->getData(['page', $this->getUrl(0), 'group']) === self::GROUP_VISITOR $this->getData(['page', $this->getUrl(0), 'group']) === self::GROUP_VISITOR
@ -1816,6 +1818,7 @@ class core extends common {
} }
} }
} }
/** /**
* Contrôle si la page demandée est en édition ou accès à la gestion du site * Contrôle si la page demandée est en édition ou accès à la gestion du site
* conditions de blocage : * conditions de blocage :
@ -1824,8 +1827,6 @@ class core extends common {
* - Une partie de l'URL fait partie de la liste de filtrage (édition d'un module etc..) * - Une partie de l'URL fait partie de la liste de filtrage (édition d'un module etc..)
* - L'édition est ouverte depuis un temps dépassé, on considère que la page est restée ouverte et qu'elle ne sera pas validée * - L'édition est ouverte depuis un temps dépassé, on considère que la page est restée ouverte et qu'elle ne sera pas validée
*/ */
$accessInfo['userName'] = '';
$accessInfo['pageId'] = '';
foreach($this->getData(['user']) as $userId => $userIds){ foreach($this->getData(['user']) as $userId => $userIds){
$t = explode('/',$this->getData(['user', $userId, 'accessUrl'])); $t = explode('/',$this->getData(['user', $userId, 'accessUrl']));
if ( $this->getuser('id') && if ( $this->getuser('id') &&

View File

@ -70,14 +70,6 @@ class page extends common {
* Duplication * Duplication
*/ */
public function duplicate() { public function duplicate() {
// Contrôle d'accès
if ( self::$actions[__FUNCTION__] >= $this->getUser('group')) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
return;
}
// Adresse sans le token // Adresse sans le token
$url = explode('&',$this->getUrl(2)); $url = explode('&',$this->getUrl(2));
// La page n'existe pas // La page n'existe pas
@ -134,14 +126,6 @@ class page extends common {
* Création * Création
*/ */
public function add() { public function add() {
// Contrôle d'accès
if ( self::$actions[__FUNCTION__] >= $this->getUser('group')) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
return;
}
$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([
@ -150,7 +134,7 @@ class page extends common {
[ [
'typeMenu' => 'text', 'typeMenu' => 'text',
'iconUrl' => '', 'iconUrl' => '',
'disable' => false, 'disable' => false,
'content' => 'Contenu de votre nouvelle page.', 'content' => 'Contenu de votre nouvelle page.',
'hideTitle' => false, 'hideTitle' => false,
'breadCrumb' => false, 'breadCrumb' => false,
@ -186,14 +170,6 @@ class page extends common {
* Suppression * Suppression
*/ */
public function delete() { public function delete() {
// Contrôle d'accès
if ( self::$actions[__FUNCTION__] >= $this->getUser('group')) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
return;
}
// $url prend l'adresse sans le token // $url prend l'adresse sans le token
$url = explode('&',$this->getUrl(2)); $url = explode('&',$this->getUrl(2));
// La page n'existe pas // La page n'existe pas
@ -290,11 +266,11 @@ class page extends common {
} }
// Suppression // Suppression
else { else {
// Met à jour le site map
$this->createSitemap('all');
// Effacer la page // Effacer la page
$this->deleteData(['page', $url[0]]); $this->deleteData(['page', $url[0]]);
$this->deleteData(['module', $url[0]]); $this->deleteData(['module', $url[0]]);
// Met à jour le site map
$this->createSitemap('all');
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl(false), 'redirect' => helper::baseUrl(false),
@ -315,199 +291,206 @@ class page extends common {
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
]); ]);
return;
} }
// La page existe // La page existe
// Soumission du formulaire else {
if($this->isPost()) { // Soumission du formulaire
// Génére l'ID si le titre de la page a changé if($this->isPost()) {
if ( $this->getInput('pageEditTitle') !== $this->getData(['page',$this->getUrl(2),'title']) ) { // Génére l'ID si le titre de la page a changé
$pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true); if ( $this->getInput('pageEditTitle') !== $this->getData(['page',$this->getUrl(2),'title']) ) {
} else { $pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true);
$pageId = $this->getUrl(2);
}
// un dossier existe du même nom (erreur en cas de redirection)
if (file_exists($pageId)) {
$pageId = uniqid($pageId);
}
// Si l'id a changée
if ($pageId !== $this->getUrl(2)) {
// Incrémente le nouvel id de la page
$pageId = helper::increment($pageId, $this->getData(['page']));
$pageId = helper::increment($pageId, self::$coreModuleIds);
$pageId = helper::increment($pageId, self::$moduleIds);
// Met à jour les enfants
foreach($this->getHierarchy($this->getUrl(2)) as $childrenPageId) {
$this->setData(['page', $childrenPageId, 'parentPageId', $pageId]);
}
// Change l'id de page dans les données des modules
$this->setData(['module', $pageId, $this->getData(['module', $this->getUrl(2)])]);
$this->deleteData(['module', $this->getUrl(2)]);
// Si la page correspond à la page d'accueil, change l'id dans la configuration du site
if($this->getData(['config', 'homePageId']) === $this->getUrl(2)) {
$this->setData(['config', 'homePageId', $pageId]);
}
}
// Supprime les données du module en cas de changement de module
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
if($pageId !== $this->getUrl(2)) {
$this->deleteData(['page', $this->getUrl(2)]);
}
// Traitement des pages spéciales affectées dans la config :
if ($this->getUrl(2) === $this->getData(['config', 'legalPageId']) ) {
$this->setData(['config','legalPageId', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'searchPageId']) ) {
$this->setData(['config','searchPageId', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page404']) ) {
$this->setData(['config','page404', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page403']) ) {
$this->setData(['config','page403', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page302']) ) {
$this->setData(['config','page302', $pageId]);
}
// Si la page est une page enfant, actualise les positions des autres enfants du parent, sinon actualise les pages sans parents
$lastPosition = 1;
$hierarchy = $this->getInput('pageEditParentPageId') ? $this->getHierarchy($this->getInput('pageEditParentPageId')) : array_keys($this->getHierarchy());
$position = $this->getInput('pageEditPosition', helper::FILTER_INT);
foreach($hierarchy as $hierarchyPageId) {
// Ignore la page en cours de modification
if($hierarchyPageId === $this->getUrl(2)) {
continue;
}
// Incrémente de +1 pour laisser la place à la position de la page en cours de modification
if($lastPosition === $position) {
$lastPosition++;
}
// Change la position
$this->setData(['page', $hierarchyPageId, 'position', $lastPosition]);
// Incrémente pour la prochaine position
$lastPosition++;
}
if ($this->getinput('pageEditBlock') !== 'bar') {
$barLeft = $this->getinput('pageEditBarLeft');
$barRight = $this->getinput('pageEditBarRight');
$hideTitle = $this->getInput('pageEditHideTitle', helper::FILTER_BOOLEAN);
} else {
// Une barre ne peut pas avoir de barres
$barLeft = "";
$barRight = "";
// Une barre est masquée
$position = 0;
$hideTitle = true;
}
// Modifie la page ou en crée une nouvelle si l'id a changé
$this->setData([
'page',
$pageId,
[
'typeMenu' => $this->getinput('pageTypeMenu'),
'iconUrl' => $this->getinput('pageIconUrl'),
'disable'=> $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN),
'content' => (empty($this->getInput('pageEditContent', null)) ? '<p>&nbsp;</p>' : $this->getInput('pageEditContent', null)),
'hideTitle' => $hideTitle,
'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN),
'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG),
'metaTitle' => $this->getInput('pageEditMetaTitle'),
'moduleId' => $this->getInput('pageEditModuleId'),
'modulePosition' => $this->getInput('configModulePosition'),
'parentPageId' => $this->getInput('pageEditParentPageId'),
'position' => $position,
'group' => $this->getinput('pageEditBlock') !== 'bar' ? $this->getInput('pageEditGroup', helper::FILTER_INT) : 0,
'targetBlank' => $this->getInput('pageEditTargetBlank', helper::FILTER_BOOLEAN),
'title' => $this->getInput('pageEditTitle', helper::FILTER_STRING_SHORT),
'block' => $this->getinput('pageEditBlock'),
'barLeft' => $barLeft,
'barRight' => $barRight,
'displayMenu' => $this->getinput('pageEditDisplayMenu'),
'hideMenuSide' => $this->getinput('pageEditHideMenuSide', helper::FILTER_BOOLEAN),
'hideMenuHead' => $this->getinput('pageEditHideMenuHead', helper::FILTER_BOOLEAN),
'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN),
]
]);
// Barre renommée : changement le nom de la barre dans les pages mères
if ($this->getinput('pageEditBlock') === 'bar') {
foreach ($this->getHierarchy() as $eachPageId=>$parentId) {
if ($this->getData(['page',$eachPageId,'barRight']) === $this->getUrl(2)) {
$this->setData(['page',$eachPageId,'barRight',$pageId]);
}
if ($this->getData(['page',$eachPageId,'barLeft']) === $this->getUrl(2)) {
$this->setData(['page',$eachPageId,'barLeft',$pageId]);
}
foreach ($parentId as $childId) {
if ($this->getData(['page',$childId,'barRight']) === $this->getUrl(2)) {
$this->setData(['page',$childId,'barRight',$pageId]);
}
if ($this->getData(['page',$childId,'barLeft']) === $this->getUrl(2)) {
$this->setData(['page',$childId,'barLeft',$pageId]);
}
}
}
}
// Met à jour le site map
$this->createSitemap('all');
// Redirection vers la configuration
if($this->getInput('pageEditModuleRedirect', helper::FILTER_BOOLEAN)) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $pageId . '/config',
'state' => true
]);
}
// Redirection vers la page
else {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $pageId,
'notification' => 'Modifications enregistrées',
'state' => true
]);
}
}
// Liste des modules
$moduleIds = [];
$iterator = new DirectoryIterator('module/');
foreach($iterator as $fileInfos) {
if(is_file($fileInfos->getPathname() . '/' . $fileInfos->getFilename() . '.php')) {
if (array_key_exists($fileInfos->getBasename(),self::$moduleNames)) {
$moduleIds[$fileInfos->getBasename()] = self::$moduleNames[$fileInfos->getBasename()];
} else { } else {
$moduleIds[$fileInfos->getBasename()] = ucfirst($fileInfos->getBasename()); $pageId = $this->getUrl(2);
}
// un dossier existe du même nom (erreur en cas de redirection)
if (file_exists($pageId)) {
$pageId = uniqid($pageId);
}
// Si l'id a changée
if ($pageId !== $this->getUrl(2)) {
// Incrémente le nouvel id de la page
$pageId = helper::increment($pageId, $this->getData(['page']));
$pageId = helper::increment($pageId, self::$coreModuleIds);
$pageId = helper::increment($pageId, self::$moduleIds);
// Met à jour les enfants
foreach($this->getHierarchy($this->getUrl(2)) as $childrenPageId) {
$this->setData(['page', $childrenPageId, 'parentPageId', $pageId]);
}
// Change l'id de page dans les données des modules
$this->setData(['module', $pageId, $this->getData(['module', $this->getUrl(2)])]);
$this->deleteData(['module', $this->getUrl(2)]);
// Si la page correspond à la page d'accueil, change l'id dans la configuration du site
if($this->getData(['config', 'homePageId']) === $this->getUrl(2)) {
$this->setData(['config', 'homePageId', $pageId]);
}
}
// Pour éditeurs et adminisrateurs
if( $this->getUser('group') >= self::GROUP_MODERATOR){
// Supprime les données du module en cas de changement de module
if( $this->getInput('pageEditModuleId') !== $this->getData(['page', $this->getUrl(2), 'moduleId'])) {
$this->deleteData(['module', $pageId]);
}
// Supprime l'ancienne page si l'id a changée
if($pageId !== $this->getUrl(2)) {
$this->deleteData(['page', $this->getUrl(2)]);
}
// Traitement des pages spéciales affectées dans la config :
if ($this->getUrl(2) === $this->getData(['config', 'legalPageId']) ) {
$this->setData(['config','legalPageId', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'searchPageId']) ) {
$this->setData(['config','searchPageId', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page404']) ) {
$this->setData(['config','page404', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page403']) ) {
$this->setData(['config','page403', $pageId]);
}
if ($this->getUrl(2) === $this->getData(['config', 'page302']) ) {
$this->setData(['config','page302', $pageId]);
}
// Si la page est une page enfant, actualise les positions des autres enfants du parent, sinon actualise les pages sans parents
$lastPosition = 1;
$hierarchy = $this->getInput('pageEditParentPageId') ? $this->getHierarchy($this->getInput('pageEditParentPageId')) : array_keys($this->getHierarchy());
$position = $this->getInput('pageEditPosition', helper::FILTER_INT);
foreach($hierarchy as $hierarchyPageId) {
// Ignore la page en cours de modification
if($hierarchyPageId === $this->getUrl(2)) {
continue;
}
// Incrémente de +1 pour laisser la place à la position de la page en cours de modification
if($lastPosition === $position) {
$lastPosition++;
}
// Change la position
$this->setData(['page', $hierarchyPageId, 'position', $lastPosition]);
// Incrémente pour la prochaine position
$lastPosition++;
}
if ($this->getinput('pageEditBlock') !== 'bar') {
$barLeft = $this->getinput('pageEditBarLeft');
$barRight = $this->getinput('pageEditBarRight');
$hideTitle = $this->getInput('pageEditHideTitle', helper::FILTER_BOOLEAN);
} else {
// Une barre ne peut pas avoir de barres
$barLeft = "";
$barRight = "";
// Une barre est masquée
$position = 0;
$hideTitle = true;
}
// Modifie la page ou en crée une nouvelle si l'id a changé
$this->setData([
'page',
$pageId,
[
'typeMenu' => $this->getinput('pageTypeMenu'),
'iconUrl' => $this->getinput('pageIconUrl'),
'disable'=> $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN),
'content' => (empty($this->getInput('pageEditContent', null)) ? '<p>&nbsp;</p>' : $this->getInput('pageEditContent', null)),
'hideTitle' => $hideTitle,
'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN),
'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG),
'metaTitle' => $this->getInput('pageEditMetaTitle'),
'moduleId' => $this->getInput('pageEditModuleId'),
'modulePosition' => $this->getInput('configModulePosition'),
'parentPageId' => $this->getInput('pageEditParentPageId'),
'position' => $position,
'group' => $this->getinput('pageEditBlock') !== 'bar' ? $this->getInput('pageEditGroup', helper::FILTER_INT) : 0,
'targetBlank' => $this->getInput('pageEditTargetBlank', helper::FILTER_BOOLEAN),
'title' => $this->getInput('pageEditTitle', helper::FILTER_STRING_SHORT),
'block' => $this->getinput('pageEditBlock'),
'barLeft' => $barLeft,
'barRight' => $barRight,
'displayMenu' => $this->getinput('pageEditDisplayMenu'),
'hideMenuSide' => $this->getinput('pageEditHideMenuSide', helper::FILTER_BOOLEAN),
'hideMenuHead' => $this->getinput('pageEditHideMenuHead', helper::FILTER_BOOLEAN),
'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN),
]
]);
// Barre renommée : changement le nom de la barre dans les pages mères
if ($this->getinput('pageEditBlock') === 'bar') {
foreach ($this->getHierarchy() as $eachPageId=>$parentId) {
if ($this->getData(['page',$eachPageId,'barRight']) === $this->getUrl(2)) {
$this->setData(['page',$eachPageId,'barRight',$pageId]);
}
if ($this->getData(['page',$eachPageId,'barLeft']) === $this->getUrl(2)) {
$this->setData(['page',$eachPageId,'barLeft',$pageId]);
}
foreach ($parentId as $childId) {
if ($this->getData(['page',$childId,'barRight']) === $this->getUrl(2)) {
$this->setData(['page',$childId,'barRight',$pageId]);
}
if ($this->getData(['page',$childId,'barLeft']) === $this->getUrl(2)) {
$this->setData(['page',$childId,'barLeft',$pageId]);
}
}
}
}
}
// Sinon pour le rédacteur seul le contenu peut changer
else{
$this->setData(['page', $pageId, 'content', (empty($this->getInput('pageEditContent', null)) ? '<p>&nbsp;</p>' : $this->getInput('pageEditContent', null))]);
}
// Met à jour le site map
$this->createSitemap('all');
// Redirection vers la configuration
if($this->getInput('pageEditModuleRedirect', helper::FILTER_BOOLEAN)) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $pageId . '/config',
'state' => true
]);
}
// Redirection vers la page
else {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $pageId,
'notification' => 'Modifications enregistrées',
'state' => true
]);
} }
} }
} // Liste des modules
self::$moduleIds = $moduleIds; $moduleIds = [];
asort(self::$moduleIds); $iterator = new DirectoryIterator('module/');
self::$moduleIds = array_merge( ['' => 'Aucun'] , self::$moduleIds); foreach($iterator as $fileInfos) {
// Pages sans parent if(is_file($fileInfos->getPathname() . '/' . $fileInfos->getFilename() . '.php')) {
foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) { if (array_key_exists($fileInfos->getBasename(),self::$moduleNames)) {
if($parentPageId !== $this->getUrl(2)) { $moduleIds[$fileInfos->getBasename()] = self::$moduleNames[$fileInfos->getBasename()];
self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); } else {
} $moduleIds[$fileInfos->getBasename()] = ucfirst($fileInfos->getBasename());
} }
// Pages barre latérales
foreach($this->getHierarchy(null,false,true) as $parentPageId => $childrenPageIds) {
if($parentPageId !== $this->getUrl(2) &&
$this->getData(['page', $parentPageId, 'block']) === 'bar') {
self::$pagesBarId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
} }
}
self::$moduleIds = $moduleIds;
asort(self::$moduleIds);
self::$moduleIds = array_merge( ['' => 'Aucun'] , self::$moduleIds);
// Pages sans parent
foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) {
if($parentPageId !== $this->getUrl(2)) {
self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
}
}
// Pages barre latérales
foreach($this->getHierarchy(null,false,true) as $parentPageId => $childrenPageIds) {
if($parentPageId !== $this->getUrl(2) &&
$this->getData(['page', $parentPageId, 'block']) === 'bar') {
self::$pagesBarId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
}
}
// Valeurs en sortie
$this->addOutput([
'title' => $this->getData(['page', $this->getUrl(2), 'title']),
'vendor' => [
'tinymce'
],
'view' => 'edit'
]);
} }
// Valeurs en sortie
$this->addOutput([
'title' => $this->getData(['page', $this->getUrl(2), 'title']),
'vendor' => [
'tinymce'
],
'view' => 'edit'
]);
} }
} }

View File

@ -1,9 +1,10 @@
<?php <?php
echo template::formOpen('pageEditForm'); echo template::formOpen('pageEditForm');
// Mise à jour de la liste des pages pour TinyMCE // Mise à jour de la liste des pages pour TinyMCE
$this->pages2Json(); ?> $this->pages2Json();
// Validation des buttons réservés aux modérateurs et administrateurs
<div class="row"> <div class="row">
<div class="col2"> <div class="col2">
<?php $href = helper::baseUrl() . $this->getUrl(2); ?> <?php $href = helper::baseUrl() . $this->getUrl(2); ?>
<?php if ($this->getData(['page', $this->getUrl(2), 'moduleId']) === 'redirection' || 'code')$href = helper::baseUrl(); ?> <?php if ($this->getData(['page', $this->getUrl(2), 'moduleId']) === 'redirection' || 'code')$href = helper::baseUrl(); ?>
<?php echo template::button('pageEditBack', [ <?php echo template::button('pageEditBack', [
@ -14,23 +15,23 @@ echo template::formOpen('pageEditForm');
]); ?> ]); ?>
</div> </div>
<div class="col2 offset4"> <div class="col2 offset4">
<?php if ( $module::$actions['duplicate'] < $this->getUser('group')): ?> <?php if( $this->getUser('group') >= self::GROUP_MODERATOR ){
<?php echo template::button('pageEditDuplicate', [ echo template::button('pageEditDuplicate', [
'href' => helper::baseUrl() . 'page/duplicate/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'], 'href' => helper::baseUrl() . 'page/duplicate/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'],
'value' => 'Dupliquer', 'value' => 'Dupliquer',
'ico' => 'clone' 'ico' => 'clone'
]); ?> ]);
<?php endif;?> }?>
</div> </div>
<div class="col2"> <div class="col2">
<?php if ( $module::$actions['delete'] < $this->getUser('group')): ?> <?php if( $this->getUser('group') >= self::GROUP_MODERATOR ){
<?php echo template::button('pageEditDelete', [ echo template::button('pageEditDelete', [
'class' => 'buttonRed', 'class' => 'buttonRed',
'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'], 'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'],
'value' => 'Supprimer', 'value' => 'Supprimer',
'ico' => 'cancel' 'ico' => 'cancel'
]); ?> ]);
<?php endif;?> }?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::submit('pageEditSubmit'); ?> <?php echo template::submit('pageEditSubmit'); ?>
@ -51,23 +52,25 @@ echo template::formOpen('pageEditForm');
<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', $listModules, [ <?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.', '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' => $this->getUser('group') >= self::GROUP_MODERATOR ? false : true
]); ?> ]); ?>
<!-- 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 if( $this->getUser('group') >= self::GROUP_MODERATOR){
'disabled' => (bool) $this->getData(['page', $this->getUrl(2), 'moduleId']) === false, echo template::button('pageEditModuleConfig', [
'uniqueSubmission' => true, 'disabled' => (bool) $this->getData(['page', $this->getUrl(2), 'moduleId']) === false,
'value' => template::ico('gear') 'uniqueSubmission' => true,
]); ?> 'value' => template::ico('gear')
]);
}?>
</div> </div>
</div> </div>
</div> </div>
@ -90,7 +93,8 @@ echo template::formOpen('pageEditForm');
<?php echo template::select('configModulePosition', $module::$modulePosition,[ <?php echo template::select('configModulePosition', $module::$modulePosition,[
'help' => 'En position libre ajoutez le module en plaçant [MODULE] à l\'endroit voulu dans votre page.', 'help' => 'En position libre ajoutez le module en plaçant [MODULE] à l\'endroit voulu dans votre page.',
'label' => 'Position du module', 'label' => 'Position du module',
'selected' => $this->getData(['page', $this->getUrl(2), 'modulePosition']) 'selected' => $this->getData(['page', $this->getUrl(2), 'modulePosition']),
'disabled' => $this->getUser('group') >= self::GROUP_MODERATOR ? false : true
]); ?> ]); ?>
</div> </div>
</div> </div>
@ -162,6 +166,7 @@ echo template::formOpen('pageEditForm');
</div> </div>
</div> </div>
</div> </div>
<?php if( $this->getUser('group') >= self::GROUP_MODERATOR){ ?>
<div class="row"> <div class="row">
<div class="col12" id="pageEditMenu"> <div class="col12" id="pageEditMenu">
<div class="block" id="location"> <div class="block" id="location">
@ -289,4 +294,4 @@ echo template::formOpen('pageEditForm');
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php } echo template::formClose(); ?>

View File

@ -367,6 +367,7 @@ class user extends common {
// Check la captcha // Check la captcha
if( if(
$this->getData(['config','connect','captcha']) $this->getData(['config','connect','captcha'])
//$this->getInput('userLoginCaptcha', helper::FILTER_INT) !== $this->getInput('userLoginCaptchaFirstNumber', helper::FILTER_INT) + $this->getInput('userLoginCaptchaSecondNumber', helper::FILTER_INT))
AND password_verify($this->getInput('userLoginCaptcha', helper::FILTER_INT), $this->getInput('userLoginCaptchaResult') ) === false ) AND password_verify($this->getInput('userLoginCaptcha', helper::FILTER_INT), $this->getInput('userLoginCaptchaResult') ) === false )
{ {
self::$inputNotices['userLoginCaptcha'] = 'Incorrect'; self::$inputNotices['userLoginCaptcha'] = 'Incorrect';
@ -444,7 +445,6 @@ class user extends common {
$this->addOutput([ $this->addOutput([
'notification' => 'Connexion réussie', 'notification' => 'Connexion réussie',
'redirect' => helper::baseUrl(), 'redirect' => helper::baseUrl(),
//'redirect' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))),
'state' => true 'state' => true
]); ]);
} }

View File

@ -13,6 +13,16 @@ ob_start('mb_output_handler');
date_default_timezone_set('Europe/Paris'); date_default_timezone_set('Europe/Paris');
setlocale(LC_CTYPE, 'fr_FR'); //correct transliteration setlocale(LC_CTYPE, 'fr_FR'); //correct transliteration
// Validation des actions (delete, rename) par lecture du groupe de l'utilisateur via cookie et user.json
if( is_file('../../../site/data/user.json')){
$json = file_get_contents('../../../site/data/user.json');
}
else{
$json = '{}';
}
$user = json_decode($json, true);
$val = $user['user'][$_COOKIE["ZWII_USER_ID"]]['group'] >= 3 ? true : false;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Optional security | Optional security
@ -336,18 +346,18 @@ $config = array(
//************************* //*************************
//Permissions configuration //Permissions configuration
//****************** //******************
'delete_files' => true, 'delete_files' => $val,
'create_folders' => true, 'create_folders' => true,
'delete_folders' => true, 'delete_folders' => $val,
'upload_files' => true, 'upload_files' => true,
'rename_files' => true, 'rename_files' => $val,
'rename_folders' => true, 'rename_folders' => $val,
'duplicate_files' => true, 'duplicate_files' => true,
'extract_files' => true, 'extract_files' => true,
'copy_cut_files' => true, // for copy/cut files 'copy_cut_files' => $val, // for copy/cut files
'copy_cut_dirs' => true, // for copy/cut directories 'copy_cut_dirs' => $val, // for copy/cut directories
'chmod_files' => true, // change file permissions 'chmod_files' => $val, // change file permissions
'chmod_dirs' => true, // change folder permissions 'chmod_dirs' => $val, // change folder permissions
'preview_text_files' => true, // eg.: txt, log etc. 'preview_text_files' => true, // eg.: txt, log etc.
'edit_text_files' => true, // eg.: txt, log etc. 'edit_text_files' => true, // eg.: txt, log etc.
'create_text_files' => true, // only create files with exts. defined in $config['editable_text_file_exts'] 'create_text_files' => true, // only create files with exts. defined in $config['editable_text_file_exts']

View File

@ -21,12 +21,12 @@ class blog extends common {
const EDIT_ADMIN = '03'; // Groupe des admin const EDIT_ADMIN = '03'; // Groupe des admin
public static $actions = [ public static $actions = [
'add' => self::GROUP_EDITOR, 'add' => self::GROUP_MODERATOR,
'comment' => self::GROUP_MODERATOR, 'comment' => self::GROUP_MODERATOR,
'commentApprove' => self::GROUP_MODERATOR, 'commentApprove' => self::GROUP_MODERATOR,
'commentDelete' => self::GROUP_MODERATOR, 'commentDelete' => self::GROUP_MODERATOR,
'commentDeleteAll' => self::GROUP_MODERATOR, 'commentDeleteAll' => self::GROUP_MODERATOR,
'config' => self::GROUP_EDITOR, 'config' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR, 'delete' => self::GROUP_MODERATOR,
'edit' => self::GROUP_EDITOR, 'edit' => self::GROUP_EDITOR,
'index' => self::GROUP_VISITOR 'index' => self::GROUP_VISITOR
@ -375,37 +375,29 @@ class blog extends common {
* Suppression * Suppression
*/ */
public function delete() { public function delete() {
// Contrôle d'accès if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) {
if ( self::$actions[__FUNCTION__] >= $this->getUser('group')) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
]); ]);
} else { }
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) { // Jeton incorrect
// Valeurs en sortie elseif ($this->getUrl(3) !== $_SESSION['csrf']) {
$this->addOutput([ // Valeurs en sortie
'access' => false $this->addOutput([
]); 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
} 'notification' => 'Action non autorisée'
// Jeton incorrect ]);
elseif ($this->getUrl(3) !== $_SESSION['csrf']) { }
// Valeurs en sortie // Suppression
$this->addOutput([ else {
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', $this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]);
'notification' => 'Action non autorisée' // Valeurs en sortie
]); $this->addOutput([
} 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
// Suppression 'notification' => 'Article supprimé',
else { 'state' => true
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]); ]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'notification' => 'Article supprimé',
'state' => true
]);
}
} }
} }
@ -469,7 +461,7 @@ class blog extends common {
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', 'redirect' => $this->getUser('group') >= self::GROUP_MODERATOR ? helper::baseUrl() . $this->getUrl(0) . '/config' : helper::baseUrl() . $this->getUrl(0),
'notification' => 'Modifications enregistrées', 'notification' => 'Modifications enregistrées',
'state' => true 'state' => true
]); ]);
@ -479,7 +471,7 @@ class blog extends common {
ksort(self::$users); ksort(self::$users);
foreach(self::$users as $userId => &$userFirstname) { foreach(self::$users as $userId => &$userFirstname) {
// Les membres ne sont pas éditeurs, les exclure de la liste // Les membres ne sont pas éditeurs, les exclure de la liste
if ( $this->getData(['user', $userId, 'group']) < self::GROUP_MODERATOR) { if ( $this->getData(['user', $userId, 'group']) < self::GROUP_EDITOR) {
unset(self::$users[$userId]); unset(self::$users[$userId]);
} }
$userFirstname = $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']) . ' (' . self::$groupEdits[$this->getData(['user', $userId, 'group'])] . ')'; $userFirstname = $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']) . ' (' . self::$groupEdits[$this->getData(['user', $userId, 'group'])] . ')';

View File

@ -8,7 +8,7 @@
</div> </div>
</div> </div>
<?php if( <?php if(
$this->getUser('group') >= self::GROUP_MODERATOR $this->getUser('group') >= self::GROUP_EDITOR
AND $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') AND $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
): ?> ): ?>
<div class="col2"> <div class="col2">

View File

@ -103,6 +103,7 @@
</div> </div>
</div> </div>
</div> </div>
<?php if( $this->getUser('group') >= self::GROUP_MODERATOR){ ?>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<div class="block"> <div class="block">
@ -145,4 +146,4 @@
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php } echo template::formClose(); ?>

View File

@ -36,13 +36,13 @@ class gallery extends common {
public static $thumbs = []; public static $thumbs = [];
public static $actions = [ public static $actions = [
'config' => self::GROUP_EDITOR, 'config' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR, 'delete' => self::GROUP_MODERATOR,
'dirs' => self::GROUP_EDITOR, 'dirs' => self::GROUP_MODERATOR,
'sortGalleries' => self::GROUP_EDITOR, 'sortGalleries' => self::GROUP_MODERATOR,
'sortPictures' => self::GROUP_EDITOR, 'sortPictures' => self::GROUP_MODERATOR,
'edit' => self::GROUP_EDITOR, 'edit' => self::GROUP_MODERATOR,
'theme' => self::GROUP_EDITOR, 'theme' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR 'index' => self::GROUP_VISITOR
]; ];
@ -287,39 +287,31 @@ class gallery extends common {
* Suppression * Suppression
*/ */
public function delete() { public function delete() {
// Contrôle d'accès // $url prend l'adresse sans le token
if ( self::$actions[__FUNCTION__] >= $this->getUser('group')) { // La galerie n'existe pas
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
]); ]);
} else { }
// $url prend l'adresse sans le token // Jeton incorrect
// La galerie n'existe pas if ($this->getUrl(3) !== $_SESSION['csrf']) {
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) { // Valeurs en sortie
// Valeurs en sortie $this->addOutput([
$this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'access' => false 'notification' => 'Suppression non autorisée'
]); ]);
} }
// Jeton incorrect // Suppression
if ($this->getUrl(3) !== $_SESSION['csrf']) { else {
// Valeurs en sortie $this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]);
$this->addOutput([ // Valeurs en sortie
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', $this->addOutput([
'notification' => 'Suppression non autorisée' 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
]); 'notification' => 'Galerie supprimée',
} 'state' => true
// Suppression ]);
else {
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'notification' => 'Galerie supprimée',
'state' => true
]);
}
} }
} }

View File

@ -15,10 +15,10 @@
class news extends common { class news extends common {
public static $actions = [ public static $actions = [
'add' => self::GROUP_EDITOR, 'add' => self::GROUP_MODERATOR,
'config' => self::GROUP_EDITOR, 'config' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR, 'delete' => self::GROUP_MODERATOR,
'edit' => self::GROUP_EDITOR, 'edit' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR 'index' => self::GROUP_VISITOR
]; ];
@ -117,38 +117,30 @@ class news extends common {
* Suppression * Suppression
*/ */
public function delete() { public function delete() {
// Contrôle d'accès // La news n'existe pas
if ( self::$actions[__FUNCTION__] >= $this->getUser('group')) { if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
]); ]);
} else { }
// La news n'existe pas // Jeton incorrect
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) { elseif ($this->getUrl(3) !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
]); 'notification' => 'Action non autorisée'
} ]);
// Jeton incorrect }
elseif ($this->getUrl(3) !== $_SESSION['csrf']) { // Suppression
// Valeurs en sortie else {
$this->addOutput([ $this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]);
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', // Valeurs en sortie
'notification' => 'Action non autorisée' $this->addOutput([
]); 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
} 'notification' => 'News supprimée',
// Suppression 'state' => true
else { ]);
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'notification' => 'News supprimée',
'state' => true
]);
}
} }
} }