Revert "Modif Sylvain"

This reverts commit 87d2e22577.
This commit is contained in:
Fred Tempez 2020-10-11 18:45:43 +02:00
parent 87d2e22577
commit 50f8d5afe3
12 changed files with 347 additions and 317 deletions

6
.gitignore vendored
View File

@ -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

View File

@ -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') &&

View File

@ -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([
@ -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,9 +315,9 @@ 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é
@ -324,10 +348,9 @@ class page extends common {
$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'])) {
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
@ -429,11 +452,6 @@ class page extends common {
}
}
}
}
// 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
@ -491,6 +509,5 @@ class page extends common {
'view' => 'edit'
]);
}
}
}

View File

@ -1,8 +1,7 @@
<?php
echo template::formOpen('pageEditForm');
// Mise à jour de la liste des pages pour TinyMCE
$this->pages2Json();
// Validation des buttons réservés aux modérateurs et administrateurs
$this->pages2Json(); ?>
<div class="row">
<div class="col2">
<?php $href = helper::baseUrl() . $this->getUrl(2); ?>
@ -15,23 +14,23 @@ echo template::formOpen('pageEditForm');
]); ?>
</div>
<div class="col2 offset4">
<?php if( $this->getUser('group') >= self::GROUP_MODERATOR ){
echo template::button('pageEditDuplicate', [
<?php if ( $module::$actions['duplicate'] < $this->getUser('group')): ?>
<?php echo template::button('pageEditDuplicate', [
'href' => helper::baseUrl() . 'page/duplicate/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'],
'value' => 'Dupliquer',
'ico' => 'clone'
]);
}?>
]); ?>
<?php endif;?>
</div>
<div class="col2">
<?php if( $this->getUser('group') >= self::GROUP_MODERATOR ){
echo template::button('pageEditDelete', [
<?php if ( $module::$actions['delete'] < $this->getUser('group')): ?>
<?php echo template::button('pageEditDelete', [
'class' => 'buttonRed',
'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'],
'value' => 'Supprimer',
'ico' => 'cancel'
]);
}?>
]); ?>
<?php endif;?>
</div>
<div class="col2">
<?php echo template::submit('pageEditSubmit'); ?>
@ -52,25 +51,23 @@ echo template::formOpen('pageEditForm');
<div class="row">
<div class="col9">
<?php echo template::hidden('pageEditModuleRedirect'); ?>
<?php echo template::select('pageEditModuleId', $module::$moduleIds, [
<?php echo template::select('pageEditModuleId', $listModules, [
'help' => 'En cas de changement de module, les données du module précédent seront supprimées.',
'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'])
]); ?>
<!-- Confirmation de suppression e ca sd'annulation -->
<?php echo template::hidden('pageEditModuleIdOld',['value' => $this->getData(['page', $this->getUrl(2), 'moduleId'])]); ?>
<?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']))
]); ?>
</div>
<div class="col3 verticalAlignBottom">
<?php if( $this->getUser('group') >= self::GROUP_MODERATOR){
echo template::button('pageEditModuleConfig', [
<?php echo template::button('pageEditModuleConfig', [
'disabled' => (bool) $this->getData(['page', $this->getUrl(2), 'moduleId']) === false,
'uniqueSubmission' => true,
'value' => template::ico('gear')
]);
}?>
]); ?>
</div>
</div>
</div>
@ -93,8 +90,7 @@ echo template::formOpen('pageEditForm');
<?php echo template::select('configModulePosition', $module::$modulePosition,[
'help' => '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'])
]); ?>
</div>
</div>
@ -166,7 +162,6 @@ echo template::formOpen('pageEditForm');
</div>
</div>
</div>
<?php if( $this->getUser('group') >= self::GROUP_MODERATOR){ ?>
<div class="row">
<div class="col12" id="pageEditMenu">
<div class="block" id="location">
@ -294,4 +289,4 @@ echo template::formOpen('pageEditForm');
</div>
</div>
</div>
<?php } echo template::formClose(); ?>
<?php echo template::formClose(); ?>

View File

@ -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
]);
}

View File

@ -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']

View File

@ -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,6 +375,13 @@ class blog 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
]);
} else {
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) {
// Valeurs en sortie
$this->addOutput([
@ -400,6 +407,7 @@ class blog extends common {
]);
}
}
}
/**
* Édition
@ -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'])] . ')';

View File

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

View File

@ -103,7 +103,6 @@
</div>
</div>
</div>
<?php if( $this->getUser('group') >= self::GROUP_MODERATOR){ ?>
<div class="row">
<div class="col6">
<div class="block">
@ -146,4 +145,4 @@
</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 $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,6 +287,13 @@ class gallery 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
]);
} else {
// $url prend l'adresse sans le token
// La galerie n'existe pas
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) {
@ -314,6 +321,7 @@ class gallery extends common {
]);
}
}
}
/**
* Liste des dossiers

View File

@ -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,6 +117,13 @@ class news 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
]);
} else {
// La news n'existe pas
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) {
// Valeurs en sortie
@ -143,6 +150,7 @@ class news extends common {
]);
}
}
}
/**
* Édition