[SPIP] v3.2.1-->v3.2.2
[lhc/web/www.git] / www / ecrire / inc / autoriser.php
index 2be9ef9..c56bceb 100644 (file)
@@ -3,7 +3,7 @@
 /***************************************************************************\
  *  SPIP, Systeme de publication pour l'internet                           *
  *                                                                         *
- *  Copyright (c) 2001-2017                                                *
+ *  Copyright (c) 2001-2019                                                *
  *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
  *                                                                         *
  *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
@@ -36,12 +36,6 @@ defined('_STATUT_AUTEUR_CREATION') || define('_STATUT_AUTEUR_CREATION', '1comite
 /** statuts associables a des rubriques (separes par des virgules) */
 defined('_STATUT_AUTEUR_RUBRIQUE') || define('_STATUT_AUTEUR_RUBRIQUE', _ADMINS_RESTREINTS ? '0minirezo' : '');
 
-// mes_fonctions peut aussi declarer des autorisations, donc il faut donc le charger
-if ($f = find_in_path('mes_fonctions.php')) {
-       global $dossier_squelettes;
-       include_once(_ROOT_CWD . $f);
-}
-
 
 if (!function_exists('autoriser')) {
        /**
@@ -116,6 +110,14 @@ if (!function_exists('autoriser')) {
 }
 
 
+// mes_fonctions peut aussi declarer des autorisations, il faut donc le charger
+// mais apres la fonction autoriser()
+if ($f = find_in_path('mes_fonctions.php')) {
+       global $dossier_squelettes;
+       include_once(_ROOT_CWD . $f);
+}
+
+
 /**
  * Autoriser une action
  *
@@ -494,13 +496,14 @@ function autoriser_changertraduction_dist($faire, $type, $id, $qui, $opt) {
  * @return bool          true s'il a le droit, false sinon
  **/
 function autoriser_dater_dist($faire, $type, $id, $qui, $opt) {
+       $table = table_objet($type);
+       $trouver_table = charger_fonction('trouver_table', 'base');
+       $desc = $trouver_table($table);
+       if (!$desc) {
+               return false;
+       }
+       
        if (!isset($opt['statut'])) {
-               $table = table_objet($type);
-               $trouver_table = charger_fonction('trouver_table', 'base');
-               $desc = $trouver_table($table);
-               if (!$desc) {
-                       return false;
-               }
                if (isset($desc['field']['statut'])) {
                        $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id));
                } else {
@@ -509,9 +512,21 @@ function autoriser_dater_dist($faire, $type, $id, $qui, $opt) {
        } else {
                $statut = $opt['statut'];
        }
-
-       if ($statut == 'publie'
-               or ($statut == 'prop' and $type == 'article' and $GLOBALS['meta']['post_dates'] == 'non')) {
+       
+       // Liste des statuts publiés pour cet objet
+       if (isset($desc['statut'][0]['publie'])) {
+               $statuts_publies = explode(',', $desc['statut'][0]['publie']);
+       }
+       // Sinon en dur le statut "publie"
+       else {
+               $statuts_publies = array('publie');
+       }
+       
+       if (
+               in_array($statut, $statuts_publies)
+               // Ou cas particulier géré en dur ici pour les articles
+               or ($statut == 'prop' and $type == 'article' and $GLOBALS['meta']['post_dates'] == 'non')
+       ) {
                return autoriser('modifier', $type, $id);
        }
 
@@ -1714,7 +1729,7 @@ function auteurs_article($id_article, $cond = '') {
        return sql_allfetsel(
                'id_auteur',
                'spip_auteurs_liens',
-               "objet='article' AND id_objet=$id_article" . ($cond ? " AND $cond" : '')
+               "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '')
        );
 }