From 50f8d5afe3b8744a0abcb641cbad4a32e1bb9028 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sun, 11 Oct 2020 18:45:43 +0200 Subject: [PATCH] Revert "Modif Sylvain" This reverts commit 87d2e22577bcbdd1bc9234f7511c699325393776. --- .gitignore | 6 + core/class/template.class.php | 2 +- core/core.php | 5 +- core/module/page/page.php | 395 +++++++++++----------- core/module/page/view/edit/edit.php | 53 ++- core/module/user/user.php | 2 +- core/vendor/filemanager/config/config.php | 26 +- module/blog/blog.php | 54 +-- module/blog/view/article/article.php | 2 +- module/blog/view/edit/edit.php | 3 +- module/gallery/gallery.php | 62 ++-- module/news/news.php | 54 +-- 12 files changed, 347 insertions(+), 317 deletions(-) diff --git a/.gitignore b/.gitignore index 218b1ed4..8a247dc6 100755 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,9 @@ site/data/journal.log .DS_Store site/.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 diff --git a/core/class/template.class.php b/core/class/template.class.php index 2cb85bab..f7384a10 100644 --- a/core/class/template.class.php +++ b/core/class/template.class.php @@ -64,7 +64,7 @@ class template { $html = '
'; // Label $html .= self::label($attributes['id'], - '' . template::ico('plus') . ' en chiffres ?', [ + '' . template::ico('plus') . ' en chiffres ?', [ 'help' => $attributes['help'] ]); // Notice diff --git a/core/core.php b/core/core.php index 9990d47e..1b8145ed 100644 --- a/core/core.php +++ b/core/core.php @@ -1797,8 +1797,6 @@ class core extends common { } // Check l'accès à la page $access = null; - $accessInfo['userName'] = ''; - $accessInfo['pageId'] = ''; if($this->getData(['page', $this->getUrl(0)]) !== null) { if( $this->getData(['page', $this->getUrl(0), 'group']) === self::GROUP_VISITOR @@ -1818,7 +1816,6 @@ class core extends common { } } } - /** * Contrôle si la page demandée est en édition ou accès à la gestion du site * conditions de blocage : @@ -1827,6 +1824,8 @@ class core extends common { * - 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 */ + $accessInfo['userName'] = ''; + $accessInfo['pageId'] = ''; foreach($this->getData(['user']) as $userId => $userIds){ $t = explode('/',$this->getData(['user', $userId, 'accessUrl'])); if ( $this->getuser('id') && diff --git a/core/module/page/page.php b/core/module/page/page.php index 8b9408c4..3d4314b2 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -70,6 +70,14 @@ class page extends common { * Duplication */ 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 $url = explode('&',$this->getUrl(2)); // La page n'existe pas @@ -126,6 +134,14 @@ class page extends common { * Création */ 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'; $pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page'])); $this->setData([ @@ -134,7 +150,7 @@ class page extends common { [ 'typeMenu' => 'text', 'iconUrl' => '', - 'disable' => false, + 'disable' => false, 'content' => 'Contenu de votre nouvelle page.', 'hideTitle' => false, 'breadCrumb' => false, @@ -170,6 +186,14 @@ class page extends common { * Suppression */ 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 = explode('&',$this->getUrl(2)); // La page n'existe pas @@ -266,11 +290,11 @@ class page extends common { } // Suppression else { - // Met à jour le site map - $this->createSitemap('all'); // Effacer la page $this->deleteData(['page', $url[0]]); $this->deleteData(['module', $url[0]]); + // Met à jour le site map + $this->createSitemap('all'); // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl(false), @@ -291,206 +315,199 @@ class page extends common { $this->addOutput([ 'access' => false ]); + return; } // La page existe - else { - // Soumission du formulaire - if($this->isPost()) { - // Génére l'ID si le titre de la page a changé - if ( $this->getInput('pageEditTitle') !== $this->getData(['page',$this->getUrl(2),'title']) ) { - $pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true); - } else { - $pageId = $this->getUrl(2); + // Soumission du formulaire + if($this->isPost()) { + // Génére l'ID si le titre de la page a changé + if ( $this->getInput('pageEditTitle') !== $this->getData(['page',$this->getUrl(2),'title']) ) { + $pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true); + } else { + $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]); } - // un dossier existe du même nom (erreur en cas de redirection) - if (file_exists($pageId)) { - $pageId = uniqid($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]); } - // 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; } - // 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); + // 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; + } 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)) ? '

 

' : $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]); } - // 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)) ? '

 

' : $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]); - } - } + 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)) ? '

 

' : $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 - $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 { - $moduleIds[$fileInfos->getBasename()] = ucfirst($fileInfos->getBasename()); - } - } + // 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 + ]); } - 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']); - } + // Redirection vers la page + else { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $pageId, + 'notification' => 'Modifications enregistrées', + 'state' => true + ]); } - // 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' - ]); } + // 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 { + $moduleIds[$fileInfos->getBasename()] = ucfirst($fileInfos->getBasename()); + } + } + } + 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' + ]); } } diff --git a/core/module/page/view/edit/edit.php b/core/module/page/view/edit/edit.php index 3538bc7e..b540f2d2 100644 --- a/core/module/page/view/edit/edit.php +++ b/core/module/page/view/edit/edit.php @@ -1,10 +1,9 @@ pages2Json(); - // Validation des buttons réservés aux modérateurs et administrateurs + $this->pages2Json(); ?>
-
+
getUrl(2); ?> getData(['page', $this->getUrl(2), 'moduleId']) === 'redirection' || 'code')$href = helper::baseUrl(); ?>
- getUser('group') >= self::GROUP_MODERATOR ){ - echo template::button('pageEditDuplicate', [ + getUser('group')): ?> + helper::baseUrl() . 'page/duplicate/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'], 'value' => 'Dupliquer', 'ico' => 'clone' - ]); - }?> + ]); ?> +
- getUser('group') >= self::GROUP_MODERATOR ){ - echo template::button('pageEditDelete', [ - 'class' => 'buttonRed', - 'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'], - 'value' => 'Supprimer', - 'ico' => 'cancel' - ]); - }?> + getUser('group')): ?> + 'buttonRed', + 'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'], + 'value' => 'Supprimer', + 'ico' => 'cancel' + ]); ?> +
@@ -52,25 +51,23 @@ echo template::formOpen('pageEditForm');
- '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' => $this->getUser('group') >= self::GROUP_MODERATOR ? false : true + 'selected' => $this->getData(['page', $this->getUrl(2), 'moduleId']) ]); ?> + $this->getData(['page', $this->getUrl(2), 'moduleId'])]); ?> 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'])) ]); ?>
- getUser('group') >= self::GROUP_MODERATOR){ - echo template::button('pageEditModuleConfig', [ - 'disabled' => (bool) $this->getData(['page', $this->getUrl(2), 'moduleId']) === false, - 'uniqueSubmission' => true, - 'value' => template::ico('gear') - ]); - }?> + (bool) $this->getData(['page', $this->getUrl(2), 'moduleId']) === false, + 'uniqueSubmission' => true, + 'value' => template::ico('gear') + ]); ?>
@@ -93,8 +90,7 @@ echo template::formOpen('pageEditForm'); 'En position libre ajoutez le module en plaçant [MODULE] à l\'endroit voulu dans votre page.', 'label' => 'Position du module', - 'selected' => $this->getData(['page', $this->getUrl(2), 'modulePosition']), - 'disabled' => $this->getUser('group') >= self::GROUP_MODERATOR ? false : true + 'selected' => $this->getData(['page', $this->getUrl(2), 'modulePosition']) ]); ?>
@@ -166,7 +162,6 @@ echo template::formOpen('pageEditForm');
- getUser('group') >= self::GROUP_MODERATOR){ ?>
@@ -294,4 +289,4 @@ echo template::formOpen('pageEditForm');
- + diff --git a/core/module/user/user.php b/core/module/user/user.php index 3b76a820..a385bdeb 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -367,7 +367,6 @@ class user extends common { // Check la captcha if( $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 ) { self::$inputNotices['userLoginCaptcha'] = 'Incorrect'; @@ -445,6 +444,7 @@ class user extends common { $this->addOutput([ 'notification' => 'Connexion réussie', 'redirect' => helper::baseUrl(), + //'redirect' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))), 'state' => true ]); } diff --git a/core/vendor/filemanager/config/config.php b/core/vendor/filemanager/config/config.php index 17ba8331..73e03b8b 100644 --- a/core/vendor/filemanager/config/config.php +++ b/core/vendor/filemanager/config/config.php @@ -13,16 +13,6 @@ ob_start('mb_output_handler'); date_default_timezone_set('Europe/Paris'); 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 @@ -346,18 +336,18 @@ $config = array( //************************* //Permissions configuration //****************** - 'delete_files' => $val, + 'delete_files' => true, 'create_folders' => true, - 'delete_folders' => $val, + 'delete_folders' => true, 'upload_files' => true, - 'rename_files' => $val, - 'rename_folders' => $val, + 'rename_files' => true, + 'rename_folders' => true, 'duplicate_files' => true, 'extract_files' => true, - 'copy_cut_files' => $val, // for copy/cut files - 'copy_cut_dirs' => $val, // for copy/cut directories - 'chmod_files' => $val, // change file permissions - 'chmod_dirs' => $val, // change folder permissions + 'copy_cut_files' => true, // for copy/cut files + 'copy_cut_dirs' => true, // for copy/cut directories + 'chmod_files' => true, // change file permissions + 'chmod_dirs' => true, // change folder permissions 'preview_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'] diff --git a/module/blog/blog.php b/module/blog/blog.php index 93f5eb04..9deda6d0 100644 --- a/module/blog/blog.php +++ b/module/blog/blog.php @@ -21,12 +21,12 @@ class blog extends common { const EDIT_ADMIN = '03'; // Groupe des admin public static $actions = [ - 'add' => self::GROUP_MODERATOR, + 'add' => self::GROUP_EDITOR, 'comment' => self::GROUP_MODERATOR, 'commentApprove' => self::GROUP_MODERATOR, 'commentDelete' => self::GROUP_MODERATOR, 'commentDeleteAll' => self::GROUP_MODERATOR, - 'config' => self::GROUP_MODERATOR, + 'config' => self::GROUP_EDITOR, 'delete' => self::GROUP_MODERATOR, 'edit' => self::GROUP_EDITOR, 'index' => self::GROUP_VISITOR @@ -375,29 +375,37 @@ class blog extends common { * Suppression */ public function delete() { - if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) { + // Contrôle d'accès + if ( self::$actions[__FUNCTION__] >= $this->getUser('group')) { // Valeurs en sortie $this->addOutput([ 'access' => false ]); - } - // Jeton incorrect - elseif ($this->getUrl(3) !== $_SESSION['csrf']) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', - 'notification' => 'Action non autorisée' - ]); - } - // Suppression - else { - $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 - ]); + } else { + if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } + // Jeton incorrect + elseif ($this->getUrl(3) !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', + 'notification' => 'Action non autorisée' + ]); + } + // Suppression + else { + $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 + ]); + } } } @@ -461,7 +469,7 @@ class blog extends common { } // Valeurs en sortie $this->addOutput([ - 'redirect' => $this->getUser('group') >= self::GROUP_MODERATOR ? helper::baseUrl() . $this->getUrl(0) . '/config' : helper::baseUrl() . $this->getUrl(0), + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', 'notification' => 'Modifications enregistrées', 'state' => true ]); @@ -471,7 +479,7 @@ class blog extends common { ksort(self::$users); foreach(self::$users as $userId => &$userFirstname) { // Les membres ne sont pas éditeurs, les exclure de la liste - if ( $this->getData(['user', $userId, 'group']) < self::GROUP_EDITOR) { + if ( $this->getData(['user', $userId, 'group']) < self::GROUP_MODERATOR) { unset(self::$users[$userId]); } $userFirstname = $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']) . ' (' . self::$groupEdits[$this->getData(['user', $userId, 'group'])] . ')'; diff --git a/module/blog/view/article/article.php b/module/blog/view/article/article.php index 73e6c015..f25cc37b 100644 --- a/module/blog/view/article/article.php +++ b/module/blog/view/article/article.php @@ -8,7 +8,7 @@ getUser('group') >= self::GROUP_EDITOR + $this->getUser('group') >= self::GROUP_MODERATOR AND $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') ): ?>
diff --git a/module/blog/view/edit/edit.php b/module/blog/view/edit/edit.php index ffd051fd..d6ff0965 100644 --- a/module/blog/view/edit/edit.php +++ b/module/blog/view/edit/edit.php @@ -103,7 +103,6 @@
- getUser('group') >= self::GROUP_MODERATOR){ ?>
@@ -146,4 +145,4 @@
- + diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 77d0f2c3..809ef835 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -36,13 +36,13 @@ class gallery extends common { public static $thumbs = []; public static $actions = [ - 'config' => self::GROUP_MODERATOR, + 'config' => self::GROUP_EDITOR, 'delete' => self::GROUP_MODERATOR, - 'dirs' => self::GROUP_MODERATOR, - 'sortGalleries' => self::GROUP_MODERATOR, - 'sortPictures' => self::GROUP_MODERATOR, - 'edit' => self::GROUP_MODERATOR, - 'theme' => self::GROUP_MODERATOR, + 'dirs' => self::GROUP_EDITOR, + 'sortGalleries' => self::GROUP_EDITOR, + 'sortPictures' => self::GROUP_EDITOR, + 'edit' => self::GROUP_EDITOR, + 'theme' => self::GROUP_EDITOR, 'index' => self::GROUP_VISITOR ]; @@ -287,31 +287,39 @@ class gallery extends common { * Suppression */ public function delete() { - // $url prend l'adresse sans le token - // La galerie n'existe pas - if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) { + // Contrôle d'accès + if ( self::$actions[__FUNCTION__] >= $this->getUser('group')) { // Valeurs en sortie $this->addOutput([ 'access' => false ]); - } - // Jeton incorrect - if ($this->getUrl(3) !== $_SESSION['csrf']) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', - 'notification' => 'Suppression non autorisée' - ]); - } - // 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 - ]); + } else { + // $url prend l'adresse sans le token + // La galerie n'existe pas + if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } + // Jeton incorrect + if ($this->getUrl(3) !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', + 'notification' => 'Suppression non autorisée' + ]); + } + // 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 + ]); + } } } diff --git a/module/news/news.php b/module/news/news.php index 4499028c..6c648599 100644 --- a/module/news/news.php +++ b/module/news/news.php @@ -15,10 +15,10 @@ class news extends common { public static $actions = [ - 'add' => self::GROUP_MODERATOR, - 'config' => self::GROUP_MODERATOR, + 'add' => self::GROUP_EDITOR, + 'config' => self::GROUP_EDITOR, 'delete' => self::GROUP_MODERATOR, - 'edit' => self::GROUP_MODERATOR, + 'edit' => self::GROUP_EDITOR, 'index' => self::GROUP_VISITOR ]; @@ -117,30 +117,38 @@ class news extends common { * Suppression */ public function delete() { - // La news n'existe pas - if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) { + // Contrôle d'accès + if ( self::$actions[__FUNCTION__] >= $this->getUser('group')) { // Valeurs en sortie $this->addOutput([ 'access' => false ]); - } - // Jeton incorrect - elseif ($this->getUrl(3) !== $_SESSION['csrf']) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', - 'notification' => 'Action non autorisée' - ]); - } - // Suppression - 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 - ]); + } else { + // La news n'existe pas + if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } + // Jeton incorrect + elseif ($this->getUrl(3) !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', + 'notification' => 'Action non autorisée' + ]); + } + // Suppression + 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 + ]); + } } }