+ helper::baseUrl() . 'user/import',
+ 'ico' => 'plus',
+ 'value' => 'Importation'
+ ]); ?>
+
helper::baseUrl() . 'user/add',
'ico' => 'plus',
diff --git a/core/vendor/filemanager/config/config.php b/core/vendor/filemanager/config/config.php
index 29537313..73e03b8b 100644
--- a/core/vendor/filemanager/config/config.php
+++ b/core/vendor/filemanager/config/config.php
@@ -119,7 +119,7 @@ $config = array(
| If you want to be forced to assign the extension starting from the mime type
|
*/
- 'mime_extension_rename' => true,
+ 'mime_extension_rename' => false,
/*
diff --git a/core/vendor/tinymce/init.js b/core/vendor/tinymce/init.js
index fafb074b..809ad9f2 100755
--- a/core/vendor/tinymce/init.js
+++ b/core/vendor/tinymce/init.js
@@ -4,6 +4,13 @@
*/
+ /**
+ * Quand tinyMCE est invoqué hors connexion, initialiser privateKey
+ */
+ if ( typeof(privateKey) == 'undefined') {
+ var privateKey = null;
+};
+
tinymce.init({
// Classe où appliquer l'éditeur
selector: ".editorWysiwyg",
@@ -20,7 +27,7 @@ tinymce.init({
// Plugins
plugins: "advlist anchor autolink autoresize autosave codemirror colorpicker contextmenu fullscreen hr image imagetools link lists media paste searchreplace stickytoolbar tabfocus table template textcolor emoticons nonbreaking",
// Contenu de la barre d'outils
- toolbar: "restoredraft | undo redo | bold italic underline forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist emoticons | table template | image media link | code fullscreen",
+ toolbar: "restoredraft | undo redo | formatselect bold italic underline forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist emoticons | table template | image media link | code fullscreen",
// Emoticons
emoticons_append: {
custom_mind_explode: {
@@ -118,12 +125,6 @@ tinymce.init({
external_plugins: {
"filemanager": baseUrl + "core/vendor/filemanager/plugin.min.js"
},
- // Thème mobile
- // mobile: {
- // theme: "mobile",
- // plugins: [ 'autosave', 'lists', 'autolink' ],
- // toolbar: [ 'undo', 'bold', 'italic', 'styleselect' ]
- //},
// Contenu du bouton insérer
insert_button_items: "anchor hr table",
// Contenu du bouton formats
@@ -206,6 +207,144 @@ tinymce.init({
]
});
+
+tinymce.init({
+ // Classe où appliquer l'éditeur
+ selector: ".editorWysiwygComment",
+ setup:function(ed) {
+ // Aperçu dans le pied de page
+ ed.on('change', function(e) {
+ if (ed.id === 'themeFooterText') {
+ $("#footerText").html(tinyMCE.get('themeFooterText').getContent());
+ }
+ });
+ // Limitation du nombre de caractères des commentaires à maxlength
+ var alarmCaraMin = 200; // alarme sur le nombre de caractères restants à partir de...
+ var maxlength = parseInt($("#" + (ed.id)).attr("maxlength"));
+ var id_alarm = "#blogArticleContentAlarm"
+ var contentLength = 0;
+ ed.on("keydown", function(e) {
+ contentLength = ed.getContent({format : 'text'}).length;
+ if (contentLength > maxlength) {
+ $(id_alarm).html("Vous avez atteint le maximum de " + maxlength + " caractères ! ");
+ if(e.keyCode != 8 && e.keyCode != 46){
+ e.preventDefault();
+ e.stopPropagation();
+ return false;
+ }
+ }
+ else{
+ if(maxlength - contentLength < alarmCaraMin){
+ $(id_alarm).html((maxlength - contentLength) + " caractères restants");
+ }
+ else{
+ $(id_alarm).html(" ");
+ }
+ }
+ });
+ // Limitation y compris lors d'un copier/coller
+ ed.on("paste", function(e){
+ contentLeng = ed.getContent({format : 'text'}).length - 16;
+ var data = e.clipboardData.getData('Text');
+ if (data.length > (maxlength - contentLeng)) {
+ $(id_alarm).html("Vous alliez dépasser le maximum de " + maxlength + " caractères ! ");
+ return false;
+ } else {
+ if(maxlength - contentLeng < alarmCaraMin){
+ $(id_alarm).html((maxlength - contentLeng - data.length) + " caractères restants");
+ }
+ else{
+ $(id_alarm).html(" ");
+ }
+ return true;
+ }
+ });
+ },
+ // Langue
+ language: "fr_FR",
+ // Plugins
+ plugins: "advlist anchor autolink autoresize autosave colorpicker contextmenu fullscreen hr lists paste searchreplace stickytoolbar tabfocus template textcolor visualblocks emoticons",
+ // Contenu de la barre d'outils
+ toolbar: "restoredraft | undo redo | formatselect bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist emoticons | visualblocks fullscreen",
+ // Emoticons
+ emoticons_append: {
+ custom_mind_explode: {
+ keywords: ["brain", "mind", "explode", "blown"],
+ char: "🤯"
+ }
+ },
+ // Titre des images
+ image_title: true,
+ // Pages internes
+ link_list: baseUrl + "core/vendor/tinymce/links.php",
+ // Contenu du menu contextuel
+ contextmenu: "cut copy paste pastetext | selectall searchreplace ",
+ // Fichiers CSS à intégrer à l'éditeur
+ content_css: [
+ baseUrl + "core/layout/common.css",
+ baseUrl + "core/vendor/tinymce/content.css",
+ baseUrl + "site/data/theme.css",
+ baseUrl + "site/data/custom.css"
+ ],
+// Classe à ajouter à la balise body dans l'iframe
+ body_class: "editorWysiwyg",
+ // Cache les menus
+ menubar: false,
+ // URL menu contextuel
+ link_context_toolbar: true,
+ // Cache la barre de statut
+ statusbar: false,
+ // Autorise le copié collé à partir du web
+ paste_data_images: true,
+ // Autorise tous les éléments
+ //valid_elements :"*[*]",
+ //valid_children : "*[*]",
+ // Autorise l'ajout de script
+ // extended_valid_elements: "script[language|type|src]",
+ // Bloque le dimensionnement des médias (car automatiquement en fullsize avec fitvids pour le responsive)
+ media_dimensions: true,
+ // Désactiver la dimension des images
+ image_dimensions: true,
+ // Active l'onglet avancé lors de l'ajout d'une image
+ image_advtab: true,
+ // Urls absolues
+ relative_urls: false,
+ // Url de base
+ document_base_url: baseUrl,
+ // Contenu du bouton formats
+ style_formats: [
+ {title: "Headers", items: [
+ {title: "Header 1", format: "h1"},
+ {title: "Header 2", format: "h2"},
+ {title: "Header 3", format: "h3"},
+ {title: "Header 4", format: "h4"}
+ ]},
+ {title: "Inline", items: [
+ {title: "Bold", icon: "bold", format: "bold"},
+ {title: "Italic", icon: "italic", format: "italic"},
+ {title: "Underline", icon: "underline", format: "underline"},
+ {title: "Strikethrough", icon: "strikethrough", format: "strikethrough"},
+ {title: "Superscript", icon: "superscript", format: "superscript"},
+ {title: "Subscript", icon: "subscript", format: "subscript"},
+ {title: "Code", icon: "code", format: "code"}
+ ]},
+ {title: "Blocks", items: [
+ {title: "Paragraph", format: "p"},
+ {title: "Blockquote", format: "blockquote"},
+ {title: "Div", format: "div"},
+ {title: "Pre", format: "pre"}
+ ]},
+ {title: "Alignment", items: [
+ {title: "Left", icon: "alignleft", format: "alignleft"},
+ {title: "Center", icon: "aligncenter", format: "aligncenter"},
+ {title: "Right", icon: "alignright", format: "alignright"},
+ {title: "Justify", icon: "alignjustify", format: "alignjustify"}
+ ]}
+ ]
+});
+
+
+
tinymce.PluginManager.add('stickytoolbar', function(editor, url) {
editor.on('init', function() {
setSticky();
diff --git a/module/blog/blog.php b/module/blog/blog.php
index a13c011c..c679d769 100644
--- a/module/blog/blog.php
+++ b/module/blog/blog.php
@@ -14,10 +14,16 @@
class blog extends common {
+ const EDIT_OWNER = 'owner';
+ const EDIT_GROUP = 'group';
+ const EDIT_ALL = 'all';
+
public static $actions = [
'add' => self::GROUP_MODERATOR,
'comment' => self::GROUP_MODERATOR,
+ 'commentApprove' => self::GROUP_MODERATOR,
'commentDelete' => self::GROUP_MODERATOR,
+ 'commentDeleteAll' => self::GROUP_MODERATOR,
'config' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
@@ -26,8 +32,21 @@ class blog extends common {
public static $articles = [];
+ // Signature de l'article
+ public static $articleSignature = '';
+
+ // Signature du commentaire
+ public static $editCommentSignature = '';
+
public static $comments = [];
+ public static $nbCommentsApproved = 0;
+
+ public static $commentsDelete;
+
+ // Signatures des commentaires déjà saisis
+ public static $commentsSignature = [];
+
public static $pages;
public static $states = [
@@ -48,10 +67,26 @@ class blog extends common {
'right' => 'À droite ',
];
+ //Paramètre longueur maximale des commentaires en nb de caractères
+ public static $commentLength = [
+ '500' => '500',
+ '1000' => '1000',
+ '2000' => '2000',
+ '5000' => '5000',
+ '10000' => '10000'
+ ];
+
+ // Permissions d'un article
+ public static $articleConsent = [
+ self::EDIT_ALL => 'Tous les groupes',
+ self::EDIT_GROUP => 'Groupe du propriétaire',
+ self::EDIT_OWNER => 'Propiétaire'
+ ];
+
public static $users = [];
- const BLOG_VERSION = '2.02';
+ const BLOG_VERSION = '3.1';
/**
* Édition
@@ -59,26 +94,39 @@ class blog extends common {
public function add() {
// Soumission du formulaire
if($this->isPost()) {
+ // Modification de l'userId
+ if($this->getUser('group') === self::GROUP_ADMIN){
+ $newuserid = $this->getInput('blogAddUserId', helper::FILTER_STRING_SHORT, true);
+ }
+ else{
+ $newuserid = $this->getUser('id');
+ }
// Incrémente l'id de l'article
$articleId = helper::increment($this->getInput('blogAddTitle', helper::FILTER_ID), $this->getData(['page']));
$articleId = helper::increment($articleId, (array) $this->getData(['module', $this->getUrl(0)]));
$articleId = helper::increment($articleId, array_keys(self::$actions));
// Crée l'article
- $this->setData(['module', $this->getUrl(0), $articleId, [
- 'closeComment' => $this->getInput('blogAddCloseComment', helper::FILTER_BOOLEAN),
- 'mailNotification' => $this->getInput('blogAddMailNotification', helper::FILTER_BOOLEAN),
- 'groupNotification' => $this->getInput('blogAddGroupNotification', helper::FILTER_INT),
- 'comment' => [],
- 'content' => $this->getInput('blogAddContent', null),
- 'picture' => $this->getInput('blogAddPicture', helper::FILTER_STRING_SHORT, true),
- 'hidePicture' => $this->getInput('blogAddHidePicture', helper::FILTER_BOOLEAN),
- 'pictureSize' => $this->getInput('blogAddPictureSize', helper::FILTER_STRING_SHORT),
- 'picturePosition' => $this->getInput('blogAddPicturePosition', helper::FILTER_STRING_SHORT),
- 'publishedOn' => $this->getInput('blogAddPublishedOn', helper::FILTER_DATETIME, true),
- 'state' => $this->getInput('blogAddState', helper::FILTER_BOOLEAN),
- 'title' => $this->getInput('blogAddTitle', helper::FILTER_STRING_SHORT, true),
- 'userId' => $this->getInput('blogAddUserId', helper::FILTER_ID, true)
- ]]);
+ $this->setData(['module',
+ $this->getUrl(0),
+ $articleId, [
+ 'comment' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment']),
+ 'content' => $this->getInput('blogAddContent', null),
+ 'picture' => $this->getInput('blogAddPicture', helper::FILTER_STRING_SHORT, true),
+ 'hidePicture' => $this->getInput('blogAddHidePicture', helper::FILTER_BOOLEAN),
+ 'pictureSize' => $this->getInput('blogAddPictureSize', helper::FILTER_STRING_SHORT),
+ 'picturePosition' => $this->getInput('blogAddPicturePosition', helper::FILTER_STRING_SHORT),
+ 'publishedOn' => $this->getInput('blogAddPublishedOn', helper::FILTER_DATETIME, true),
+ 'state' => $this->getInput('blogAddState', helper::FILTER_BOOLEAN),
+ 'title' => $this->getInput('blogAddTitle', helper::FILTER_STRING_SHORT, true),
+ 'userId' => $newuserid,
+ 'editConsent' => $this->getInput('blogAddConsent') === self::EDIT_GROUP ? $this->getUser('group') : $this->getInput('blogAddConsent'),
+ 'commentMaxlength' => $this->getInput('blogAddCommentMaxlength'),
+ 'commentApproved' => $this->getInput('blogAddCommentApproved', helper::FILTER_BOOLEAN),
+ 'commentClose' => $this->getInput('blogAddCommentClose', helper::FILTER_BOOLEAN),
+ 'commentNotification' => $this->getInput('blogAddCommentNotification', helper::FILTER_BOOLEAN),
+ 'commentGroupNotification' => $this->getInput('blogAddCommentGroupNotification', helper::FILTER_INT)
+ ]
+ ]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
@@ -108,14 +156,13 @@ class blog extends common {
* Liste des commentaires
*/
public function comment() {
- // Liste les commentaires
- $comments = [];
- foreach((array) $this->getData(['module', $this->getUrl(0)]) as $articleId => $article) {
- foreach($article['comment'] as &$comment) {
- $comment['articleId'] = $articleId;
- }
- $comments += $article['comment'];
- }
+ $comments = $this->getData(['module', $this->getUrl(0), $this->getUrl(2),'comment']);
+ self::$commentsDelete = template::button('blogCommentDeleteAll', [
+ 'class' => 'blogCommentDeleteAll buttonRed',
+ 'href' => helper::baseUrl() . $this->getUrl(0) . '/commentDeleteAll/' . $this->getUrl(2).'/' . $_SESSION['csrf'] ,
+ 'ico' => 'cancel',
+ 'value' => 'Tout effacer'
+ ]);
// Ids des commentaires par ordre de création
$commentIds = array_keys(helper::arrayCollumn($comments, 'createdOn', 'SORT_DESC'));
// Pagination
@@ -126,22 +173,34 @@ class blog extends common {
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
// Met en forme le tableau
$comment = $comments[$commentIds[$i]];
+ // Bouton d'approbation
+ $buttonApproval = '';
+ // Compatibilité avec les commentaires des versions précédentes, les valider
+ $comment['approval'] = array_key_exists('approval', $comment) === false ? true : $comment['approval'] ;
+ if ( $this->getData(['module', $this->getUrl(0), $this->getUrl(2),'commentApproved']) === true) {
+ $buttonApproval = template::button('blogCommentApproved' . $commentIds[$i], [
+ 'class' => $comment['approval'] === true ? 'blogCommentRejected buttonGreen' : 'blogCommentApproved buttonRed' ,
+ 'href' => helper::baseUrl() . $this->getUrl(0) . '/commentApprove/' . $this->getUrl(2) . '/' . $commentIds[$i] . '/' . $_SESSION['csrf'] ,
+ 'value' => $comment['approval'] === true ? 'A' : 'R'
+ ]);
+ }
self::$comments[] = [
mb_detect_encoding(strftime('%d %B %Y - %H:%M', $comment['createdOn']), 'UTF-8', true)
? strftime('%d %B %Y - %H:%M', $comment['createdOn'])
: utf8_encode(strftime('%d %B %Y - %H:%M', $comment['createdOn'])),
$comment['content'],
$comment['userId'] ? $this->getData(['user', $comment['userId'], 'firstname']) . ' ' . $this->getData(['user', $comment['userId'], 'lastname']) : $comment['author'],
+ $buttonApproval,
template::button('blogCommentDelete' . $commentIds[$i], [
'class' => 'blogCommentDelete buttonRed',
- 'href' => helper::baseUrl() . $this->getUrl(0) . '/comment-delete/' . $comment['articleId'] . '/' . $commentIds[$i] . '/' . $_SESSION['csrf'] ,
+ 'href' => helper::baseUrl() . $this->getUrl(0) . '/commentDelete/' . $this->getUrl(2) . '/' . $commentIds[$i] . '/' . $_SESSION['csrf'] ,
'value' => template::ico('cancel')
])
];
}
// Valeurs en sortie
$this->addOutput([
- 'title' => 'Gestion des commentaires',
+ 'title' => 'Gestion des commentaires : '. $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'title']),
'view' => 'comment'
]);
}
@@ -170,25 +229,122 @@ class blog extends common {
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3)]);
// Valeurs en sortie
$this->addOutput([
- 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/comment',
+ 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/comment/'.$this->getUrl(2),
'notification' => 'Commentaire supprimé',
'state' => true
]);
}
}
+ /**
+ * Suppression de tous les commentaires de l'article $this->getUrl(2)
+ */
+ public function commentDeleteAll() {
+ // Jeton incorrect
+ if ($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->setData(['module', $this->getUrl(0), $this->getUrl(2), 'comment',[] ]);
+ // Valeurs en sortie
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/comment',
+ 'notification' => 'Commentaires supprimés',
+ 'state' => true
+ ]);
+ }
+ }
+
+ /**
+ * Approbation oou désapprobation de commentaire
+ */
+ public function commentApprove() {
+ // Le commentaire n'existe pas
+ if($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3)]) === null) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'access' => false
+ ]);
+ }
+ // Jeton incorrect
+ elseif ($this->getUrl(4) !== $_SESSION['csrf']) {
+ // Valeurs en sortie
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
+ 'notification' => 'Action non autorisée'
+ ]);
+ }
+ // Inversion du statut
+ else {
+ $approved = !$this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'approval']) ;
+ $this->setData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), [
+ 'author' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'author']),
+ 'content' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'content']),
+ 'createdOn' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'createdOn']),
+ 'userId' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'userId']),
+ 'approval' => $approved
+ ]]);
+
+ // Valeurs en sortie
+ $this->addOutput([
+ 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/comment/'.$this->getUrl(2),
+ 'notification' => $approved ? 'Commentaire approuvé' : 'Commentaire rejeté',
+ 'state' => $approved
+ ]);
+ }
+ }
+
/**
* Configuration
*/
public function config() {
// Ids des articles par ordre de publication
$articleIds = array_keys(helper::arrayCollumn($this->getData(['module', $this->getUrl(0)]), 'publishedOn', 'SORT_DESC'));
+ // Gestion des droits d'accès
+ $filterData=[];
+ foreach ($articleIds as $key => $value) {
+ if (
+ ( // Propriétaire
+ $this->getData(['module', $this->getUrl(0), $value,'editConsent']) === self::EDIT_OWNER
+ AND ( $this->getData(['module', $this->getUrl(0), $value,'userId']) === $this->getUser('id')
+ OR $this->getUser('group') === self::GROUP_ADMIN )
+ )
+
+ OR (
+ // Groupe
+ $this->getData(['module', $this->getUrl(0), $value,'editConsent']) !== self::EDIT_OWNER
+ AND $this->getUser('group') >= $this->getData(['module',$this->getUrl(0), $value,'editConsent'])
+ )
+ OR (
+ // Tout le monde
+ $this->getData(['module', $this->getUrl(0), $value,'editConsent']) === self::EDIT_ALL
+ )
+ ) {
+ $filterData[] = $value;
+ }
+ }
+ $articleIds = $filterData;
// Pagination
$pagination = helper::pagination($articleIds, $this->getUrl(),$this->getData(['config','itemsperPage']));
// Liste des pages
self::$pages = $pagination['pages'];
// Articles en fonction de la pagination
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
+ // Nombre de commentaires à approuver et approuvés
+ $approvals = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), $articleIds[$i], 'comment' ]),'approval', 'SORT_DESC');
+ if ( is_array($approvals) ) {
+ $a = array_values($approvals);
+ $toApprove = count(array_keys($a,false));
+ $approved = count(array_keys($a,true));
+ } else {
+ $toApprove = 0;
+ $approved = count($this->getData(['module', $this->getUrl(0), $articleIds[$i],'comment']));
+ }
// Met en forme le tableau
$date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])), 'UTF-8', true)
? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn']))
@@ -197,9 +353,17 @@ class blog extends common {
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn']))
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])));
self::$articles[] = [
- $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'title']),
+ '
' .
+ $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'title']) .
+ '',
$date .' à '. $heure,
self::$states[$this->getData(['module', $this->getUrl(0), $articleIds[$i], 'state'])],
+ // Bouton pour afficher les commentaires de l'article
+ template::button('blogConfigComment' . $articleIds[$i], [
+ 'class' => ($toApprove || $approved ) > 0 ? 'buttonBlue' : 'buttonGrey' ,
+ 'href' => ($toApprove || $approved ) > 0 ? helper::baseUrl() . $this->getUrl(0) . '/comment/' . $articleIds[$i] : '',
+ 'value' => $toApprove > 0 ? $toApprove . '/' . $approved : $approved
+ ]),
template::button('blogConfigEdit' . $articleIds[$i], [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $articleIds[$i] . '/' . $_SESSION['csrf'],
'value' => template::ico('pencil')
@@ -271,6 +435,12 @@ class blog extends common {
else {
// Soumission du formulaire
if($this->isPost()) {
+ if($this->getUser('group') === self::GROUP_ADMIN){
+ $newuserid = $this->getInput('blogEditUserId', helper::FILTER_STRING_SHORT, true);
+ }
+ else{
+ $newuserid = $this->getUser('id');
+ }
$articleId = $this->getInput('blogEditTitle', helper::FILTER_ID, true);
// Incrémente le nouvel id de l'article
if($articleId !== $this->getUrl(2)) {
@@ -278,21 +448,27 @@ class blog extends common {
$articleId = helper::increment($articleId, $this->getData(['module', $this->getUrl(0)]));
$articleId = helper::increment($articleId, array_keys(self::$actions));
}
- $this->setData(['module', $this->getUrl(0), $articleId, [
- 'closeComment' => $this->getInput('blogEditCloseComment'),
- 'mailNotification' => $this->getInput('blogEditMailNotification', helper::FILTER_BOOLEAN),
- 'groupNotification' => $this->getInput('blogEditGroupNotification', helper::FILTER_INT),
- 'comment' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment']),
- 'content' => $this->getInput('blogEditContent', null),
- 'picture' => $this->getInput('blogEditPicture', helper::FILTER_STRING_SHORT, true),
- 'hidePicture' => $this->getInput('blogEditHidePicture', helper::FILTER_BOOLEAN),
- 'pictureSize' => $this->getInput('blogEditPictureSize', helper::FILTER_STRING_SHORT),
- 'picturePosition' => $this->getInput('blogEditPicturePosition', helper::FILTER_STRING_SHORT),
- 'publishedOn' => $this->getInput('blogEditPublishedOn', helper::FILTER_DATETIME, true),
- 'state' => $this->getInput('blogEditState', helper::FILTER_BOOLEAN),
- 'title' => $this->getInput('blogEditTitle', helper::FILTER_STRING_SHORT, true),
- 'userId' => $this->getInput('blogEditUserId', helper::FILTER_ID, true)
- ]]);
+ $this->setData(['module',
+ $this->getUrl(0),
+ $articleId, [
+ 'comment' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment']),
+ 'content' => $this->getInput('blogEditContent', null),
+ 'picture' => $this->getInput('blogEditPicture', helper::FILTER_STRING_SHORT, true),
+ 'hidePicture' => $this->getInput('blogEditHidePicture', helper::FILTER_BOOLEAN),
+ 'pictureSize' => $this->getInput('blogEditPictureSize', helper::FILTER_STRING_SHORT),
+ 'picturePosition' => $this->getInput('blogEditPicturePosition', helper::FILTER_STRING_SHORT),
+ 'publishedOn' => $this->getInput('blogEditPublishedOn', helper::FILTER_DATETIME, true),
+ 'state' => $this->getInput('blogEditState', helper::FILTER_BOOLEAN),
+ 'title' => $this->getInput('blogEditTitle', helper::FILTER_STRING_SHORT, true),
+ 'userId' => $newuserid,
+ 'editConsent' => $this->getInput('blogEditConsent') === self::EDIT_GROUP ? $this->getUser('group') : $this->getInput('blogEditConsent'),
+ 'commentMaxlength' => $this->getInput('blogEditCommentMaxlength'),
+ 'commentApproved' => $this->getInput('blogEditCommentApproved', helper::FILTER_BOOLEAN),
+ 'commentClose' => $this->getInput('blogEditCommentClose', helper::FILTER_BOOLEAN),
+ 'commentNotification' => $this->getInput('blogEditCommentNotification', helper::FILTER_BOOLEAN),
+ 'commentGroupNotification' => $this->getInput('blogEditCommentGroupNotification', helper::FILTER_INT)
+ ]
+ ]);
// Supprime l'ancien article
if($articleId !== $this->getUrl(2)) {
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]);
@@ -308,7 +484,11 @@ class blog extends common {
self::$users = helper::arrayCollumn($this->getData(['user']), 'firstname');
ksort(self::$users);
foreach(self::$users as $userId => &$userFirstname) {
- $userFirstname = $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']);
+ // Les membres ne sont pas éditeurs, les exclure de la liste
+ 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'])] . ')';
}
unset($userFirstname);
// Valeurs en sortie
@@ -354,37 +534,38 @@ class blog extends common {
}
// Crée le commentaire
$commentId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment']));
+ $content = $this->getInput('blogArticleContent', false);
$this->setData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentId, [
'author' => $this->getInput('blogArticleAuthor', helper::FILTER_STRING_SHORT, empty($this->getInput('blogArticleUserId')) ? TRUE : FALSE),
- 'content' => $this->getInput('blogArticleContent', helper::FILTER_STRING_SHORT, true),
+ 'content' => $content,
'createdOn' => time(),
'userId' => $this->getInput('blogArticleUserId'),
+ 'approval' => !$this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'commentApproved']) // true commentaire publié false en attente de publication
]]);
-
// Envoi d'une notification aux administrateurs
// Init tableau
$to = [];
// Liste des destinataires
foreach($this->getData(['user']) as $userId => $user) {
- if ($user['group'] >= $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'groupNotification']) ) {
+ if ($user['group'] >= $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'commentGroupNotification']) ) {
$to[] = $user['mail'];
}
}
// Envoi du mail $sent code d'erreur ou de réussite
- if ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'mailNotification']) === true) {
+ $notification = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'commentApproved']) === true ? 'Commentaire déposé en attente d\'approbation': 'Commentaire déposé';
+ if ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'commentNotification']) === true) {
$sent = $this->sendMail(
$to,
'Nouveau commentaire',
- 'Bonjour' . '
' . $user['firstname'] . ' ' . $user['lastname'] . ',
' .
- 'Nouveau commentaire déposé sur la page "' . $this->getData(['page', $this->getUrl(0), 'title']) . '" :
',
+ 'Bonjour,'.'
'. $notification.
+ ' sur la page "'. $this->getData(['page', $this->getUrl(0), 'title']). '" dans l\'article "'.$this->getUrl(1) .'" :
'.
+ $content,
''
);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl() . '#comment',
- //'notification' => 'Commentaire ajouté',
- //'state' => true
- 'notification' => ($sent === true ? 'Commentaire ajouté et une notification envoyée' : 'Commentaire ajouté, erreur de notification :
' . $sent),
+ 'notification' => ($sent === true ? $notification . '
Une notification a été envoyée.' : $notification . '
Erreur de notification : ' . $sent),
'state' => ($sent === true ? true : null)
]);
@@ -392,26 +573,98 @@ class blog extends common {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl() . '#comment',
- 'notification' => 'Commentaire ajouté',
+ 'notification' => $notification,
'state' => true
]);
}
}
- // Ids des commentaires par ordre de publication
- $commentIds = array_keys(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment']), 'createdOn', 'SORT_DESC'));
+ // Ids des commentaires approuvés par ordre de publication
+ $commentsApproved = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment']);
+ if ($commentsApproved) {
+ foreach( $commentsApproved as $key => $value){
+ if($value['approval']===false) unset($commentsApproved[$key]);
+ }
+ // Ligne suivante si affichage du nombre total de commentaires approuvés sous l'article
+ self::$nbCommentsApproved = count($commentsApproved);
+ }
+ $commentIds = array_keys(helper::arrayCollumn($commentsApproved, 'createdOn', 'SORT_DESC'));
// Pagination
$pagination = helper::pagination($commentIds, $this->getUrl(),$this->getData(['config','itemsperPage']),'#comment');
// Liste des pages
self::$pages = $pagination['pages'];
+ // Signature de l'article
+ $userIdArticle = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'userId']);
+ switch ($this->getData(['user', $userIdArticle, 'signature'])){
+ case 1:
+ self::$articleSignature = $userIdArticle;
+ break;
+ case 2:
+ self::$articleSignature = $this->getData(['user', $userIdArticle, 'pseudo']);
+ break;
+ case 3:
+ self::$articleSignature = $this->getData(['user', $userIdArticle, 'firstname']) . ' ' . $this->getData(['user', $userIdArticle, 'lastname']);
+ break;
+ case 4:
+ self::$articleSignature = $this->getData(['user', $userIdArticle, 'lastname']) . ' ' . $this->getData(['user', $userIdArticle, 'firstname']);
+ break;
+ default:
+ self::$articleSignature = $this->getData(['user', $userIdArticle, 'firstname']);
+ }
+ // Signature du commentaire édité
+ if($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')) {
+ $useridcomment = $this->getUser('id');
+ switch ($this->getData(['user', $useridcomment, 'signature'])){
+ case 1:
+ self::$editCommentSignature = $useridcomment;
+ break;
+ case 2:
+ self::$editCommentSignature = $this->getData(['user', $useridcomment, 'pseudo']);
+ break;
+ case 3:
+ self::$editCommentSignature = $this->getData(['user', $useridcomment, 'firstname']) . ' ' . $this->getData(['user', $useridcomment, 'lastname']);
+ break;
+ case 4:
+ self::$editCommentSignature = $this->getData(['user', $useridcomment, 'lastname']) . ' ' . $this->getData(['user', $useridcomment, 'firstname']);
+ break;
+ default:
+ self::$editCommentSignature = $this->getData(['user', $useridcomment, 'firstname']);
+ }
+ }
// Commentaires en fonction de la pagination
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
- self::$comments[$commentIds[$i]] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentIds[$i]]);
+ // Signatures des commentaires
+ $e = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentIds[$i],'userId']);
+ if ($e) {
+ switch ($this->getData(['user', $e, 'signature'])){
+ case 1:
+ self::$commentsSignature[$commentIds[$i]] = $e;
+ break;
+ case 2:
+ self::$commentsSignature[$commentIds[$i]] = $this->getData(['user', $e, 'pseudo']);
+ break;
+ case 3:
+ self::$commentsSignature[$commentIds[$i]] = $this->getData(['user', $e, 'firstname']) . ' ' . $this->getData(['user', $e, 'lastname']);
+ break;
+ case 4:
+ self::$commentsSignature[$commentIds[$i]] = $this->getData(['user', $e, 'lastname']) . ' ' . $this->getData(['user', $e, 'firstname']);
+ break;
+ }
+ } else {
+ self::$commentsSignature[$commentIds[$i]] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentIds[$i],'author']);
+ }
+ // Données du commentaire si approuvé
+ if ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentIds[$i],'approval']) === true ) {
+ self::$comments[$commentIds[$i]] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentIds[$i]]);
+ }
}
// Valeurs en sortie
$this->addOutput([
'showBarEditButton' => true,
'title' => $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'title']),
+ 'vendor' => [
+ 'tinymce'
+ ],
'view' => 'article'
]);
}
@@ -444,4 +697,5 @@ class blog extends common {
]);
}
}
-}
\ No newline at end of file
+}
+
diff --git a/module/blog/view/add/add.js.php b/module/blog/view/add/add.js.php
index 1ade9625..6067ca10 100644
--- a/module/blog/view/add/add.js.php
+++ b/module/blog/view/add/add.js.php
@@ -16,4 +16,39 @@
$("#blogAddDraft").on("click", function() {
$("#blogAddState").val(0);
$("#blogAddForm").trigger("submit");
+});
+
+/**
+ * Options de commentaires
+ */
+$("#blogAddCommentClose").on("change", function() {
+ if ($(this).is(':checked') ) {
+ $(".commentOptionsWrapper").slideUp();
+ } else {
+ $(".commentOptionsWrapper").slideDown();
+ }
+});
+
+$("#blogAddCommentNotification").on("change", function() {
+ if ($(this).is(':checked') ) {
+ $("#blogAddCommentGroupNotification").slideDown();
+ } else {
+ $("#blogAddCommentGroupNotification").slideUp();
+ }
+});
+
+
+$( document).ready(function() {
+
+ if ($("#blogAddCloseComment").is(':checked') ) {
+ $(".commentOptionsWrapper").slideUp();
+ } else {
+ $(".commentOptionsWrapper").slideDown();
+ }
+
+ if ($("#blogAddCommentNotification").is(':checked') ) {
+ $("#blogAddCommentGroupNotification").slideDown();
+ } else {
+ $("#blogAddCommentGroupNotification").slideUp();
+ }
});
\ No newline at end of file
diff --git a/module/blog/view/add/add.php b/module/blog/view/add/add.php
index 37230abd..f3ec7731 100644
--- a/module/blog/view/add/add.php
+++ b/module/blog/view/add/add.php
@@ -56,9 +56,7 @@