From 060aa9e4d597b95d7af8862149fd072158b683db Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sat, 23 Mar 2024 15:39:22 +0100 Subject: [PATCH 1/3] Squashed commit of the following: commit 9052247e53c9198bea35d44e654b242643b23432 Merge: df06b1f7 f18d4eee Author: Fred Tempez Date: Sat Mar 23 15:36:43 2024 +0100 Merge commit 'f18d4eee1d1cd9500a30d47d05bea1f773d787af' into HEAD commit df06b1f7ba5ee611962b713424e400c6678942d3 Merge: 8d324f9c fd511229 Author: Fred Tempez Date: Sat Mar 23 15:36:02 2024 +0100 Merge commit 'fd511229181cca42029257d29b0407e5ca598dc9' into HEAD commit 8d324f9c79a049c78a0606e8bce5044cbdff9078 Author: Fred Tempez Date: Sat Mar 23 15:33:52 2024 +0100 Revert "Merge commit 'f924a2b2b3a8a6c53ce050da64e57ac76d388872'" This reverts commit b8c0b47fafc994384920a158eb2bf7244760b61f, reversing changes made to f5f04c90d94444d7908880773b59fce2bb21c704. --- core/class/router.class.php | 3 +- module/folder/folder.php | 149 --------------------------- module/folder/view/config/config.css | 19 ---- module/folder/view/config/config.php | 33 ------ module/folder/view/index/index.css | 45 -------- module/folder/view/index/index.php | 6 -- 6 files changed, 1 insertion(+), 254 deletions(-) delete mode 100644 module/folder/folder.php delete mode 100755 module/folder/view/config/config.css delete mode 100644 module/folder/view/config/config.php delete mode 100644 module/folder/view/index/index.css delete mode 100644 module/folder/view/index/index.php diff --git a/core/class/router.class.php b/core/class/router.class.php index 4517ef7a..98e348d1 100644 --- a/core/class/router.class.php +++ b/core/class/router.class.php @@ -761,9 +761,8 @@ class core extends common // Librairies if ($output['vendor'] !== $this->output['vendor']) { $this->addOutput([ - 'vendor' => array_merge($this->output['vendor'], $this->output['vendor']) + 'vendor' => array_merge($this->output['vendor'], $output['vendor']) ]); - } if ($output['title'] !== null) { diff --git a/module/folder/folder.php b/module/folder/folder.php deleted file mode 100644 index f79022bf..00000000 --- a/module/folder/folder.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @copyright Copyright (C) 2008-2018, Rémi Jean - * @author Frédéric Tempez - * @copyright Copyright (C) 2018-2024, Frédéric Tempez - * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International - * @link http://zwiicms.fr/ - */ - -class folder extends common -{ - - const VERSION = '0.1'; - const REALNAME = 'Partage de dossier'; - const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) - - public static $actions = [ - 'config' => self::GROUP_EDITOR, - 'index' => self::GROUP_VISITOR, - ]; - - // Contenu du chemin sélectionné - public static $folders = ''; - - public static $sharePath = [ - 'site/file/source/' - ]; - - public function index() - { - - self::$folders = $this->getFolderContent($this->getData(['module', $this->getUrl(0), 'path'])); - - // Valeurs en sortie - $this->addOutput([ - 'showBarEditButton' => true, - 'showPageContent' => true, - 'view' => 'index' - ]); - } - - - public function config() - { - // Soumission du formulaire - if ( - $this->getUser('permission', __CLASS__, __FUNCTION__) === true && - $this->isPost() - ) { - $this->setData(['module', $this->getUrl(0), 'path', preg_replace('/^\\./', '', $this->getInput('folderEditPath')) ]); - - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(0), - 'notification' => helper::translate('Modifications enregistrées'), - 'state' => true - ]); - - } - - self::$sharePath = $this->getSubdirectories('site/file/source'); - self::$sharePath = array_flip(self::$sharePath); - - // Valeurs en sortie - $this->addOutput([ - 'view' => 'config' - ]); - } - - -private function getFolderContent($chemin) -{ - // Vérifier si le chemin existe et est un dossier - if (is_dir($chemin)) { - // Ouvrir le dossier - if ($dh = opendir($chemin)) { - $items = isset($items) ? $items : '
    '; - // Parcourir les éléments du dossier - while (($element = readdir($dh)) !== false) { - // Exclure les éléments spéciaux - if ($element != '.' && $element != '..') { - // Construire le chemin complet de l'élément - $cheminComplet = $chemin . $element; - - // Vérifier si c'est un dossier - if (is_dir($cheminComplet)) { - // Afficher le nom du dossier avec un élément details - $items .= "
  • $element"; - // Appeler récursivement la fonction pour ce sous-dossier - $items .= $this->getFolderContent($cheminComplet); - $items .= '
  • '; - } else { - // Afficher le nom du fichier comme un lien - $items .= "
  • $element
  • "; - } - } - } - $items .= "
"; - - // Fermer le dossier - closedir($dh); - } - return $items; - } -} - - - - - /** - * Liste les dossier contenus dans RFM - */ - private function getSubdirectories($dir, $basePath = '') - { - $subdirs = array(); - // Ouvrez le répertoire spécifié - $dh = opendir($dir); - // Parcourez tous les fichiers et répertoires dans le répertoire - while (($file = readdir($dh)) !== false) { - // Ignorer les entrées de répertoire parent et actuel - if ($file == '.' || $file == '..') { - continue; - } - // Construisez le chemin complet du fichier ou du répertoire - $path = $dir . '/' . $file; - // Vérifiez si c'est un répertoire - if (is_dir($path)) { - // Construisez la clé et la valeur pour le tableau associatif - $key = $basePath === '' ? ucfirst($file) : $basePath . '/' . $file; - $value = $path . '/'; - // Ajouter la clé et la valeur au tableau associatif - $subdirs[$key] = $value; - // Appeler la fonction récursivement pour ajouter les sous-répertoires - $subdirs = array_merge($subdirs, $this->getSubdirectories($path, $key)); - } - } - // Fermez le gestionnaire de dossier - closedir($dh); - return $subdirs; - } - -} \ No newline at end of file diff --git a/module/folder/view/config/config.css b/module/folder/view/config/config.css deleted file mode 100755 index f3cc838d..00000000 --- a/module/folder/view/config/config.css +++ /dev/null @@ -1,19 +0,0 @@ - -/** - * This file is part of Zwii. - * - * For full copyright and license information, please see the LICENSE - * file that was distributed with this source code. - * - * @author Rémi Jean - * @copyright Copyright (C) 2008-2018, Rémi Jean - * @author Frédéric Tempez - * @copyright Copyright (C) 2018-2024, Frédéric Tempez - * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International - * @link http://zwiicms.fr/ - */ - -/** NE PAS EFFACER -* admin.css -*/ - diff --git a/module/folder/view/config/config.php b/module/folder/view/config/config.php deleted file mode 100644 index b38dd561..00000000 --- a/module/folder/view/config/config.php +++ /dev/null @@ -1,33 +0,0 @@ - -
-
- 'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), - 'value' => template::ico('left') - ]); ?> -
-
- -
-
-
-
-
-

-
-
- 'Dossier', - 'class' => 'filemanager', - 'selected' => $this->getData(['module', $this->getUrl(0), 'path']) - ]); ?> -
-
-
-
-
- -
Version n° - -
\ No newline at end of file diff --git a/module/folder/view/index/index.css b/module/folder/view/index/index.css deleted file mode 100644 index ac52c9db..00000000 --- a/module/folder/view/index/index.css +++ /dev/null @@ -1,45 +0,0 @@ -#dirindex article { - display: block; - margin: 0 auto; - width: 480px; -} - -#dirindex a { - color: #004466; - text-decoration: none; -} - -#dirindex a:hover { - text-decoration: underline; -} - -#dirindex a:visited { - color: #666666; -} - -#dirindex details summary, -#dirindex details summary::-webkit-details-marker { - list-style: none; - cursor: pointer; -} - -#dirindex { - list-style: none; -} - -#dirindex .directory { - list-style-type: "\1F4C1"; -} - -#dirindex .file { - list-style-type: "\1F4C4"; -} - -#dirindex ul li { - margin-top: 10px; -} - -#dirindex li { - padding-left: 5px; - list-style-position : outside; -} \ No newline at end of file diff --git a/module/folder/view/index/index.php b/module/folder/view/index/index.php deleted file mode 100644 index 25607194..00000000 --- a/module/folder/view/index/index.php +++ /dev/null @@ -1,6 +0,0 @@ -
-
-

Répertoire

- -
-
\ No newline at end of file From 660398bad7926d5f8326bc4f36b4c66d2034d700 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Fri, 29 Mar 2024 21:40:55 +0100 Subject: [PATCH 2/3] bug de page parente avec permission --- core/core.php | 118 +++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/core/core.php b/core/core.php index f9c969b7..f37460d8 100644 --- a/core/core.php +++ b/core/core.php @@ -706,65 +706,65 @@ class common * Appelée par le core uniquement */ - private function buildHierarchy() - { - - $pages = helper::arrayColumn($this->getData(['page']), 'position', 'SORT_ASC'); - // Parents - foreach ($pages as $pageId => $pagePosition) { - if ( - // Page parent - $this->getData(['page', $pageId, 'parentPageId']) === "" - // Ignore les pages dont l'utilisateur n'a pas accès - and ($this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR - or ($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') - //and $this->getUser('group') >= $this->getData(['page', $pageId, 'group']) - // Modification qui tient compte du profil de la page - and ($this->getUser('group') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $pageId, 'group']) * self::MAX_PROFILS + $this->getData(['page', $pageId, 'profil'])) - - ) - ) - ) { - if ($pagePosition !== 0) { - $this->hierarchy['visible'][$pageId] = []; - } - if ($this->getData(['page', $pageId, 'block']) === 'bar') { - $this->hierarchy['bar'][$pageId] = []; - } - $this->hierarchy['all'][$pageId] = []; - } - } - // Enfants - foreach ($pages as $pageId => $pagePosition) { - if ( - // Page parent - $parentId = $this->getData(['page', $pageId, 'parentPageId']) - // Ignore les pages dont l'utilisateur n'a pas accès - and ( - ($this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR - and $this->getData(['page', $parentId, 'group']) === self::GROUP_VISITOR - ) - or ($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') - //and $this->getUser('group') >= $this->getData(['page', $parentId, 'group']) - //and $this->getUser('group') >= $this->getData(['page', $pageId, 'group']) - - // Modification qui tient compte du profil de la page - and ($this->getUser('group') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $this->$parentId, 'group']) * self::MAX_PROFILS + $this->getData(['page', $this->$parentId, 'profil'])) - and ($this->getUser('group') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $this->$pageId, 'group']) * self::MAX_PROFILS + $this->getData(['page', $pageId, 'profil'])) - - ) - ) - ) { - if ($pagePosition !== 0) { - $this->hierarchy['visible'][$parentId][] = $pageId; - } - if ($this->getData(['page', $pageId, 'block']) === 'bar') { - $this->hierarchy['bar'][$pageId] = []; - } - $this->hierarchy['all'][$parentId][] = $pageId; - } - } - } + private function buildHierarchy() + { + + $pages = helper::arrayColumn($this->getData(['page']), 'position', 'SORT_ASC'); + // Parents + foreach ($pages as $pageId => $pagePosition) { + if ( + // Page parent + $this->getData(['page', $pageId, 'parentPageId']) === "" + // Ignore les pages dont l'utilisateur n'a pas accès + and ($this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR + or ($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') + //and $this->getUser('group') >= $this->getData(['page', $pageId, 'group']) + // Modification qui tient compte du profil de la page + and ($this->getUser('group') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $pageId, 'group']) * self::MAX_PROFILS + $this->getData(['page', $pageId, 'profil'])) + + ) + ) + ) { + if ($pagePosition !== 0) { + $this->hierarchy['visible'][$pageId] = []; + } + if ($this->getData(['page', $pageId, 'block']) === 'bar') { + $this->hierarchy['bar'][$pageId] = []; + } + $this->hierarchy['all'][$pageId] = []; + } + } + // Enfants + foreach ($pages as $pageId => $pagePosition) { + + if ( + // Page parent + $parentId = $this->getData(['page', $pageId, 'parentPageId']) + // Ignore les pages dont l'utilisateur n'a pas accès + and ( + ( + $this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR + and + $this->getData(['page', $parentId, 'group']) === self::GROUP_VISITOR + ) + or ( + $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') + and + $this->getUser('group') * self::MAX_PROFILS + $this->getUser('profil')) >= ($this->getData(['page', $pageId, 'group']) * self::MAX_PROFILS + $this->getData(['page', $pageId, 'profil']) + + ) + ) + ) { + if ($pagePosition !== 0) { + $this->hierarchy['visible'][$parentId][] = $pageId; + } + if ($this->getData(['page', $pageId, 'block']) === 'bar') { + $this->hierarchy['bar'][$pageId] = []; + } + $this->hierarchy['all'][$parentId][] = $pageId; + } + } + } /** * Génère un fichier json avec la liste des pages From 457c8e0f66d34a1d9d3c7edcc7e43ff94770e4f5 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Fri, 29 Mar 2024 21:41:49 +0100 Subject: [PATCH 3/3] 13.1.08 Bug de page parente avec permission --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 7fcba400..f7e38143 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,8 @@ ## Version 13.1.08 +### Corrige des erreurs quand une page parente ou des pages enfants ont des permissions limitées. + ### Améliorations - Sauvegarde de l'état des sélecteurs dans les tables des fontes et des utilisateurs.