@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Autorisations |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -38,89 +38,89 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | if (!function_exists('autoriser')) { |
| 41 | - /** |
|
| 42 | - * Autoriser une action |
|
| 43 | - * |
|
| 44 | - * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 45 | - * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 46 | - * les autorisations. |
|
| 47 | - * |
|
| 48 | - * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 49 | - * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 50 | - * dans cet ordre : |
|
| 51 | - * |
|
| 52 | - * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 53 | - * - autoriser_{type}, sinon avec _dist |
|
| 54 | - * - autoriser_{faire}, sinon avec _dist |
|
| 55 | - * - autoriser_{defaut}, sinon avec _dist |
|
| 56 | - * |
|
| 57 | - * Seul le premier argument est obligatoire. |
|
| 58 | - * |
|
| 59 | - * @note |
|
| 60 | - * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 61 | - * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 62 | - * cette valeur. |
|
| 63 | - * |
|
| 64 | - * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 65 | - * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 66 | - * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 67 | - * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 68 | - * |
|
| 69 | - * @note |
|
| 70 | - * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 71 | - * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 72 | - * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 73 | - * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 74 | - * quel serait le type, quel serait l'action ? |
|
| 75 | - * |
|
| 76 | - * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 77 | - * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 78 | - * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 79 | - * |
|
| 80 | - * @api |
|
| 81 | - * @see autoriser_dist() |
|
| 82 | - * @see objet_type() |
|
| 83 | - * |
|
| 84 | - * @param string $faire |
|
| 85 | - * une action ('modifier', 'publier'...) |
|
| 86 | - * @param string|null $type |
|
| 87 | - * Type d’objet ou élément sur lequel appliquer l’action. |
|
| 88 | - * - null: indifférent à tout type d’élément ou objet éditorial |
|
| 89 | - * - string: objet éditorial (objet_type() est appliqué pour homogénéiser l’entrée) |
|
| 90 | - * - _string: autre élément (avec un souligné en premier caractère, désactive objet_type()). |
|
| 91 | - * Les soulignés seront retirés (cf. la note). |
|
| 92 | - * @param string|int|null $id |
|
| 93 | - * id de l'objet ou élément sur lequel on veut agir, si pertinent. |
|
| 94 | - * - null: non utile pour l’autorisation |
|
| 95 | - * - int: identifiant numérique (cas de tous les objets éditoriaux de SPIP) |
|
| 96 | - * - string: identifiant textuel |
|
| 97 | - * @param null|int|array $qui |
|
| 98 | - * - si null on prend alors visiteur_session |
|
| 99 | - * - un id_auteur (on regarde dans la base) |
|
| 100 | - * - un tableau auteur complet, y compris [restreint] |
|
| 101 | - * @param array $opt |
|
| 102 | - * options sous forme de tableau associatif |
|
| 103 | - * @return bool |
|
| 104 | - * true si la personne peut effectuer l'action |
|
| 105 | - */ |
|
| 106 | - function autoriser(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
|
| 107 | - // Charger les fonctions d'autorisation supplementaires |
|
| 108 | - static $pipe; |
|
| 109 | - if (!isset($pipe)) { |
|
| 110 | - $pipe = 1; |
|
| 111 | - pipeline('autoriser'); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return autoriser_dist($faire, $type, $id, $qui, $opt); |
|
| 115 | - } |
|
| 41 | + /** |
|
| 42 | + * Autoriser une action |
|
| 43 | + * |
|
| 44 | + * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 45 | + * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 46 | + * les autorisations. |
|
| 47 | + * |
|
| 48 | + * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 49 | + * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 50 | + * dans cet ordre : |
|
| 51 | + * |
|
| 52 | + * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 53 | + * - autoriser_{type}, sinon avec _dist |
|
| 54 | + * - autoriser_{faire}, sinon avec _dist |
|
| 55 | + * - autoriser_{defaut}, sinon avec _dist |
|
| 56 | + * |
|
| 57 | + * Seul le premier argument est obligatoire. |
|
| 58 | + * |
|
| 59 | + * @note |
|
| 60 | + * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 61 | + * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 62 | + * cette valeur. |
|
| 63 | + * |
|
| 64 | + * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 65 | + * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 66 | + * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 67 | + * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 68 | + * |
|
| 69 | + * @note |
|
| 70 | + * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 71 | + * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 72 | + * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 73 | + * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 74 | + * quel serait le type, quel serait l'action ? |
|
| 75 | + * |
|
| 76 | + * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 77 | + * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 78 | + * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 79 | + * |
|
| 80 | + * @api |
|
| 81 | + * @see autoriser_dist() |
|
| 82 | + * @see objet_type() |
|
| 83 | + * |
|
| 84 | + * @param string $faire |
|
| 85 | + * une action ('modifier', 'publier'...) |
|
| 86 | + * @param string|null $type |
|
| 87 | + * Type d’objet ou élément sur lequel appliquer l’action. |
|
| 88 | + * - null: indifférent à tout type d’élément ou objet éditorial |
|
| 89 | + * - string: objet éditorial (objet_type() est appliqué pour homogénéiser l’entrée) |
|
| 90 | + * - _string: autre élément (avec un souligné en premier caractère, désactive objet_type()). |
|
| 91 | + * Les soulignés seront retirés (cf. la note). |
|
| 92 | + * @param string|int|null $id |
|
| 93 | + * id de l'objet ou élément sur lequel on veut agir, si pertinent. |
|
| 94 | + * - null: non utile pour l’autorisation |
|
| 95 | + * - int: identifiant numérique (cas de tous les objets éditoriaux de SPIP) |
|
| 96 | + * - string: identifiant textuel |
|
| 97 | + * @param null|int|array $qui |
|
| 98 | + * - si null on prend alors visiteur_session |
|
| 99 | + * - un id_auteur (on regarde dans la base) |
|
| 100 | + * - un tableau auteur complet, y compris [restreint] |
|
| 101 | + * @param array $opt |
|
| 102 | + * options sous forme de tableau associatif |
|
| 103 | + * @return bool |
|
| 104 | + * true si la personne peut effectuer l'action |
|
| 105 | + */ |
|
| 106 | + function autoriser(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
|
| 107 | + // Charger les fonctions d'autorisation supplementaires |
|
| 108 | + static $pipe; |
|
| 109 | + if (!isset($pipe)) { |
|
| 110 | + $pipe = 1; |
|
| 111 | + pipeline('autoriser'); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return autoriser_dist($faire, $type, $id, $qui, $opt); |
|
| 115 | + } |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | // mes_fonctions peut aussi declarer des autorisations, il faut donc le charger |
| 120 | 120 | // mais apres la fonction autoriser() |
| 121 | 121 | if ($f = find_in_path('mes_fonctions.php')) { |
| 122 | - global $dossier_squelettes; |
|
| 123 | - include_once(_ROOT_CWD . $f); |
|
| 122 | + global $dossier_squelettes; |
|
| 123 | + include_once(_ROOT_CWD . $f); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -151,85 +151,85 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | function autoriser_dist(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
| 153 | 153 | |
| 154 | - if ($type === null) { |
|
| 155 | - $type = ''; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - // Qui ? visiteur_session ? |
|
| 159 | - // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 160 | - if ($qui === null or $qui === '') { |
|
| 161 | - $qui = $GLOBALS['visiteur_session'] ?: []; |
|
| 162 | - $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 163 | - } elseif (is_numeric($qui)) { |
|
| 164 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 165 | - if (!$qui) { |
|
| 166 | - return false; |
|
| 167 | - } |
|
| 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 | - $a = false; |
|
| 220 | - foreach ($fonctions as $f) { |
|
| 221 | - if (function_exists($f)) { |
|
| 222 | - $a = $f($faire, $type, $id, $qui, $opt); |
|
| 223 | - break; |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - spip_log( |
|
| 228 | - "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 229 | - 'autoriser' . _LOG_DEBUG |
|
| 230 | - ); |
|
| 231 | - |
|
| 232 | - return $a; |
|
| 154 | + if ($type === null) { |
|
| 155 | + $type = ''; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + // Qui ? visiteur_session ? |
|
| 159 | + // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 160 | + if ($qui === null or $qui === '') { |
|
| 161 | + $qui = $GLOBALS['visiteur_session'] ?: []; |
|
| 162 | + $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 163 | + } elseif (is_numeric($qui)) { |
|
| 164 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 165 | + if (!$qui) { |
|
| 166 | + return false; |
|
| 167 | + } |
|
| 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 | + $a = false; |
|
| 220 | + foreach ($fonctions as $f) { |
|
| 221 | + if (function_exists($f)) { |
|
| 222 | + $a = $f($faire, $type, $id, $qui, $opt); |
|
| 223 | + break; |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + spip_log( |
|
| 228 | + "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 229 | + 'autoriser' . _LOG_DEBUG |
|
| 230 | + ); |
|
| 231 | + |
|
| 232 | + return $a; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | // une globale pour aller au plus vite dans la fonction generique ci dessus |
@@ -249,33 +249,33 @@ discard block |
||
| 249 | 249 | * @return bool |
| 250 | 250 | */ |
| 251 | 251 | function autoriser_exception(string $faire, ?string $type = '', $id = null, $autoriser = true): bool { |
| 252 | - // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 253 | - static $autorisation; |
|
| 254 | - // Tolérance avec certains appels |
|
| 255 | - if ($type === null) { |
|
| 256 | - $type = ''; |
|
| 257 | - } |
|
| 258 | - if ($id === null) { |
|
| 259 | - $id = 0; |
|
| 260 | - } |
|
| 261 | - if ($autoriser === 'verifier') { |
|
| 262 | - return isset($autorisation[$faire][$type][$id]); |
|
| 263 | - } |
|
| 264 | - if ($autoriser === true) { |
|
| 265 | - $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 266 | - } |
|
| 267 | - if ($autoriser === false) { |
|
| 268 | - if ($id === '*') { |
|
| 269 | - unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 270 | - unset($autorisation[$faire][$type]); |
|
| 271 | - } |
|
| 272 | - else { |
|
| 273 | - unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 274 | - unset($autorisation[$faire][$type][$id]); |
|
| 275 | - } |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - return false; |
|
| 252 | + // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 253 | + static $autorisation; |
|
| 254 | + // Tolérance avec certains appels |
|
| 255 | + if ($type === null) { |
|
| 256 | + $type = ''; |
|
| 257 | + } |
|
| 258 | + if ($id === null) { |
|
| 259 | + $id = 0; |
|
| 260 | + } |
|
| 261 | + if ($autoriser === 'verifier') { |
|
| 262 | + return isset($autorisation[$faire][$type][$id]); |
|
| 263 | + } |
|
| 264 | + if ($autoriser === true) { |
|
| 265 | + $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 266 | + } |
|
| 267 | + if ($autoriser === false) { |
|
| 268 | + if ($id === '*') { |
|
| 269 | + unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 270 | + unset($autorisation[$faire][$type]); |
|
| 271 | + } |
|
| 272 | + else { |
|
| 273 | + unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 274 | + unset($autorisation[$faire][$type][$id]); |
|
| 275 | + } |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + return false; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -294,9 +294,9 @@ discard block |
||
| 294 | 294 | * @return bool true s'il a le droit, false sinon |
| 295 | 295 | **/ |
| 296 | 296 | function autoriser_defaut_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 297 | - return |
|
| 298 | - $qui['statut'] === '0minirezo' |
|
| 299 | - and !$qui['restreint']; |
|
| 297 | + return |
|
| 298 | + $qui['statut'] === '0minirezo' |
|
| 299 | + and !$qui['restreint']; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | * @return bool true s'il a le droit, false sinon |
| 317 | 317 | */ |
| 318 | 318 | function autoriser_loger_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 319 | - if ($qui['statut'] === '5poubelle') { |
|
| 320 | - return false; |
|
| 321 | - } |
|
| 322 | - return true; |
|
| 319 | + if ($qui['statut'] === '5poubelle') { |
|
| 320 | + return false; |
|
| 321 | + } |
|
| 322 | + return true; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @return bool true s'il a le droit, false sinon |
| 336 | 336 | **/ |
| 337 | 337 | function autoriser_ecrire_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 338 | - return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 338 | + return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @return bool true s'il a le droit, false sinon |
| 355 | 355 | **/ |
| 356 | 356 | function autoriser_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 357 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 357 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -374,18 +374,18 @@ discard block |
||
| 374 | 374 | **/ |
| 375 | 375 | function autoriser_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 376 | 376 | |
| 377 | - // Le visiteur a-t-il un statut prevu par la config ? |
|
| 378 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 379 | - return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 380 | - } |
|
| 377 | + // Le visiteur a-t-il un statut prevu par la config ? |
|
| 378 | + if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 379 | + return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | - // A-t-on un token de prévisualisation valable ? |
|
| 383 | - include_spip('inc/securiser_action'); |
|
| 384 | - if (decrire_token_previsu()) { |
|
| 385 | - return true; |
|
| 386 | - } |
|
| 382 | + // A-t-on un token de prévisualisation valable ? |
|
| 383 | + include_spip('inc/securiser_action'); |
|
| 384 | + if (decrire_token_previsu()) { |
|
| 385 | + return true; |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - return false; |
|
| 388 | + return false; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
@@ -414,58 +414,58 @@ discard block |
||
| 414 | 414 | */ |
| 415 | 415 | function test_previsualiser_objet_champ(string $type = '', $id = null, array $qui = [], array $opt = []): bool { |
| 416 | 416 | |
| 417 | - // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 418 | - if (!$type) { |
|
| 419 | - return true; |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - include_spip('base/objets'); |
|
| 423 | - $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 424 | - if (isset($infos['statut'])) { |
|
| 425 | - foreach ($infos['statut'] as $c) { |
|
| 426 | - if (isset($c['publie'])) { |
|
| 427 | - if (!isset($c['previsu'])) { |
|
| 428 | - return false; |
|
| 429 | - } // pas de previsu definie => NIET |
|
| 430 | - $champ = $c['champ']; |
|
| 431 | - if (!isset($opt[$champ])) { |
|
| 432 | - return false; |
|
| 433 | - } // pas de champ passe a la demande => NIET |
|
| 434 | - $previsu = explode(',', $c['previsu']); |
|
| 435 | - // regarder si ce statut est autorise pour l'auteur |
|
| 436 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 437 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 438 | - // sinon l’auteur en session |
|
| 439 | - include_spip('inc/securiser_action'); |
|
| 440 | - if ($desc = decrire_token_previsu()) { |
|
| 441 | - $id_auteur = $desc['id_auteur']; |
|
| 442 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 443 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 444 | - } else { |
|
| 445 | - $id_auteur = null; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - if (!$id_auteur) { |
|
| 449 | - return false; |
|
| 450 | - } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 451 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 452 | - } elseif ( |
|
| 453 | - !sql_countsel( |
|
| 454 | - 'spip_auteurs_liens', |
|
| 455 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 456 | - ) |
|
| 457 | - ) { |
|
| 458 | - return false; |
|
| 459 | - } // pas auteur de cet objet => NIET |
|
| 460 | - } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 461 | - // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 462 | - return false; |
|
| 463 | - } |
|
| 464 | - } |
|
| 465 | - } |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - return true; |
|
| 417 | + // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 418 | + if (!$type) { |
|
| 419 | + return true; |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + include_spip('base/objets'); |
|
| 423 | + $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 424 | + if (isset($infos['statut'])) { |
|
| 425 | + foreach ($infos['statut'] as $c) { |
|
| 426 | + if (isset($c['publie'])) { |
|
| 427 | + if (!isset($c['previsu'])) { |
|
| 428 | + return false; |
|
| 429 | + } // pas de previsu definie => NIET |
|
| 430 | + $champ = $c['champ']; |
|
| 431 | + if (!isset($opt[$champ])) { |
|
| 432 | + return false; |
|
| 433 | + } // pas de champ passe a la demande => NIET |
|
| 434 | + $previsu = explode(',', $c['previsu']); |
|
| 435 | + // regarder si ce statut est autorise pour l'auteur |
|
| 436 | + if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 437 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 438 | + // sinon l’auteur en session |
|
| 439 | + include_spip('inc/securiser_action'); |
|
| 440 | + if ($desc = decrire_token_previsu()) { |
|
| 441 | + $id_auteur = $desc['id_auteur']; |
|
| 442 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 443 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 444 | + } else { |
|
| 445 | + $id_auteur = null; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + if (!$id_auteur) { |
|
| 449 | + return false; |
|
| 450 | + } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 451 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 452 | + } elseif ( |
|
| 453 | + !sql_countsel( |
|
| 454 | + 'spip_auteurs_liens', |
|
| 455 | + 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 456 | + ) |
|
| 457 | + ) { |
|
| 458 | + return false; |
|
| 459 | + } // pas auteur de cet objet => NIET |
|
| 460 | + } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 461 | + // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 462 | + return false; |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + return true; |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -481,51 +481,51 @@ discard block |
||
| 481 | 481 | * @return bool true s'il a le droit, false sinon |
| 482 | 482 | **/ |
| 483 | 483 | function autoriser_changerlangue_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 484 | - $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 485 | - $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 486 | - $table = table_objet_sql($type); |
|
| 487 | - if ( |
|
| 488 | - in_array($table, $multi_objets) |
|
| 489 | - or in_array($table, $gerer_trad_objets) |
|
| 490 | - ) { // affichage du formulaire si la configuration l'accepte |
|
| 491 | - $multi_secteurs = lire_config('multi_secteurs'); |
|
| 492 | - $champs = objet_info($type, 'field'); |
|
| 493 | - if ( |
|
| 494 | - $multi_secteurs === 'oui' |
|
| 495 | - and array_key_exists('id_rubrique', $champs) |
|
| 496 | - ) { |
|
| 497 | - // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 498 | - $primary = id_table_objet($type); |
|
| 499 | - if ($table != 'spip_rubriques') { |
|
| 500 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 501 | - } else { |
|
| 502 | - $id_rubrique = $id; |
|
| 503 | - } |
|
| 504 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 505 | - if (!$id_secteur > 0) { |
|
| 506 | - $id_secteur = $id_rubrique; |
|
| 507 | - } |
|
| 508 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 509 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 510 | - if ($langue_secteur != $langue_objet) { |
|
| 511 | - // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 512 | - return true; |
|
| 513 | - } |
|
| 514 | - if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 515 | - return false; |
|
| 516 | - } else { |
|
| 517 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 518 | - if ($id_parent != 0) { |
|
| 519 | - // sous-rubriques : pas de choix de langue |
|
| 520 | - return false; |
|
| 521 | - } |
|
| 522 | - } |
|
| 523 | - } |
|
| 524 | - } else { |
|
| 525 | - return false; |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 484 | + $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 485 | + $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 486 | + $table = table_objet_sql($type); |
|
| 487 | + if ( |
|
| 488 | + in_array($table, $multi_objets) |
|
| 489 | + or in_array($table, $gerer_trad_objets) |
|
| 490 | + ) { // affichage du formulaire si la configuration l'accepte |
|
| 491 | + $multi_secteurs = lire_config('multi_secteurs'); |
|
| 492 | + $champs = objet_info($type, 'field'); |
|
| 493 | + if ( |
|
| 494 | + $multi_secteurs === 'oui' |
|
| 495 | + and array_key_exists('id_rubrique', $champs) |
|
| 496 | + ) { |
|
| 497 | + // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 498 | + $primary = id_table_objet($type); |
|
| 499 | + if ($table != 'spip_rubriques') { |
|
| 500 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 501 | + } else { |
|
| 502 | + $id_rubrique = $id; |
|
| 503 | + } |
|
| 504 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 505 | + if (!$id_secteur > 0) { |
|
| 506 | + $id_secteur = $id_rubrique; |
|
| 507 | + } |
|
| 508 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 509 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 510 | + if ($langue_secteur != $langue_objet) { |
|
| 511 | + // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 512 | + return true; |
|
| 513 | + } |
|
| 514 | + if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 515 | + return false; |
|
| 516 | + } else { |
|
| 517 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 518 | + if ($id_parent != 0) { |
|
| 519 | + // sous-rubriques : pas de choix de langue |
|
| 520 | + return false; |
|
| 521 | + } |
|
| 522 | + } |
|
| 523 | + } |
|
| 524 | + } else { |
|
| 525 | + return false; |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | * @return bool true s'il a le droit, false sinon |
| 542 | 542 | **/ |
| 543 | 543 | function autoriser_changertraduction_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 544 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 544 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -557,41 +557,41 @@ discard block |
||
| 557 | 557 | * @return bool true s'il a le droit, false sinon |
| 558 | 558 | **/ |
| 559 | 559 | function autoriser_dater_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 560 | - $table = table_objet($type); |
|
| 561 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 562 | - $desc = $trouver_table($table); |
|
| 563 | - if (!$desc) { |
|
| 564 | - return false; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - if (!isset($opt['statut'])) { |
|
| 568 | - if (isset($desc['field']['statut'])) { |
|
| 569 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 570 | - } else { |
|
| 571 | - $statut = 'publie'; |
|
| 572 | - } // pas de statut => publie |
|
| 573 | - } else { |
|
| 574 | - $statut = $opt['statut']; |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - // Liste des statuts publiés pour cet objet |
|
| 578 | - if (isset($desc['statut'][0]['publie'])) { |
|
| 579 | - $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 580 | - } |
|
| 581 | - // Sinon en dur le statut "publie" |
|
| 582 | - else { |
|
| 583 | - $statuts_publies = ['publie']; |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - if ( |
|
| 587 | - in_array($statut, $statuts_publies) |
|
| 588 | - // Ou cas particulier géré en dur ici pour les articles |
|
| 589 | - or ($statut === 'prop' and $type === 'article' and $GLOBALS['meta']['post_dates'] === 'non') |
|
| 590 | - ) { |
|
| 591 | - return autoriser('modifier', $type, $id); |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - return false; |
|
| 560 | + $table = table_objet($type); |
|
| 561 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 562 | + $desc = $trouver_table($table); |
|
| 563 | + if (!$desc) { |
|
| 564 | + return false; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + if (!isset($opt['statut'])) { |
|
| 568 | + if (isset($desc['field']['statut'])) { |
|
| 569 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 570 | + } else { |
|
| 571 | + $statut = 'publie'; |
|
| 572 | + } // pas de statut => publie |
|
| 573 | + } else { |
|
| 574 | + $statut = $opt['statut']; |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + // Liste des statuts publiés pour cet objet |
|
| 578 | + if (isset($desc['statut'][0]['publie'])) { |
|
| 579 | + $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 580 | + } |
|
| 581 | + // Sinon en dur le statut "publie" |
|
| 582 | + else { |
|
| 583 | + $statuts_publies = ['publie']; |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + if ( |
|
| 587 | + in_array($statut, $statuts_publies) |
|
| 588 | + // Ou cas particulier géré en dur ici pour les articles |
|
| 589 | + or ($statut === 'prop' and $type === 'article' and $GLOBALS['meta']['post_dates'] === 'non') |
|
| 590 | + ) { |
|
| 591 | + return autoriser('modifier', $type, $id); |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + return false; |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | /** |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * @return bool true s'il a le droit, false sinon |
| 611 | 611 | **/ |
| 612 | 612 | function autoriser_instituer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 613 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 613 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | /** |
@@ -628,12 +628,12 @@ discard block |
||
| 628 | 628 | * @return bool true s'il a le droit, false sinon |
| 629 | 629 | **/ |
| 630 | 630 | function autoriser_rubrique_publierdans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 631 | - return |
|
| 632 | - ($qui['statut'] === '0minirezo') |
|
| 633 | - and ( |
|
| 634 | - !$qui['restreint'] or !$id |
|
| 635 | - or in_array($id, $qui['restreint']) |
|
| 636 | - ); |
|
| 631 | + return |
|
| 632 | + ($qui['statut'] === '0minirezo') |
|
| 633 | + and ( |
|
| 634 | + !$qui['restreint'] or !$id |
|
| 635 | + or in_array($id, $qui['restreint']) |
|
| 636 | + ); |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | /** |
@@ -651,12 +651,12 @@ discard block |
||
| 651 | 651 | * @return bool true s'il a le droit, false sinon |
| 652 | 652 | **/ |
| 653 | 653 | function autoriser_rubrique_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 654 | - if (!empty($opt['id_parent'])) { |
|
| 655 | - return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 656 | - } |
|
| 657 | - else { |
|
| 658 | - return autoriser('defaut', null, 0, $qui, $opt); |
|
| 659 | - } |
|
| 654 | + if (!empty($opt['id_parent'])) { |
|
| 655 | + return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 656 | + } |
|
| 657 | + else { |
|
| 658 | + return autoriser('defaut', null, 0, $qui, $opt); |
|
| 659 | + } |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | /** |
@@ -674,10 +674,10 @@ discard block |
||
| 674 | 674 | * @return bool true s'il a le droit, false sinon |
| 675 | 675 | **/ |
| 676 | 676 | function autoriser_rubrique_creerrubriquedans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 677 | - return |
|
| 678 | - ($id or ($qui['statut'] === '0minirezo' and !$qui['restreint'])) |
|
| 679 | - and autoriser('voir', 'rubrique', $id) |
|
| 680 | - and autoriser('publierdans', 'rubrique', $id); |
|
| 677 | + return |
|
| 678 | + ($id or ($qui['statut'] === '0minirezo' and !$qui['restreint'])) |
|
| 679 | + and autoriser('voir', 'rubrique', $id) |
|
| 680 | + and autoriser('publierdans', 'rubrique', $id); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -695,10 +695,10 @@ discard block |
||
| 695 | 695 | * @return bool true s'il a le droit, false sinon |
| 696 | 696 | **/ |
| 697 | 697 | function autoriser_rubrique_creerarticledans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 698 | - return |
|
| 699 | - $id |
|
| 700 | - and autoriser('voir', 'rubrique', $id) |
|
| 701 | - and autoriser('creer', 'article'); |
|
| 698 | + return |
|
| 699 | + $id |
|
| 700 | + and autoriser('voir', 'rubrique', $id) |
|
| 701 | + and autoriser('creer', 'article'); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | |
@@ -717,8 +717,8 @@ discard block |
||
| 717 | 717 | * @return bool true s'il a le droit, false sinon |
| 718 | 718 | **/ |
| 719 | 719 | function autoriser_rubrique_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 720 | - return |
|
| 721 | - autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 720 | + return |
|
| 721 | + autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | /** |
@@ -736,29 +736,29 @@ discard block |
||
| 736 | 736 | * @return bool true s'il a le droit, false sinon |
| 737 | 737 | **/ |
| 738 | 738 | function autoriser_rubrique_supprimer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 739 | - if (!$id = intval($id)) { |
|
| 740 | - return false; |
|
| 741 | - } |
|
| 739 | + if (!$id = intval($id)) { |
|
| 740 | + return false; |
|
| 741 | + } |
|
| 742 | 742 | |
| 743 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 744 | - return false; |
|
| 745 | - } |
|
| 743 | + if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 744 | + return false; |
|
| 745 | + } |
|
| 746 | 746 | |
| 747 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 748 | - return false; |
|
| 749 | - } |
|
| 747 | + if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 748 | + return false; |
|
| 749 | + } |
|
| 750 | 750 | |
| 751 | - $compte = pipeline( |
|
| 752 | - 'objet_compte_enfants', |
|
| 753 | - ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 754 | - ); |
|
| 755 | - foreach ($compte as $objet => $n) { |
|
| 756 | - if ($n) { |
|
| 757 | - return false; |
|
| 758 | - } |
|
| 759 | - } |
|
| 751 | + $compte = pipeline( |
|
| 752 | + 'objet_compte_enfants', |
|
| 753 | + ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 754 | + ); |
|
| 755 | + foreach ($compte as $objet => $n) { |
|
| 756 | + if ($n) { |
|
| 757 | + return false; |
|
| 758 | + } |
|
| 759 | + } |
|
| 760 | 760 | |
| 761 | - return autoriser('modifier', 'rubrique', $id); |
|
| 761 | + return autoriser('modifier', 'rubrique', $id); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | |
@@ -778,23 +778,23 @@ discard block |
||
| 778 | 778 | * @return bool true s'il a le droit, false sinon |
| 779 | 779 | **/ |
| 780 | 780 | function autoriser_article_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 781 | - if (!$id) { |
|
| 782 | - return false; |
|
| 783 | - } |
|
| 784 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 785 | - |
|
| 786 | - return |
|
| 787 | - $r |
|
| 788 | - and |
|
| 789 | - ( |
|
| 790 | - autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 791 | - or ( |
|
| 792 | - (!isset($opt['statut']) or !in_array($opt['statut'], ['publie', 'refuse'], true)) |
|
| 793 | - and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 794 | - and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 795 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 796 | - ) |
|
| 797 | - ); |
|
| 781 | + if (!$id) { |
|
| 782 | + return false; |
|
| 783 | + } |
|
| 784 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 785 | + |
|
| 786 | + return |
|
| 787 | + $r |
|
| 788 | + and |
|
| 789 | + ( |
|
| 790 | + autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 791 | + or ( |
|
| 792 | + (!isset($opt['statut']) or !in_array($opt['statut'], ['publie', 'refuse'], true)) |
|
| 793 | + and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 794 | + and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 795 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 796 | + ) |
|
| 797 | + ); |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | /** |
@@ -812,13 +812,13 @@ discard block |
||
| 812 | 812 | * @return bool true s'il a le droit, false sinon |
| 813 | 813 | **/ |
| 814 | 814 | function autoriser_article_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 815 | - if (!empty($opt['id_parent'])) { |
|
| 816 | - // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 817 | - return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 818 | - } |
|
| 819 | - else { |
|
| 820 | - return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 821 | - } |
|
| 815 | + if (!empty($opt['id_parent'])) { |
|
| 816 | + // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 817 | + return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 818 | + } |
|
| 819 | + else { |
|
| 820 | + return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 821 | + } |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
@@ -840,28 +840,28 @@ discard block |
||
| 840 | 840 | * @return bool true s'il a le droit, false sinon |
| 841 | 841 | */ |
| 842 | 842 | function autoriser_article_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 843 | - if ($qui['statut'] === '0minirezo') { |
|
| 844 | - return true; |
|
| 845 | - } |
|
| 846 | - // cas des articles : depend du statut de l'article et de l'auteur |
|
| 847 | - if (isset($opt['statut'])) { |
|
| 848 | - $statut = $opt['statut']; |
|
| 849 | - } else { |
|
| 850 | - if (!$id) { |
|
| 851 | - return false; |
|
| 852 | - } |
|
| 853 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 854 | - } |
|
| 855 | - |
|
| 856 | - return |
|
| 857 | - // si on est pas auteur de l'article, |
|
| 858 | - // seuls les propose et publies sont visibles |
|
| 859 | - in_array($statut, ['prop', 'publie']) |
|
| 860 | - // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 861 | - or |
|
| 862 | - ($id |
|
| 863 | - and $qui['id_auteur'] |
|
| 864 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 843 | + if ($qui['statut'] === '0minirezo') { |
|
| 844 | + return true; |
|
| 845 | + } |
|
| 846 | + // cas des articles : depend du statut de l'article et de l'auteur |
|
| 847 | + if (isset($opt['statut'])) { |
|
| 848 | + $statut = $opt['statut']; |
|
| 849 | + } else { |
|
| 850 | + if (!$id) { |
|
| 851 | + return false; |
|
| 852 | + } |
|
| 853 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + return |
|
| 857 | + // si on est pas auteur de l'article, |
|
| 858 | + // seuls les propose et publies sont visibles |
|
| 859 | + in_array($statut, ['prop', 'publie']) |
|
| 860 | + // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 861 | + or |
|
| 862 | + ($id |
|
| 863 | + and $qui['id_auteur'] |
|
| 864 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | |
@@ -880,24 +880,24 @@ discard block |
||
| 880 | 880 | * @return bool true s'il a le droit, false sinon |
| 881 | 881 | **/ |
| 882 | 882 | function autoriser_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 883 | - # securite, mais on aurait pas du arriver ici ! |
|
| 884 | - if ( |
|
| 885 | - function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 886 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 887 | - ) { |
|
| 888 | - return $f($faire, $type, $id, $qui, $opt); |
|
| 889 | - } |
|
| 883 | + # securite, mais on aurait pas du arriver ici ! |
|
| 884 | + if ( |
|
| 885 | + function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 886 | + or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 887 | + ) { |
|
| 888 | + return $f($faire, $type, $id, $qui, $opt); |
|
| 889 | + } |
|
| 890 | 890 | |
| 891 | - if ($qui['statut'] === '0minirezo') { |
|
| 892 | - return true; |
|
| 893 | - } |
|
| 894 | - // admins et redacteurs peuvent voir un auteur |
|
| 895 | - if ($type === 'auteur') { |
|
| 896 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 897 | - } |
|
| 898 | - // sinon par defaut tout est visible |
|
| 899 | - // sauf cas particuliers traites separemment (ie article) |
|
| 900 | - return true; |
|
| 891 | + if ($qui['statut'] === '0minirezo') { |
|
| 892 | + return true; |
|
| 893 | + } |
|
| 894 | + // admins et redacteurs peuvent voir un auteur |
|
| 895 | + if ($type === 'auteur') { |
|
| 896 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 897 | + } |
|
| 898 | + // sinon par defaut tout est visible |
|
| 899 | + // sauf cas particuliers traites separemment (ie article) |
|
| 900 | + return true; |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | |
@@ -920,12 +920,12 @@ discard block |
||
| 920 | 920 | * @return bool true s'il a le droit, false sinon |
| 921 | 921 | **/ |
| 922 | 922 | function autoriser_webmestre_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 923 | - return |
|
| 924 | - (defined('_ID_WEBMESTRES') ? |
|
| 925 | - in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 926 | - : $qui['webmestre'] === 'oui') |
|
| 927 | - and $qui['statut'] === '0minirezo' |
|
| 928 | - and !$qui['restreint']; |
|
| 923 | + return |
|
| 924 | + (defined('_ID_WEBMESTRES') ? |
|
| 925 | + in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 926 | + : $qui['webmestre'] === 'oui') |
|
| 927 | + and $qui['statut'] === '0minirezo' |
|
| 928 | + and !$qui['restreint']; |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | /** |
@@ -943,9 +943,9 @@ discard block |
||
| 943 | 943 | * @return bool true s'il a le droit, false sinon |
| 944 | 944 | **/ |
| 945 | 945 | function autoriser_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 946 | - return |
|
| 947 | - $qui['statut'] === '0minirezo' |
|
| 948 | - and !$qui['restreint']; |
|
| 946 | + return |
|
| 947 | + $qui['statut'] === '0minirezo' |
|
| 948 | + and !$qui['restreint']; |
|
| 949 | 949 | } |
| 950 | 950 | |
| 951 | 951 | /** |
@@ -963,8 +963,8 @@ discard block |
||
| 963 | 963 | * @return bool true s'il a le droit, false sinon |
| 964 | 964 | **/ |
| 965 | 965 | function autoriser_sauvegarder_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 966 | - return |
|
| 967 | - $qui['statut'] === '0minirezo'; |
|
| 966 | + return |
|
| 967 | + $qui['statut'] === '0minirezo'; |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | /** |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | * @return bool true s'il a le droit, false sinon |
| 983 | 983 | **/ |
| 984 | 984 | function autoriser_detruire_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 985 | - return autoriser('webmestre', null, 0, $qui, $opt); |
|
| 985 | + return autoriser('webmestre', null, 0, $qui, $opt); |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | /** |
@@ -1001,23 +1001,23 @@ discard block |
||
| 1001 | 1001 | * @return bool true s'il a le droit, false sinon |
| 1002 | 1002 | **/ |
| 1003 | 1003 | function autoriser_auteur_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1004 | - // les admins peuvent "previsualiser" une page auteur |
|
| 1005 | - if ( |
|
| 1006 | - $qui['statut'] === '0minirezo' |
|
| 1007 | - and !$qui['restreint'] |
|
| 1008 | - ) { |
|
| 1009 | - return true; |
|
| 1010 | - } elseif ($id === 0) { |
|
| 1011 | - return false; |
|
| 1012 | - } |
|
| 1013 | - // "Voir en ligne" si l'auteur a un article publie |
|
| 1014 | - $n = sql_fetsel( |
|
| 1015 | - 'A.id_article', |
|
| 1016 | - 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 1017 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1018 | - ); |
|
| 1004 | + // les admins peuvent "previsualiser" une page auteur |
|
| 1005 | + if ( |
|
| 1006 | + $qui['statut'] === '0minirezo' |
|
| 1007 | + and !$qui['restreint'] |
|
| 1008 | + ) { |
|
| 1009 | + return true; |
|
| 1010 | + } elseif ($id === 0) { |
|
| 1011 | + return false; |
|
| 1012 | + } |
|
| 1013 | + // "Voir en ligne" si l'auteur a un article publie |
|
| 1014 | + $n = sql_fetsel( |
|
| 1015 | + 'A.id_article', |
|
| 1016 | + 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 1017 | + "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1018 | + ); |
|
| 1019 | 1019 | |
| 1020 | - return $n ? true : false; |
|
| 1020 | + return $n ? true : false; |
|
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | * @return bool true s'il a le droit, false sinon |
| 1047 | 1047 | **/ |
| 1048 | 1048 | function autoriser_auteur_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1049 | - return ($qui['statut'] === '0minirezo'); |
|
| 1049 | + return ($qui['statut'] === '0minirezo'); |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | |
@@ -1067,75 +1067,75 @@ discard block |
||
| 1067 | 1067 | * @return bool true s'il a le droit, false sinon |
| 1068 | 1068 | **/ |
| 1069 | 1069 | function autoriser_auteur_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1070 | - $id = intval($id); |
|
| 1071 | - |
|
| 1072 | - // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 1073 | - // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 1074 | - if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 1075 | - if ( |
|
| 1076 | - $id == $qui['id_auteur'] |
|
| 1077 | - && empty($opt['statut']) |
|
| 1078 | - && empty($opt['webmestre']) |
|
| 1079 | - && empty($opt['restreintes']) |
|
| 1080 | - && empty($opt['login']) |
|
| 1081 | - ) { |
|
| 1082 | - return true; |
|
| 1083 | - } |
|
| 1084 | - return false; |
|
| 1085 | - } |
|
| 1086 | - |
|
| 1087 | - // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 1088 | - // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1089 | - if ($qui['restreint']) { |
|
| 1090 | - if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1091 | - return false; |
|
| 1092 | - } elseif ( |
|
| 1093 | - (isset($opt['statut']) and ($opt['statut'] === '0minirezo')) |
|
| 1094 | - or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1095 | - ) { |
|
| 1096 | - return false; |
|
| 1097 | - } else { |
|
| 1098 | - if ($id == $qui['id_auteur']) { |
|
| 1099 | - if (isset($opt['statut']) and $opt['statut']) { |
|
| 1100 | - return false; |
|
| 1101 | - } else { |
|
| 1102 | - return true; |
|
| 1103 | - } |
|
| 1104 | - } else { |
|
| 1105 | - if ($id_auteur = intval($id)) { |
|
| 1106 | - $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1107 | - if ($t and $t['statut'] != '0minirezo') { |
|
| 1108 | - return true; |
|
| 1109 | - } else { |
|
| 1110 | - return false; |
|
| 1111 | - } |
|
| 1112 | - } // id = 0 => creation |
|
| 1113 | - else { |
|
| 1114 | - return true; |
|
| 1115 | - } |
|
| 1116 | - } |
|
| 1117 | - } |
|
| 1118 | - } |
|
| 1119 | - |
|
| 1120 | - // Un admin complet fait ce qu'il veut |
|
| 1121 | - // sauf se degrader |
|
| 1122 | - if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1123 | - return false; |
|
| 1124 | - } elseif ( |
|
| 1125 | - isset($opt['webmestre']) |
|
| 1126 | - and $opt['webmestre'] |
|
| 1127 | - and (defined('_ID_WEBMESTRES') |
|
| 1128 | - or !autoriser('webmestre')) |
|
| 1129 | - ) { |
|
| 1130 | - // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1131 | - // ou si les webmestres sont fixes par constante (securite) |
|
| 1132 | - return false; |
|
| 1133 | - } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1134 | - elseif (intval($id) and !autoriser('webmestre') and autoriser('webmestre', '', 0, $id)) { |
|
| 1135 | - return false; |
|
| 1136 | - } else { |
|
| 1137 | - return true; |
|
| 1138 | - } |
|
| 1070 | + $id = intval($id); |
|
| 1071 | + |
|
| 1072 | + // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 1073 | + // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 1074 | + if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 1075 | + if ( |
|
| 1076 | + $id == $qui['id_auteur'] |
|
| 1077 | + && empty($opt['statut']) |
|
| 1078 | + && empty($opt['webmestre']) |
|
| 1079 | + && empty($opt['restreintes']) |
|
| 1080 | + && empty($opt['login']) |
|
| 1081 | + ) { |
|
| 1082 | + return true; |
|
| 1083 | + } |
|
| 1084 | + return false; |
|
| 1085 | + } |
|
| 1086 | + |
|
| 1087 | + // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 1088 | + // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1089 | + if ($qui['restreint']) { |
|
| 1090 | + if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1091 | + return false; |
|
| 1092 | + } elseif ( |
|
| 1093 | + (isset($opt['statut']) and ($opt['statut'] === '0minirezo')) |
|
| 1094 | + or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1095 | + ) { |
|
| 1096 | + return false; |
|
| 1097 | + } else { |
|
| 1098 | + if ($id == $qui['id_auteur']) { |
|
| 1099 | + if (isset($opt['statut']) and $opt['statut']) { |
|
| 1100 | + return false; |
|
| 1101 | + } else { |
|
| 1102 | + return true; |
|
| 1103 | + } |
|
| 1104 | + } else { |
|
| 1105 | + if ($id_auteur = intval($id)) { |
|
| 1106 | + $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1107 | + if ($t and $t['statut'] != '0minirezo') { |
|
| 1108 | + return true; |
|
| 1109 | + } else { |
|
| 1110 | + return false; |
|
| 1111 | + } |
|
| 1112 | + } // id = 0 => creation |
|
| 1113 | + else { |
|
| 1114 | + return true; |
|
| 1115 | + } |
|
| 1116 | + } |
|
| 1117 | + } |
|
| 1118 | + } |
|
| 1119 | + |
|
| 1120 | + // Un admin complet fait ce qu'il veut |
|
| 1121 | + // sauf se degrader |
|
| 1122 | + if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1123 | + return false; |
|
| 1124 | + } elseif ( |
|
| 1125 | + isset($opt['webmestre']) |
|
| 1126 | + and $opt['webmestre'] |
|
| 1127 | + and (defined('_ID_WEBMESTRES') |
|
| 1128 | + or !autoriser('webmestre')) |
|
| 1129 | + ) { |
|
| 1130 | + // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1131 | + // ou si les webmestres sont fixes par constante (securite) |
|
| 1132 | + return false; |
|
| 1133 | + } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1134 | + elseif (intval($id) and !autoriser('webmestre') and autoriser('webmestre', '', 0, $id)) { |
|
| 1135 | + return false; |
|
| 1136 | + } else { |
|
| 1137 | + return true; |
|
| 1138 | + } |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | |
@@ -1154,7 +1154,7 @@ discard block |
||
| 1154 | 1154 | * @return bool true s'il a le droit, false sinon |
| 1155 | 1155 | **/ |
| 1156 | 1156 | function autoriser_associerauteurs_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1157 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1157 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | |
@@ -1173,7 +1173,7 @@ discard block |
||
| 1173 | 1173 | * @return bool true s'il a le droit, false sinon |
| 1174 | 1174 | **/ |
| 1175 | 1175 | function autoriser_chargerftp_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1176 | - return $qui['statut'] === '0minirezo'; |
|
| 1176 | + return $qui['statut'] === '0minirezo'; |
|
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | /** |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | * @return bool true s'il a le droit, false sinon |
| 1192 | 1192 | **/ |
| 1193 | 1193 | function autoriser_debug_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1194 | - return $qui['statut'] === '0minirezo'; |
|
| 1194 | + return $qui['statut'] === '0minirezo'; |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | /** |
@@ -1208,54 +1208,54 @@ discard block |
||
| 1208 | 1208 | * @return array Liste des rubriques |
| 1209 | 1209 | **/ |
| 1210 | 1210 | function liste_rubriques_auteur($id_auteur, $raz = false) { |
| 1211 | - static $restreint = []; |
|
| 1212 | - |
|
| 1213 | - if (!$id_auteur = intval($id_auteur)) { |
|
| 1214 | - return []; |
|
| 1215 | - } |
|
| 1216 | - if ($raz) { |
|
| 1217 | - unset($restreint[$id_auteur]); |
|
| 1218 | - } elseif (isset($restreint[$id_auteur])) { |
|
| 1219 | - return $restreint[$id_auteur]; |
|
| 1220 | - } |
|
| 1221 | - |
|
| 1222 | - $rubriques = []; |
|
| 1223 | - if ( |
|
| 1224 | - (!isset($GLOBALS['meta']['version_installee']) |
|
| 1225 | - or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1226 | - and $r = sql_allfetsel( |
|
| 1227 | - 'id_objet', |
|
| 1228 | - 'spip_auteurs_liens', |
|
| 1229 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1230 | - ) |
|
| 1231 | - and is_countable($r) ? count($r) : 0 |
|
| 1232 | - ) { |
|
| 1233 | - $r = array_column($r, 'id_objet'); |
|
| 1234 | - |
|
| 1235 | - // recuperer toute la branche, au format chaine enumeration |
|
| 1236 | - include_spip('inc/rubriques'); |
|
| 1237 | - $r = calcul_branche_in($r); |
|
| 1238 | - $r = explode(',', $r); |
|
| 1239 | - |
|
| 1240 | - // passer les rubriques en index, elimine les doublons |
|
| 1241 | - $r = array_flip($r); |
|
| 1242 | - // recuperer les index seuls |
|
| 1243 | - $r = array_keys($r); |
|
| 1244 | - // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1245 | - // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1246 | - $rubriques = array_combine($r, $r); |
|
| 1247 | - } |
|
| 1248 | - |
|
| 1249 | - // Affecter l'auteur session le cas echeant |
|
| 1250 | - if ( |
|
| 1251 | - isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1252 | - and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1253 | - ) { |
|
| 1254 | - $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - |
|
| 1258 | - return $restreint[$id_auteur] = $rubriques; |
|
| 1211 | + static $restreint = []; |
|
| 1212 | + |
|
| 1213 | + if (!$id_auteur = intval($id_auteur)) { |
|
| 1214 | + return []; |
|
| 1215 | + } |
|
| 1216 | + if ($raz) { |
|
| 1217 | + unset($restreint[$id_auteur]); |
|
| 1218 | + } elseif (isset($restreint[$id_auteur])) { |
|
| 1219 | + return $restreint[$id_auteur]; |
|
| 1220 | + } |
|
| 1221 | + |
|
| 1222 | + $rubriques = []; |
|
| 1223 | + if ( |
|
| 1224 | + (!isset($GLOBALS['meta']['version_installee']) |
|
| 1225 | + or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1226 | + and $r = sql_allfetsel( |
|
| 1227 | + 'id_objet', |
|
| 1228 | + 'spip_auteurs_liens', |
|
| 1229 | + 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1230 | + ) |
|
| 1231 | + and is_countable($r) ? count($r) : 0 |
|
| 1232 | + ) { |
|
| 1233 | + $r = array_column($r, 'id_objet'); |
|
| 1234 | + |
|
| 1235 | + // recuperer toute la branche, au format chaine enumeration |
|
| 1236 | + include_spip('inc/rubriques'); |
|
| 1237 | + $r = calcul_branche_in($r); |
|
| 1238 | + $r = explode(',', $r); |
|
| 1239 | + |
|
| 1240 | + // passer les rubriques en index, elimine les doublons |
|
| 1241 | + $r = array_flip($r); |
|
| 1242 | + // recuperer les index seuls |
|
| 1243 | + $r = array_keys($r); |
|
| 1244 | + // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1245 | + // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1246 | + $rubriques = array_combine($r, $r); |
|
| 1247 | + } |
|
| 1248 | + |
|
| 1249 | + // Affecter l'auteur session le cas echeant |
|
| 1250 | + if ( |
|
| 1251 | + isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1252 | + and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1253 | + ) { |
|
| 1254 | + $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + |
|
| 1258 | + return $restreint[$id_auteur] = $rubriques; |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | /** |
@@ -1273,7 +1273,7 @@ discard block |
||
| 1273 | 1273 | * @return bool true s'il a le droit, false sinon |
| 1274 | 1274 | **/ |
| 1275 | 1275 | function autoriser_rubrique_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1276 | - return autoriser('previsualiser'); |
|
| 1276 | + return autoriser('previsualiser'); |
|
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | 1279 | /** |
@@ -1291,7 +1291,7 @@ discard block |
||
| 1291 | 1291 | * @return bool true s'il a le droit, false sinon |
| 1292 | 1292 | **/ |
| 1293 | 1293 | function autoriser_rubrique_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1294 | - return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1294 | + return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | /** |
@@ -1309,9 +1309,9 @@ discard block |
||
| 1309 | 1309 | * @return bool true s'il a le droit, false sinon |
| 1310 | 1310 | **/ |
| 1311 | 1311 | function autoriser_auteur_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1312 | - $id = intval($id); |
|
| 1313 | - return (($id == $qui['id_auteur']) or |
|
| 1314 | - (($qui['statut'] === '0minirezo') and !$qui['restreint'])); |
|
| 1312 | + $id = intval($id); |
|
| 1313 | + return (($id == $qui['id_auteur']) or |
|
| 1314 | + (($qui['statut'] === '0minirezo') and !$qui['restreint'])); |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | /** |
@@ -1329,8 +1329,8 @@ discard block |
||
| 1329 | 1329 | * @return bool true s'il a le droit, false sinon |
| 1330 | 1330 | **/ |
| 1331 | 1331 | function autoriser_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1332 | - // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1333 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1332 | + // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1333 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | |
@@ -1350,7 +1350,7 @@ discard block |
||
| 1350 | 1350 | * @return true |
| 1351 | 1351 | **/ |
| 1352 | 1352 | function autoriser_ok_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1353 | - return true; |
|
| 1353 | + return true; |
|
| 1354 | 1354 | } |
| 1355 | 1355 | |
| 1356 | 1356 | /** |
@@ -1369,7 +1369,7 @@ discard block |
||
| 1369 | 1369 | * @return false |
| 1370 | 1370 | **/ |
| 1371 | 1371 | function autoriser_niet_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1372 | - return false; |
|
| 1372 | + return false; |
|
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | /** |
@@ -1387,11 +1387,11 @@ discard block |
||
| 1387 | 1387 | * @return bool true s'il a le droit, false sinon |
| 1388 | 1388 | **/ |
| 1389 | 1389 | function autoriser_base_reparer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1390 | - if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1391 | - return false; |
|
| 1392 | - } |
|
| 1390 | + if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1391 | + return false; |
|
| 1392 | + } |
|
| 1393 | 1393 | |
| 1394 | - return true; |
|
| 1394 | + return true; |
|
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | /** |
@@ -1409,7 +1409,7 @@ discard block |
||
| 1409 | 1409 | * @return true |
| 1410 | 1410 | **/ |
| 1411 | 1411 | function autoriser_infosperso_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1412 | - return true; |
|
| 1412 | + return true; |
|
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | 1415 | /** |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | * @return true |
| 1428 | 1428 | **/ |
| 1429 | 1429 | function autoriser_langage_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1430 | - return true; |
|
| 1430 | + return true; |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | /** |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | * @return bool true s'il a le droit, false sinon |
| 1446 | 1446 | **/ |
| 1447 | 1447 | function autoriser_configurerlangage_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1448 | - return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1448 | + return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | 1451 | /** |
@@ -1463,7 +1463,7 @@ discard block |
||
| 1463 | 1463 | * @return true |
| 1464 | 1464 | **/ |
| 1465 | 1465 | function autoriser_preferences_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1466 | - return true; |
|
| 1466 | + return true; |
|
| 1467 | 1467 | } |
| 1468 | 1468 | |
| 1469 | 1469 | /** |
@@ -1481,7 +1481,7 @@ discard block |
||
| 1481 | 1481 | * @return bool true s'il a le droit, false sinon |
| 1482 | 1482 | **/ |
| 1483 | 1483 | function autoriser_configurerpreferences_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1484 | - return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1484 | + return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | /** |
@@ -1499,8 +1499,8 @@ discard block |
||
| 1499 | 1499 | * @return bool true s'il a le droit, false sinon |
| 1500 | 1500 | **/ |
| 1501 | 1501 | function autoriser_menudeveloppement_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1502 | - return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1503 | - and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui'); |
|
| 1502 | + return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1503 | + and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui'); |
|
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | 1506 | /** |
@@ -1519,7 +1519,7 @@ discard block |
||
| 1519 | 1519 | * @return true |
| 1520 | 1520 | **/ |
| 1521 | 1521 | function autoriser_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1522 | - return true; |
|
| 1522 | + return true; |
|
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | /** |
@@ -1537,7 +1537,7 @@ discard block |
||
| 1537 | 1537 | * @return true |
| 1538 | 1538 | **/ |
| 1539 | 1539 | function autoriser_auteurs_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1540 | - return true; |
|
| 1540 | + return true; |
|
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | 1543 | /** |
@@ -1555,7 +1555,7 @@ discard block |
||
| 1555 | 1555 | * @return bool true s'il a le droit, false sinon |
| 1556 | 1556 | **/ |
| 1557 | 1557 | function autoriser_auteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1558 | - return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1558 | + return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | 1561 | /** |
@@ -1573,7 +1573,7 @@ discard block |
||
| 1573 | 1573 | * @return true |
| 1574 | 1574 | **/ |
| 1575 | 1575 | function autoriser_articles_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1576 | - return true; |
|
| 1576 | + return true; |
|
| 1577 | 1577 | } |
| 1578 | 1578 | |
| 1579 | 1579 | /** |
@@ -1591,7 +1591,7 @@ discard block |
||
| 1591 | 1591 | * @return bool true s'il a le droit, false sinon |
| 1592 | 1592 | **/ |
| 1593 | 1593 | function autoriser_articles_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1594 | - return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1594 | + return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | /** |
@@ -1609,7 +1609,7 @@ discard block |
||
| 1609 | 1609 | * @return true |
| 1610 | 1610 | **/ |
| 1611 | 1611 | function autoriser_rubriques_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1612 | - return true; |
|
| 1612 | + return true; |
|
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | 1615 | /** |
@@ -1627,7 +1627,7 @@ discard block |
||
| 1627 | 1627 | * @return bool true s'il a le droit, false sinon |
| 1628 | 1628 | **/ |
| 1629 | 1629 | function autoriser_rubriques_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1630 | - return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1630 | + return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | 1633 | /** |
@@ -1645,7 +1645,7 @@ discard block |
||
| 1645 | 1645 | * @return bool true s'il a le droit, false sinon |
| 1646 | 1646 | **/ |
| 1647 | 1647 | function autoriser_articlecreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1648 | - return verifier_table_non_vide(); |
|
| 1648 | + return verifier_table_non_vide(); |
|
| 1649 | 1649 | } |
| 1650 | 1650 | |
| 1651 | 1651 | |
@@ -1666,7 +1666,7 @@ discard block |
||
| 1666 | 1666 | * @return bool true s'il a le droit, false sinon |
| 1667 | 1667 | **/ |
| 1668 | 1668 | function autoriser_auteurcreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1669 | - return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1669 | + return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1670 | 1670 | } |
| 1671 | 1671 | |
| 1672 | 1672 | /** |
@@ -1684,13 +1684,13 @@ discard block |
||
| 1684 | 1684 | * @return bool true s'il a le droit, false sinon |
| 1685 | 1685 | **/ |
| 1686 | 1686 | function autoriser_visiteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1687 | - include_spip('base/abstract_sql'); |
|
| 1688 | - return |
|
| 1689 | - $qui['statut'] === '0minirezo' and !$qui['restreint'] |
|
| 1690 | - and ( |
|
| 1691 | - $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1692 | - or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1693 | - ); |
|
| 1687 | + include_spip('base/abstract_sql'); |
|
| 1688 | + return |
|
| 1689 | + $qui['statut'] === '0minirezo' and !$qui['restreint'] |
|
| 1690 | + and ( |
|
| 1691 | + $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1692 | + or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1693 | + ); |
|
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | 1696 | /** |
@@ -1708,7 +1708,7 @@ discard block |
||
| 1708 | 1708 | * @return bool true s'il a le droit, false sinon |
| 1709 | 1709 | **/ |
| 1710 | 1710 | function autoriser_suiviedito_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1711 | - return $qui['statut'] === '0minirezo'; |
|
| 1711 | + return $qui['statut'] === '0minirezo'; |
|
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | 1714 | /** |
@@ -1726,7 +1726,7 @@ discard block |
||
| 1726 | 1726 | * @return bool true s'il a le droit, false sinon |
| 1727 | 1727 | **/ |
| 1728 | 1728 | function autoriser_synchro_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1729 | - return $qui['statut'] === '0minirezo'; |
|
| 1729 | + return $qui['statut'] === '0minirezo'; |
|
| 1730 | 1730 | } |
| 1731 | 1731 | |
| 1732 | 1732 | /** |
@@ -1744,7 +1744,7 @@ discard block |
||
| 1744 | 1744 | * @return bool true s'il a le droit, false sinon |
| 1745 | 1745 | **/ |
| 1746 | 1746 | function autoriser_configurerinteractions_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1747 | - return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1747 | + return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | 1750 | /** |
@@ -1762,7 +1762,7 @@ discard block |
||
| 1762 | 1762 | * @return bool true s'il a le droit, false sinon |
| 1763 | 1763 | **/ |
| 1764 | 1764 | function autoriser_configurerlangue_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1765 | - return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1765 | + return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | 1768 | /** |
@@ -1780,7 +1780,7 @@ discard block |
||
| 1780 | 1780 | * @return bool true s'il a le droit, false sinon |
| 1781 | 1781 | **/ |
| 1782 | 1782 | function autoriser_configurermultilinguisme_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1783 | - return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1783 | + return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1784 | 1784 | } |
| 1785 | 1785 | |
| 1786 | 1786 | /** |
@@ -1798,7 +1798,7 @@ discard block |
||
| 1798 | 1798 | * @return bool true s'il a le droit, false sinon |
| 1799 | 1799 | **/ |
| 1800 | 1800 | function autoriser_configurercontenu_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1801 | - return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1801 | + return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | 1804 | /** |
@@ -1816,7 +1816,7 @@ discard block |
||
| 1816 | 1816 | * @return bool true s'il a le droit, false sinon |
| 1817 | 1817 | **/ |
| 1818 | 1818 | function autoriser_configureravancees_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1819 | - return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1819 | + return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1820 | 1820 | } |
| 1821 | 1821 | |
| 1822 | 1822 | /** |
@@ -1834,7 +1834,7 @@ discard block |
||
| 1834 | 1834 | * @return bool true s'il a le droit, false sinon |
| 1835 | 1835 | **/ |
| 1836 | 1836 | function autoriser_adminplugin_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1837 | - return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1837 | + return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1838 | 1838 | } |
| 1839 | 1839 | |
| 1840 | 1840 | /** |
@@ -1852,7 +1852,7 @@ discard block |
||
| 1852 | 1852 | * @return bool true s'il a le droit, false sinon |
| 1853 | 1853 | **/ |
| 1854 | 1854 | function autoriser_admintech_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1855 | - return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1855 | + return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | 1858 | /** |
@@ -1870,7 +1870,7 @@ discard block |
||
| 1870 | 1870 | * @return bool true s'il a le droit, false sinon |
| 1871 | 1871 | **/ |
| 1872 | 1872 | function autoriser_queue_purger_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1873 | - return autoriser('webmestre'); |
|
| 1873 | + return autoriser('webmestre'); |
|
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | 1876 | |
@@ -1890,11 +1890,11 @@ discard block |
||
| 1890 | 1890 | * @return bool true s'il a le droit, false sinon |
| 1891 | 1891 | **/ |
| 1892 | 1892 | function autoriser_echafauder_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1893 | - if (test_espace_prive()) { |
|
| 1894 | - return intval($qui['id_auteur']) ? true : false; |
|
| 1895 | - } else { |
|
| 1896 | - return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1897 | - } |
|
| 1893 | + if (test_espace_prive()) { |
|
| 1894 | + return intval($qui['id_auteur']) ? true : false; |
|
| 1895 | + } else { |
|
| 1896 | + return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1897 | + } |
|
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | 1900 | |
@@ -1909,27 +1909,27 @@ discard block |
||
| 1909 | 1909 | * Identifiants d'auteurs |
| 1910 | 1910 | */ |
| 1911 | 1911 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1912 | - $objet = objet_type($objet); |
|
| 1913 | - $where = [ |
|
| 1914 | - 'objet=' . sql_quote($objet), |
|
| 1915 | - 'id_objet=' . intval($id_objet) |
|
| 1916 | - ]; |
|
| 1917 | - if (!empty($cond)) { |
|
| 1918 | - if (is_array($cond)) { |
|
| 1919 | - $where = array_merge($where, $cond); |
|
| 1920 | - } else { |
|
| 1921 | - $where[] = $cond; |
|
| 1922 | - } |
|
| 1923 | - } |
|
| 1924 | - $auteurs = sql_allfetsel( |
|
| 1925 | - 'id_auteur', |
|
| 1926 | - 'spip_auteurs_liens', |
|
| 1927 | - $where |
|
| 1928 | - ); |
|
| 1929 | - if (is_array($auteurs)) { |
|
| 1930 | - return array_column($auteurs, 'id_auteur'); |
|
| 1931 | - } |
|
| 1932 | - return []; |
|
| 1912 | + $objet = objet_type($objet); |
|
| 1913 | + $where = [ |
|
| 1914 | + 'objet=' . sql_quote($objet), |
|
| 1915 | + 'id_objet=' . intval($id_objet) |
|
| 1916 | + ]; |
|
| 1917 | + if (!empty($cond)) { |
|
| 1918 | + if (is_array($cond)) { |
|
| 1919 | + $where = array_merge($where, $cond); |
|
| 1920 | + } else { |
|
| 1921 | + $where[] = $cond; |
|
| 1922 | + } |
|
| 1923 | + } |
|
| 1924 | + $auteurs = sql_allfetsel( |
|
| 1925 | + 'id_auteur', |
|
| 1926 | + 'spip_auteurs_liens', |
|
| 1927 | + $where |
|
| 1928 | + ); |
|
| 1929 | + if (is_array($auteurs)) { |
|
| 1930 | + return array_column($auteurs, 'id_auteur'); |
|
| 1931 | + } |
|
| 1932 | + return []; |
|
| 1933 | 1933 | } |
| 1934 | 1934 | |
| 1935 | 1935 | /** |
@@ -1944,11 +1944,11 @@ discard block |
||
| 1944 | 1944 | * - false : serveur SQL indisponible |
| 1945 | 1945 | */ |
| 1946 | 1946 | function auteurs_article($id_article, $cond = '') { |
| 1947 | - return sql_allfetsel( |
|
| 1948 | - 'id_auteur', |
|
| 1949 | - 'spip_auteurs_liens', |
|
| 1950 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1951 | - ); |
|
| 1947 | + return sql_allfetsel( |
|
| 1948 | + 'id_auteur', |
|
| 1949 | + 'spip_auteurs_liens', |
|
| 1950 | + "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1951 | + ); |
|
| 1952 | 1952 | } |
| 1953 | 1953 | |
| 1954 | 1954 | |
@@ -1962,7 +1962,7 @@ discard block |
||
| 1962 | 1962 | */ |
| 1963 | 1963 | function acces_restreint_rubrique($id_rubrique) { |
| 1964 | 1964 | |
| 1965 | - return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1965 | + return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1966 | 1966 | } |
| 1967 | 1967 | |
| 1968 | 1968 | |
@@ -1975,12 +1975,12 @@ discard block |
||
| 1975 | 1975 | * @return bool true si un parent existe |
| 1976 | 1976 | */ |
| 1977 | 1977 | function verifier_table_non_vide($table = 'spip_rubriques') { |
| 1978 | - static $done = []; |
|
| 1979 | - if (!isset($done[$table])) { |
|
| 1980 | - $done[$table] = sql_countsel($table) > 0; |
|
| 1981 | - } |
|
| 1978 | + static $done = []; |
|
| 1979 | + if (!isset($done[$table])) { |
|
| 1980 | + $done[$table] = sql_countsel($table) > 0; |
|
| 1981 | + } |
|
| 1982 | 1982 | |
| 1983 | - return $done[$table]; |
|
| 1983 | + return $done[$table]; |
|
| 1984 | 1984 | } |
| 1985 | 1985 | |
| 1986 | 1986 | /** |
@@ -2007,15 +2007,15 @@ discard block |
||
| 2007 | 2007 | */ |
| 2008 | 2008 | function autoriser_inscrireauteur_dist($faire, $quoi, $id, $qui, $opt) { |
| 2009 | 2009 | |
| 2010 | - $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 2011 | - switch ($s) { |
|
| 2012 | - case 'info_redacteurs': |
|
| 2013 | - return ($GLOBALS['meta']['accepter_inscriptions'] === 'oui'); |
|
| 2014 | - case 'info_visiteurs': |
|
| 2015 | - return ($GLOBALS['meta']['accepter_visiteurs'] === 'oui' or $GLOBALS['meta']['forums_publics'] === 'abo'); |
|
| 2016 | - } |
|
| 2010 | + $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 2011 | + switch ($s) { |
|
| 2012 | + case 'info_redacteurs': |
|
| 2013 | + return ($GLOBALS['meta']['accepter_inscriptions'] === 'oui'); |
|
| 2014 | + case 'info_visiteurs': |
|
| 2015 | + return ($GLOBALS['meta']['accepter_visiteurs'] === 'oui' or $GLOBALS['meta']['forums_publics'] === 'abo'); |
|
| 2016 | + } |
|
| 2017 | 2017 | |
| 2018 | - return false; |
|
| 2018 | + return false; |
|
| 2019 | 2019 | } |
| 2020 | 2020 | |
| 2021 | 2021 | /** |
@@ -2033,7 +2033,7 @@ discard block |
||
| 2033 | 2033 | * @return bool true s'il a le droit, false sinon |
| 2034 | 2034 | **/ |
| 2035 | 2035 | function autoriser_inscription_relancer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 2036 | - return $qui['statut'] === '0minirezo' and !$qui['restreint']; |
|
| 2036 | + return $qui['statut'] === '0minirezo' and !$qui['restreint']; |
|
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | 2039 | /** |
@@ -2051,5 +2051,5 @@ discard block |
||
| 2051 | 2051 | * @return bool true s'il a le droit, false sinon |
| 2052 | 2052 | **/ |
| 2053 | 2053 | function autoriser_phpinfos_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 2054 | - return autoriser('webmestre'); |
|
| 2054 | + return autoriser('webmestre'); |
|
| 2055 | 2055 | } |