From f2636c87d824bfa9c51d9727b082cd28dcbebd5c Mon Sep 17 00:00:00 2001 From: fredtempez Date: Wed, 10 May 2023 16:50:02 +0200 Subject: [PATCH] Profil RFM --- core/class/layout.class.php | 23 ++++++---- core/core.php | 26 ++++++++--- core/module/install/ressource/defaultdata.php | 6 ++- core/module/user/user.php | 46 +++++++++++++++++-- core/module/user/view/profilAdd/profilAdd.php | 2 +- .../user/view/profilEdit/profilEdit.php | 4 +- core/vendor/filemanager/config/config.php | 2 +- 7 files changed, 84 insertions(+), 25 deletions(-) diff --git a/core/class/layout.class.php b/core/class/layout.class.php index 163d6240..fa22c3d1 100644 --- a/core/class/layout.class.php +++ b/core/class/layout.class.php @@ -317,7 +317,7 @@ class layout extends common $items .= 'getData(['config', 'cookieConsent']) === true && $this->getData(['theme', 'footer', 'displayCookie']) === true) ? '>' : ' class="displayNone" >'; $label = empty($this->getData(['locale', 'cookies', 'cookiesFooterText'])) ? 'Cookies' : $this->getData(['locale', 'cookies', 'cookiesFooterText']); - $items .= ' | ' . $label . ''; + $items .= ' | ' . $label . ''; $items .= ''; // Affichage du lien de connexion if ( @@ -344,7 +344,7 @@ class layout extends common $items .= $this->getData(['theme', 'footer', 'displaymemberAccount']) === false ? ' class="displayNone">' : '>'; $items .= ' | '; if ( - $this->getUser('group') >= self::GROUP_MEMBER && $this->getPermission('folder', 'share') === true + $this->getPermission('filemanager') === true ) { $items .= '' . template::ico('folder', [ 'href' => helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR . 'core.json') . '&lang=' . $this->getData(['user', $this->getUser('id'), 'language']), @@ -354,10 +354,10 @@ class layout extends common ]); } $items .= '' . template::ico('user', [ - 'margin' => 'all', - 'help' => 'Mon compte', - 'href' => helper::baseUrl() . 'user/edit/' . $this->getUser('id') . '/' . $_SESSION['csrf'] - ]); + 'margin' => 'all', + 'help' => 'Mon compte', + 'href' => helper::baseUrl() . 'user/edit/' . $this->getUser('id') . '/' . $_SESSION['csrf'] + ]); $items .= '' . template::ico('logout', [ 'margin' => 'all', 'help' => 'Déconnecter', @@ -523,14 +523,14 @@ class layout extends common // Drapeau les langues foreach (self::$languages as $key => $value) { if (is_dir(self::DATA_DIR . $key)) { - $t[] = $this->showi18n($key); + $t[] = $this->showi18n($key); } } // Pas de drapeau si la langue est unique if (count($t) > 1) { foreach ($t as $key) { echo $key; - } + } } echo ''; } @@ -926,7 +926,7 @@ class layout extends common } $leftItems .= ' // Afficher les barres - $leftItems .= ''; + $leftItems .= ''; foreach ($this->getHierarchy(null, false, true) as $parentPageId => $childrenPageIds) { $leftItems .= ''; foreach ($childrenPageIds as $childKey) { @@ -977,7 +977,10 @@ class layout extends common } // Items de droite $rightItems = ''; - if ($this->getUser('group') >= self::GROUP_MODERATOR) { + if ( + $this->getUser('group') >= self::GROUP_MODERATOR + && $this->getPermission('filemanager') + ) { $rightItems .= '
  • ' . template::ico('folder', [ 'help' => 'Fichiers', 'href' => helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR . 'core.json') . '&lang=' . $this->getData(['user', $this->getUser('id'), 'language']), diff --git a/core/core.php b/core/core.php index 0b8b07e7..c4ff06ca 100644 --- a/core/core.php +++ b/core/core.php @@ -415,7 +415,6 @@ class common // Mise à jour des données core include('core/include/update.inc.php'); - // Données de proxy $proxy = $this->getData(['config', 'proxyType']) . $this->getData(['config', 'proxyUrl']) . ':' . $this->getData(['config', 'proxyPort']); if ( @@ -911,13 +910,25 @@ class common { if (is_array($this->user) === false) { return false; - } elseif ($key2 === null && array_key_exists($key1, $this->getData(['profil', $this->user['group']]))) { - return $this->getData(['profil', $this->user['group'], $key1]); - } elseif ($key2 && array_key_exists($key2, $this->getData(['profil', $this->user['group'], $key1]))) { - return $this->getData(['profil', $this->user['group'], $key1, $key2]); + } elseif ($this->getUser('group') === self::GROUP_ADMIN) { + return true; + } elseif ($this->getUser('group') < 1) { + return false; + } elseif ( + $key2 + && $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1]) + && array_key_exists($key2, $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1])) + ) { + return $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1, $key2]); + } elseif ( + $this->getData(['profil', $this->user['group'], $this->user['profil']]) + && array_key_exists($key1, $this->getData(['profil', $this->user['group'], $this->user['profil']])) + ) { + return $this->getData(['profil', $this->user['group'], $this->user['profil'], $key1]); } else { return false; } + } /** @@ -1320,12 +1331,13 @@ class common /** * Journalisation */ - public function saveLog($message = '') { + public function saveLog($message = '') + { // Journalisation $dataLog = helper::dateUTF8('%Y %m %d', time()) . ' - ' . helper::dateUTF8('%H:%M', time()); $dataLog .= helper::getIp($this->getData(['config', 'connect', 'anonymousIp'])) . ';'; $dataLog .= empty($this->getUser('id')) ? 'visitor;' : $this->getUser('id') . ';'; - $dataLog .= $message ? $this->getUrl() . ';'. $message : $this->getUrl(); + $dataLog .= $message ? $this->getUrl() . ';' . $message : $this->getUrl(); $dataLog .= PHP_EOL; if ($this->getData(['config', 'connect', 'log'])) { file_put_contents(self::DATA_DIR . 'journal.log', $dataLog, FILE_APPEND); diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index a85f1df9..50f9d781 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -313,6 +313,7 @@ class init extends common 'name' => 'Membre simple', 'readonly' => false, 'comment' => 'Accède aux pages réservées', + 'filemanager' => false, 'file' => [ 'download' => false, 'edit' => false, @@ -333,13 +334,14 @@ class init extends common 'copycut' => false, 'chmod' => false, 'share' => false, - 'path' => './site/file/source/partage/', + 'path' => null, ] ], '1' => [ 'name' => 'Membre', 'readonly' => false, 'comment' => 'Accède aux pages réservées et à un dossier partagé', + 'filemanager' => true, 'file' => [ 'download' => false, 'edit' => false, @@ -369,6 +371,7 @@ class init extends common 'name' => 'Modérateur', 'readonly' => false, 'comment' => 'Edition des pages', + 'filemanager' => true, 'file' => [ 'download' => true, 'edit' => true, @@ -396,6 +399,7 @@ class init extends common 'name' => 'Editeur avec gestion des fichiers', 'readonly' => false, 'comment' => 'Edition des pages', + 'filemanager' => true, 'file' => [ 'download' => true, 'edit' => true, diff --git a/core/module/user/user.php b/core/module/user/user.php index fb94bb15..955d693d 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -535,8 +535,6 @@ class user extends common $this->deleteData(['profil', $oldGroup, $profil]); $profil = helper::increment($profil, $this->getData(['profil', $group])); } - echo "groupe " . $group; - echo "profil " . $profil; $this->setData([ 'profil', $group, @@ -545,6 +543,7 @@ class user extends common 'name' => $this->getInput('profilEditName', helper::FILTER_STRING_SHORT, true), 'readonly' => false, 'comment' => $this->getInput('profilEditComment', helper::FILTER_STRING_SHORT, true), + 'filemanager' => $this->getInput('profilEditFileManager', helper::FILTER_BOOLEAN), 'file' => [ 'download' => $this->getInput('profilEditDownload', helper::FILTER_BOOLEAN), 'edit' => $this->getInput('profilEditEdit', helper::FILTER_BOOLEAN), @@ -564,7 +563,6 @@ class user extends common 'rename' => $this->getInput('profilEditFolderRename', helper::FILTER_BOOLEAN), 'copycut' => $this->getInput('profilEditFolderCopycut', helper::FILTER_BOOLEAN), 'chmod' => $this->getInput('profilEditFolderChmod', helper::FILTER_BOOLEAN), - 'share' => $this->getInput('profilEditShare', helper::FILTER_BOOLEAN), 'path' => $this->getInput('profilEditPath'), ] ] @@ -595,6 +593,48 @@ class user extends common public function profilAdd() { + // Soumission du formulaire + if ($this->isPost()) { + // Sauvegarder les données + $this->setData([ + 'profil', + $this->getInput('profilAddGroup'), + $this->getInput('profilAddProfil'), + [ + 'name' => $this->getInput('profilAddName', helper::FILTER_STRING_SHORT, true), + 'readonly' => false, + 'comment' => $this->getInput('profilAddComment', helper::FILTER_STRING_SHORT, true), + 'filemanager' => $this->getInput('profilAddFileManager', helper::FILTER_BOOLEAN), + 'file' => [ + 'download' => $this->getInput('profilAddDownload', helper::FILTER_BOOLEAN), + 'edit' => $this->getInput('profilAddEdit', helper::FILTER_BOOLEAN), + 'create' => $this->getInput('profilAddCreate', helper::FILTER_BOOLEAN), + 'rename' => $this->getInput('profilAddRename', helper::FILTER_BOOLEAN), + 'upload' => $this->getInput('profilAddUpload', helper::FILTER_BOOLEAN), + 'delete' => $this->getInput('profilAddDelete', helper::FILTER_BOOLEAN), + 'preview' => $this->getInput('profilAddPreview', helper::FILTER_BOOLEAN), + 'duplicate' => $this->getInput('profilAddDuplicate', helper::FILTER_BOOLEAN), + 'extract' => $this->getInput('profilAddExtract', helper::FILTER_BOOLEAN), + 'copycut' => $this->getInput('profilAddCopycut', helper::FILTER_BOOLEAN), + 'chmod' => $this->getInput('profilAddChmod', helper::FILTER_BOOLEAN), + ], + 'folder' => [ + 'create' => $this->getInput('profilAddFolderCreate', helper::FILTER_BOOLEAN), + 'delete' => $this->getInput('profilAddFolderDelete', helper::FILTER_BOOLEAN), + 'rename' => $this->getInput('profilAddFolderRename', helper::FILTER_BOOLEAN), + 'copycut' => $this->getInput('profilAddFolderCopycut', helper::FILTER_BOOLEAN), + 'chmod' => $this->getInput('profilAddFolderChmod', helper::FILTER_BOOLEAN), + 'path' => $this->getInput('profilAddPath'), + ] + ] + ]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'user/profil', + 'notification' => helper::translate('Modifications enregistrées'), + 'state' => true + ]); + } // Valeurs en sortie; $this->addOutput([ diff --git a/core/module/user/view/profilAdd/profilAdd.php b/core/module/user/view/profilAdd/profilAdd.php index 7ca99fe3..d41bfc35 100644 --- a/core/module/user/view/profilAdd/profilAdd.php +++ b/core/module/user/view/profilAdd/profilAdd.php @@ -52,7 +52,7 @@
    - +
    - $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'folder', 'share']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'filemanager']) ]); ?>
    diff --git a/core/vendor/filemanager/config/config.php b/core/vendor/filemanager/config/config.php index 70b071ea..b6786991 100644 --- a/core/vendor/filemanager/config/config.php +++ b/core/vendor/filemanager/config/config.php @@ -424,7 +424,7 @@ $config = array( // for copy/cut files 'copy_cut_dirs' => $folder['copycut'] ? $folder['copycut'] : false, // for copy/cut directories - 'chmod_files' => $file['permission'] ? $file['permission'] : false, + 'chmod_files' => $file['chmod'] ? $file['chmod'] : false, // change file permissions 'chmod_dirs' => $folder['chmod'] ? $folder['chmod'] : false, // change folder permissions