@@ -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,91 +38,91 @@ 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 | - $args = func_get_args(); |
|
| 115 | - |
|
| 116 | - return call_user_func_array('autoriser_dist', $args); |
|
| 117 | - } |
|
| 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 | + $args = func_get_args(); |
|
| 115 | + |
|
| 116 | + return call_user_func_array('autoriser_dist', $args); |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
| 121 | 121 | // mes_fonctions peut aussi declarer des autorisations, il faut donc le charger |
| 122 | 122 | // mais apres la fonction autoriser() |
| 123 | 123 | if ($f = find_in_path('mes_fonctions.php')) { |
| 124 | - global $dossier_squelettes; |
|
| 125 | - include_once(_ROOT_CWD . $f); |
|
| 124 | + global $dossier_squelettes; |
|
| 125 | + include_once(_ROOT_CWD . $f); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
@@ -153,82 +153,82 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | function autoriser_dist(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
| 155 | 155 | |
| 156 | - $a = null; |
|
| 157 | - if ($type === null) { |
|
| 158 | - $type = ''; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - // Qui ? visiteur_session ? |
|
| 162 | - // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 163 | - if ($qui === null or $qui === '') { |
|
| 164 | - $qui = $GLOBALS['visiteur_session'] ?: []; |
|
| 165 | - $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 166 | - } elseif (is_numeric($qui)) { |
|
| 167 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - // Admins restreints, on construit ici (pas generique mais...) |
|
| 171 | - // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 172 | - if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 173 | - $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : []; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - spip_log( |
|
| 177 | - "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?', |
|
| 178 | - 'autoriser' . _LOG_DEBUG |
|
| 179 | - ); |
|
| 180 | - |
|
| 181 | - // passer par objet_type pour avoir les alias |
|
| 182 | - // sauf si _ est le premier caractère. |
|
| 183 | - if ($type and $type[0] !== '_') { |
|
| 184 | - $type = objet_type($type, false); |
|
| 185 | - } |
|
| 186 | - // et supprimer les _ |
|
| 187 | - $type = str_replace('_', '', (string) $type); |
|
| 188 | - |
|
| 189 | - // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 190 | - if ( |
|
| 191 | - (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 192 | - or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 193 | - ) { |
|
| 194 | - spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 195 | - return true; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - // Chercher une fonction d'autorisation |
|
| 199 | - // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 200 | - // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 201 | - $fonctions = $type |
|
| 202 | - ? [ |
|
| 203 | - 'autoriser_' . $type . '_' . $faire, |
|
| 204 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 205 | - 'autoriser_' . $type, |
|
| 206 | - 'autoriser_' . $type . '_dist', |
|
| 207 | - 'autoriser_' . $faire, |
|
| 208 | - 'autoriser_' . $faire . '_dist', |
|
| 209 | - 'autoriser_defaut', |
|
| 210 | - 'autoriser_defaut_dist' |
|
| 211 | - ] |
|
| 212 | - : [ |
|
| 213 | - 'autoriser_' . $faire, |
|
| 214 | - 'autoriser_' . $faire . '_dist', |
|
| 215 | - 'autoriser_defaut', |
|
| 216 | - 'autoriser_defaut_dist' |
|
| 217 | - ]; |
|
| 218 | - |
|
| 219 | - foreach ($fonctions as $f) { |
|
| 220 | - if (function_exists($f)) { |
|
| 221 | - $a = $f($faire, $type, $id, $qui, $opt); |
|
| 222 | - break; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - spip_log( |
|
| 227 | - "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 228 | - 'autoriser' . _LOG_DEBUG |
|
| 229 | - ); |
|
| 230 | - |
|
| 231 | - return $a; |
|
| 156 | + $a = null; |
|
| 157 | + if ($type === null) { |
|
| 158 | + $type = ''; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + // Qui ? visiteur_session ? |
|
| 162 | + // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 163 | + if ($qui === null or $qui === '') { |
|
| 164 | + $qui = $GLOBALS['visiteur_session'] ?: []; |
|
| 165 | + $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 166 | + } elseif (is_numeric($qui)) { |
|
| 167 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + // Admins restreints, on construit ici (pas generique mais...) |
|
| 171 | + // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 172 | + if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 173 | + $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : []; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + spip_log( |
|
| 177 | + "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?', |
|
| 178 | + 'autoriser' . _LOG_DEBUG |
|
| 179 | + ); |
|
| 180 | + |
|
| 181 | + // passer par objet_type pour avoir les alias |
|
| 182 | + // sauf si _ est le premier caractère. |
|
| 183 | + if ($type and $type[0] !== '_') { |
|
| 184 | + $type = objet_type($type, false); |
|
| 185 | + } |
|
| 186 | + // et supprimer les _ |
|
| 187 | + $type = str_replace('_', '', (string) $type); |
|
| 188 | + |
|
| 189 | + // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 190 | + if ( |
|
| 191 | + (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 192 | + or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 193 | + ) { |
|
| 194 | + spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 195 | + return true; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + // Chercher une fonction d'autorisation |
|
| 199 | + // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 200 | + // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 201 | + $fonctions = $type |
|
| 202 | + ? [ |
|
| 203 | + 'autoriser_' . $type . '_' . $faire, |
|
| 204 | + 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 205 | + 'autoriser_' . $type, |
|
| 206 | + 'autoriser_' . $type . '_dist', |
|
| 207 | + 'autoriser_' . $faire, |
|
| 208 | + 'autoriser_' . $faire . '_dist', |
|
| 209 | + 'autoriser_defaut', |
|
| 210 | + 'autoriser_defaut_dist' |
|
| 211 | + ] |
|
| 212 | + : [ |
|
| 213 | + 'autoriser_' . $faire, |
|
| 214 | + 'autoriser_' . $faire . '_dist', |
|
| 215 | + 'autoriser_defaut', |
|
| 216 | + 'autoriser_defaut_dist' |
|
| 217 | + ]; |
|
| 218 | + |
|
| 219 | + foreach ($fonctions as $f) { |
|
| 220 | + if (function_exists($f)) { |
|
| 221 | + $a = $f($faire, $type, $id, $qui, $opt); |
|
| 222 | + break; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + spip_log( |
|
| 227 | + "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 228 | + 'autoriser' . _LOG_DEBUG |
|
| 229 | + ); |
|
| 230 | + |
|
| 231 | + return $a; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // une globale pour aller au plus vite dans la fonction generique ci dessus |
@@ -248,33 +248,33 @@ discard block |
||
| 248 | 248 | * @return bool |
| 249 | 249 | */ |
| 250 | 250 | function autoriser_exception(string $faire, ?string $type = '', $id = null, $autoriser = true): bool { |
| 251 | - // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 252 | - static $autorisation; |
|
| 253 | - // Tolérance avec certains appels |
|
| 254 | - if ($type === null) { |
|
| 255 | - $type = ''; |
|
| 256 | - } |
|
| 257 | - if ($id === null) { |
|
| 258 | - $id = 0; |
|
| 259 | - } |
|
| 260 | - if ($autoriser === 'verifier') { |
|
| 261 | - return isset($autorisation[$faire][$type][$id]); |
|
| 262 | - } |
|
| 263 | - if ($autoriser === true) { |
|
| 264 | - $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 265 | - } |
|
| 266 | - if ($autoriser === false) { |
|
| 267 | - if ($id === '*') { |
|
| 268 | - unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 269 | - unset($autorisation[$faire][$type]); |
|
| 270 | - } |
|
| 271 | - else { |
|
| 272 | - unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 273 | - unset($autorisation[$faire][$type][$id]); |
|
| 274 | - } |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - return false; |
|
| 251 | + // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 252 | + static $autorisation; |
|
| 253 | + // Tolérance avec certains appels |
|
| 254 | + if ($type === null) { |
|
| 255 | + $type = ''; |
|
| 256 | + } |
|
| 257 | + if ($id === null) { |
|
| 258 | + $id = 0; |
|
| 259 | + } |
|
| 260 | + if ($autoriser === 'verifier') { |
|
| 261 | + return isset($autorisation[$faire][$type][$id]); |
|
| 262 | + } |
|
| 263 | + if ($autoriser === true) { |
|
| 264 | + $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 265 | + } |
|
| 266 | + if ($autoriser === false) { |
|
| 267 | + if ($id === '*') { |
|
| 268 | + unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 269 | + unset($autorisation[$faire][$type]); |
|
| 270 | + } |
|
| 271 | + else { |
|
| 272 | + unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 273 | + unset($autorisation[$faire][$type][$id]); |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + return false; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | |
@@ -293,9 +293,9 @@ discard block |
||
| 293 | 293 | * @return bool true s'il a le droit, false sinon |
| 294 | 294 | **/ |
| 295 | 295 | function autoriser_defaut_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 296 | - return |
|
| 297 | - $qui['statut'] === '0minirezo' |
|
| 298 | - and !$qui['restreint']; |
|
| 296 | + return |
|
| 297 | + $qui['statut'] === '0minirezo' |
|
| 298 | + and !$qui['restreint']; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -315,10 +315,10 @@ discard block |
||
| 315 | 315 | * @return bool true s'il a le droit, false sinon |
| 316 | 316 | */ |
| 317 | 317 | function autoriser_loger_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 318 | - if ($qui['statut'] === '5poubelle') { |
|
| 319 | - return false; |
|
| 320 | - } |
|
| 321 | - return true; |
|
| 318 | + if ($qui['statut'] === '5poubelle') { |
|
| 319 | + return false; |
|
| 320 | + } |
|
| 321 | + return true; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | * @return bool true s'il a le droit, false sinon |
| 335 | 335 | **/ |
| 336 | 336 | function autoriser_ecrire_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 337 | - return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 337 | + return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * @return bool true s'il a le droit, false sinon |
| 354 | 354 | **/ |
| 355 | 355 | function autoriser_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 356 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 356 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
@@ -373,18 +373,18 @@ discard block |
||
| 373 | 373 | **/ |
| 374 | 374 | function autoriser_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 375 | 375 | |
| 376 | - // Le visiteur a-t-il un statut prevu par la config ? |
|
| 377 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 378 | - return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 379 | - } |
|
| 376 | + // Le visiteur a-t-il un statut prevu par la config ? |
|
| 377 | + if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 378 | + return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | - // A-t-on un token de prévisualisation valable ? |
|
| 382 | - include_spip('inc/securiser_action'); |
|
| 383 | - if (decrire_token_previsu()) { |
|
| 384 | - return true; |
|
| 385 | - } |
|
| 381 | + // A-t-on un token de prévisualisation valable ? |
|
| 382 | + include_spip('inc/securiser_action'); |
|
| 383 | + if (decrire_token_previsu()) { |
|
| 384 | + return true; |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - return false; |
|
| 387 | + return false; |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
@@ -413,58 +413,58 @@ discard block |
||
| 413 | 413 | */ |
| 414 | 414 | function test_previsualiser_objet_champ(string $type = '', $id = null, array $qui = [], array $opt = []): bool { |
| 415 | 415 | |
| 416 | - // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 417 | - if (!$type) { |
|
| 418 | - return true; |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - include_spip('base/objets'); |
|
| 422 | - $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 423 | - if (isset($infos['statut'])) { |
|
| 424 | - foreach ($infos['statut'] as $c) { |
|
| 425 | - if (isset($c['publie'])) { |
|
| 426 | - if (!isset($c['previsu'])) { |
|
| 427 | - return false; |
|
| 428 | - } // pas de previsu definie => NIET |
|
| 429 | - $champ = $c['champ']; |
|
| 430 | - if (!isset($opt[$champ])) { |
|
| 431 | - return false; |
|
| 432 | - } // pas de champ passe a la demande => NIET |
|
| 433 | - $previsu = explode(',', $c['previsu']); |
|
| 434 | - // regarder si ce statut est autorise pour l'auteur |
|
| 435 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 436 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 437 | - // sinon l’auteur en session |
|
| 438 | - include_spip('inc/securiser_action'); |
|
| 439 | - if ($desc = decrire_token_previsu()) { |
|
| 440 | - $id_auteur = $desc['id_auteur']; |
|
| 441 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 442 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 443 | - } else { |
|
| 444 | - $id_auteur = null; |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - if (!$id_auteur) { |
|
| 448 | - return false; |
|
| 449 | - } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 450 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 451 | - } elseif ( |
|
| 452 | - !sql_countsel( |
|
| 453 | - 'spip_auteurs_liens', |
|
| 454 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 455 | - ) |
|
| 456 | - ) { |
|
| 457 | - return false; |
|
| 458 | - } // pas auteur de cet objet => NIET |
|
| 459 | - } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 460 | - // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 461 | - return false; |
|
| 462 | - } |
|
| 463 | - } |
|
| 464 | - } |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - return true; |
|
| 416 | + // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 417 | + if (!$type) { |
|
| 418 | + return true; |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + include_spip('base/objets'); |
|
| 422 | + $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 423 | + if (isset($infos['statut'])) { |
|
| 424 | + foreach ($infos['statut'] as $c) { |
|
| 425 | + if (isset($c['publie'])) { |
|
| 426 | + if (!isset($c['previsu'])) { |
|
| 427 | + return false; |
|
| 428 | + } // pas de previsu definie => NIET |
|
| 429 | + $champ = $c['champ']; |
|
| 430 | + if (!isset($opt[$champ])) { |
|
| 431 | + return false; |
|
| 432 | + } // pas de champ passe a la demande => NIET |
|
| 433 | + $previsu = explode(',', $c['previsu']); |
|
| 434 | + // regarder si ce statut est autorise pour l'auteur |
|
| 435 | + if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 436 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 437 | + // sinon l’auteur en session |
|
| 438 | + include_spip('inc/securiser_action'); |
|
| 439 | + if ($desc = decrire_token_previsu()) { |
|
| 440 | + $id_auteur = $desc['id_auteur']; |
|
| 441 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 442 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 443 | + } else { |
|
| 444 | + $id_auteur = null; |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + if (!$id_auteur) { |
|
| 448 | + return false; |
|
| 449 | + } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 450 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 451 | + } elseif ( |
|
| 452 | + !sql_countsel( |
|
| 453 | + 'spip_auteurs_liens', |
|
| 454 | + 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 455 | + ) |
|
| 456 | + ) { |
|
| 457 | + return false; |
|
| 458 | + } // pas auteur de cet objet => NIET |
|
| 459 | + } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 460 | + // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 461 | + return false; |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + return true; |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -480,51 +480,51 @@ discard block |
||
| 480 | 480 | * @return bool true s'il a le droit, false sinon |
| 481 | 481 | **/ |
| 482 | 482 | function autoriser_changerlangue_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 483 | - $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 484 | - $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 485 | - $table = table_objet_sql($type); |
|
| 486 | - if ( |
|
| 487 | - in_array($table, $multi_objets) |
|
| 488 | - or in_array($table, $gerer_trad_objets) |
|
| 489 | - ) { // affichage du formulaire si la configuration l'accepte |
|
| 490 | - $multi_secteurs = lire_config('multi_secteurs'); |
|
| 491 | - $champs = objet_info($type, 'field'); |
|
| 492 | - if ( |
|
| 493 | - $multi_secteurs === 'oui' |
|
| 494 | - and array_key_exists('id_rubrique', $champs) |
|
| 495 | - ) { |
|
| 496 | - // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 497 | - $primary = id_table_objet($type); |
|
| 498 | - if ($table != 'spip_rubriques') { |
|
| 499 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 500 | - } else { |
|
| 501 | - $id_rubrique = $id; |
|
| 502 | - } |
|
| 503 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 504 | - if (!$id_secteur > 0) { |
|
| 505 | - $id_secteur = $id_rubrique; |
|
| 506 | - } |
|
| 507 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 508 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 509 | - if ($langue_secteur != $langue_objet) { |
|
| 510 | - // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 511 | - return true; |
|
| 512 | - } |
|
| 513 | - if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 514 | - return false; |
|
| 515 | - } else { |
|
| 516 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 517 | - if ($id_parent != 0) { |
|
| 518 | - // sous-rubriques : pas de choix de langue |
|
| 519 | - return false; |
|
| 520 | - } |
|
| 521 | - } |
|
| 522 | - } |
|
| 523 | - } else { |
|
| 524 | - return false; |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 483 | + $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 484 | + $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 485 | + $table = table_objet_sql($type); |
|
| 486 | + if ( |
|
| 487 | + in_array($table, $multi_objets) |
|
| 488 | + or in_array($table, $gerer_trad_objets) |
|
| 489 | + ) { // affichage du formulaire si la configuration l'accepte |
|
| 490 | + $multi_secteurs = lire_config('multi_secteurs'); |
|
| 491 | + $champs = objet_info($type, 'field'); |
|
| 492 | + if ( |
|
| 493 | + $multi_secteurs === 'oui' |
|
| 494 | + and array_key_exists('id_rubrique', $champs) |
|
| 495 | + ) { |
|
| 496 | + // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 497 | + $primary = id_table_objet($type); |
|
| 498 | + if ($table != 'spip_rubriques') { |
|
| 499 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 500 | + } else { |
|
| 501 | + $id_rubrique = $id; |
|
| 502 | + } |
|
| 503 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 504 | + if (!$id_secteur > 0) { |
|
| 505 | + $id_secteur = $id_rubrique; |
|
| 506 | + } |
|
| 507 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 508 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 509 | + if ($langue_secteur != $langue_objet) { |
|
| 510 | + // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 511 | + return true; |
|
| 512 | + } |
|
| 513 | + if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 514 | + return false; |
|
| 515 | + } else { |
|
| 516 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 517 | + if ($id_parent != 0) { |
|
| 518 | + // sous-rubriques : pas de choix de langue |
|
| 519 | + return false; |
|
| 520 | + } |
|
| 521 | + } |
|
| 522 | + } |
|
| 523 | + } else { |
|
| 524 | + return false; |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | /** |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | * @return bool true s'il a le droit, false sinon |
| 541 | 541 | **/ |
| 542 | 542 | function autoriser_changertraduction_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 543 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 543 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
@@ -556,41 +556,41 @@ discard block |
||
| 556 | 556 | * @return bool true s'il a le droit, false sinon |
| 557 | 557 | **/ |
| 558 | 558 | function autoriser_dater_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 559 | - $table = table_objet($type); |
|
| 560 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 561 | - $desc = $trouver_table($table); |
|
| 562 | - if (!$desc) { |
|
| 563 | - return false; |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - if (!isset($opt['statut'])) { |
|
| 567 | - if (isset($desc['field']['statut'])) { |
|
| 568 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 569 | - } else { |
|
| 570 | - $statut = 'publie'; |
|
| 571 | - } // pas de statut => publie |
|
| 572 | - } else { |
|
| 573 | - $statut = $opt['statut']; |
|
| 574 | - } |
|
| 575 | - |
|
| 576 | - // Liste des statuts publiés pour cet objet |
|
| 577 | - if (isset($desc['statut'][0]['publie'])) { |
|
| 578 | - $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 579 | - } |
|
| 580 | - // Sinon en dur le statut "publie" |
|
| 581 | - else { |
|
| 582 | - $statuts_publies = ['publie']; |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - if ( |
|
| 586 | - in_array($statut, $statuts_publies) |
|
| 587 | - // Ou cas particulier géré en dur ici pour les articles |
|
| 588 | - or ($statut === 'prop' and $type === 'article' and $GLOBALS['meta']['post_dates'] === 'non') |
|
| 589 | - ) { |
|
| 590 | - return autoriser('modifier', $type, $id); |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - return false; |
|
| 559 | + $table = table_objet($type); |
|
| 560 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 561 | + $desc = $trouver_table($table); |
|
| 562 | + if (!$desc) { |
|
| 563 | + return false; |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + if (!isset($opt['statut'])) { |
|
| 567 | + if (isset($desc['field']['statut'])) { |
|
| 568 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 569 | + } else { |
|
| 570 | + $statut = 'publie'; |
|
| 571 | + } // pas de statut => publie |
|
| 572 | + } else { |
|
| 573 | + $statut = $opt['statut']; |
|
| 574 | + } |
|
| 575 | + |
|
| 576 | + // Liste des statuts publiés pour cet objet |
|
| 577 | + if (isset($desc['statut'][0]['publie'])) { |
|
| 578 | + $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 579 | + } |
|
| 580 | + // Sinon en dur le statut "publie" |
|
| 581 | + else { |
|
| 582 | + $statuts_publies = ['publie']; |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + if ( |
|
| 586 | + in_array($statut, $statuts_publies) |
|
| 587 | + // Ou cas particulier géré en dur ici pour les articles |
|
| 588 | + or ($statut === 'prop' and $type === 'article' and $GLOBALS['meta']['post_dates'] === 'non') |
|
| 589 | + ) { |
|
| 590 | + return autoriser('modifier', $type, $id); |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + return false; |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | * @return bool true s'il a le droit, false sinon |
| 610 | 610 | **/ |
| 611 | 611 | function autoriser_instituer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 612 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 612 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -627,12 +627,12 @@ discard block |
||
| 627 | 627 | * @return bool true s'il a le droit, false sinon |
| 628 | 628 | **/ |
| 629 | 629 | function autoriser_rubrique_publierdans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 630 | - return |
|
| 631 | - ($qui['statut'] === '0minirezo') |
|
| 632 | - and ( |
|
| 633 | - !$qui['restreint'] or !$id |
|
| 634 | - or in_array($id, $qui['restreint']) |
|
| 635 | - ); |
|
| 630 | + return |
|
| 631 | + ($qui['statut'] === '0minirezo') |
|
| 632 | + and ( |
|
| 633 | + !$qui['restreint'] or !$id |
|
| 634 | + or in_array($id, $qui['restreint']) |
|
| 635 | + ); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | /** |
@@ -650,12 +650,12 @@ discard block |
||
| 650 | 650 | * @return bool true s'il a le droit, false sinon |
| 651 | 651 | **/ |
| 652 | 652 | function autoriser_rubrique_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 653 | - if (!empty($opt['id_parent'])) { |
|
| 654 | - return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 655 | - } |
|
| 656 | - else { |
|
| 657 | - return autoriser('defaut', null, 0, $qui, $opt); |
|
| 658 | - } |
|
| 653 | + if (!empty($opt['id_parent'])) { |
|
| 654 | + return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 655 | + } |
|
| 656 | + else { |
|
| 657 | + return autoriser('defaut', null, 0, $qui, $opt); |
|
| 658 | + } |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | /** |
@@ -673,10 +673,10 @@ discard block |
||
| 673 | 673 | * @return bool true s'il a le droit, false sinon |
| 674 | 674 | **/ |
| 675 | 675 | function autoriser_rubrique_creerrubriquedans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 676 | - return |
|
| 677 | - ($id or ($qui['statut'] === '0minirezo' and !$qui['restreint'])) |
|
| 678 | - and autoriser('voir', 'rubrique', $id) |
|
| 679 | - and autoriser('publierdans', 'rubrique', $id); |
|
| 676 | + return |
|
| 677 | + ($id or ($qui['statut'] === '0minirezo' and !$qui['restreint'])) |
|
| 678 | + and autoriser('voir', 'rubrique', $id) |
|
| 679 | + and autoriser('publierdans', 'rubrique', $id); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | /** |
@@ -694,10 +694,10 @@ discard block |
||
| 694 | 694 | * @return bool true s'il a le droit, false sinon |
| 695 | 695 | **/ |
| 696 | 696 | function autoriser_rubrique_creerarticledans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 697 | - return |
|
| 698 | - $id |
|
| 699 | - and autoriser('voir', 'rubrique', $id) |
|
| 700 | - and autoriser('creer', 'article'); |
|
| 697 | + return |
|
| 698 | + $id |
|
| 699 | + and autoriser('voir', 'rubrique', $id) |
|
| 700 | + and autoriser('creer', 'article'); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | |
@@ -716,8 +716,8 @@ discard block |
||
| 716 | 716 | * @return bool true s'il a le droit, false sinon |
| 717 | 717 | **/ |
| 718 | 718 | function autoriser_rubrique_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 719 | - return |
|
| 720 | - autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 719 | + return |
|
| 720 | + autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | /** |
@@ -735,29 +735,29 @@ discard block |
||
| 735 | 735 | * @return bool true s'il a le droit, false sinon |
| 736 | 736 | **/ |
| 737 | 737 | function autoriser_rubrique_supprimer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 738 | - if (!$id = intval($id)) { |
|
| 739 | - return false; |
|
| 740 | - } |
|
| 738 | + if (!$id = intval($id)) { |
|
| 739 | + return false; |
|
| 740 | + } |
|
| 741 | 741 | |
| 742 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 743 | - return false; |
|
| 744 | - } |
|
| 742 | + if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 743 | + return false; |
|
| 744 | + } |
|
| 745 | 745 | |
| 746 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 747 | - return false; |
|
| 748 | - } |
|
| 746 | + if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 747 | + return false; |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | - $compte = pipeline( |
|
| 751 | - 'objet_compte_enfants', |
|
| 752 | - ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 753 | - ); |
|
| 754 | - foreach ($compte as $objet => $n) { |
|
| 755 | - if ($n) { |
|
| 756 | - return false; |
|
| 757 | - } |
|
| 758 | - } |
|
| 750 | + $compte = pipeline( |
|
| 751 | + 'objet_compte_enfants', |
|
| 752 | + ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 753 | + ); |
|
| 754 | + foreach ($compte as $objet => $n) { |
|
| 755 | + if ($n) { |
|
| 756 | + return false; |
|
| 757 | + } |
|
| 758 | + } |
|
| 759 | 759 | |
| 760 | - return autoriser('modifier', 'rubrique', $id); |
|
| 760 | + return autoriser('modifier', 'rubrique', $id); |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | |
@@ -777,23 +777,23 @@ discard block |
||
| 777 | 777 | * @return bool true s'il a le droit, false sinon |
| 778 | 778 | **/ |
| 779 | 779 | function autoriser_article_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 780 | - if (!$id) { |
|
| 781 | - return false; |
|
| 782 | - } |
|
| 783 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 784 | - |
|
| 785 | - return |
|
| 786 | - $r |
|
| 787 | - and |
|
| 788 | - ( |
|
| 789 | - autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 790 | - or ( |
|
| 791 | - (!isset($opt['statut']) or $opt['statut'] !== 'publie') |
|
| 792 | - and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 793 | - and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 794 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 795 | - ) |
|
| 796 | - ); |
|
| 780 | + if (!$id) { |
|
| 781 | + return false; |
|
| 782 | + } |
|
| 783 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 784 | + |
|
| 785 | + return |
|
| 786 | + $r |
|
| 787 | + and |
|
| 788 | + ( |
|
| 789 | + autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 790 | + or ( |
|
| 791 | + (!isset($opt['statut']) or $opt['statut'] !== 'publie') |
|
| 792 | + and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 793 | + and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 794 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 795 | + ) |
|
| 796 | + ); |
|
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | /** |
@@ -811,13 +811,13 @@ discard block |
||
| 811 | 811 | * @return bool true s'il a le droit, false sinon |
| 812 | 812 | **/ |
| 813 | 813 | function autoriser_article_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 814 | - if (!empty($opt['id_parent'])) { |
|
| 815 | - // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 816 | - return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 817 | - } |
|
| 818 | - else { |
|
| 819 | - return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 820 | - } |
|
| 814 | + if (!empty($opt['id_parent'])) { |
|
| 815 | + // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 816 | + return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 817 | + } |
|
| 818 | + else { |
|
| 819 | + return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 820 | + } |
|
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | /** |
@@ -839,28 +839,28 @@ discard block |
||
| 839 | 839 | * @return bool true s'il a le droit, false sinon |
| 840 | 840 | */ |
| 841 | 841 | function autoriser_article_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 842 | - if ($qui['statut'] === '0minirezo') { |
|
| 843 | - return true; |
|
| 844 | - } |
|
| 845 | - // cas des articles : depend du statut de l'article et de l'auteur |
|
| 846 | - if (isset($opt['statut'])) { |
|
| 847 | - $statut = $opt['statut']; |
|
| 848 | - } else { |
|
| 849 | - if (!$id) { |
|
| 850 | - return false; |
|
| 851 | - } |
|
| 852 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 853 | - } |
|
| 854 | - |
|
| 855 | - return |
|
| 856 | - // si on est pas auteur de l'article, |
|
| 857 | - // seuls les propose et publies sont visibles |
|
| 858 | - in_array($statut, ['prop', 'publie']) |
|
| 859 | - // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 860 | - or |
|
| 861 | - ($id |
|
| 862 | - and $qui['id_auteur'] |
|
| 863 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 842 | + if ($qui['statut'] === '0minirezo') { |
|
| 843 | + return true; |
|
| 844 | + } |
|
| 845 | + // cas des articles : depend du statut de l'article et de l'auteur |
|
| 846 | + if (isset($opt['statut'])) { |
|
| 847 | + $statut = $opt['statut']; |
|
| 848 | + } else { |
|
| 849 | + if (!$id) { |
|
| 850 | + return false; |
|
| 851 | + } |
|
| 852 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 853 | + } |
|
| 854 | + |
|
| 855 | + return |
|
| 856 | + // si on est pas auteur de l'article, |
|
| 857 | + // seuls les propose et publies sont visibles |
|
| 858 | + in_array($statut, ['prop', 'publie']) |
|
| 859 | + // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 860 | + or |
|
| 861 | + ($id |
|
| 862 | + and $qui['id_auteur'] |
|
| 863 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | |
@@ -879,24 +879,24 @@ discard block |
||
| 879 | 879 | * @return bool true s'il a le droit, false sinon |
| 880 | 880 | **/ |
| 881 | 881 | function autoriser_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 882 | - # securite, mais on aurait pas du arriver ici ! |
|
| 883 | - if ( |
|
| 884 | - function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 885 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 886 | - ) { |
|
| 887 | - return $f($faire, $type, $id, $qui, $opt); |
|
| 888 | - } |
|
| 882 | + # securite, mais on aurait pas du arriver ici ! |
|
| 883 | + if ( |
|
| 884 | + function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 885 | + or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 886 | + ) { |
|
| 887 | + return $f($faire, $type, $id, $qui, $opt); |
|
| 888 | + } |
|
| 889 | 889 | |
| 890 | - if ($qui['statut'] === '0minirezo') { |
|
| 891 | - return true; |
|
| 892 | - } |
|
| 893 | - // admins et redacteurs peuvent voir un auteur |
|
| 894 | - if ($type === 'auteur') { |
|
| 895 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 896 | - } |
|
| 897 | - // sinon par defaut tout est visible |
|
| 898 | - // sauf cas particuliers traites separemment (ie article) |
|
| 899 | - return true; |
|
| 890 | + if ($qui['statut'] === '0minirezo') { |
|
| 891 | + return true; |
|
| 892 | + } |
|
| 893 | + // admins et redacteurs peuvent voir un auteur |
|
| 894 | + if ($type === 'auteur') { |
|
| 895 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 896 | + } |
|
| 897 | + // sinon par defaut tout est visible |
|
| 898 | + // sauf cas particuliers traites separemment (ie article) |
|
| 899 | + return true; |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | |
@@ -919,12 +919,12 @@ discard block |
||
| 919 | 919 | * @return bool true s'il a le droit, false sinon |
| 920 | 920 | **/ |
| 921 | 921 | function autoriser_webmestre_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 922 | - return |
|
| 923 | - (defined('_ID_WEBMESTRES') ? |
|
| 924 | - in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 925 | - : $qui['webmestre'] === 'oui') |
|
| 926 | - and $qui['statut'] === '0minirezo' |
|
| 927 | - and !$qui['restreint']; |
|
| 922 | + return |
|
| 923 | + (defined('_ID_WEBMESTRES') ? |
|
| 924 | + in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 925 | + : $qui['webmestre'] === 'oui') |
|
| 926 | + and $qui['statut'] === '0minirezo' |
|
| 927 | + and !$qui['restreint']; |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | /** |
@@ -942,9 +942,9 @@ discard block |
||
| 942 | 942 | * @return bool true s'il a le droit, false sinon |
| 943 | 943 | **/ |
| 944 | 944 | function autoriser_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 945 | - return |
|
| 946 | - $qui['statut'] === '0minirezo' |
|
| 947 | - and !$qui['restreint']; |
|
| 945 | + return |
|
| 946 | + $qui['statut'] === '0minirezo' |
|
| 947 | + and !$qui['restreint']; |
|
| 948 | 948 | } |
| 949 | 949 | |
| 950 | 950 | /** |
@@ -962,8 +962,8 @@ discard block |
||
| 962 | 962 | * @return bool true s'il a le droit, false sinon |
| 963 | 963 | **/ |
| 964 | 964 | function autoriser_sauvegarder_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 965 | - return |
|
| 966 | - $qui['statut'] === '0minirezo'; |
|
| 965 | + return |
|
| 966 | + $qui['statut'] === '0minirezo'; |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | /** |
@@ -981,7 +981,7 @@ discard block |
||
| 981 | 981 | * @return bool true s'il a le droit, false sinon |
| 982 | 982 | **/ |
| 983 | 983 | function autoriser_detruire_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 984 | - return autoriser('webmestre', null, 0, $qui, $opt); |
|
| 984 | + return autoriser('webmestre', null, 0, $qui, $opt); |
|
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | /** |
@@ -1000,23 +1000,23 @@ discard block |
||
| 1000 | 1000 | * @return bool true s'il a le droit, false sinon |
| 1001 | 1001 | **/ |
| 1002 | 1002 | function autoriser_auteur_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1003 | - // les admins peuvent "previsualiser" une page auteur |
|
| 1004 | - if ( |
|
| 1005 | - $qui['statut'] === '0minirezo' |
|
| 1006 | - and !$qui['restreint'] |
|
| 1007 | - ) { |
|
| 1008 | - return true; |
|
| 1009 | - } elseif ($id === 0) { |
|
| 1010 | - return false; |
|
| 1011 | - } |
|
| 1012 | - // "Voir en ligne" si l'auteur a un article publie |
|
| 1013 | - $n = sql_fetsel( |
|
| 1014 | - 'A.id_article', |
|
| 1015 | - 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 1016 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1017 | - ); |
|
| 1003 | + // les admins peuvent "previsualiser" une page auteur |
|
| 1004 | + if ( |
|
| 1005 | + $qui['statut'] === '0minirezo' |
|
| 1006 | + and !$qui['restreint'] |
|
| 1007 | + ) { |
|
| 1008 | + return true; |
|
| 1009 | + } elseif ($id === 0) { |
|
| 1010 | + return false; |
|
| 1011 | + } |
|
| 1012 | + // "Voir en ligne" si l'auteur a un article publie |
|
| 1013 | + $n = sql_fetsel( |
|
| 1014 | + 'A.id_article', |
|
| 1015 | + 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 1016 | + "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1017 | + ); |
|
| 1018 | 1018 | |
| 1019 | - return $n ? true : false; |
|
| 1019 | + return $n ? true : false; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | |
@@ -1045,7 +1045,7 @@ discard block |
||
| 1045 | 1045 | * @return bool true s'il a le droit, false sinon |
| 1046 | 1046 | **/ |
| 1047 | 1047 | function autoriser_auteur_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1048 | - return ($qui['statut'] === '0minirezo'); |
|
| 1048 | + return ($qui['statut'] === '0minirezo'); |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | |
@@ -1066,75 +1066,75 @@ discard block |
||
| 1066 | 1066 | * @return bool true s'il a le droit, false sinon |
| 1067 | 1067 | **/ |
| 1068 | 1068 | function autoriser_auteur_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1069 | - $id = intval($id); |
|
| 1070 | - |
|
| 1071 | - // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 1072 | - // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 1073 | - if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 1074 | - if ( |
|
| 1075 | - $id == $qui['id_auteur'] |
|
| 1076 | - && empty($opt['statut']) |
|
| 1077 | - && empty($opt['webmestre']) |
|
| 1078 | - && empty($opt['restreintes']) |
|
| 1079 | - && empty($opt['login']) |
|
| 1080 | - ) { |
|
| 1081 | - return true; |
|
| 1082 | - } |
|
| 1083 | - return false; |
|
| 1084 | - } |
|
| 1085 | - |
|
| 1086 | - // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 1087 | - // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1088 | - if ($qui['restreint']) { |
|
| 1089 | - if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1090 | - return false; |
|
| 1091 | - } elseif ( |
|
| 1092 | - (isset($opt['statut']) and ($opt['statut'] === '0minirezo')) |
|
| 1093 | - or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1094 | - ) { |
|
| 1095 | - return false; |
|
| 1096 | - } else { |
|
| 1097 | - if ($id == $qui['id_auteur']) { |
|
| 1098 | - if (isset($opt['statut']) and $opt['statut']) { |
|
| 1099 | - return false; |
|
| 1100 | - } else { |
|
| 1101 | - return true; |
|
| 1102 | - } |
|
| 1103 | - } else { |
|
| 1104 | - if ($id_auteur = intval($id)) { |
|
| 1105 | - $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1106 | - if ($t and $t['statut'] != '0minirezo') { |
|
| 1107 | - return true; |
|
| 1108 | - } else { |
|
| 1109 | - return false; |
|
| 1110 | - } |
|
| 1111 | - } // id = 0 => creation |
|
| 1112 | - else { |
|
| 1113 | - return true; |
|
| 1114 | - } |
|
| 1115 | - } |
|
| 1116 | - } |
|
| 1117 | - } |
|
| 1118 | - |
|
| 1119 | - // Un admin complet fait ce qu'il veut |
|
| 1120 | - // sauf se degrader |
|
| 1121 | - if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1122 | - return false; |
|
| 1123 | - } elseif ( |
|
| 1124 | - isset($opt['webmestre']) |
|
| 1125 | - and $opt['webmestre'] |
|
| 1126 | - and (defined('_ID_WEBMESTRES') |
|
| 1127 | - or !autoriser('webmestre')) |
|
| 1128 | - ) { |
|
| 1129 | - // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1130 | - // ou si les webmestres sont fixes par constante (securite) |
|
| 1131 | - return false; |
|
| 1132 | - } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1133 | - elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) { |
|
| 1134 | - return false; |
|
| 1135 | - } else { |
|
| 1136 | - return true; |
|
| 1137 | - } |
|
| 1069 | + $id = intval($id); |
|
| 1070 | + |
|
| 1071 | + // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 1072 | + // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 1073 | + if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 1074 | + if ( |
|
| 1075 | + $id == $qui['id_auteur'] |
|
| 1076 | + && empty($opt['statut']) |
|
| 1077 | + && empty($opt['webmestre']) |
|
| 1078 | + && empty($opt['restreintes']) |
|
| 1079 | + && empty($opt['login']) |
|
| 1080 | + ) { |
|
| 1081 | + return true; |
|
| 1082 | + } |
|
| 1083 | + return false; |
|
| 1084 | + } |
|
| 1085 | + |
|
| 1086 | + // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 1087 | + // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1088 | + if ($qui['restreint']) { |
|
| 1089 | + if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1090 | + return false; |
|
| 1091 | + } elseif ( |
|
| 1092 | + (isset($opt['statut']) and ($opt['statut'] === '0minirezo')) |
|
| 1093 | + or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1094 | + ) { |
|
| 1095 | + return false; |
|
| 1096 | + } else { |
|
| 1097 | + if ($id == $qui['id_auteur']) { |
|
| 1098 | + if (isset($opt['statut']) and $opt['statut']) { |
|
| 1099 | + return false; |
|
| 1100 | + } else { |
|
| 1101 | + return true; |
|
| 1102 | + } |
|
| 1103 | + } else { |
|
| 1104 | + if ($id_auteur = intval($id)) { |
|
| 1105 | + $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1106 | + if ($t and $t['statut'] != '0minirezo') { |
|
| 1107 | + return true; |
|
| 1108 | + } else { |
|
| 1109 | + return false; |
|
| 1110 | + } |
|
| 1111 | + } // id = 0 => creation |
|
| 1112 | + else { |
|
| 1113 | + return true; |
|
| 1114 | + } |
|
| 1115 | + } |
|
| 1116 | + } |
|
| 1117 | + } |
|
| 1118 | + |
|
| 1119 | + // Un admin complet fait ce qu'il veut |
|
| 1120 | + // sauf se degrader |
|
| 1121 | + if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1122 | + return false; |
|
| 1123 | + } elseif ( |
|
| 1124 | + isset($opt['webmestre']) |
|
| 1125 | + and $opt['webmestre'] |
|
| 1126 | + and (defined('_ID_WEBMESTRES') |
|
| 1127 | + or !autoriser('webmestre')) |
|
| 1128 | + ) { |
|
| 1129 | + // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1130 | + // ou si les webmestres sont fixes par constante (securite) |
|
| 1131 | + return false; |
|
| 1132 | + } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1133 | + elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) { |
|
| 1134 | + return false; |
|
| 1135 | + } else { |
|
| 1136 | + return true; |
|
| 1137 | + } |
|
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | 1140 | |
@@ -1153,7 +1153,7 @@ discard block |
||
| 1153 | 1153 | * @return bool true s'il a le droit, false sinon |
| 1154 | 1154 | **/ |
| 1155 | 1155 | function autoriser_associerauteurs_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1156 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1156 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1157 | 1157 | } |
| 1158 | 1158 | |
| 1159 | 1159 | |
@@ -1172,7 +1172,7 @@ discard block |
||
| 1172 | 1172 | * @return bool true s'il a le droit, false sinon |
| 1173 | 1173 | **/ |
| 1174 | 1174 | function autoriser_chargerftp_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1175 | - return $qui['statut'] === '0minirezo'; |
|
| 1175 | + return $qui['statut'] === '0minirezo'; |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | /** |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | * @return bool true s'il a le droit, false sinon |
| 1191 | 1191 | **/ |
| 1192 | 1192 | function autoriser_debug_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1193 | - return $qui['statut'] === '0minirezo'; |
|
| 1193 | + return $qui['statut'] === '0minirezo'; |
|
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | 1196 | /** |
@@ -1207,54 +1207,54 @@ discard block |
||
| 1207 | 1207 | * @return array Liste des rubriques |
| 1208 | 1208 | **/ |
| 1209 | 1209 | function liste_rubriques_auteur($id_auteur, $raz = false) { |
| 1210 | - static $restreint = []; |
|
| 1211 | - |
|
| 1212 | - if (!$id_auteur = intval($id_auteur)) { |
|
| 1213 | - return []; |
|
| 1214 | - } |
|
| 1215 | - if ($raz) { |
|
| 1216 | - unset($restreint[$id_auteur]); |
|
| 1217 | - } elseif (isset($restreint[$id_auteur])) { |
|
| 1218 | - return $restreint[$id_auteur]; |
|
| 1219 | - } |
|
| 1220 | - |
|
| 1221 | - $rubriques = []; |
|
| 1222 | - if ( |
|
| 1223 | - (!isset($GLOBALS['meta']['version_installee']) |
|
| 1224 | - or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1225 | - and $r = sql_allfetsel( |
|
| 1226 | - 'id_objet', |
|
| 1227 | - 'spip_auteurs_liens', |
|
| 1228 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1229 | - ) |
|
| 1230 | - and is_countable($r) ? count($r) : 0 |
|
| 1231 | - ) { |
|
| 1232 | - $r = array_column($r, 'id_objet'); |
|
| 1233 | - |
|
| 1234 | - // recuperer toute la branche, au format chaine enumeration |
|
| 1235 | - include_spip('inc/rubriques'); |
|
| 1236 | - $r = calcul_branche_in($r); |
|
| 1237 | - $r = explode(',', $r); |
|
| 1238 | - |
|
| 1239 | - // passer les rubriques en index, elimine les doublons |
|
| 1240 | - $r = array_flip($r); |
|
| 1241 | - // recuperer les index seuls |
|
| 1242 | - $r = array_keys($r); |
|
| 1243 | - // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1244 | - // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1245 | - $rubriques = array_combine($r, $r); |
|
| 1246 | - } |
|
| 1247 | - |
|
| 1248 | - // Affecter l'auteur session le cas echeant |
|
| 1249 | - if ( |
|
| 1250 | - isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1251 | - and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1252 | - ) { |
|
| 1253 | - $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1254 | - } |
|
| 1255 | - |
|
| 1256 | - |
|
| 1257 | - return $restreint[$id_auteur] = $rubriques; |
|
| 1210 | + static $restreint = []; |
|
| 1211 | + |
|
| 1212 | + if (!$id_auteur = intval($id_auteur)) { |
|
| 1213 | + return []; |
|
| 1214 | + } |
|
| 1215 | + if ($raz) { |
|
| 1216 | + unset($restreint[$id_auteur]); |
|
| 1217 | + } elseif (isset($restreint[$id_auteur])) { |
|
| 1218 | + return $restreint[$id_auteur]; |
|
| 1219 | + } |
|
| 1220 | + |
|
| 1221 | + $rubriques = []; |
|
| 1222 | + if ( |
|
| 1223 | + (!isset($GLOBALS['meta']['version_installee']) |
|
| 1224 | + or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1225 | + and $r = sql_allfetsel( |
|
| 1226 | + 'id_objet', |
|
| 1227 | + 'spip_auteurs_liens', |
|
| 1228 | + 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1229 | + ) |
|
| 1230 | + and is_countable($r) ? count($r) : 0 |
|
| 1231 | + ) { |
|
| 1232 | + $r = array_column($r, 'id_objet'); |
|
| 1233 | + |
|
| 1234 | + // recuperer toute la branche, au format chaine enumeration |
|
| 1235 | + include_spip('inc/rubriques'); |
|
| 1236 | + $r = calcul_branche_in($r); |
|
| 1237 | + $r = explode(',', $r); |
|
| 1238 | + |
|
| 1239 | + // passer les rubriques en index, elimine les doublons |
|
| 1240 | + $r = array_flip($r); |
|
| 1241 | + // recuperer les index seuls |
|
| 1242 | + $r = array_keys($r); |
|
| 1243 | + // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1244 | + // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1245 | + $rubriques = array_combine($r, $r); |
|
| 1246 | + } |
|
| 1247 | + |
|
| 1248 | + // Affecter l'auteur session le cas echeant |
|
| 1249 | + if ( |
|
| 1250 | + isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1251 | + and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1252 | + ) { |
|
| 1253 | + $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1254 | + } |
|
| 1255 | + |
|
| 1256 | + |
|
| 1257 | + return $restreint[$id_auteur] = $rubriques; |
|
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | 1260 | /** |
@@ -1272,7 +1272,7 @@ discard block |
||
| 1272 | 1272 | * @return bool true s'il a le droit, false sinon |
| 1273 | 1273 | **/ |
| 1274 | 1274 | function autoriser_rubrique_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1275 | - return autoriser('previsualiser'); |
|
| 1275 | + return autoriser('previsualiser'); |
|
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | 1278 | /** |
@@ -1290,7 +1290,7 @@ discard block |
||
| 1290 | 1290 | * @return bool true s'il a le droit, false sinon |
| 1291 | 1291 | **/ |
| 1292 | 1292 | function autoriser_rubrique_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1293 | - return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1293 | + return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | 1296 | /** |
@@ -1308,9 +1308,9 @@ discard block |
||
| 1308 | 1308 | * @return bool true s'il a le droit, false sinon |
| 1309 | 1309 | **/ |
| 1310 | 1310 | function autoriser_auteur_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1311 | - $id = intval($id); |
|
| 1312 | - return (($id == $qui['id_auteur']) or |
|
| 1313 | - (($qui['statut'] === '0minirezo') and !$qui['restreint'])); |
|
| 1311 | + $id = intval($id); |
|
| 1312 | + return (($id == $qui['id_auteur']) or |
|
| 1313 | + (($qui['statut'] === '0minirezo') and !$qui['restreint'])); |
|
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | /** |
@@ -1328,8 +1328,8 @@ discard block |
||
| 1328 | 1328 | * @return bool true s'il a le droit, false sinon |
| 1329 | 1329 | **/ |
| 1330 | 1330 | function autoriser_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1331 | - // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1332 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1331 | + // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1332 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | 1335 | |
@@ -1349,7 +1349,7 @@ discard block |
||
| 1349 | 1349 | * @return true |
| 1350 | 1350 | **/ |
| 1351 | 1351 | function autoriser_ok_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1352 | - return true; |
|
| 1352 | + return true; |
|
| 1353 | 1353 | } |
| 1354 | 1354 | |
| 1355 | 1355 | /** |
@@ -1368,7 +1368,7 @@ discard block |
||
| 1368 | 1368 | * @return false |
| 1369 | 1369 | **/ |
| 1370 | 1370 | function autoriser_niet_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1371 | - return false; |
|
| 1371 | + return false; |
|
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | /** |
@@ -1386,11 +1386,11 @@ discard block |
||
| 1386 | 1386 | * @return bool true s'il a le droit, false sinon |
| 1387 | 1387 | **/ |
| 1388 | 1388 | function autoriser_base_reparer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1389 | - if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1390 | - return false; |
|
| 1391 | - } |
|
| 1389 | + if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1390 | + return false; |
|
| 1391 | + } |
|
| 1392 | 1392 | |
| 1393 | - return true; |
|
| 1393 | + return true; |
|
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | 1396 | /** |
@@ -1408,7 +1408,7 @@ discard block |
||
| 1408 | 1408 | * @return true |
| 1409 | 1409 | **/ |
| 1410 | 1410 | function autoriser_infosperso_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1411 | - return true; |
|
| 1411 | + return true; |
|
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | 1414 | /** |
@@ -1426,7 +1426,7 @@ discard block |
||
| 1426 | 1426 | * @return true |
| 1427 | 1427 | **/ |
| 1428 | 1428 | function autoriser_langage_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1429 | - return true; |
|
| 1429 | + return true; |
|
| 1430 | 1430 | } |
| 1431 | 1431 | |
| 1432 | 1432 | /** |
@@ -1444,7 +1444,7 @@ discard block |
||
| 1444 | 1444 | * @return bool true s'il a le droit, false sinon |
| 1445 | 1445 | **/ |
| 1446 | 1446 | function autoriser_configurerlangage_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1447 | - return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1447 | + return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1448 | 1448 | } |
| 1449 | 1449 | |
| 1450 | 1450 | /** |
@@ -1462,7 +1462,7 @@ discard block |
||
| 1462 | 1462 | * @return true |
| 1463 | 1463 | **/ |
| 1464 | 1464 | function autoriser_preferences_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1465 | - return true; |
|
| 1465 | + return true; |
|
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | 1468 | /** |
@@ -1480,7 +1480,7 @@ discard block |
||
| 1480 | 1480 | * @return bool true s'il a le droit, false sinon |
| 1481 | 1481 | **/ |
| 1482 | 1482 | function autoriser_configurerpreferences_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1483 | - return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1483 | + return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | 1486 | /** |
@@ -1498,8 +1498,8 @@ discard block |
||
| 1498 | 1498 | * @return bool true s'il a le droit, false sinon |
| 1499 | 1499 | **/ |
| 1500 | 1500 | function autoriser_menudeveloppement_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1501 | - return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1502 | - and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui'); |
|
| 1501 | + return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1502 | + and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui'); |
|
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | 1505 | /** |
@@ -1518,7 +1518,7 @@ discard block |
||
| 1518 | 1518 | * @return true |
| 1519 | 1519 | **/ |
| 1520 | 1520 | function autoriser_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1521 | - return true; |
|
| 1521 | + return true; |
|
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | 1524 | /** |
@@ -1536,7 +1536,7 @@ discard block |
||
| 1536 | 1536 | * @return true |
| 1537 | 1537 | **/ |
| 1538 | 1538 | function autoriser_auteurs_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1539 | - return true; |
|
| 1539 | + return true; |
|
| 1540 | 1540 | } |
| 1541 | 1541 | |
| 1542 | 1542 | /** |
@@ -1554,7 +1554,7 @@ discard block |
||
| 1554 | 1554 | * @return bool true s'il a le droit, false sinon |
| 1555 | 1555 | **/ |
| 1556 | 1556 | function autoriser_auteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1557 | - return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1557 | + return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | 1560 | /** |
@@ -1572,7 +1572,7 @@ discard block |
||
| 1572 | 1572 | * @return true |
| 1573 | 1573 | **/ |
| 1574 | 1574 | function autoriser_articles_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1575 | - return true; |
|
| 1575 | + return true; |
|
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | 1578 | /** |
@@ -1590,7 +1590,7 @@ discard block |
||
| 1590 | 1590 | * @return bool true s'il a le droit, false sinon |
| 1591 | 1591 | **/ |
| 1592 | 1592 | function autoriser_articles_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1593 | - return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1593 | + return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1594 | 1594 | } |
| 1595 | 1595 | |
| 1596 | 1596 | /** |
@@ -1608,7 +1608,7 @@ discard block |
||
| 1608 | 1608 | * @return true |
| 1609 | 1609 | **/ |
| 1610 | 1610 | function autoriser_rubriques_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1611 | - return true; |
|
| 1611 | + return true; |
|
| 1612 | 1612 | } |
| 1613 | 1613 | |
| 1614 | 1614 | /** |
@@ -1626,7 +1626,7 @@ discard block |
||
| 1626 | 1626 | * @return bool true s'il a le droit, false sinon |
| 1627 | 1627 | **/ |
| 1628 | 1628 | function autoriser_rubriques_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1629 | - return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1629 | + return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | 1632 | /** |
@@ -1644,7 +1644,7 @@ discard block |
||
| 1644 | 1644 | * @return bool true s'il a le droit, false sinon |
| 1645 | 1645 | **/ |
| 1646 | 1646 | function autoriser_articlecreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1647 | - return verifier_table_non_vide(); |
|
| 1647 | + return verifier_table_non_vide(); |
|
| 1648 | 1648 | } |
| 1649 | 1649 | |
| 1650 | 1650 | |
@@ -1665,7 +1665,7 @@ discard block |
||
| 1665 | 1665 | * @return bool true s'il a le droit, false sinon |
| 1666 | 1666 | **/ |
| 1667 | 1667 | function autoriser_auteurcreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1668 | - return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1668 | + return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1669 | 1669 | } |
| 1670 | 1670 | |
| 1671 | 1671 | /** |
@@ -1683,13 +1683,13 @@ discard block |
||
| 1683 | 1683 | * @return bool true s'il a le droit, false sinon |
| 1684 | 1684 | **/ |
| 1685 | 1685 | function autoriser_visiteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1686 | - include_spip('base/abstract_sql'); |
|
| 1687 | - return |
|
| 1688 | - $qui['statut'] === '0minirezo' and !$qui['restreint'] |
|
| 1689 | - and ( |
|
| 1690 | - $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1691 | - or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1692 | - ); |
|
| 1686 | + include_spip('base/abstract_sql'); |
|
| 1687 | + return |
|
| 1688 | + $qui['statut'] === '0minirezo' and !$qui['restreint'] |
|
| 1689 | + and ( |
|
| 1690 | + $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1691 | + or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1692 | + ); |
|
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | 1695 | /** |
@@ -1707,7 +1707,7 @@ discard block |
||
| 1707 | 1707 | * @return bool true s'il a le droit, false sinon |
| 1708 | 1708 | **/ |
| 1709 | 1709 | function autoriser_suiviedito_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1710 | - return $qui['statut'] === '0minirezo'; |
|
| 1710 | + return $qui['statut'] === '0minirezo'; |
|
| 1711 | 1711 | } |
| 1712 | 1712 | |
| 1713 | 1713 | /** |
@@ -1725,7 +1725,7 @@ discard block |
||
| 1725 | 1725 | * @return bool true s'il a le droit, false sinon |
| 1726 | 1726 | **/ |
| 1727 | 1727 | function autoriser_synchro_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1728 | - return $qui['statut'] === '0minirezo'; |
|
| 1728 | + return $qui['statut'] === '0minirezo'; |
|
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | 1731 | /** |
@@ -1743,7 +1743,7 @@ discard block |
||
| 1743 | 1743 | * @return bool true s'il a le droit, false sinon |
| 1744 | 1744 | **/ |
| 1745 | 1745 | function autoriser_configurerinteractions_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1746 | - return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1746 | + return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1747 | 1747 | } |
| 1748 | 1748 | |
| 1749 | 1749 | /** |
@@ -1761,7 +1761,7 @@ discard block |
||
| 1761 | 1761 | * @return bool true s'il a le droit, false sinon |
| 1762 | 1762 | **/ |
| 1763 | 1763 | function autoriser_configurerlangue_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1764 | - return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1764 | + return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1765 | 1765 | } |
| 1766 | 1766 | |
| 1767 | 1767 | /** |
@@ -1779,7 +1779,7 @@ discard block |
||
| 1779 | 1779 | * @return bool true s'il a le droit, false sinon |
| 1780 | 1780 | **/ |
| 1781 | 1781 | function autoriser_configurermultilinguisme_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1782 | - return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1782 | + return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1783 | 1783 | } |
| 1784 | 1784 | |
| 1785 | 1785 | /** |
@@ -1797,7 +1797,7 @@ discard block |
||
| 1797 | 1797 | * @return bool true s'il a le droit, false sinon |
| 1798 | 1798 | **/ |
| 1799 | 1799 | function autoriser_configurercontenu_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1800 | - return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1800 | + return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1801 | 1801 | } |
| 1802 | 1802 | |
| 1803 | 1803 | /** |
@@ -1815,7 +1815,7 @@ discard block |
||
| 1815 | 1815 | * @return bool true s'il a le droit, false sinon |
| 1816 | 1816 | **/ |
| 1817 | 1817 | function autoriser_configureravancees_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1818 | - return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1818 | + return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1819 | 1819 | } |
| 1820 | 1820 | |
| 1821 | 1821 | /** |
@@ -1833,7 +1833,7 @@ discard block |
||
| 1833 | 1833 | * @return bool true s'il a le droit, false sinon |
| 1834 | 1834 | **/ |
| 1835 | 1835 | function autoriser_adminplugin_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1836 | - return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1836 | + return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1837 | 1837 | } |
| 1838 | 1838 | |
| 1839 | 1839 | /** |
@@ -1851,7 +1851,7 @@ discard block |
||
| 1851 | 1851 | * @return bool true s'il a le droit, false sinon |
| 1852 | 1852 | **/ |
| 1853 | 1853 | function autoriser_admintech_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1854 | - return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1854 | + return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | 1857 | /** |
@@ -1869,7 +1869,7 @@ discard block |
||
| 1869 | 1869 | * @return bool true s'il a le droit, false sinon |
| 1870 | 1870 | **/ |
| 1871 | 1871 | function autoriser_queue_purger_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1872 | - return autoriser('webmestre'); |
|
| 1872 | + return autoriser('webmestre'); |
|
| 1873 | 1873 | } |
| 1874 | 1874 | |
| 1875 | 1875 | |
@@ -1889,11 +1889,11 @@ discard block |
||
| 1889 | 1889 | * @return bool true s'il a le droit, false sinon |
| 1890 | 1890 | **/ |
| 1891 | 1891 | function autoriser_echafauder_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1892 | - if (test_espace_prive()) { |
|
| 1893 | - return intval($qui['id_auteur']) ? true : false; |
|
| 1894 | - } else { |
|
| 1895 | - return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1896 | - } |
|
| 1892 | + if (test_espace_prive()) { |
|
| 1893 | + return intval($qui['id_auteur']) ? true : false; |
|
| 1894 | + } else { |
|
| 1895 | + return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1896 | + } |
|
| 1897 | 1897 | } |
| 1898 | 1898 | |
| 1899 | 1899 | |
@@ -1908,27 +1908,27 @@ discard block |
||
| 1908 | 1908 | * Identifiants d'auteurs |
| 1909 | 1909 | */ |
| 1910 | 1910 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1911 | - $objet = objet_type($objet); |
|
| 1912 | - $where = [ |
|
| 1913 | - 'objet=' . sql_quote($objet), |
|
| 1914 | - 'id_objet=' . intval($id_objet) |
|
| 1915 | - ]; |
|
| 1916 | - if (!empty($cond)) { |
|
| 1917 | - if (is_array($cond)) { |
|
| 1918 | - $where = array_merge($where, $cond); |
|
| 1919 | - } else { |
|
| 1920 | - $where[] = $cond; |
|
| 1921 | - } |
|
| 1922 | - } |
|
| 1923 | - $auteurs = sql_allfetsel( |
|
| 1924 | - 'id_auteur', |
|
| 1925 | - 'spip_auteurs_liens', |
|
| 1926 | - $where |
|
| 1927 | - ); |
|
| 1928 | - if (is_array($auteurs)) { |
|
| 1929 | - return array_column($auteurs, 'id_auteur'); |
|
| 1930 | - } |
|
| 1931 | - return []; |
|
| 1911 | + $objet = objet_type($objet); |
|
| 1912 | + $where = [ |
|
| 1913 | + 'objet=' . sql_quote($objet), |
|
| 1914 | + 'id_objet=' . intval($id_objet) |
|
| 1915 | + ]; |
|
| 1916 | + if (!empty($cond)) { |
|
| 1917 | + if (is_array($cond)) { |
|
| 1918 | + $where = array_merge($where, $cond); |
|
| 1919 | + } else { |
|
| 1920 | + $where[] = $cond; |
|
| 1921 | + } |
|
| 1922 | + } |
|
| 1923 | + $auteurs = sql_allfetsel( |
|
| 1924 | + 'id_auteur', |
|
| 1925 | + 'spip_auteurs_liens', |
|
| 1926 | + $where |
|
| 1927 | + ); |
|
| 1928 | + if (is_array($auteurs)) { |
|
| 1929 | + return array_column($auteurs, 'id_auteur'); |
|
| 1930 | + } |
|
| 1931 | + return []; |
|
| 1932 | 1932 | } |
| 1933 | 1933 | |
| 1934 | 1934 | /** |
@@ -1943,11 +1943,11 @@ discard block |
||
| 1943 | 1943 | * - false : serveur SQL indisponible |
| 1944 | 1944 | */ |
| 1945 | 1945 | function auteurs_article($id_article, $cond = '') { |
| 1946 | - return sql_allfetsel( |
|
| 1947 | - 'id_auteur', |
|
| 1948 | - 'spip_auteurs_liens', |
|
| 1949 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1950 | - ); |
|
| 1946 | + return sql_allfetsel( |
|
| 1947 | + 'id_auteur', |
|
| 1948 | + 'spip_auteurs_liens', |
|
| 1949 | + "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1950 | + ); |
|
| 1951 | 1951 | } |
| 1952 | 1952 | |
| 1953 | 1953 | |
@@ -1961,7 +1961,7 @@ discard block |
||
| 1961 | 1961 | */ |
| 1962 | 1962 | function acces_restreint_rubrique($id_rubrique) { |
| 1963 | 1963 | |
| 1964 | - return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1964 | + return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1965 | 1965 | } |
| 1966 | 1966 | |
| 1967 | 1967 | |
@@ -1974,12 +1974,12 @@ discard block |
||
| 1974 | 1974 | * @return bool true si un parent existe |
| 1975 | 1975 | */ |
| 1976 | 1976 | function verifier_table_non_vide($table = 'spip_rubriques') { |
| 1977 | - static $done = []; |
|
| 1978 | - if (!isset($done[$table])) { |
|
| 1979 | - $done[$table] = sql_countsel($table) > 0; |
|
| 1980 | - } |
|
| 1977 | + static $done = []; |
|
| 1978 | + if (!isset($done[$table])) { |
|
| 1979 | + $done[$table] = sql_countsel($table) > 0; |
|
| 1980 | + } |
|
| 1981 | 1981 | |
| 1982 | - return $done[$table]; |
|
| 1982 | + return $done[$table]; |
|
| 1983 | 1983 | } |
| 1984 | 1984 | |
| 1985 | 1985 | /** |
@@ -2006,15 +2006,15 @@ discard block |
||
| 2006 | 2006 | */ |
| 2007 | 2007 | function autoriser_inscrireauteur_dist($faire, $quoi, $id, $qui, $opt) { |
| 2008 | 2008 | |
| 2009 | - $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 2010 | - switch ($s) { |
|
| 2011 | - case 'info_redacteurs': |
|
| 2012 | - return ($GLOBALS['meta']['accepter_inscriptions'] === 'oui'); |
|
| 2013 | - case 'info_visiteurs': |
|
| 2014 | - return ($GLOBALS['meta']['accepter_visiteurs'] === 'oui' or $GLOBALS['meta']['forums_publics'] === 'abo'); |
|
| 2015 | - } |
|
| 2009 | + $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 2010 | + switch ($s) { |
|
| 2011 | + case 'info_redacteurs': |
|
| 2012 | + return ($GLOBALS['meta']['accepter_inscriptions'] === 'oui'); |
|
| 2013 | + case 'info_visiteurs': |
|
| 2014 | + return ($GLOBALS['meta']['accepter_visiteurs'] === 'oui' or $GLOBALS['meta']['forums_publics'] === 'abo'); |
|
| 2015 | + } |
|
| 2016 | 2016 | |
| 2017 | - return false; |
|
| 2017 | + return false; |
|
| 2018 | 2018 | } |
| 2019 | 2019 | |
| 2020 | 2020 | /** |
@@ -2032,7 +2032,7 @@ discard block |
||
| 2032 | 2032 | * @return bool true s'il a le droit, false sinon |
| 2033 | 2033 | **/ |
| 2034 | 2034 | function autoriser_inscription_relancer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 2035 | - return $qui['statut'] === '0minirezo' and !$qui['restreint']; |
|
| 2035 | + return $qui['statut'] === '0minirezo' and !$qui['restreint']; |
|
| 2036 | 2036 | } |
| 2037 | 2037 | |
| 2038 | 2038 | /** |
@@ -2050,5 +2050,5 @@ discard block |
||
| 2050 | 2050 | * @return bool true s'il a le droit, false sinon |
| 2051 | 2051 | **/ |
| 2052 | 2052 | function autoriser_phpinfos_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 2053 | - return autoriser('webmestre'); |
|
| 2053 | + return autoriser('webmestre'); |
|
| 2054 | 2054 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | // mais apres la fonction autoriser() |
| 123 | 123 | if ($f = find_in_path('mes_fonctions.php')) { |
| 124 | 124 | global $dossier_squelettes; |
| 125 | - include_once(_ROOT_CWD . $f); |
|
| 125 | + include_once(_ROOT_CWD.$f); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $qui = $GLOBALS['visiteur_session'] ?: []; |
| 165 | 165 | $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
| 166 | 166 | } elseif (is_numeric($qui)) { |
| 167 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 167 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.$qui); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // Admins restreints, on construit ici (pas generique mais...) |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | spip_log( |
| 177 | - "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?', |
|
| 178 | - 'autoriser' . _LOG_DEBUG |
|
| 177 | + "autoriser $faire $type $id (".($qui['nom'] ?? '').') ?', |
|
| 178 | + 'autoriser'._LOG_DEBUG |
|
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | 181 | // passer par objet_type pour avoir les alias |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
| 192 | 192 | or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
| 193 | 193 | ) { |
| 194 | - spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 194 | + spip_log("autoriser ($faire, $type, $id, ".($qui['nom'] ?? '').') : OK Exception', 'autoriser'._LOG_DEBUG); |
|
| 195 | 195 | return true; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -200,18 +200,18 @@ discard block |
||
| 200 | 200 | // autoriser_faire[_dist], autoriser_defaut[_dist] |
| 201 | 201 | $fonctions = $type |
| 202 | 202 | ? [ |
| 203 | - 'autoriser_' . $type . '_' . $faire, |
|
| 204 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 205 | - 'autoriser_' . $type, |
|
| 206 | - 'autoriser_' . $type . '_dist', |
|
| 207 | - 'autoriser_' . $faire, |
|
| 208 | - 'autoriser_' . $faire . '_dist', |
|
| 203 | + 'autoriser_'.$type.'_'.$faire, |
|
| 204 | + 'autoriser_'.$type.'_'.$faire.'_dist', |
|
| 205 | + 'autoriser_'.$type, |
|
| 206 | + 'autoriser_'.$type.'_dist', |
|
| 207 | + 'autoriser_'.$faire, |
|
| 208 | + 'autoriser_'.$faire.'_dist', |
|
| 209 | 209 | 'autoriser_defaut', |
| 210 | 210 | 'autoriser_defaut_dist' |
| 211 | 211 | ] |
| 212 | 212 | : [ |
| 213 | - 'autoriser_' . $faire, |
|
| 214 | - 'autoriser_' . $faire . '_dist', |
|
| 213 | + 'autoriser_'.$faire, |
|
| 214 | + 'autoriser_'.$faire.'_dist', |
|
| 215 | 215 | 'autoriser_defaut', |
| 216 | 216 | 'autoriser_defaut_dist' |
| 217 | 217 | ]; |
@@ -224,8 +224,8 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | spip_log( |
| 227 | - "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 228 | - 'autoriser' . _LOG_DEBUG |
|
| 227 | + "$f($faire, $type, $id, ".($qui['nom'] ?? '').') : '.($a ? 'OK' : 'niet'), |
|
| 228 | + 'autoriser'._LOG_DEBUG |
|
| 229 | 229 | ); |
| 230 | 230 | |
| 231 | 231 | return $a; |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | function autoriser_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 375 | 375 | |
| 376 | 376 | // Le visiteur a-t-il un statut prevu par la config ? |
| 377 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 377 | + if (strpos($GLOBALS['meta']['preview'], ','.$qui['statut'].',') !== false) { |
|
| 378 | 378 | return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
| 379 | 379 | } |
| 380 | 380 | |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | } // pas de champ passe a la demande => NIET |
| 433 | 433 | $previsu = explode(',', $c['previsu']); |
| 434 | 434 | // regarder si ce statut est autorise pour l'auteur |
| 435 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 435 | + if (in_array($opt[$champ].'/auteur', $previsu)) { |
|
| 436 | 436 | // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
| 437 | 437 | // sinon l’auteur en session |
| 438 | 438 | include_spip('inc/securiser_action'); |
@@ -446,12 +446,12 @@ discard block |
||
| 446 | 446 | |
| 447 | 447 | if (!$id_auteur) { |
| 448 | 448 | return false; |
| 449 | - } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 449 | + } elseif (autoriser('previsualiser'.$opt[$champ], $type, 0, $id_auteur)) { |
|
| 450 | 450 | // dans ce cas (admin en general), pas de filtrage sur ce statut |
| 451 | 451 | } elseif ( |
| 452 | 452 | !sql_countsel( |
| 453 | 453 | 'spip_auteurs_liens', |
| 454 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 454 | + 'id_auteur='.intval($id_auteur).' AND objet='.sql_quote($type).' AND id_objet='.intval($id) |
|
| 455 | 455 | ) |
| 456 | 456 | ) { |
| 457 | 457 | return false; |
@@ -496,16 +496,16 @@ discard block |
||
| 496 | 496 | // multilinguisme par secteur et objet rattaché à une rubrique |
| 497 | 497 | $primary = id_table_objet($type); |
| 498 | 498 | if ($table != 'spip_rubriques') { |
| 499 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 499 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=".intval($id)); |
|
| 500 | 500 | } else { |
| 501 | 501 | $id_rubrique = $id; |
| 502 | 502 | } |
| 503 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 503 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 504 | 504 | if (!$id_secteur > 0) { |
| 505 | 505 | $id_secteur = $id_rubrique; |
| 506 | 506 | } |
| 507 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 508 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 507 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_secteur)); |
|
| 508 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=".intval($id)); |
|
| 509 | 509 | if ($langue_secteur != $langue_objet) { |
| 510 | 510 | // configuration incohérente, on laisse l'utilisateur corriger la situation |
| 511 | 511 | return true; |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
| 514 | 514 | return false; |
| 515 | 515 | } else { |
| 516 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 516 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique='.intval($id)); |
|
| 517 | 517 | if ($id_parent != 0) { |
| 518 | 518 | // sous-rubriques : pas de choix de langue |
| 519 | 519 | return false; |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | if (!isset($opt['statut'])) { |
| 567 | 567 | if (isset($desc['field']['statut'])) { |
| 568 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 568 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type).'='.intval($id)); |
|
| 569 | 569 | } else { |
| 570 | 570 | $statut = 'publie'; |
| 571 | 571 | } // pas de statut => publie |
@@ -739,11 +739,11 @@ discard block |
||
| 739 | 739 | return false; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 742 | + if (sql_countsel('spip_rubriques', 'id_parent='.intval($id))) { |
|
| 743 | 743 | return false; |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 746 | + if (sql_countsel('spip_articles', 'id_rubrique='.intval($id)." AND (statut<>'poubelle')")) { |
|
| 747 | 747 | return false; |
| 748 | 748 | } |
| 749 | 749 | |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | if (!$id) { |
| 781 | 781 | return false; |
| 782 | 782 | } |
| 783 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 783 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article='.sql_quote($id)); |
|
| 784 | 784 | |
| 785 | 785 | return |
| 786 | 786 | $r |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | (!isset($opt['statut']) or $opt['statut'] !== 'publie') |
| 792 | 792 | and in_array($qui['statut'], ['0minirezo', '1comite']) |
| 793 | 793 | and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
| 794 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 794 | + and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur']) |
|
| 795 | 795 | ) |
| 796 | 796 | ); |
| 797 | 797 | } |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | if (!$id) { |
| 850 | 850 | return false; |
| 851 | 851 | } |
| 852 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 852 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article='.intval($id)); |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | return |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | or |
| 861 | 861 | ($id |
| 862 | 862 | and $qui['id_auteur'] |
| 863 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 863 | + and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur'])); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | |
@@ -881,8 +881,8 @@ discard block |
||
| 881 | 881 | function autoriser_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 882 | 882 | # securite, mais on aurait pas du arriver ici ! |
| 883 | 883 | if ( |
| 884 | - function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 885 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 884 | + function_exists($f = 'autoriser_'.$type.'_voir') |
|
| 885 | + or function_exists($f = 'autoriser_'.$type.'_voir_dist') |
|
| 886 | 886 | ) { |
| 887 | 887 | return $f($faire, $type, $id, $qui, $opt); |
| 888 | 888 | } |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | $n = sql_fetsel( |
| 1014 | 1014 | 'A.id_article', |
| 1015 | 1015 | 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
| 1016 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1016 | + "A.statut='publie' AND L.id_auteur=".sql_quote($id) |
|
| 1017 | 1017 | ); |
| 1018 | 1018 | |
| 1019 | 1019 | return $n ? true : false; |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | and $r = sql_allfetsel( |
| 1226 | 1226 | 'id_objet', |
| 1227 | 1227 | 'spip_auteurs_liens', |
| 1228 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1228 | + 'id_auteur='.intval($id_auteur)." AND objet='rubrique' AND id_objet!=0" |
|
| 1229 | 1229 | ) |
| 1230 | 1230 | and is_countable($r) ? count($r) : 0 |
| 1231 | 1231 | ) { |
@@ -1910,8 +1910,8 @@ discard block |
||
| 1910 | 1910 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1911 | 1911 | $objet = objet_type($objet); |
| 1912 | 1912 | $where = [ |
| 1913 | - 'objet=' . sql_quote($objet), |
|
| 1914 | - 'id_objet=' . intval($id_objet) |
|
| 1913 | + 'objet='.sql_quote($objet), |
|
| 1914 | + 'id_objet='.intval($id_objet) |
|
| 1915 | 1915 | ]; |
| 1916 | 1916 | if (!empty($cond)) { |
| 1917 | 1917 | if (is_array($cond)) { |
@@ -1946,7 +1946,7 @@ discard block |
||
| 1946 | 1946 | return sql_allfetsel( |
| 1947 | 1947 | 'id_auteur', |
| 1948 | 1948 | 'spip_auteurs_liens', |
| 1949 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1949 | + "objet='article' AND id_objet=".intval($id_article).($cond ? " AND $cond" : '') |
|
| 1950 | 1950 | ); |
| 1951 | 1951 | } |
| 1952 | 1952 | |
@@ -267,8 +267,7 @@ discard block |
||
| 267 | 267 | if ($id === '*') { |
| 268 | 268 | unset($GLOBALS['autoriser_exception'][$faire][$type]); |
| 269 | 269 | unset($autorisation[$faire][$type]); |
| 270 | - } |
|
| 271 | - else { |
|
| 270 | + } else { |
|
| 272 | 271 | unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
| 273 | 272 | unset($autorisation[$faire][$type][$id]); |
| 274 | 273 | } |
@@ -652,8 +651,7 @@ discard block |
||
| 652 | 651 | function autoriser_rubrique_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 653 | 652 | if (!empty($opt['id_parent'])) { |
| 654 | 653 | return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
| 655 | - } |
|
| 656 | - else { |
|
| 654 | + } else { |
|
| 657 | 655 | return autoriser('defaut', null, 0, $qui, $opt); |
| 658 | 656 | } |
| 659 | 657 | } |
@@ -814,8 +812,7 @@ discard block |
||
| 814 | 812 | if (!empty($opt['id_parent'])) { |
| 815 | 813 | // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
| 816 | 814 | return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
| 817 | - } |
|
| 818 | - else { |
|
| 815 | + } else { |
|
| 819 | 816 | return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
| 820 | 817 | } |
| 821 | 818 | } |