@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Autorisations |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -38,89 +38,89 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | if (!function_exists('autoriser')) { |
| 41 | - /** |
|
| 42 | - * Autoriser une action |
|
| 43 | - * |
|
| 44 | - * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 45 | - * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 46 | - * les autorisations. |
|
| 47 | - * |
|
| 48 | - * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 49 | - * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 50 | - * dans cet ordre : |
|
| 51 | - * |
|
| 52 | - * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 53 | - * - autoriser_{type}, sinon avec _dist |
|
| 54 | - * - autoriser_{faire}, sinon avec _dist |
|
| 55 | - * - autoriser_{defaut}, sinon avec _dist |
|
| 56 | - * |
|
| 57 | - * Seul le premier argument est obligatoire. |
|
| 58 | - * |
|
| 59 | - * @note |
|
| 60 | - * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 61 | - * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 62 | - * cette valeur. |
|
| 63 | - * |
|
| 64 | - * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 65 | - * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 66 | - * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 67 | - * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 68 | - * |
|
| 69 | - * @note |
|
| 70 | - * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 71 | - * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 72 | - * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 73 | - * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 74 | - * quel serait le type, quel serait l'action ? |
|
| 75 | - * |
|
| 76 | - * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 77 | - * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 78 | - * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 79 | - * |
|
| 80 | - * @api |
|
| 81 | - * @see autoriser_dist() |
|
| 82 | - * @see objet_type() |
|
| 83 | - * |
|
| 84 | - * @param string $faire |
|
| 85 | - * une action ('modifier', 'publier'...) |
|
| 86 | - * @param string|null $type |
|
| 87 | - * Type d’objet ou élément sur lequel appliquer l’action. |
|
| 88 | - * - null: indifférent à tout type d’élément ou objet éditorial |
|
| 89 | - * - string: objet éditorial (objet_type() est appliqué pour homogénéiser l’entrée) |
|
| 90 | - * - _string: autre élément (avec un souligné en premier caractère, désactive objet_type()). |
|
| 91 | - * Les soulignés seront retirés (cf. la note). |
|
| 92 | - * @param string|int|null $id |
|
| 93 | - * id de l'objet ou élément sur lequel on veut agir, si pertinent. |
|
| 94 | - * - null: non utile pour l’autorisation |
|
| 95 | - * - int: identifiant numérique (cas de tous les objets éditoriaux de SPIP) |
|
| 96 | - * - string: identifiant textuel |
|
| 97 | - * @param null|int|array $qui |
|
| 98 | - * - si null on prend alors visiteur_session |
|
| 99 | - * - un id_auteur (on regarde dans la base) |
|
| 100 | - * - un tableau auteur complet, y compris [restreint] |
|
| 101 | - * @param array $opt |
|
| 102 | - * options sous forme de tableau associatif |
|
| 103 | - * @return bool |
|
| 104 | - * true si la personne peut effectuer l'action |
|
| 105 | - */ |
|
| 106 | - function autoriser(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
|
| 107 | - // Charger les fonctions d'autorisation supplementaires |
|
| 108 | - static $pipe; |
|
| 109 | - if (!isset($pipe)) { |
|
| 110 | - $pipe = 1; |
|
| 111 | - pipeline('autoriser'); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return autoriser_dist($faire, $type, $id, $qui, $opt); |
|
| 115 | - } |
|
| 41 | + /** |
|
| 42 | + * Autoriser une action |
|
| 43 | + * |
|
| 44 | + * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 45 | + * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 46 | + * les autorisations. |
|
| 47 | + * |
|
| 48 | + * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 49 | + * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 50 | + * dans cet ordre : |
|
| 51 | + * |
|
| 52 | + * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 53 | + * - autoriser_{type}, sinon avec _dist |
|
| 54 | + * - autoriser_{faire}, sinon avec _dist |
|
| 55 | + * - autoriser_{defaut}, sinon avec _dist |
|
| 56 | + * |
|
| 57 | + * Seul le premier argument est obligatoire. |
|
| 58 | + * |
|
| 59 | + * @note |
|
| 60 | + * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 61 | + * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 62 | + * cette valeur. |
|
| 63 | + * |
|
| 64 | + * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 65 | + * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 66 | + * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 67 | + * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 68 | + * |
|
| 69 | + * @note |
|
| 70 | + * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 71 | + * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 72 | + * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 73 | + * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 74 | + * quel serait le type, quel serait l'action ? |
|
| 75 | + * |
|
| 76 | + * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 77 | + * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 78 | + * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 79 | + * |
|
| 80 | + * @api |
|
| 81 | + * @see autoriser_dist() |
|
| 82 | + * @see objet_type() |
|
| 83 | + * |
|
| 84 | + * @param string $faire |
|
| 85 | + * une action ('modifier', 'publier'...) |
|
| 86 | + * @param string|null $type |
|
| 87 | + * Type d’objet ou élément sur lequel appliquer l’action. |
|
| 88 | + * - null: indifférent à tout type d’élément ou objet éditorial |
|
| 89 | + * - string: objet éditorial (objet_type() est appliqué pour homogénéiser l’entrée) |
|
| 90 | + * - _string: autre élément (avec un souligné en premier caractère, désactive objet_type()). |
|
| 91 | + * Les soulignés seront retirés (cf. la note). |
|
| 92 | + * @param string|int|null $id |
|
| 93 | + * id de l'objet ou élément sur lequel on veut agir, si pertinent. |
|
| 94 | + * - null: non utile pour l’autorisation |
|
| 95 | + * - int: identifiant numérique (cas de tous les objets éditoriaux de SPIP) |
|
| 96 | + * - string: identifiant textuel |
|
| 97 | + * @param null|int|array $qui |
|
| 98 | + * - si null on prend alors visiteur_session |
|
| 99 | + * - un id_auteur (on regarde dans la base) |
|
| 100 | + * - un tableau auteur complet, y compris [restreint] |
|
| 101 | + * @param array $opt |
|
| 102 | + * options sous forme de tableau associatif |
|
| 103 | + * @return bool |
|
| 104 | + * true si la personne peut effectuer l'action |
|
| 105 | + */ |
|
| 106 | + function autoriser(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
|
| 107 | + // Charger les fonctions d'autorisation supplementaires |
|
| 108 | + static $pipe; |
|
| 109 | + if (!isset($pipe)) { |
|
| 110 | + $pipe = 1; |
|
| 111 | + pipeline('autoriser'); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return autoriser_dist($faire, $type, $id, $qui, $opt); |
|
| 115 | + } |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | // mes_fonctions peut aussi declarer des autorisations, il faut donc le charger |
| 120 | 120 | // mais apres la fonction autoriser() |
| 121 | 121 | if ($f = find_in_path('mes_fonctions.php')) { |
| 122 | - global $dossier_squelettes; |
|
| 123 | - include_once(_ROOT_CWD . $f); |
|
| 122 | + global $dossier_squelettes; |
|
| 123 | + include_once(_ROOT_CWD . $f); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -151,82 +151,82 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | function autoriser_dist(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
| 153 | 153 | |
| 154 | - $a = null; |
|
| 155 | - if ($type === null) { |
|
| 156 | - $type = ''; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - // Qui ? visiteur_session ? |
|
| 160 | - // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 161 | - if ($qui === null or $qui === '') { |
|
| 162 | - $qui = $GLOBALS['visiteur_session'] ?: []; |
|
| 163 | - $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 164 | - } elseif (is_numeric($qui)) { |
|
| 165 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // Admins restreints, on construit ici (pas generique mais...) |
|
| 169 | - // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 170 | - if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 171 | - $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : []; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - spip_log( |
|
| 175 | - "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?', |
|
| 176 | - 'autoriser' . _LOG_DEBUG |
|
| 177 | - ); |
|
| 178 | - |
|
| 179 | - // passer par objet_type pour avoir les alias |
|
| 180 | - // sauf si _ est le premier caractère. |
|
| 181 | - if ($type and $type[0] !== '_') { |
|
| 182 | - $type = objet_type($type, false); |
|
| 183 | - } |
|
| 184 | - // et supprimer les _ |
|
| 185 | - $type = str_replace('_', '', (string) $type); |
|
| 186 | - |
|
| 187 | - // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 188 | - if ( |
|
| 189 | - (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 190 | - or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 191 | - ) { |
|
| 192 | - spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 193 | - return true; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - // Chercher une fonction d'autorisation |
|
| 197 | - // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 198 | - // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 199 | - $fonctions = $type |
|
| 200 | - ? [ |
|
| 201 | - 'autoriser_' . $type . '_' . $faire, |
|
| 202 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 203 | - 'autoriser_' . $type, |
|
| 204 | - 'autoriser_' . $type . '_dist', |
|
| 205 | - 'autoriser_' . $faire, |
|
| 206 | - 'autoriser_' . $faire . '_dist', |
|
| 207 | - 'autoriser_defaut', |
|
| 208 | - 'autoriser_defaut_dist' |
|
| 209 | - ] |
|
| 210 | - : [ |
|
| 211 | - 'autoriser_' . $faire, |
|
| 212 | - 'autoriser_' . $faire . '_dist', |
|
| 213 | - 'autoriser_defaut', |
|
| 214 | - 'autoriser_defaut_dist' |
|
| 215 | - ]; |
|
| 216 | - |
|
| 217 | - foreach ($fonctions as $f) { |
|
| 218 | - if (function_exists($f)) { |
|
| 219 | - $a = $f($faire, $type, $id, $qui, $opt); |
|
| 220 | - break; |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - spip_log( |
|
| 225 | - "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 226 | - 'autoriser' . _LOG_DEBUG |
|
| 227 | - ); |
|
| 228 | - |
|
| 229 | - return $a; |
|
| 154 | + $a = null; |
|
| 155 | + if ($type === null) { |
|
| 156 | + $type = ''; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + // Qui ? visiteur_session ? |
|
| 160 | + // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 161 | + if ($qui === null or $qui === '') { |
|
| 162 | + $qui = $GLOBALS['visiteur_session'] ?: []; |
|
| 163 | + $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 164 | + } elseif (is_numeric($qui)) { |
|
| 165 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // Admins restreints, on construit ici (pas generique mais...) |
|
| 169 | + // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 170 | + if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 171 | + $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : []; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + spip_log( |
|
| 175 | + "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?', |
|
| 176 | + 'autoriser' . _LOG_DEBUG |
|
| 177 | + ); |
|
| 178 | + |
|
| 179 | + // passer par objet_type pour avoir les alias |
|
| 180 | + // sauf si _ est le premier caractère. |
|
| 181 | + if ($type and $type[0] !== '_') { |
|
| 182 | + $type = objet_type($type, false); |
|
| 183 | + } |
|
| 184 | + // et supprimer les _ |
|
| 185 | + $type = str_replace('_', '', (string) $type); |
|
| 186 | + |
|
| 187 | + // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 188 | + if ( |
|
| 189 | + (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 190 | + or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 191 | + ) { |
|
| 192 | + spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 193 | + return true; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + // Chercher une fonction d'autorisation |
|
| 197 | + // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 198 | + // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 199 | + $fonctions = $type |
|
| 200 | + ? [ |
|
| 201 | + 'autoriser_' . $type . '_' . $faire, |
|
| 202 | + 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 203 | + 'autoriser_' . $type, |
|
| 204 | + 'autoriser_' . $type . '_dist', |
|
| 205 | + 'autoriser_' . $faire, |
|
| 206 | + 'autoriser_' . $faire . '_dist', |
|
| 207 | + 'autoriser_defaut', |
|
| 208 | + 'autoriser_defaut_dist' |
|
| 209 | + ] |
|
| 210 | + : [ |
|
| 211 | + 'autoriser_' . $faire, |
|
| 212 | + 'autoriser_' . $faire . '_dist', |
|
| 213 | + 'autoriser_defaut', |
|
| 214 | + 'autoriser_defaut_dist' |
|
| 215 | + ]; |
|
| 216 | + |
|
| 217 | + foreach ($fonctions as $f) { |
|
| 218 | + if (function_exists($f)) { |
|
| 219 | + $a = $f($faire, $type, $id, $qui, $opt); |
|
| 220 | + break; |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + spip_log( |
|
| 225 | + "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 226 | + 'autoriser' . _LOG_DEBUG |
|
| 227 | + ); |
|
| 228 | + |
|
| 229 | + return $a; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // une globale pour aller au plus vite dans la fonction generique ci dessus |
@@ -246,33 +246,33 @@ discard block |
||
| 246 | 246 | * @return bool |
| 247 | 247 | */ |
| 248 | 248 | function autoriser_exception(string $faire, ?string $type = '', $id = null, $autoriser = true): bool { |
| 249 | - // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 250 | - static $autorisation; |
|
| 251 | - // Tolérance avec certains appels |
|
| 252 | - if ($type === null) { |
|
| 253 | - $type = ''; |
|
| 254 | - } |
|
| 255 | - if ($id === null) { |
|
| 256 | - $id = 0; |
|
| 257 | - } |
|
| 258 | - if ($autoriser === 'verifier') { |
|
| 259 | - return isset($autorisation[$faire][$type][$id]); |
|
| 260 | - } |
|
| 261 | - if ($autoriser === true) { |
|
| 262 | - $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 263 | - } |
|
| 264 | - if ($autoriser === false) { |
|
| 265 | - if ($id === '*') { |
|
| 266 | - unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 267 | - unset($autorisation[$faire][$type]); |
|
| 268 | - } |
|
| 269 | - else { |
|
| 270 | - unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 271 | - unset($autorisation[$faire][$type][$id]); |
|
| 272 | - } |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - return false; |
|
| 249 | + // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 250 | + static $autorisation; |
|
| 251 | + // Tolérance avec certains appels |
|
| 252 | + if ($type === null) { |
|
| 253 | + $type = ''; |
|
| 254 | + } |
|
| 255 | + if ($id === null) { |
|
| 256 | + $id = 0; |
|
| 257 | + } |
|
| 258 | + if ($autoriser === 'verifier') { |
|
| 259 | + return isset($autorisation[$faire][$type][$id]); |
|
| 260 | + } |
|
| 261 | + if ($autoriser === true) { |
|
| 262 | + $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 263 | + } |
|
| 264 | + if ($autoriser === false) { |
|
| 265 | + if ($id === '*') { |
|
| 266 | + unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 267 | + unset($autorisation[$faire][$type]); |
|
| 268 | + } |
|
| 269 | + else { |
|
| 270 | + unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 271 | + unset($autorisation[$faire][$type][$id]); |
|
| 272 | + } |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + return false; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | * @return bool true s'il a le droit, false sinon |
| 292 | 292 | **/ |
| 293 | 293 | function autoriser_defaut_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 294 | - return |
|
| 295 | - $qui['statut'] === '0minirezo' |
|
| 296 | - and !$qui['restreint']; |
|
| 294 | + return |
|
| 295 | + $qui['statut'] === '0minirezo' |
|
| 296 | + and !$qui['restreint']; |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | * @return bool true s'il a le droit, false sinon |
| 314 | 314 | */ |
| 315 | 315 | function autoriser_loger_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 316 | - if ($qui['statut'] === '5poubelle') { |
|
| 317 | - return false; |
|
| 318 | - } |
|
| 319 | - return true; |
|
| 316 | + if ($qui['statut'] === '5poubelle') { |
|
| 317 | + return false; |
|
| 318 | + } |
|
| 319 | + return true; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | * @return bool true s'il a le droit, false sinon |
| 333 | 333 | **/ |
| 334 | 334 | function autoriser_ecrire_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 335 | - return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 335 | + return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | * @return bool true s'il a le droit, false sinon |
| 352 | 352 | **/ |
| 353 | 353 | function autoriser_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 354 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 354 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | /** |
@@ -371,18 +371,18 @@ discard block |
||
| 371 | 371 | **/ |
| 372 | 372 | function autoriser_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 373 | 373 | |
| 374 | - // Le visiteur a-t-il un statut prevu par la config ? |
|
| 375 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 376 | - return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 377 | - } |
|
| 374 | + // Le visiteur a-t-il un statut prevu par la config ? |
|
| 375 | + if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 376 | + return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | - // A-t-on un token de prévisualisation valable ? |
|
| 380 | - include_spip('inc/securiser_action'); |
|
| 381 | - if (decrire_token_previsu()) { |
|
| 382 | - return true; |
|
| 383 | - } |
|
| 379 | + // A-t-on un token de prévisualisation valable ? |
|
| 380 | + include_spip('inc/securiser_action'); |
|
| 381 | + if (decrire_token_previsu()) { |
|
| 382 | + return true; |
|
| 383 | + } |
|
| 384 | 384 | |
| 385 | - return false; |
|
| 385 | + return false; |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -411,58 +411,58 @@ discard block |
||
| 411 | 411 | */ |
| 412 | 412 | function test_previsualiser_objet_champ(string $type = '', $id = null, array $qui = [], array $opt = []): bool { |
| 413 | 413 | |
| 414 | - // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 415 | - if (!$type) { |
|
| 416 | - return true; |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - include_spip('base/objets'); |
|
| 420 | - $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 421 | - if (isset($infos['statut'])) { |
|
| 422 | - foreach ($infos['statut'] as $c) { |
|
| 423 | - if (isset($c['publie'])) { |
|
| 424 | - if (!isset($c['previsu'])) { |
|
| 425 | - return false; |
|
| 426 | - } // pas de previsu definie => NIET |
|
| 427 | - $champ = $c['champ']; |
|
| 428 | - if (!isset($opt[$champ])) { |
|
| 429 | - return false; |
|
| 430 | - } // pas de champ passe a la demande => NIET |
|
| 431 | - $previsu = explode(',', $c['previsu']); |
|
| 432 | - // regarder si ce statut est autorise pour l'auteur |
|
| 433 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 434 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 435 | - // sinon l’auteur en session |
|
| 436 | - include_spip('inc/securiser_action'); |
|
| 437 | - if ($desc = decrire_token_previsu()) { |
|
| 438 | - $id_auteur = $desc['id_auteur']; |
|
| 439 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 440 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 441 | - } else { |
|
| 442 | - $id_auteur = null; |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - if (!$id_auteur) { |
|
| 446 | - return false; |
|
| 447 | - } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 448 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 449 | - } elseif ( |
|
| 450 | - !sql_countsel( |
|
| 451 | - 'spip_auteurs_liens', |
|
| 452 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 453 | - ) |
|
| 454 | - ) { |
|
| 455 | - return false; |
|
| 456 | - } // pas auteur de cet objet => NIET |
|
| 457 | - } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 458 | - // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 459 | - return false; |
|
| 460 | - } |
|
| 461 | - } |
|
| 462 | - } |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - return true; |
|
| 414 | + // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 415 | + if (!$type) { |
|
| 416 | + return true; |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + include_spip('base/objets'); |
|
| 420 | + $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 421 | + if (isset($infos['statut'])) { |
|
| 422 | + foreach ($infos['statut'] as $c) { |
|
| 423 | + if (isset($c['publie'])) { |
|
| 424 | + if (!isset($c['previsu'])) { |
|
| 425 | + return false; |
|
| 426 | + } // pas de previsu definie => NIET |
|
| 427 | + $champ = $c['champ']; |
|
| 428 | + if (!isset($opt[$champ])) { |
|
| 429 | + return false; |
|
| 430 | + } // pas de champ passe a la demande => NIET |
|
| 431 | + $previsu = explode(',', $c['previsu']); |
|
| 432 | + // regarder si ce statut est autorise pour l'auteur |
|
| 433 | + if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 434 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 435 | + // sinon l’auteur en session |
|
| 436 | + include_spip('inc/securiser_action'); |
|
| 437 | + if ($desc = decrire_token_previsu()) { |
|
| 438 | + $id_auteur = $desc['id_auteur']; |
|
| 439 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 440 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 441 | + } else { |
|
| 442 | + $id_auteur = null; |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + if (!$id_auteur) { |
|
| 446 | + return false; |
|
| 447 | + } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 448 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 449 | + } elseif ( |
|
| 450 | + !sql_countsel( |
|
| 451 | + 'spip_auteurs_liens', |
|
| 452 | + 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 453 | + ) |
|
| 454 | + ) { |
|
| 455 | + return false; |
|
| 456 | + } // pas auteur de cet objet => NIET |
|
| 457 | + } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 458 | + // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 459 | + return false; |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + return true; |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | /** |
@@ -478,51 +478,51 @@ discard block |
||
| 478 | 478 | * @return bool true s'il a le droit, false sinon |
| 479 | 479 | **/ |
| 480 | 480 | function autoriser_changerlangue_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 481 | - $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 482 | - $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 483 | - $table = table_objet_sql($type); |
|
| 484 | - if ( |
|
| 485 | - in_array($table, $multi_objets) |
|
| 486 | - or in_array($table, $gerer_trad_objets) |
|
| 487 | - ) { // affichage du formulaire si la configuration l'accepte |
|
| 488 | - $multi_secteurs = lire_config('multi_secteurs'); |
|
| 489 | - $champs = objet_info($type, 'field'); |
|
| 490 | - if ( |
|
| 491 | - $multi_secteurs === 'oui' |
|
| 492 | - and array_key_exists('id_rubrique', $champs) |
|
| 493 | - ) { |
|
| 494 | - // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 495 | - $primary = id_table_objet($type); |
|
| 496 | - if ($table != 'spip_rubriques') { |
|
| 497 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 498 | - } else { |
|
| 499 | - $id_rubrique = $id; |
|
| 500 | - } |
|
| 501 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 502 | - if (!$id_secteur > 0) { |
|
| 503 | - $id_secteur = $id_rubrique; |
|
| 504 | - } |
|
| 505 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 506 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 507 | - if ($langue_secteur != $langue_objet) { |
|
| 508 | - // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 509 | - return true; |
|
| 510 | - } |
|
| 511 | - if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 512 | - return false; |
|
| 513 | - } else { |
|
| 514 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 515 | - if ($id_parent != 0) { |
|
| 516 | - // sous-rubriques : pas de choix de langue |
|
| 517 | - return false; |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - } |
|
| 521 | - } else { |
|
| 522 | - return false; |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 481 | + $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 482 | + $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 483 | + $table = table_objet_sql($type); |
|
| 484 | + if ( |
|
| 485 | + in_array($table, $multi_objets) |
|
| 486 | + or in_array($table, $gerer_trad_objets) |
|
| 487 | + ) { // affichage du formulaire si la configuration l'accepte |
|
| 488 | + $multi_secteurs = lire_config('multi_secteurs'); |
|
| 489 | + $champs = objet_info($type, 'field'); |
|
| 490 | + if ( |
|
| 491 | + $multi_secteurs === 'oui' |
|
| 492 | + and array_key_exists('id_rubrique', $champs) |
|
| 493 | + ) { |
|
| 494 | + // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 495 | + $primary = id_table_objet($type); |
|
| 496 | + if ($table != 'spip_rubriques') { |
|
| 497 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 498 | + } else { |
|
| 499 | + $id_rubrique = $id; |
|
| 500 | + } |
|
| 501 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 502 | + if (!$id_secteur > 0) { |
|
| 503 | + $id_secteur = $id_rubrique; |
|
| 504 | + } |
|
| 505 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 506 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 507 | + if ($langue_secteur != $langue_objet) { |
|
| 508 | + // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 509 | + return true; |
|
| 510 | + } |
|
| 511 | + if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 512 | + return false; |
|
| 513 | + } else { |
|
| 514 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 515 | + if ($id_parent != 0) { |
|
| 516 | + // sous-rubriques : pas de choix de langue |
|
| 517 | + return false; |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + } |
|
| 521 | + } else { |
|
| 522 | + return false; |
|
| 523 | + } |
|
| 524 | + |
|
| 525 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | /** |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | * @return bool true s'il a le droit, false sinon |
| 539 | 539 | **/ |
| 540 | 540 | function autoriser_changertraduction_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 541 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 541 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -554,41 +554,41 @@ discard block |
||
| 554 | 554 | * @return bool true s'il a le droit, false sinon |
| 555 | 555 | **/ |
| 556 | 556 | function autoriser_dater_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 557 | - $table = table_objet($type); |
|
| 558 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 559 | - $desc = $trouver_table($table); |
|
| 560 | - if (!$desc) { |
|
| 561 | - return false; |
|
| 562 | - } |
|
| 563 | - |
|
| 564 | - if (!isset($opt['statut'])) { |
|
| 565 | - if (isset($desc['field']['statut'])) { |
|
| 566 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 567 | - } else { |
|
| 568 | - $statut = 'publie'; |
|
| 569 | - } // pas de statut => publie |
|
| 570 | - } else { |
|
| 571 | - $statut = $opt['statut']; |
|
| 572 | - } |
|
| 573 | - |
|
| 574 | - // Liste des statuts publiés pour cet objet |
|
| 575 | - if (isset($desc['statut'][0]['publie'])) { |
|
| 576 | - $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 577 | - } |
|
| 578 | - // Sinon en dur le statut "publie" |
|
| 579 | - else { |
|
| 580 | - $statuts_publies = ['publie']; |
|
| 581 | - } |
|
| 582 | - |
|
| 583 | - if ( |
|
| 584 | - in_array($statut, $statuts_publies) |
|
| 585 | - // Ou cas particulier géré en dur ici pour les articles |
|
| 586 | - or ($statut === 'prop' and $type === 'article' and $GLOBALS['meta']['post_dates'] === 'non') |
|
| 587 | - ) { |
|
| 588 | - return autoriser('modifier', $type, $id); |
|
| 589 | - } |
|
| 590 | - |
|
| 591 | - return false; |
|
| 557 | + $table = table_objet($type); |
|
| 558 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 559 | + $desc = $trouver_table($table); |
|
| 560 | + if (!$desc) { |
|
| 561 | + return false; |
|
| 562 | + } |
|
| 563 | + |
|
| 564 | + if (!isset($opt['statut'])) { |
|
| 565 | + if (isset($desc['field']['statut'])) { |
|
| 566 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 567 | + } else { |
|
| 568 | + $statut = 'publie'; |
|
| 569 | + } // pas de statut => publie |
|
| 570 | + } else { |
|
| 571 | + $statut = $opt['statut']; |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + // Liste des statuts publiés pour cet objet |
|
| 575 | + if (isset($desc['statut'][0]['publie'])) { |
|
| 576 | + $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 577 | + } |
|
| 578 | + // Sinon en dur le statut "publie" |
|
| 579 | + else { |
|
| 580 | + $statuts_publies = ['publie']; |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + if ( |
|
| 584 | + in_array($statut, $statuts_publies) |
|
| 585 | + // Ou cas particulier géré en dur ici pour les articles |
|
| 586 | + or ($statut === 'prop' and $type === 'article' and $GLOBALS['meta']['post_dates'] === 'non') |
|
| 587 | + ) { |
|
| 588 | + return autoriser('modifier', $type, $id); |
|
| 589 | + } |
|
| 590 | + |
|
| 591 | + return false; |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | * @return bool true s'il a le droit, false sinon |
| 608 | 608 | **/ |
| 609 | 609 | function autoriser_instituer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 610 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 610 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | /** |
@@ -625,12 +625,12 @@ discard block |
||
| 625 | 625 | * @return bool true s'il a le droit, false sinon |
| 626 | 626 | **/ |
| 627 | 627 | function autoriser_rubrique_publierdans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 628 | - return |
|
| 629 | - ($qui['statut'] === '0minirezo') |
|
| 630 | - and ( |
|
| 631 | - !$qui['restreint'] or !$id |
|
| 632 | - or in_array($id, $qui['restreint']) |
|
| 633 | - ); |
|
| 628 | + return |
|
| 629 | + ($qui['statut'] === '0minirezo') |
|
| 630 | + and ( |
|
| 631 | + !$qui['restreint'] or !$id |
|
| 632 | + or in_array($id, $qui['restreint']) |
|
| 633 | + ); |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | /** |
@@ -648,12 +648,12 @@ discard block |
||
| 648 | 648 | * @return bool true s'il a le droit, false sinon |
| 649 | 649 | **/ |
| 650 | 650 | function autoriser_rubrique_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 651 | - if (!empty($opt['id_parent'])) { |
|
| 652 | - return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 653 | - } |
|
| 654 | - else { |
|
| 655 | - return autoriser('defaut', null, 0, $qui, $opt); |
|
| 656 | - } |
|
| 651 | + if (!empty($opt['id_parent'])) { |
|
| 652 | + return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 653 | + } |
|
| 654 | + else { |
|
| 655 | + return autoriser('defaut', null, 0, $qui, $opt); |
|
| 656 | + } |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | /** |
@@ -671,10 +671,10 @@ discard block |
||
| 671 | 671 | * @return bool true s'il a le droit, false sinon |
| 672 | 672 | **/ |
| 673 | 673 | function autoriser_rubrique_creerrubriquedans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 674 | - return |
|
| 675 | - ($id or ($qui['statut'] === '0minirezo' and !$qui['restreint'])) |
|
| 676 | - and autoriser('voir', 'rubrique', $id) |
|
| 677 | - and autoriser('publierdans', 'rubrique', $id); |
|
| 674 | + return |
|
| 675 | + ($id or ($qui['statut'] === '0minirezo' and !$qui['restreint'])) |
|
| 676 | + and autoriser('voir', 'rubrique', $id) |
|
| 677 | + and autoriser('publierdans', 'rubrique', $id); |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | /** |
@@ -692,10 +692,10 @@ discard block |
||
| 692 | 692 | * @return bool true s'il a le droit, false sinon |
| 693 | 693 | **/ |
| 694 | 694 | function autoriser_rubrique_creerarticledans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 695 | - return |
|
| 696 | - $id |
|
| 697 | - and autoriser('voir', 'rubrique', $id) |
|
| 698 | - and autoriser('creer', 'article'); |
|
| 695 | + return |
|
| 696 | + $id |
|
| 697 | + and autoriser('voir', 'rubrique', $id) |
|
| 698 | + and autoriser('creer', 'article'); |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | |
@@ -714,8 +714,8 @@ discard block |
||
| 714 | 714 | * @return bool true s'il a le droit, false sinon |
| 715 | 715 | **/ |
| 716 | 716 | function autoriser_rubrique_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 717 | - return |
|
| 718 | - autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 717 | + return |
|
| 718 | + autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | /** |
@@ -733,29 +733,29 @@ discard block |
||
| 733 | 733 | * @return bool true s'il a le droit, false sinon |
| 734 | 734 | **/ |
| 735 | 735 | function autoriser_rubrique_supprimer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 736 | - if (!$id = intval($id)) { |
|
| 737 | - return false; |
|
| 738 | - } |
|
| 736 | + if (!$id = intval($id)) { |
|
| 737 | + return false; |
|
| 738 | + } |
|
| 739 | 739 | |
| 740 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 741 | - return false; |
|
| 742 | - } |
|
| 740 | + if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 741 | + return false; |
|
| 742 | + } |
|
| 743 | 743 | |
| 744 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 745 | - return false; |
|
| 746 | - } |
|
| 744 | + if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 745 | + return false; |
|
| 746 | + } |
|
| 747 | 747 | |
| 748 | - $compte = pipeline( |
|
| 749 | - 'objet_compte_enfants', |
|
| 750 | - ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 751 | - ); |
|
| 752 | - foreach ($compte as $objet => $n) { |
|
| 753 | - if ($n) { |
|
| 754 | - return false; |
|
| 755 | - } |
|
| 756 | - } |
|
| 748 | + $compte = pipeline( |
|
| 749 | + 'objet_compte_enfants', |
|
| 750 | + ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 751 | + ); |
|
| 752 | + foreach ($compte as $objet => $n) { |
|
| 753 | + if ($n) { |
|
| 754 | + return false; |
|
| 755 | + } |
|
| 756 | + } |
|
| 757 | 757 | |
| 758 | - return autoriser('modifier', 'rubrique', $id); |
|
| 758 | + return autoriser('modifier', 'rubrique', $id); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | |
@@ -775,23 +775,23 @@ discard block |
||
| 775 | 775 | * @return bool true s'il a le droit, false sinon |
| 776 | 776 | **/ |
| 777 | 777 | function autoriser_article_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 778 | - if (!$id) { |
|
| 779 | - return false; |
|
| 780 | - } |
|
| 781 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 782 | - |
|
| 783 | - return |
|
| 784 | - $r |
|
| 785 | - and |
|
| 786 | - ( |
|
| 787 | - autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 788 | - or ( |
|
| 789 | - (!isset($opt['statut']) or !in_array($opt['statut'], ['publie', 'refuse'], true)) |
|
| 790 | - and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 791 | - and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 792 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 793 | - ) |
|
| 794 | - ); |
|
| 778 | + if (!$id) { |
|
| 779 | + return false; |
|
| 780 | + } |
|
| 781 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 782 | + |
|
| 783 | + return |
|
| 784 | + $r |
|
| 785 | + and |
|
| 786 | + ( |
|
| 787 | + autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 788 | + or ( |
|
| 789 | + (!isset($opt['statut']) or !in_array($opt['statut'], ['publie', 'refuse'], true)) |
|
| 790 | + and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 791 | + and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 792 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 793 | + ) |
|
| 794 | + ); |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | /** |
@@ -809,13 +809,13 @@ discard block |
||
| 809 | 809 | * @return bool true s'il a le droit, false sinon |
| 810 | 810 | **/ |
| 811 | 811 | function autoriser_article_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 812 | - if (!empty($opt['id_parent'])) { |
|
| 813 | - // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 814 | - return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 815 | - } |
|
| 816 | - else { |
|
| 817 | - return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 818 | - } |
|
| 812 | + if (!empty($opt['id_parent'])) { |
|
| 813 | + // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 814 | + return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 815 | + } |
|
| 816 | + else { |
|
| 817 | + return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 818 | + } |
|
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | /** |
@@ -837,28 +837,28 @@ discard block |
||
| 837 | 837 | * @return bool true s'il a le droit, false sinon |
| 838 | 838 | */ |
| 839 | 839 | function autoriser_article_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 840 | - if ($qui['statut'] === '0minirezo') { |
|
| 841 | - return true; |
|
| 842 | - } |
|
| 843 | - // cas des articles : depend du statut de l'article et de l'auteur |
|
| 844 | - if (isset($opt['statut'])) { |
|
| 845 | - $statut = $opt['statut']; |
|
| 846 | - } else { |
|
| 847 | - if (!$id) { |
|
| 848 | - return false; |
|
| 849 | - } |
|
| 850 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 851 | - } |
|
| 852 | - |
|
| 853 | - return |
|
| 854 | - // si on est pas auteur de l'article, |
|
| 855 | - // seuls les propose et publies sont visibles |
|
| 856 | - in_array($statut, ['prop', 'publie']) |
|
| 857 | - // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 858 | - or |
|
| 859 | - ($id |
|
| 860 | - and $qui['id_auteur'] |
|
| 861 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 840 | + if ($qui['statut'] === '0minirezo') { |
|
| 841 | + return true; |
|
| 842 | + } |
|
| 843 | + // cas des articles : depend du statut de l'article et de l'auteur |
|
| 844 | + if (isset($opt['statut'])) { |
|
| 845 | + $statut = $opt['statut']; |
|
| 846 | + } else { |
|
| 847 | + if (!$id) { |
|
| 848 | + return false; |
|
| 849 | + } |
|
| 850 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 851 | + } |
|
| 852 | + |
|
| 853 | + return |
|
| 854 | + // si on est pas auteur de l'article, |
|
| 855 | + // seuls les propose et publies sont visibles |
|
| 856 | + in_array($statut, ['prop', 'publie']) |
|
| 857 | + // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 858 | + or |
|
| 859 | + ($id |
|
| 860 | + and $qui['id_auteur'] |
|
| 861 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | |
@@ -877,24 +877,24 @@ discard block |
||
| 877 | 877 | * @return bool true s'il a le droit, false sinon |
| 878 | 878 | **/ |
| 879 | 879 | function autoriser_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 880 | - # securite, mais on aurait pas du arriver ici ! |
|
| 881 | - if ( |
|
| 882 | - function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 883 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 884 | - ) { |
|
| 885 | - return $f($faire, $type, $id, $qui, $opt); |
|
| 886 | - } |
|
| 880 | + # securite, mais on aurait pas du arriver ici ! |
|
| 881 | + if ( |
|
| 882 | + function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 883 | + or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 884 | + ) { |
|
| 885 | + return $f($faire, $type, $id, $qui, $opt); |
|
| 886 | + } |
|
| 887 | 887 | |
| 888 | - if ($qui['statut'] === '0minirezo') { |
|
| 889 | - return true; |
|
| 890 | - } |
|
| 891 | - // admins et redacteurs peuvent voir un auteur |
|
| 892 | - if ($type === 'auteur') { |
|
| 893 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 894 | - } |
|
| 895 | - // sinon par defaut tout est visible |
|
| 896 | - // sauf cas particuliers traites separemment (ie article) |
|
| 897 | - return true; |
|
| 888 | + if ($qui['statut'] === '0minirezo') { |
|
| 889 | + return true; |
|
| 890 | + } |
|
| 891 | + // admins et redacteurs peuvent voir un auteur |
|
| 892 | + if ($type === 'auteur') { |
|
| 893 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 894 | + } |
|
| 895 | + // sinon par defaut tout est visible |
|
| 896 | + // sauf cas particuliers traites separemment (ie article) |
|
| 897 | + return true; |
|
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | |
@@ -917,12 +917,12 @@ discard block |
||
| 917 | 917 | * @return bool true s'il a le droit, false sinon |
| 918 | 918 | **/ |
| 919 | 919 | function autoriser_webmestre_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 920 | - return |
|
| 921 | - (defined('_ID_WEBMESTRES') ? |
|
| 922 | - in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 923 | - : $qui['webmestre'] === 'oui') |
|
| 924 | - and $qui['statut'] === '0minirezo' |
|
| 925 | - and !$qui['restreint']; |
|
| 920 | + return |
|
| 921 | + (defined('_ID_WEBMESTRES') ? |
|
| 922 | + in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 923 | + : $qui['webmestre'] === 'oui') |
|
| 924 | + and $qui['statut'] === '0minirezo' |
|
| 925 | + and !$qui['restreint']; |
|
| 926 | 926 | } |
| 927 | 927 | |
| 928 | 928 | /** |
@@ -940,9 +940,9 @@ discard block |
||
| 940 | 940 | * @return bool true s'il a le droit, false sinon |
| 941 | 941 | **/ |
| 942 | 942 | function autoriser_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 943 | - return |
|
| 944 | - $qui['statut'] === '0minirezo' |
|
| 945 | - and !$qui['restreint']; |
|
| 943 | + return |
|
| 944 | + $qui['statut'] === '0minirezo' |
|
| 945 | + and !$qui['restreint']; |
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | /** |
@@ -960,8 +960,8 @@ discard block |
||
| 960 | 960 | * @return bool true s'il a le droit, false sinon |
| 961 | 961 | **/ |
| 962 | 962 | function autoriser_sauvegarder_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 963 | - return |
|
| 964 | - $qui['statut'] === '0minirezo'; |
|
| 963 | + return |
|
| 964 | + $qui['statut'] === '0minirezo'; |
|
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | /** |
@@ -979,7 +979,7 @@ discard block |
||
| 979 | 979 | * @return bool true s'il a le droit, false sinon |
| 980 | 980 | **/ |
| 981 | 981 | function autoriser_detruire_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 982 | - return autoriser('webmestre', null, 0, $qui, $opt); |
|
| 982 | + return autoriser('webmestre', null, 0, $qui, $opt); |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | /** |
@@ -998,23 +998,23 @@ discard block |
||
| 998 | 998 | * @return bool true s'il a le droit, false sinon |
| 999 | 999 | **/ |
| 1000 | 1000 | function autoriser_auteur_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1001 | - // les admins peuvent "previsualiser" une page auteur |
|
| 1002 | - if ( |
|
| 1003 | - $qui['statut'] === '0minirezo' |
|
| 1004 | - and !$qui['restreint'] |
|
| 1005 | - ) { |
|
| 1006 | - return true; |
|
| 1007 | - } elseif ($id === 0) { |
|
| 1008 | - return false; |
|
| 1009 | - } |
|
| 1010 | - // "Voir en ligne" si l'auteur a un article publie |
|
| 1011 | - $n = sql_fetsel( |
|
| 1012 | - 'A.id_article', |
|
| 1013 | - 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 1014 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1015 | - ); |
|
| 1001 | + // les admins peuvent "previsualiser" une page auteur |
|
| 1002 | + if ( |
|
| 1003 | + $qui['statut'] === '0minirezo' |
|
| 1004 | + and !$qui['restreint'] |
|
| 1005 | + ) { |
|
| 1006 | + return true; |
|
| 1007 | + } elseif ($id === 0) { |
|
| 1008 | + return false; |
|
| 1009 | + } |
|
| 1010 | + // "Voir en ligne" si l'auteur a un article publie |
|
| 1011 | + $n = sql_fetsel( |
|
| 1012 | + 'A.id_article', |
|
| 1013 | + 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 1014 | + "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1015 | + ); |
|
| 1016 | 1016 | |
| 1017 | - return $n ? true : false; |
|
| 1017 | + return $n ? true : false; |
|
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | |
@@ -1043,7 +1043,7 @@ discard block |
||
| 1043 | 1043 | * @return bool true s'il a le droit, false sinon |
| 1044 | 1044 | **/ |
| 1045 | 1045 | function autoriser_auteur_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1046 | - return ($qui['statut'] === '0minirezo'); |
|
| 1046 | + return ($qui['statut'] === '0minirezo'); |
|
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | 1049 | |
@@ -1064,75 +1064,75 @@ discard block |
||
| 1064 | 1064 | * @return bool true s'il a le droit, false sinon |
| 1065 | 1065 | **/ |
| 1066 | 1066 | function autoriser_auteur_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1067 | - $id = intval($id); |
|
| 1068 | - |
|
| 1069 | - // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 1070 | - // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 1071 | - if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 1072 | - if ( |
|
| 1073 | - $id == $qui['id_auteur'] |
|
| 1074 | - && empty($opt['statut']) |
|
| 1075 | - && empty($opt['webmestre']) |
|
| 1076 | - && empty($opt['restreintes']) |
|
| 1077 | - && empty($opt['login']) |
|
| 1078 | - ) { |
|
| 1079 | - return true; |
|
| 1080 | - } |
|
| 1081 | - return false; |
|
| 1082 | - } |
|
| 1083 | - |
|
| 1084 | - // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 1085 | - // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1086 | - if ($qui['restreint']) { |
|
| 1087 | - if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1088 | - return false; |
|
| 1089 | - } elseif ( |
|
| 1090 | - (isset($opt['statut']) and ($opt['statut'] === '0minirezo')) |
|
| 1091 | - or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1092 | - ) { |
|
| 1093 | - return false; |
|
| 1094 | - } else { |
|
| 1095 | - if ($id == $qui['id_auteur']) { |
|
| 1096 | - if (isset($opt['statut']) and $opt['statut']) { |
|
| 1097 | - return false; |
|
| 1098 | - } else { |
|
| 1099 | - return true; |
|
| 1100 | - } |
|
| 1101 | - } else { |
|
| 1102 | - if ($id_auteur = intval($id)) { |
|
| 1103 | - $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1104 | - if ($t and $t['statut'] != '0minirezo') { |
|
| 1105 | - return true; |
|
| 1106 | - } else { |
|
| 1107 | - return false; |
|
| 1108 | - } |
|
| 1109 | - } // id = 0 => creation |
|
| 1110 | - else { |
|
| 1111 | - return true; |
|
| 1112 | - } |
|
| 1113 | - } |
|
| 1114 | - } |
|
| 1115 | - } |
|
| 1116 | - |
|
| 1117 | - // Un admin complet fait ce qu'il veut |
|
| 1118 | - // sauf se degrader |
|
| 1119 | - if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1120 | - return false; |
|
| 1121 | - } elseif ( |
|
| 1122 | - isset($opt['webmestre']) |
|
| 1123 | - and $opt['webmestre'] |
|
| 1124 | - and (defined('_ID_WEBMESTRES') |
|
| 1125 | - or !autoriser('webmestre')) |
|
| 1126 | - ) { |
|
| 1127 | - // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1128 | - // ou si les webmestres sont fixes par constante (securite) |
|
| 1129 | - return false; |
|
| 1130 | - } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1131 | - elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) { |
|
| 1132 | - return false; |
|
| 1133 | - } else { |
|
| 1134 | - return true; |
|
| 1135 | - } |
|
| 1067 | + $id = intval($id); |
|
| 1068 | + |
|
| 1069 | + // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 1070 | + // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 1071 | + if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 1072 | + if ( |
|
| 1073 | + $id == $qui['id_auteur'] |
|
| 1074 | + && empty($opt['statut']) |
|
| 1075 | + && empty($opt['webmestre']) |
|
| 1076 | + && empty($opt['restreintes']) |
|
| 1077 | + && empty($opt['login']) |
|
| 1078 | + ) { |
|
| 1079 | + return true; |
|
| 1080 | + } |
|
| 1081 | + return false; |
|
| 1082 | + } |
|
| 1083 | + |
|
| 1084 | + // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 1085 | + // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1086 | + if ($qui['restreint']) { |
|
| 1087 | + if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1088 | + return false; |
|
| 1089 | + } elseif ( |
|
| 1090 | + (isset($opt['statut']) and ($opt['statut'] === '0minirezo')) |
|
| 1091 | + or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1092 | + ) { |
|
| 1093 | + return false; |
|
| 1094 | + } else { |
|
| 1095 | + if ($id == $qui['id_auteur']) { |
|
| 1096 | + if (isset($opt['statut']) and $opt['statut']) { |
|
| 1097 | + return false; |
|
| 1098 | + } else { |
|
| 1099 | + return true; |
|
| 1100 | + } |
|
| 1101 | + } else { |
|
| 1102 | + if ($id_auteur = intval($id)) { |
|
| 1103 | + $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1104 | + if ($t and $t['statut'] != '0minirezo') { |
|
| 1105 | + return true; |
|
| 1106 | + } else { |
|
| 1107 | + return false; |
|
| 1108 | + } |
|
| 1109 | + } // id = 0 => creation |
|
| 1110 | + else { |
|
| 1111 | + return true; |
|
| 1112 | + } |
|
| 1113 | + } |
|
| 1114 | + } |
|
| 1115 | + } |
|
| 1116 | + |
|
| 1117 | + // Un admin complet fait ce qu'il veut |
|
| 1118 | + // sauf se degrader |
|
| 1119 | + if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1120 | + return false; |
|
| 1121 | + } elseif ( |
|
| 1122 | + isset($opt['webmestre']) |
|
| 1123 | + and $opt['webmestre'] |
|
| 1124 | + and (defined('_ID_WEBMESTRES') |
|
| 1125 | + or !autoriser('webmestre')) |
|
| 1126 | + ) { |
|
| 1127 | + // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1128 | + // ou si les webmestres sont fixes par constante (securite) |
|
| 1129 | + return false; |
|
| 1130 | + } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1131 | + elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) { |
|
| 1132 | + return false; |
|
| 1133 | + } else { |
|
| 1134 | + return true; |
|
| 1135 | + } |
|
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | 1138 | |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | * @return bool true s'il a le droit, false sinon |
| 1152 | 1152 | **/ |
| 1153 | 1153 | function autoriser_associerauteurs_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1154 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1154 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | 1157 | |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | * @return bool true s'il a le droit, false sinon |
| 1171 | 1171 | **/ |
| 1172 | 1172 | function autoriser_chargerftp_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1173 | - return $qui['statut'] === '0minirezo'; |
|
| 1173 | + return $qui['statut'] === '0minirezo'; |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | /** |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | * @return bool true s'il a le droit, false sinon |
| 1189 | 1189 | **/ |
| 1190 | 1190 | function autoriser_debug_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1191 | - return $qui['statut'] === '0minirezo'; |
|
| 1191 | + return $qui['statut'] === '0minirezo'; |
|
| 1192 | 1192 | } |
| 1193 | 1193 | |
| 1194 | 1194 | /** |
@@ -1205,54 +1205,54 @@ discard block |
||
| 1205 | 1205 | * @return array Liste des rubriques |
| 1206 | 1206 | **/ |
| 1207 | 1207 | function liste_rubriques_auteur($id_auteur, $raz = false) { |
| 1208 | - static $restreint = []; |
|
| 1209 | - |
|
| 1210 | - if (!$id_auteur = intval($id_auteur)) { |
|
| 1211 | - return []; |
|
| 1212 | - } |
|
| 1213 | - if ($raz) { |
|
| 1214 | - unset($restreint[$id_auteur]); |
|
| 1215 | - } elseif (isset($restreint[$id_auteur])) { |
|
| 1216 | - return $restreint[$id_auteur]; |
|
| 1217 | - } |
|
| 1218 | - |
|
| 1219 | - $rubriques = []; |
|
| 1220 | - if ( |
|
| 1221 | - (!isset($GLOBALS['meta']['version_installee']) |
|
| 1222 | - or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1223 | - and $r = sql_allfetsel( |
|
| 1224 | - 'id_objet', |
|
| 1225 | - 'spip_auteurs_liens', |
|
| 1226 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1227 | - ) |
|
| 1228 | - and is_countable($r) ? count($r) : 0 |
|
| 1229 | - ) { |
|
| 1230 | - $r = array_column($r, 'id_objet'); |
|
| 1231 | - |
|
| 1232 | - // recuperer toute la branche, au format chaine enumeration |
|
| 1233 | - include_spip('inc/rubriques'); |
|
| 1234 | - $r = calcul_branche_in($r); |
|
| 1235 | - $r = explode(',', $r); |
|
| 1236 | - |
|
| 1237 | - // passer les rubriques en index, elimine les doublons |
|
| 1238 | - $r = array_flip($r); |
|
| 1239 | - // recuperer les index seuls |
|
| 1240 | - $r = array_keys($r); |
|
| 1241 | - // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1242 | - // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1243 | - $rubriques = array_combine($r, $r); |
|
| 1244 | - } |
|
| 1245 | - |
|
| 1246 | - // Affecter l'auteur session le cas echeant |
|
| 1247 | - if ( |
|
| 1248 | - isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1249 | - and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1250 | - ) { |
|
| 1251 | - $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1252 | - } |
|
| 1253 | - |
|
| 1254 | - |
|
| 1255 | - return $restreint[$id_auteur] = $rubriques; |
|
| 1208 | + static $restreint = []; |
|
| 1209 | + |
|
| 1210 | + if (!$id_auteur = intval($id_auteur)) { |
|
| 1211 | + return []; |
|
| 1212 | + } |
|
| 1213 | + if ($raz) { |
|
| 1214 | + unset($restreint[$id_auteur]); |
|
| 1215 | + } elseif (isset($restreint[$id_auteur])) { |
|
| 1216 | + return $restreint[$id_auteur]; |
|
| 1217 | + } |
|
| 1218 | + |
|
| 1219 | + $rubriques = []; |
|
| 1220 | + if ( |
|
| 1221 | + (!isset($GLOBALS['meta']['version_installee']) |
|
| 1222 | + or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1223 | + and $r = sql_allfetsel( |
|
| 1224 | + 'id_objet', |
|
| 1225 | + 'spip_auteurs_liens', |
|
| 1226 | + 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1227 | + ) |
|
| 1228 | + and is_countable($r) ? count($r) : 0 |
|
| 1229 | + ) { |
|
| 1230 | + $r = array_column($r, 'id_objet'); |
|
| 1231 | + |
|
| 1232 | + // recuperer toute la branche, au format chaine enumeration |
|
| 1233 | + include_spip('inc/rubriques'); |
|
| 1234 | + $r = calcul_branche_in($r); |
|
| 1235 | + $r = explode(',', $r); |
|
| 1236 | + |
|
| 1237 | + // passer les rubriques en index, elimine les doublons |
|
| 1238 | + $r = array_flip($r); |
|
| 1239 | + // recuperer les index seuls |
|
| 1240 | + $r = array_keys($r); |
|
| 1241 | + // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1242 | + // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1243 | + $rubriques = array_combine($r, $r); |
|
| 1244 | + } |
|
| 1245 | + |
|
| 1246 | + // Affecter l'auteur session le cas echeant |
|
| 1247 | + if ( |
|
| 1248 | + isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1249 | + and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1250 | + ) { |
|
| 1251 | + $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1252 | + } |
|
| 1253 | + |
|
| 1254 | + |
|
| 1255 | + return $restreint[$id_auteur] = $rubriques; |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | /** |
@@ -1270,7 +1270,7 @@ discard block |
||
| 1270 | 1270 | * @return bool true s'il a le droit, false sinon |
| 1271 | 1271 | **/ |
| 1272 | 1272 | function autoriser_rubrique_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1273 | - return autoriser('previsualiser'); |
|
| 1273 | + return autoriser('previsualiser'); |
|
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | 1276 | /** |
@@ -1288,7 +1288,7 @@ discard block |
||
| 1288 | 1288 | * @return bool true s'il a le droit, false sinon |
| 1289 | 1289 | **/ |
| 1290 | 1290 | function autoriser_rubrique_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1291 | - return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1291 | + return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | 1294 | /** |
@@ -1306,9 +1306,9 @@ discard block |
||
| 1306 | 1306 | * @return bool true s'il a le droit, false sinon |
| 1307 | 1307 | **/ |
| 1308 | 1308 | function autoriser_auteur_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1309 | - $id = intval($id); |
|
| 1310 | - return (($id == $qui['id_auteur']) or |
|
| 1311 | - (($qui['statut'] === '0minirezo') and !$qui['restreint'])); |
|
| 1309 | + $id = intval($id); |
|
| 1310 | + return (($id == $qui['id_auteur']) or |
|
| 1311 | + (($qui['statut'] === '0minirezo') and !$qui['restreint'])); |
|
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | 1314 | /** |
@@ -1326,8 +1326,8 @@ discard block |
||
| 1326 | 1326 | * @return bool true s'il a le droit, false sinon |
| 1327 | 1327 | **/ |
| 1328 | 1328 | function autoriser_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1329 | - // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1330 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1329 | + // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1330 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | 1333 | |
@@ -1347,7 +1347,7 @@ discard block |
||
| 1347 | 1347 | * @return true |
| 1348 | 1348 | **/ |
| 1349 | 1349 | function autoriser_ok_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1350 | - return true; |
|
| 1350 | + return true; |
|
| 1351 | 1351 | } |
| 1352 | 1352 | |
| 1353 | 1353 | /** |
@@ -1366,7 +1366,7 @@ discard block |
||
| 1366 | 1366 | * @return false |
| 1367 | 1367 | **/ |
| 1368 | 1368 | function autoriser_niet_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1369 | - return false; |
|
| 1369 | + return false; |
|
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | /** |
@@ -1384,11 +1384,11 @@ discard block |
||
| 1384 | 1384 | * @return bool true s'il a le droit, false sinon |
| 1385 | 1385 | **/ |
| 1386 | 1386 | function autoriser_base_reparer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1387 | - if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1388 | - return false; |
|
| 1389 | - } |
|
| 1387 | + if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1388 | + return false; |
|
| 1389 | + } |
|
| 1390 | 1390 | |
| 1391 | - return true; |
|
| 1391 | + return true; |
|
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | 1394 | /** |
@@ -1406,7 +1406,7 @@ discard block |
||
| 1406 | 1406 | * @return true |
| 1407 | 1407 | **/ |
| 1408 | 1408 | function autoriser_infosperso_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1409 | - return true; |
|
| 1409 | + return true; |
|
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | 1412 | /** |
@@ -1424,7 +1424,7 @@ discard block |
||
| 1424 | 1424 | * @return true |
| 1425 | 1425 | **/ |
| 1426 | 1426 | function autoriser_langage_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1427 | - return true; |
|
| 1427 | + return true; |
|
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | 1430 | /** |
@@ -1442,7 +1442,7 @@ discard block |
||
| 1442 | 1442 | * @return bool true s'il a le droit, false sinon |
| 1443 | 1443 | **/ |
| 1444 | 1444 | function autoriser_configurerlangage_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1445 | - return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1445 | + return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | 1448 | /** |
@@ -1460,7 +1460,7 @@ discard block |
||
| 1460 | 1460 | * @return true |
| 1461 | 1461 | **/ |
| 1462 | 1462 | function autoriser_preferences_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1463 | - return true; |
|
| 1463 | + return true; |
|
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | 1466 | /** |
@@ -1478,7 +1478,7 @@ discard block |
||
| 1478 | 1478 | * @return bool true s'il a le droit, false sinon |
| 1479 | 1479 | **/ |
| 1480 | 1480 | function autoriser_configurerpreferences_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1481 | - return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1481 | + return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1482 | 1482 | } |
| 1483 | 1483 | |
| 1484 | 1484 | /** |
@@ -1496,8 +1496,8 @@ discard block |
||
| 1496 | 1496 | * @return bool true s'il a le droit, false sinon |
| 1497 | 1497 | **/ |
| 1498 | 1498 | function autoriser_menudeveloppement_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1499 | - return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1500 | - and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui'); |
|
| 1499 | + return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1500 | + and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui'); |
|
| 1501 | 1501 | } |
| 1502 | 1502 | |
| 1503 | 1503 | /** |
@@ -1516,7 +1516,7 @@ discard block |
||
| 1516 | 1516 | * @return true |
| 1517 | 1517 | **/ |
| 1518 | 1518 | function autoriser_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1519 | - return true; |
|
| 1519 | + return true; |
|
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | /** |
@@ -1534,7 +1534,7 @@ discard block |
||
| 1534 | 1534 | * @return true |
| 1535 | 1535 | **/ |
| 1536 | 1536 | function autoriser_auteurs_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1537 | - return true; |
|
| 1537 | + return true; |
|
| 1538 | 1538 | } |
| 1539 | 1539 | |
| 1540 | 1540 | /** |
@@ -1552,7 +1552,7 @@ discard block |
||
| 1552 | 1552 | * @return bool true s'il a le droit, false sinon |
| 1553 | 1553 | **/ |
| 1554 | 1554 | function autoriser_auteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1555 | - return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1555 | + return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1556 | 1556 | } |
| 1557 | 1557 | |
| 1558 | 1558 | /** |
@@ -1570,7 +1570,7 @@ discard block |
||
| 1570 | 1570 | * @return true |
| 1571 | 1571 | **/ |
| 1572 | 1572 | function autoriser_articles_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1573 | - return true; |
|
| 1573 | + return true; |
|
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | /** |
@@ -1588,7 +1588,7 @@ discard block |
||
| 1588 | 1588 | * @return bool true s'il a le droit, false sinon |
| 1589 | 1589 | **/ |
| 1590 | 1590 | function autoriser_articles_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1591 | - return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1591 | + return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1592 | 1592 | } |
| 1593 | 1593 | |
| 1594 | 1594 | /** |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | * @return true |
| 1607 | 1607 | **/ |
| 1608 | 1608 | function autoriser_rubriques_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1609 | - return true; |
|
| 1609 | + return true; |
|
| 1610 | 1610 | } |
| 1611 | 1611 | |
| 1612 | 1612 | /** |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | * @return bool true s'il a le droit, false sinon |
| 1625 | 1625 | **/ |
| 1626 | 1626 | function autoriser_rubriques_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1627 | - return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1627 | + return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1628 | 1628 | } |
| 1629 | 1629 | |
| 1630 | 1630 | /** |
@@ -1642,7 +1642,7 @@ discard block |
||
| 1642 | 1642 | * @return bool true s'il a le droit, false sinon |
| 1643 | 1643 | **/ |
| 1644 | 1644 | function autoriser_articlecreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1645 | - return verifier_table_non_vide(); |
|
| 1645 | + return verifier_table_non_vide(); |
|
| 1646 | 1646 | } |
| 1647 | 1647 | |
| 1648 | 1648 | |
@@ -1663,7 +1663,7 @@ discard block |
||
| 1663 | 1663 | * @return bool true s'il a le droit, false sinon |
| 1664 | 1664 | **/ |
| 1665 | 1665 | function autoriser_auteurcreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1666 | - return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1666 | + return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | 1669 | /** |
@@ -1681,13 +1681,13 @@ discard block |
||
| 1681 | 1681 | * @return bool true s'il a le droit, false sinon |
| 1682 | 1682 | **/ |
| 1683 | 1683 | function autoriser_visiteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1684 | - include_spip('base/abstract_sql'); |
|
| 1685 | - return |
|
| 1686 | - $qui['statut'] === '0minirezo' and !$qui['restreint'] |
|
| 1687 | - and ( |
|
| 1688 | - $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1689 | - or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1690 | - ); |
|
| 1684 | + include_spip('base/abstract_sql'); |
|
| 1685 | + return |
|
| 1686 | + $qui['statut'] === '0minirezo' and !$qui['restreint'] |
|
| 1687 | + and ( |
|
| 1688 | + $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1689 | + or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1690 | + ); |
|
| 1691 | 1691 | } |
| 1692 | 1692 | |
| 1693 | 1693 | /** |
@@ -1705,7 +1705,7 @@ discard block |
||
| 1705 | 1705 | * @return bool true s'il a le droit, false sinon |
| 1706 | 1706 | **/ |
| 1707 | 1707 | function autoriser_suiviedito_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1708 | - return $qui['statut'] === '0minirezo'; |
|
| 1708 | + return $qui['statut'] === '0minirezo'; |
|
| 1709 | 1709 | } |
| 1710 | 1710 | |
| 1711 | 1711 | /** |
@@ -1723,7 +1723,7 @@ discard block |
||
| 1723 | 1723 | * @return bool true s'il a le droit, false sinon |
| 1724 | 1724 | **/ |
| 1725 | 1725 | function autoriser_synchro_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1726 | - return $qui['statut'] === '0minirezo'; |
|
| 1726 | + return $qui['statut'] === '0minirezo'; |
|
| 1727 | 1727 | } |
| 1728 | 1728 | |
| 1729 | 1729 | /** |
@@ -1741,7 +1741,7 @@ discard block |
||
| 1741 | 1741 | * @return bool true s'il a le droit, false sinon |
| 1742 | 1742 | **/ |
| 1743 | 1743 | function autoriser_configurerinteractions_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1744 | - return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1744 | + return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1745 | 1745 | } |
| 1746 | 1746 | |
| 1747 | 1747 | /** |
@@ -1759,7 +1759,7 @@ discard block |
||
| 1759 | 1759 | * @return bool true s'il a le droit, false sinon |
| 1760 | 1760 | **/ |
| 1761 | 1761 | function autoriser_configurerlangue_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1762 | - return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1762 | + return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1763 | 1763 | } |
| 1764 | 1764 | |
| 1765 | 1765 | /** |
@@ -1777,7 +1777,7 @@ discard block |
||
| 1777 | 1777 | * @return bool true s'il a le droit, false sinon |
| 1778 | 1778 | **/ |
| 1779 | 1779 | function autoriser_configurermultilinguisme_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1780 | - return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1780 | + return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | 1783 | /** |
@@ -1795,7 +1795,7 @@ discard block |
||
| 1795 | 1795 | * @return bool true s'il a le droit, false sinon |
| 1796 | 1796 | **/ |
| 1797 | 1797 | function autoriser_configurercontenu_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1798 | - return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1798 | + return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | 1801 | /** |
@@ -1813,7 +1813,7 @@ discard block |
||
| 1813 | 1813 | * @return bool true s'il a le droit, false sinon |
| 1814 | 1814 | **/ |
| 1815 | 1815 | function autoriser_configureravancees_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1816 | - return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1816 | + return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | 1819 | /** |
@@ -1831,7 +1831,7 @@ discard block |
||
| 1831 | 1831 | * @return bool true s'il a le droit, false sinon |
| 1832 | 1832 | **/ |
| 1833 | 1833 | function autoriser_adminplugin_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1834 | - return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1834 | + return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | 1837 | /** |
@@ -1849,7 +1849,7 @@ discard block |
||
| 1849 | 1849 | * @return bool true s'il a le droit, false sinon |
| 1850 | 1850 | **/ |
| 1851 | 1851 | function autoriser_admintech_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1852 | - return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1852 | + return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | 1855 | /** |
@@ -1867,7 +1867,7 @@ discard block |
||
| 1867 | 1867 | * @return bool true s'il a le droit, false sinon |
| 1868 | 1868 | **/ |
| 1869 | 1869 | function autoriser_queue_purger_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1870 | - return autoriser('webmestre'); |
|
| 1870 | + return autoriser('webmestre'); |
|
| 1871 | 1871 | } |
| 1872 | 1872 | |
| 1873 | 1873 | |
@@ -1887,11 +1887,11 @@ discard block |
||
| 1887 | 1887 | * @return bool true s'il a le droit, false sinon |
| 1888 | 1888 | **/ |
| 1889 | 1889 | function autoriser_echafauder_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1890 | - if (test_espace_prive()) { |
|
| 1891 | - return intval($qui['id_auteur']) ? true : false; |
|
| 1892 | - } else { |
|
| 1893 | - return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1894 | - } |
|
| 1890 | + if (test_espace_prive()) { |
|
| 1891 | + return intval($qui['id_auteur']) ? true : false; |
|
| 1892 | + } else { |
|
| 1893 | + return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1894 | + } |
|
| 1895 | 1895 | } |
| 1896 | 1896 | |
| 1897 | 1897 | |
@@ -1906,27 +1906,27 @@ discard block |
||
| 1906 | 1906 | * Identifiants d'auteurs |
| 1907 | 1907 | */ |
| 1908 | 1908 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1909 | - $objet = objet_type($objet); |
|
| 1910 | - $where = [ |
|
| 1911 | - 'objet=' . sql_quote($objet), |
|
| 1912 | - 'id_objet=' . intval($id_objet) |
|
| 1913 | - ]; |
|
| 1914 | - if (!empty($cond)) { |
|
| 1915 | - if (is_array($cond)) { |
|
| 1916 | - $where = array_merge($where, $cond); |
|
| 1917 | - } else { |
|
| 1918 | - $where[] = $cond; |
|
| 1919 | - } |
|
| 1920 | - } |
|
| 1921 | - $auteurs = sql_allfetsel( |
|
| 1922 | - 'id_auteur', |
|
| 1923 | - 'spip_auteurs_liens', |
|
| 1924 | - $where |
|
| 1925 | - ); |
|
| 1926 | - if (is_array($auteurs)) { |
|
| 1927 | - return array_column($auteurs, 'id_auteur'); |
|
| 1928 | - } |
|
| 1929 | - return []; |
|
| 1909 | + $objet = objet_type($objet); |
|
| 1910 | + $where = [ |
|
| 1911 | + 'objet=' . sql_quote($objet), |
|
| 1912 | + 'id_objet=' . intval($id_objet) |
|
| 1913 | + ]; |
|
| 1914 | + if (!empty($cond)) { |
|
| 1915 | + if (is_array($cond)) { |
|
| 1916 | + $where = array_merge($where, $cond); |
|
| 1917 | + } else { |
|
| 1918 | + $where[] = $cond; |
|
| 1919 | + } |
|
| 1920 | + } |
|
| 1921 | + $auteurs = sql_allfetsel( |
|
| 1922 | + 'id_auteur', |
|
| 1923 | + 'spip_auteurs_liens', |
|
| 1924 | + $where |
|
| 1925 | + ); |
|
| 1926 | + if (is_array($auteurs)) { |
|
| 1927 | + return array_column($auteurs, 'id_auteur'); |
|
| 1928 | + } |
|
| 1929 | + return []; |
|
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | 1932 | /** |
@@ -1941,11 +1941,11 @@ discard block |
||
| 1941 | 1941 | * - false : serveur SQL indisponible |
| 1942 | 1942 | */ |
| 1943 | 1943 | function auteurs_article($id_article, $cond = '') { |
| 1944 | - return sql_allfetsel( |
|
| 1945 | - 'id_auteur', |
|
| 1946 | - 'spip_auteurs_liens', |
|
| 1947 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1948 | - ); |
|
| 1944 | + return sql_allfetsel( |
|
| 1945 | + 'id_auteur', |
|
| 1946 | + 'spip_auteurs_liens', |
|
| 1947 | + "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1948 | + ); |
|
| 1949 | 1949 | } |
| 1950 | 1950 | |
| 1951 | 1951 | |
@@ -1959,7 +1959,7 @@ discard block |
||
| 1959 | 1959 | */ |
| 1960 | 1960 | function acces_restreint_rubrique($id_rubrique) { |
| 1961 | 1961 | |
| 1962 | - return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1962 | + return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1963 | 1963 | } |
| 1964 | 1964 | |
| 1965 | 1965 | |
@@ -1972,12 +1972,12 @@ discard block |
||
| 1972 | 1972 | * @return bool true si un parent existe |
| 1973 | 1973 | */ |
| 1974 | 1974 | function verifier_table_non_vide($table = 'spip_rubriques') { |
| 1975 | - static $done = []; |
|
| 1976 | - if (!isset($done[$table])) { |
|
| 1977 | - $done[$table] = sql_countsel($table) > 0; |
|
| 1978 | - } |
|
| 1975 | + static $done = []; |
|
| 1976 | + if (!isset($done[$table])) { |
|
| 1977 | + $done[$table] = sql_countsel($table) > 0; |
|
| 1978 | + } |
|
| 1979 | 1979 | |
| 1980 | - return $done[$table]; |
|
| 1980 | + return $done[$table]; |
|
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | 1983 | /** |
@@ -2004,15 +2004,15 @@ discard block |
||
| 2004 | 2004 | */ |
| 2005 | 2005 | function autoriser_inscrireauteur_dist($faire, $quoi, $id, $qui, $opt) { |
| 2006 | 2006 | |
| 2007 | - $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 2008 | - switch ($s) { |
|
| 2009 | - case 'info_redacteurs': |
|
| 2010 | - return ($GLOBALS['meta']['accepter_inscriptions'] === 'oui'); |
|
| 2011 | - case 'info_visiteurs': |
|
| 2012 | - return ($GLOBALS['meta']['accepter_visiteurs'] === 'oui' or $GLOBALS['meta']['forums_publics'] === 'abo'); |
|
| 2013 | - } |
|
| 2007 | + $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 2008 | + switch ($s) { |
|
| 2009 | + case 'info_redacteurs': |
|
| 2010 | + return ($GLOBALS['meta']['accepter_inscriptions'] === 'oui'); |
|
| 2011 | + case 'info_visiteurs': |
|
| 2012 | + return ($GLOBALS['meta']['accepter_visiteurs'] === 'oui' or $GLOBALS['meta']['forums_publics'] === 'abo'); |
|
| 2013 | + } |
|
| 2014 | 2014 | |
| 2015 | - return false; |
|
| 2015 | + return false; |
|
| 2016 | 2016 | } |
| 2017 | 2017 | |
| 2018 | 2018 | /** |
@@ -2030,7 +2030,7 @@ discard block |
||
| 2030 | 2030 | * @return bool true s'il a le droit, false sinon |
| 2031 | 2031 | **/ |
| 2032 | 2032 | function autoriser_inscription_relancer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 2033 | - return $qui['statut'] === '0minirezo' and !$qui['restreint']; |
|
| 2033 | + return $qui['statut'] === '0minirezo' and !$qui['restreint']; |
|
| 2034 | 2034 | } |
| 2035 | 2035 | |
| 2036 | 2036 | /** |
@@ -2048,5 +2048,5 @@ discard block |
||
| 2048 | 2048 | * @return bool true s'il a le droit, false sinon |
| 2049 | 2049 | **/ |
| 2050 | 2050 | function autoriser_phpinfos_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 2051 | - return autoriser('webmestre'); |
|
| 2051 | + return autoriser('webmestre'); |
|
| 2052 | 2052 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | // mais apres la fonction autoriser() |
| 121 | 121 | if ($f = find_in_path('mes_fonctions.php')) { |
| 122 | 122 | global $dossier_squelettes; |
| 123 | - include_once(_ROOT_CWD . $f); |
|
| 123 | + include_once(_ROOT_CWD.$f); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $qui = $GLOBALS['visiteur_session'] ?: []; |
| 163 | 163 | $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
| 164 | 164 | } elseif (is_numeric($qui)) { |
| 165 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 165 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.$qui); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // Admins restreints, on construit ici (pas generique mais...) |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | spip_log( |
| 175 | - "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?', |
|
| 176 | - 'autoriser' . _LOG_DEBUG |
|
| 175 | + "autoriser $faire $type $id (".($qui['nom'] ?? '').') ?', |
|
| 176 | + 'autoriser'._LOG_DEBUG |
|
| 177 | 177 | ); |
| 178 | 178 | |
| 179 | 179 | // passer par objet_type pour avoir les alias |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
| 190 | 190 | or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
| 191 | 191 | ) { |
| 192 | - spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 192 | + spip_log("autoriser ($faire, $type, $id, ".($qui['nom'] ?? '').') : OK Exception', 'autoriser'._LOG_DEBUG); |
|
| 193 | 193 | return true; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -198,18 +198,18 @@ discard block |
||
| 198 | 198 | // autoriser_faire[_dist], autoriser_defaut[_dist] |
| 199 | 199 | $fonctions = $type |
| 200 | 200 | ? [ |
| 201 | - 'autoriser_' . $type . '_' . $faire, |
|
| 202 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 203 | - 'autoriser_' . $type, |
|
| 204 | - 'autoriser_' . $type . '_dist', |
|
| 205 | - 'autoriser_' . $faire, |
|
| 206 | - 'autoriser_' . $faire . '_dist', |
|
| 201 | + 'autoriser_'.$type.'_'.$faire, |
|
| 202 | + 'autoriser_'.$type.'_'.$faire.'_dist', |
|
| 203 | + 'autoriser_'.$type, |
|
| 204 | + 'autoriser_'.$type.'_dist', |
|
| 205 | + 'autoriser_'.$faire, |
|
| 206 | + 'autoriser_'.$faire.'_dist', |
|
| 207 | 207 | 'autoriser_defaut', |
| 208 | 208 | 'autoriser_defaut_dist' |
| 209 | 209 | ] |
| 210 | 210 | : [ |
| 211 | - 'autoriser_' . $faire, |
|
| 212 | - 'autoriser_' . $faire . '_dist', |
|
| 211 | + 'autoriser_'.$faire, |
|
| 212 | + 'autoriser_'.$faire.'_dist', |
|
| 213 | 213 | 'autoriser_defaut', |
| 214 | 214 | 'autoriser_defaut_dist' |
| 215 | 215 | ]; |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | spip_log( |
| 225 | - "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 226 | - 'autoriser' . _LOG_DEBUG |
|
| 225 | + "$f($faire, $type, $id, ".($qui['nom'] ?? '').') : '.($a ? 'OK' : 'niet'), |
|
| 226 | + 'autoriser'._LOG_DEBUG |
|
| 227 | 227 | ); |
| 228 | 228 | |
| 229 | 229 | return $a; |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | function autoriser_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 373 | 373 | |
| 374 | 374 | // Le visiteur a-t-il un statut prevu par la config ? |
| 375 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 375 | + if (strpos($GLOBALS['meta']['preview'], ','.$qui['statut'].',') !== false) { |
|
| 376 | 376 | return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
| 377 | 377 | } |
| 378 | 378 | |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | } // pas de champ passe a la demande => NIET |
| 431 | 431 | $previsu = explode(',', $c['previsu']); |
| 432 | 432 | // regarder si ce statut est autorise pour l'auteur |
| 433 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 433 | + if (in_array($opt[$champ].'/auteur', $previsu)) { |
|
| 434 | 434 | // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
| 435 | 435 | // sinon l’auteur en session |
| 436 | 436 | include_spip('inc/securiser_action'); |
@@ -444,12 +444,12 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | if (!$id_auteur) { |
| 446 | 446 | return false; |
| 447 | - } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 447 | + } elseif (autoriser('previsualiser'.$opt[$champ], $type, 0, $id_auteur)) { |
|
| 448 | 448 | // dans ce cas (admin en general), pas de filtrage sur ce statut |
| 449 | 449 | } elseif ( |
| 450 | 450 | !sql_countsel( |
| 451 | 451 | 'spip_auteurs_liens', |
| 452 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 452 | + 'id_auteur='.intval($id_auteur).' AND objet='.sql_quote($type).' AND id_objet='.intval($id) |
|
| 453 | 453 | ) |
| 454 | 454 | ) { |
| 455 | 455 | return false; |
@@ -494,16 +494,16 @@ discard block |
||
| 494 | 494 | // multilinguisme par secteur et objet rattaché à une rubrique |
| 495 | 495 | $primary = id_table_objet($type); |
| 496 | 496 | if ($table != 'spip_rubriques') { |
| 497 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 497 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=".intval($id)); |
|
| 498 | 498 | } else { |
| 499 | 499 | $id_rubrique = $id; |
| 500 | 500 | } |
| 501 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 501 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 502 | 502 | if (!$id_secteur > 0) { |
| 503 | 503 | $id_secteur = $id_rubrique; |
| 504 | 504 | } |
| 505 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 506 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 505 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_secteur)); |
|
| 506 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=".intval($id)); |
|
| 507 | 507 | if ($langue_secteur != $langue_objet) { |
| 508 | 508 | // configuration incohérente, on laisse l'utilisateur corriger la situation |
| 509 | 509 | return true; |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
| 512 | 512 | return false; |
| 513 | 513 | } else { |
| 514 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 514 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique='.intval($id)); |
|
| 515 | 515 | if ($id_parent != 0) { |
| 516 | 516 | // sous-rubriques : pas de choix de langue |
| 517 | 517 | return false; |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | |
| 564 | 564 | if (!isset($opt['statut'])) { |
| 565 | 565 | if (isset($desc['field']['statut'])) { |
| 566 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 566 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type).'='.intval($id)); |
|
| 567 | 567 | } else { |
| 568 | 568 | $statut = 'publie'; |
| 569 | 569 | } // pas de statut => publie |
@@ -737,11 +737,11 @@ discard block |
||
| 737 | 737 | return false; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 740 | + if (sql_countsel('spip_rubriques', 'id_parent='.intval($id))) { |
|
| 741 | 741 | return false; |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 744 | + if (sql_countsel('spip_articles', 'id_rubrique='.intval($id)." AND (statut<>'poubelle')")) { |
|
| 745 | 745 | return false; |
| 746 | 746 | } |
| 747 | 747 | |
@@ -778,7 +778,7 @@ discard block |
||
| 778 | 778 | if (!$id) { |
| 779 | 779 | return false; |
| 780 | 780 | } |
| 781 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 781 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article='.sql_quote($id)); |
|
| 782 | 782 | |
| 783 | 783 | return |
| 784 | 784 | $r |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | (!isset($opt['statut']) or !in_array($opt['statut'], ['publie', 'refuse'], true)) |
| 790 | 790 | and in_array($qui['statut'], ['0minirezo', '1comite']) |
| 791 | 791 | and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
| 792 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 792 | + and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur']) |
|
| 793 | 793 | ) |
| 794 | 794 | ); |
| 795 | 795 | } |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | if (!$id) { |
| 848 | 848 | return false; |
| 849 | 849 | } |
| 850 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 850 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article='.intval($id)); |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | return |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | or |
| 859 | 859 | ($id |
| 860 | 860 | and $qui['id_auteur'] |
| 861 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 861 | + and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur'])); |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | |
@@ -879,8 +879,8 @@ discard block |
||
| 879 | 879 | function autoriser_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 880 | 880 | # securite, mais on aurait pas du arriver ici ! |
| 881 | 881 | if ( |
| 882 | - function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 883 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 882 | + function_exists($f = 'autoriser_'.$type.'_voir') |
|
| 883 | + or function_exists($f = 'autoriser_'.$type.'_voir_dist') |
|
| 884 | 884 | ) { |
| 885 | 885 | return $f($faire, $type, $id, $qui, $opt); |
| 886 | 886 | } |
@@ -1011,7 +1011,7 @@ discard block |
||
| 1011 | 1011 | $n = sql_fetsel( |
| 1012 | 1012 | 'A.id_article', |
| 1013 | 1013 | 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
| 1014 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1014 | + "A.statut='publie' AND L.id_auteur=".sql_quote($id) |
|
| 1015 | 1015 | ); |
| 1016 | 1016 | |
| 1017 | 1017 | return $n ? true : false; |
@@ -1223,7 +1223,7 @@ discard block |
||
| 1223 | 1223 | and $r = sql_allfetsel( |
| 1224 | 1224 | 'id_objet', |
| 1225 | 1225 | 'spip_auteurs_liens', |
| 1226 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1226 | + 'id_auteur='.intval($id_auteur)." AND objet='rubrique' AND id_objet!=0" |
|
| 1227 | 1227 | ) |
| 1228 | 1228 | and is_countable($r) ? count($r) : 0 |
| 1229 | 1229 | ) { |
@@ -1908,8 +1908,8 @@ discard block |
||
| 1908 | 1908 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1909 | 1909 | $objet = objet_type($objet); |
| 1910 | 1910 | $where = [ |
| 1911 | - 'objet=' . sql_quote($objet), |
|
| 1912 | - 'id_objet=' . intval($id_objet) |
|
| 1911 | + 'objet='.sql_quote($objet), |
|
| 1912 | + 'id_objet='.intval($id_objet) |
|
| 1913 | 1913 | ]; |
| 1914 | 1914 | if (!empty($cond)) { |
| 1915 | 1915 | if (is_array($cond)) { |
@@ -1944,7 +1944,7 @@ discard block |
||
| 1944 | 1944 | return sql_allfetsel( |
| 1945 | 1945 | 'id_auteur', |
| 1946 | 1946 | 'spip_auteurs_liens', |
| 1947 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1947 | + "objet='article' AND id_objet=".intval($id_article).($cond ? " AND $cond" : '') |
|
| 1948 | 1948 | ); |
| 1949 | 1949 | } |
| 1950 | 1950 | |