From 4b988fc6a2b9d91510d5fe99362610f8472b94e6 Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 13 Mar 2020 19:03:50 +0100 Subject: [PATCH] =?UTF-8?q?On=20sp=C3=A9cifie=20une=20autorisation=20de=20?= =?UTF-8?q?r=C3=A9diger=20un=20article=20uniquement=20pour=20les=20animate?= =?UTF-8?q?urs=20de=20groupe=20et=20les=20admins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- balint_autorisations.php | 29 +++++++++++++++++++++++++++++ balint_options.php | 13 ------------- footer/dist.html | 8 +++++++- formulaires/editer_post.php | 10 +++++++++- 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/balint_autorisations.php b/balint_autorisations.php index 0a16040..aa364dc 100644 --- a/balint_autorisations.php +++ b/balint_autorisations.php @@ -20,6 +20,18 @@ if (!defined('_ECRIRE_INC_VERSION')) { function balint_autoriser() { } +// Pour ne permettre l'accès à l'espace privé qu'aux admins +// (pour les autres, on redirige vers l'accueil) +function autoriser_ecrire($faire, $type, $id, $qui, $opt){ + if ($qui['statut']!='0minirezo'){ + include_spip('inc/headers'); + redirige_par_entete( url_de_base()); + } + else { + return in_array($qui['statut'], array('0minirezo')); + } +} + function autoriser_auteur_modifier($faire, $type, $id, $qui, $opt) { // Ni admin ni redacteur => non @@ -106,6 +118,23 @@ function autoriser_article_modifier($faire, $type, $id, $qui, $opt) { } } +function autoriser_article_rediger($faire, $type, $id, $qui, $opt) { + // Si le membre est rédacteur, il doit être animateur d'au moins un groupe + if ($qui['statut']=="1comite"){ + $id_rub = lire_config('balint/id_rub_groupes'); + $T_id_groupes = sql_allfetsel('id_article','spip_articles','id_secteur=' . $id_rub); + foreach($T_id_groupes as $id_groupe){ + if (in_array($qui['id_auteur'],auteurs_objet('article',$id_groupe['id_article']))){ + return true; + } + } + } + // Sinon il faut être admin + else{ + return in_array($qui['statut'], array('0minirezo')); + } +} + function autoriser_sujet_creer($faire, $type, $id, $qui, $opt) { return in_array($qui['statut'], array('0minirezo','1comite','6forum')); } diff --git a/balint_options.php b/balint_options.php index d640b92..d405758 100644 --- a/balint_options.php +++ b/balint_options.php @@ -47,18 +47,5 @@ if (!isset($GLOBALS['z_blocs'])) 'breadcrumb'); -function autoriser_ecrire($faire, $type, $id, $qui, $opt){ -// Pour ne permettre l'accès à l'espace privé qu'aux admins -// (pour les autres, on redirige vers l'accueil) - if ($qui['statut']!='0minirezo'){ - include_spip('inc/headers'); - redirige_par_entete( url_de_base()); - } - else { - return in_array($qui['statut'], array('0minirezo')); - } -} - - // On retire les boutons "Espace privé" et "Recalculer" pour les admins $GLOBALS['flag_preserver'] = true; diff --git a/footer/dist.html b/footer/dist.html index 0921f8a..6d5832c 100644 --- a/footer/dist.html +++ b/footer/dist.html @@ -32,17 +32,23 @@ Mon compte +
  • Rédiger un article
  • +
  • Brouillons
  • - +
  • Créer un groupe diff --git a/formulaires/editer_post.php b/formulaires/editer_post.php index f16251b..25cd09d 100644 --- a/formulaires/editer_post.php +++ b/formulaires/editer_post.php @@ -89,9 +89,17 @@ function formulaires_editer_post_verifier_dist($id_article=0, $redirect=''){ // il faut au minimum titre et un texte pour créer un article if (_request('titre') == '' OR _request('texte') == ''){ - $erreurs['message_erreur'] = "Il faut obligatoirement un titre et un texte pour créer un article."; + $erreurs['message_erreur'] = "Il faut obligatoirement un titre et un contenu pour créer un article."; return $erreurs; } + + // Il faut sélectionner au moins un emplacement pour publier un article, sinon on le retrouve plus + if (_request('statut')=='publie'){ + if (_request('id_emplacements') == '' AND _request('id_groupe') == ''){ + $erreurs['message_erreur'] = "Il faut sélectionner un groupe ou un emplacement pour publier un article."; + return $erreurs; + } + } $bigform = charger_fonction('bigform_verifier','inc'); $options = ['mime' => 'tout_mime','taille_max'=>'5000','largeur_max'=>'2048','hauteur_max'=>'2048'];