From 1b0109981693b2cdf8a8efc29d34834bdf19974d Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Mon, 10 Oct 2022 09:48:00 +0200 Subject: [PATCH] =?UTF-8?q?Blog=206.3=20fonction=20option=20nettoy=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/blog/blog.php | 73 ++------------------------------------------ 1 file changed, 3 insertions(+), 70 deletions(-) diff --git a/module/blog/blog.php b/module/blog/blog.php index 615482c6..f3ad1147 100755 --- a/module/blog/blog.php +++ b/module/blog/blog.php @@ -15,7 +15,7 @@ class blog extends common { - const VERSION = '6.22'; + const VERSION = '6.3'; const REALNAME = 'Blog'; const DELETE = true; const UPDATE = '0.0'; @@ -519,79 +519,12 @@ class blog extends common { 'notification' => 'Modifications enregistrées', 'state' => true ]); - } else { - // Ids des articles par ordre de publication - $articleIds = array_keys(helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC')); - // Gestion des droits d'accès - $filterData=[]; - foreach ($articleIds as $key => $value) { - if ( - ( // Propriétaire - $this->getData(['module', $this->getUrl(0), 'posts', $value,'editConsent']) === self::EDIT_OWNER - AND ( $this->getData(['module', $this->getUrl(0), 'posts', $value,'userId']) === $this->getUser('id') - OR $this->getUser('group') === self::GROUP_ADMIN ) - ) - - OR ( - // Groupe - $this->getData(['module', $this->getUrl(0), 'posts', $value,'editConsent']) !== self::EDIT_OWNER - AND $this->getUser('group') >= $this->getData(['module',$this->getUrl(0), 'posts', $value,'editConsent']) - ) - OR ( - // Tout le monde - $this->getData(['module', $this->getUrl(0), 'posts', $value,'editConsent']) === self::EDIT_ALL - ) - ) { - $filterData[] = $value; - } - } - $articleIds = $filterData; - // Pagination - $pagination = helper::pagination($articleIds, $this->getUrl(),$this->getData(['module', $this->getUrl(0),'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::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts', $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), 'posts', $articleIds[$i],'comment'])); - } - // Met en forme le tableau - self::$articles[] = [ - '' . - $this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'title']) . - '', - helper::dateUTF8('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'publishedOn'])) . ' - ' . helper::dateUTF8('%H:%M', $$this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'publishedOn'])), - self::$states[$this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'state'])], - // Bouton pour afficher les commentaires de l'article - template::button('blogConfigComment' . $articleIds[$i], [ - 'class' => ($toApprove || $approved ) > 0 ? '' : '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') - ]), - template::button('blogConfigDelete' . $articleIds[$i], [ - 'class' => 'blogConfigDelete buttonRed', - 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $articleIds[$i] . '/' . $_SESSION['csrf'], - 'value' => template::ico('cancel') - ]) - ]; - } - // Valeurs en sortie + } + // Valeurs en sortie $this->addOutput([ 'title' => 'Options de configuration', 'view' => 'option' ]); - } }