diff --git a/core/core.php b/core/core.php index fcb5e126..1c6edfdf 100755 --- a/core/core.php +++ b/core/core.php @@ -1367,6 +1367,38 @@ class common { $this->setData(['user',$userId,'pseudo',$this->getData(['user',$userId,'firstname'])]); $this->setData(['user',$userId,'signature',2]); } + + // Ajouter les champs de blog v3 + // Liste des pages dans pageList + $pageList = array(); + foreach ($this->getHierarchy(null,null,null) as $parentKey=>$parentValue) { + $pageList [] = $parentKey; + foreach ($parentValue as $childKey) { + $pageList [] = $childKey; + } + } + // Parcourir pageList et rechercher les modules de blog + foreach ($pageList as $parentKey => $parent) { + //La page a une galerie + if ($this->getData(['page',$parent,'moduleId']) === 'blog' ) { + $articleIds = array_keys(helper::arrayCollumn($this->getData(['module',$parent]), 'publishedOn', 'SORT_DESC')); + foreach ($articleIds as $key => $article) { + // Droits les deux groupes + $this->setData(['module', $parent, $article,'editRights','22']); + // Limite de taille 500 + $this->setData(['module', $parent, $article,'commentMaxlength', '500']); + // Pas d'approbation des commentaires + $this->setData(['module', $parent, $article,'commentApprove', false ]); + } + // Traitement des commentaires + if ( is_array($this->getData(['module', $parent, $article,'comment'])) ) { + foreach($this->getData(['module', $parent, $article,'comment']) as $commentId => $comment) { + // Approbation + $this->setData(['module', $parent, $article,'comment', $commentId, 'approval', true ]); + } + } + } + } $this->setData(['core', 'dataVersion', 10300]); } } diff --git a/module/blog/blog.php b/module/blog/blog.php index cf7e6b05..d53d50fc 100755 --- a/module/blog/blog.php +++ b/module/blog/blog.php @@ -173,6 +173,8 @@ class blog extends common { $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),'commentApprove']) === true) { $buttonApproval = template::button('blogcommentApprove' . $commentIds[$i], [ 'class' => $comment['approval'] === true ? 'blogCommentReject' : 'blogCommentApprove buttonRed' , @@ -304,7 +306,7 @@ class blog extends common { $rights = $this->getData(['module', $this->getUrl(0), $value,'editRights']); // Compatibilité pas de droit stocké placer droit par défaut $rights = empty($rights) ? '02' : $rights; - // Check les droits du propriétaire + // Check les droits du propriétaire // Check les droits du groupe if ( ( substr($rights,0,1) === '2' @@ -323,18 +325,14 @@ class blog extends common { // Articles en fonction de la pagination for($i = $pagination['first']; $i < $pagination['last']; $i++) { // Nombre de commentaires à approuver et approuvés - $approvals = []; - // Compatibilité : vérifier si les données sont disponibles - if ( $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'comment' ,'approval' ]) !== NULL ) { - $approvals = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), $articleIds[$i], 'comment' ]),'approval', 'SORT_DESC'); - } - if ( empty($approvals) ) { - $toApprove = 0; - $approved = count($this->getData(['module', $this->getUrl(0), $articleIds[$i],'comment'])); - } else { + $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 self::$articles[] = [ diff --git a/module/blog/view/article/article.php b/module/blog/view/article/article.php index e496fc23..45d071a8 100755 --- a/module/blog/view/article/article.php +++ b/module/blog/view/article/article.php @@ -27,7 +27,7 @@

Cet article ne reçoit pas de commentaire.

- getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment'])); ?> + 0 ? $commentsNb . ' ' . 'commentaire' . $s : 'Pas encore de commentaire'; ?>