@@ -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,83 +38,83 @@ 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 | - * |
|
| 83 | - * @param string $faire |
|
| 84 | - * une action ('modifier', 'publier'...) |
|
| 85 | - * @param string $type |
|
| 86 | - * type d'objet ou nom de table ('article') |
|
| 87 | - * @param int $id |
|
| 88 | - * id de l'objet sur lequel on veut agir |
|
| 89 | - * @param null|int|array $qui |
|
| 90 | - * - si null on prend alors visiteur_session |
|
| 91 | - * - un id_auteur (on regarde dans la base) |
|
| 92 | - * - un tableau auteur complet, y compris [restreint] |
|
| 93 | - * @param null|array $opt |
|
| 94 | - * options sous forme de tableau associatif |
|
| 95 | - * @return bool |
|
| 96 | - * true si la personne peut effectuer l'action |
|
| 97 | - */ |
|
| 98 | - function autoriser($faire, $type = '', $id = 0, $qui = null, $opt = null) { |
|
| 99 | - // Charger les fonctions d'autorisation supplementaires |
|
| 100 | - static $pipe; |
|
| 101 | - if (!isset($pipe)) { |
|
| 102 | - $pipe = 1; |
|
| 103 | - pipeline('autoriser'); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $args = func_get_args(); |
|
| 107 | - |
|
| 108 | - return call_user_func_array('autoriser_dist', $args); |
|
| 109 | - } |
|
| 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 | + * |
|
| 83 | + * @param string $faire |
|
| 84 | + * une action ('modifier', 'publier'...) |
|
| 85 | + * @param string $type |
|
| 86 | + * type d'objet ou nom de table ('article') |
|
| 87 | + * @param int $id |
|
| 88 | + * id de l'objet sur lequel on veut agir |
|
| 89 | + * @param null|int|array $qui |
|
| 90 | + * - si null on prend alors visiteur_session |
|
| 91 | + * - un id_auteur (on regarde dans la base) |
|
| 92 | + * - un tableau auteur complet, y compris [restreint] |
|
| 93 | + * @param null|array $opt |
|
| 94 | + * options sous forme de tableau associatif |
|
| 95 | + * @return bool |
|
| 96 | + * true si la personne peut effectuer l'action |
|
| 97 | + */ |
|
| 98 | + function autoriser($faire, $type = '', $id = 0, $qui = null, $opt = null) { |
|
| 99 | + // Charger les fonctions d'autorisation supplementaires |
|
| 100 | + static $pipe; |
|
| 101 | + if (!isset($pipe)) { |
|
| 102 | + $pipe = 1; |
|
| 103 | + pipeline('autoriser'); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $args = func_get_args(); |
|
| 107 | + |
|
| 108 | + return call_user_func_array('autoriser_dist', $args); |
|
| 109 | + } |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | // mes_fonctions peut aussi declarer des autorisations, il faut donc le charger |
| 114 | 114 | // mais apres la fonction autoriser() |
| 115 | 115 | if ($f = find_in_path('mes_fonctions.php')) { |
| 116 | - global $dossier_squelettes; |
|
| 117 | - include_once(_ROOT_CWD . $f); |
|
| 116 | + global $dossier_squelettes; |
|
| 117 | + include_once(_ROOT_CWD . $f); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -142,72 +142,72 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | function autoriser_dist($faire, $type = '', $id = 0, $qui = null, $opt = null) { |
| 144 | 144 | |
| 145 | - // Qui ? visiteur_session ? |
|
| 146 | - // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 147 | - if ($qui === null or $qui === '') { |
|
| 148 | - $qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : array(); |
|
| 149 | - $qui = array_merge(array('statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'), $qui); |
|
| 150 | - } elseif (is_numeric($qui)) { |
|
| 151 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - // Admins restreints, on construit ici (pas generique mais...) |
|
| 155 | - // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 156 | - if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 157 | - $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : array(); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - spip_log( |
|
| 161 | - "autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ') ?', |
|
| 162 | - 'autoriser' . _LOG_DEBUG |
|
| 163 | - ); |
|
| 164 | - |
|
| 165 | - // passer par objet_type pour avoir les alias |
|
| 166 | - // et supprimer les _ |
|
| 167 | - $type = str_replace('_', '', strncmp($type, '_', 1) == 0 ? $type : objet_type($type, false)); |
|
| 168 | - |
|
| 169 | - // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 170 | - if ((isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 171 | - or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 172 | - ) { |
|
| 173 | - spip_log("autoriser ($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 174 | - return true; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - // Chercher une fonction d'autorisation |
|
| 178 | - // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 179 | - // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 180 | - $fonctions = $type |
|
| 181 | - ? array( |
|
| 182 | - 'autoriser_' . $type . '_' . $faire, |
|
| 183 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 184 | - 'autoriser_' . $type, |
|
| 185 | - 'autoriser_' . $type . '_dist', |
|
| 186 | - 'autoriser_' . $faire, |
|
| 187 | - 'autoriser_' . $faire . '_dist', |
|
| 188 | - 'autoriser_defaut', |
|
| 189 | - 'autoriser_defaut_dist' |
|
| 190 | - ) |
|
| 191 | - : array( |
|
| 192 | - 'autoriser_' . $faire, |
|
| 193 | - 'autoriser_' . $faire . '_dist', |
|
| 194 | - 'autoriser_defaut', |
|
| 195 | - 'autoriser_defaut_dist' |
|
| 196 | - ); |
|
| 197 | - |
|
| 198 | - foreach ($fonctions as $f) { |
|
| 199 | - if (function_exists($f)) { |
|
| 200 | - $a = $f($faire, $type, $id, $qui, $opt); |
|
| 201 | - break; |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - spip_log( |
|
| 206 | - "$f($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 207 | - 'autoriser' . _LOG_DEBUG |
|
| 208 | - ); |
|
| 209 | - |
|
| 210 | - return $a; |
|
| 145 | + // Qui ? visiteur_session ? |
|
| 146 | + // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 147 | + if ($qui === null or $qui === '') { |
|
| 148 | + $qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : array(); |
|
| 149 | + $qui = array_merge(array('statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'), $qui); |
|
| 150 | + } elseif (is_numeric($qui)) { |
|
| 151 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + // Admins restreints, on construit ici (pas generique mais...) |
|
| 155 | + // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 156 | + if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 157 | + $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : array(); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + spip_log( |
|
| 161 | + "autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ') ?', |
|
| 162 | + 'autoriser' . _LOG_DEBUG |
|
| 163 | + ); |
|
| 164 | + |
|
| 165 | + // passer par objet_type pour avoir les alias |
|
| 166 | + // et supprimer les _ |
|
| 167 | + $type = str_replace('_', '', strncmp($type, '_', 1) == 0 ? $type : objet_type($type, false)); |
|
| 168 | + |
|
| 169 | + // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 170 | + if ((isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 171 | + or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 172 | + ) { |
|
| 173 | + spip_log("autoriser ($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 174 | + return true; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + // Chercher une fonction d'autorisation |
|
| 178 | + // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 179 | + // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 180 | + $fonctions = $type |
|
| 181 | + ? array( |
|
| 182 | + 'autoriser_' . $type . '_' . $faire, |
|
| 183 | + 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 184 | + 'autoriser_' . $type, |
|
| 185 | + 'autoriser_' . $type . '_dist', |
|
| 186 | + 'autoriser_' . $faire, |
|
| 187 | + 'autoriser_' . $faire . '_dist', |
|
| 188 | + 'autoriser_defaut', |
|
| 189 | + 'autoriser_defaut_dist' |
|
| 190 | + ) |
|
| 191 | + : array( |
|
| 192 | + 'autoriser_' . $faire, |
|
| 193 | + 'autoriser_' . $faire . '_dist', |
|
| 194 | + 'autoriser_defaut', |
|
| 195 | + 'autoriser_defaut_dist' |
|
| 196 | + ); |
|
| 197 | + |
|
| 198 | + foreach ($fonctions as $f) { |
|
| 199 | + if (function_exists($f)) { |
|
| 200 | + $a = $f($faire, $type, $id, $qui, $opt); |
|
| 201 | + break; |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + spip_log( |
|
| 206 | + "$f($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 207 | + 'autoriser' . _LOG_DEBUG |
|
| 208 | + ); |
|
| 209 | + |
|
| 210 | + return $a; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // une globale pour aller au plus vite dans la fonction generique ci dessus |
@@ -225,26 +225,26 @@ discard block |
||
| 225 | 225 | * @return bool |
| 226 | 226 | */ |
| 227 | 227 | function autoriser_exception($faire, $type, $id, $autoriser = true) { |
| 228 | - // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 229 | - static $autorisation; |
|
| 230 | - if ($autoriser === 'verifier') { |
|
| 231 | - return isset($autorisation[$faire][$type][$id]); |
|
| 232 | - } |
|
| 233 | - if ($autoriser === true) { |
|
| 234 | - $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 235 | - } |
|
| 236 | - if ($autoriser === false) { |
|
| 237 | - if ($id === '*') { |
|
| 238 | - unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 239 | - unset($autorisation[$faire][$type]); |
|
| 240 | - } |
|
| 241 | - else { |
|
| 242 | - unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 243 | - unset($autorisation[$faire][$type][$id]); |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - return false; |
|
| 228 | + // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 229 | + static $autorisation; |
|
| 230 | + if ($autoriser === 'verifier') { |
|
| 231 | + return isset($autorisation[$faire][$type][$id]); |
|
| 232 | + } |
|
| 233 | + if ($autoriser === true) { |
|
| 234 | + $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 235 | + } |
|
| 236 | + if ($autoriser === false) { |
|
| 237 | + if ($id === '*') { |
|
| 238 | + unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 239 | + unset($autorisation[$faire][$type]); |
|
| 240 | + } |
|
| 241 | + else { |
|
| 242 | + unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 243 | + unset($autorisation[$faire][$type][$id]); |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + return false; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
@@ -261,9 +261,9 @@ discard block |
||
| 261 | 261 | * @return bool true s'il a le droit, false sinon |
| 262 | 262 | **/ |
| 263 | 263 | function autoriser_defaut_dist($faire, $type, $id, $qui, $opt) { |
| 264 | - return |
|
| 265 | - $qui['statut'] == '0minirezo' |
|
| 266 | - and !$qui['restreint']; |
|
| 264 | + return |
|
| 265 | + $qui['statut'] == '0minirezo' |
|
| 266 | + and !$qui['restreint']; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -279,10 +279,10 @@ discard block |
||
| 279 | 279 | * @return bool |
| 280 | 280 | */ |
| 281 | 281 | function autoriser_loger_dist($faire, $type, $id, $qui, $opt) { |
| 282 | - if ($qui['statut'] == '5poubelle') { |
|
| 283 | - return false; |
|
| 284 | - } |
|
| 285 | - return true; |
|
| 282 | + if ($qui['statut'] == '5poubelle') { |
|
| 283 | + return false; |
|
| 284 | + } |
|
| 285 | + return true; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @return bool true s'il a le droit, false sinon |
| 297 | 297 | **/ |
| 298 | 298 | function autoriser_ecrire_dist($faire, $type, $id, $qui, $opt) { |
| 299 | - return isset($qui['statut']) and in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 299 | + return isset($qui['statut']) and in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * @return bool true s'il a le droit, false sinon |
| 314 | 314 | **/ |
| 315 | 315 | function autoriser_creer_dist($faire, $type, $id, $qui, $opt) { |
| 316 | - return in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 316 | + return in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
@@ -331,18 +331,18 @@ discard block |
||
| 331 | 331 | **/ |
| 332 | 332 | function autoriser_previsualiser_dist($faire, $type, $id, $qui, $opt) { |
| 333 | 333 | |
| 334 | - // Le visiteur a-t-il un statut prevu par la config ? |
|
| 335 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 336 | - return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 337 | - } |
|
| 334 | + // Le visiteur a-t-il un statut prevu par la config ? |
|
| 335 | + if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 336 | + return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - // A-t-on un token de prévisualisation valable ? |
|
| 340 | - include_spip('inc/securiser_action'); |
|
| 341 | - if (decrire_token_previsu()) { |
|
| 342 | - return true; |
|
| 343 | - } |
|
| 339 | + // A-t-on un token de prévisualisation valable ? |
|
| 340 | + include_spip('inc/securiser_action'); |
|
| 341 | + if (decrire_token_previsu()) { |
|
| 342 | + return true; |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | - return false; |
|
| 345 | + return false; |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
@@ -370,57 +370,57 @@ discard block |
||
| 370 | 370 | */ |
| 371 | 371 | function test_previsualiser_objet_champ($type = null, $id = 0, $qui = array(), $opt = array()) { |
| 372 | 372 | |
| 373 | - // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 374 | - if (!$type) { |
|
| 375 | - return true; |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - include_spip('base/objets'); |
|
| 379 | - $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 380 | - if (isset($infos['statut'])) { |
|
| 381 | - foreach ($infos['statut'] as $c) { |
|
| 382 | - if (isset($c['publie'])) { |
|
| 383 | - if (!isset($c['previsu'])) { |
|
| 384 | - return false; |
|
| 385 | - } // pas de previsu definie => NIET |
|
| 386 | - $champ = $c['champ']; |
|
| 387 | - if (!isset($opt[$champ])) { |
|
| 388 | - return false; |
|
| 389 | - } // pas de champ passe a la demande => NIET |
|
| 390 | - $previsu = explode(',', $c['previsu']); |
|
| 391 | - // regarder si ce statut est autorise pour l'auteur |
|
| 392 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 393 | - |
|
| 394 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 395 | - // sinon l’auteur en session |
|
| 396 | - include_spip('inc/securiser_action'); |
|
| 397 | - if ($desc = decrire_token_previsu()) { |
|
| 398 | - $id_auteur = $desc['id_auteur']; |
|
| 399 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 400 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 401 | - } else { |
|
| 402 | - $id_auteur = null; |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - if (!$id_auteur) { |
|
| 406 | - return false; |
|
| 407 | - } elseif(autoriser('previsualiser' . $opt[$champ], $type, '', $id_auteur)) { |
|
| 408 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 409 | - } elseif (!sql_countsel( |
|
| 410 | - 'spip_auteurs_liens', |
|
| 411 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 412 | - )) { |
|
| 413 | - return false; |
|
| 414 | - } // pas auteur de cet objet => NIET |
|
| 415 | - } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 416 | - // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 417 | - return false; |
|
| 418 | - } |
|
| 419 | - } |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - return true; |
|
| 373 | + // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 374 | + if (!$type) { |
|
| 375 | + return true; |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + include_spip('base/objets'); |
|
| 379 | + $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 380 | + if (isset($infos['statut'])) { |
|
| 381 | + foreach ($infos['statut'] as $c) { |
|
| 382 | + if (isset($c['publie'])) { |
|
| 383 | + if (!isset($c['previsu'])) { |
|
| 384 | + return false; |
|
| 385 | + } // pas de previsu definie => NIET |
|
| 386 | + $champ = $c['champ']; |
|
| 387 | + if (!isset($opt[$champ])) { |
|
| 388 | + return false; |
|
| 389 | + } // pas de champ passe a la demande => NIET |
|
| 390 | + $previsu = explode(',', $c['previsu']); |
|
| 391 | + // regarder si ce statut est autorise pour l'auteur |
|
| 392 | + if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 393 | + |
|
| 394 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 395 | + // sinon l’auteur en session |
|
| 396 | + include_spip('inc/securiser_action'); |
|
| 397 | + if ($desc = decrire_token_previsu()) { |
|
| 398 | + $id_auteur = $desc['id_auteur']; |
|
| 399 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 400 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 401 | + } else { |
|
| 402 | + $id_auteur = null; |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + if (!$id_auteur) { |
|
| 406 | + return false; |
|
| 407 | + } elseif(autoriser('previsualiser' . $opt[$champ], $type, '', $id_auteur)) { |
|
| 408 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 409 | + } elseif (!sql_countsel( |
|
| 410 | + 'spip_auteurs_liens', |
|
| 411 | + 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 412 | + )) { |
|
| 413 | + return false; |
|
| 414 | + } // pas auteur de cet objet => NIET |
|
| 415 | + } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 416 | + // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 417 | + return false; |
|
| 418 | + } |
|
| 419 | + } |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + return true; |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
@@ -434,47 +434,47 @@ discard block |
||
| 434 | 434 | * @return bool true s'il a le droit, false sinon |
| 435 | 435 | **/ |
| 436 | 436 | function autoriser_changerlangue_dist($faire, $type, $id, $qui, $opt) { |
| 437 | - $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 438 | - $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 439 | - $table = table_objet_sql($type); |
|
| 440 | - if (in_array($table, $multi_objets) |
|
| 441 | - or in_array($table, $gerer_trad_objets)) { // affichage du formulaire si la configuration l'accepte |
|
| 442 | - $multi_secteurs = lire_config('multi_secteurs'); |
|
| 443 | - $champs = objet_info($type, 'field'); |
|
| 444 | - if ($multi_secteurs == 'oui' |
|
| 445 | - and array_key_exists('id_rubrique', $champs)) { |
|
| 446 | - // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 447 | - $primary = id_table_objet($type); |
|
| 448 | - if ($table != 'spip_rubriques') { |
|
| 449 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 450 | - } else { |
|
| 451 | - $id_rubrique = $id; |
|
| 452 | - } |
|
| 453 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 454 | - if (!$id_secteur > 0) { |
|
| 455 | - $id_secteur = $id_rubrique; |
|
| 456 | - } |
|
| 457 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 458 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 459 | - if ($langue_secteur != $langue_objet) { |
|
| 460 | - // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 461 | - return true; |
|
| 462 | - } |
|
| 463 | - if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 464 | - return false; |
|
| 465 | - } else { |
|
| 466 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 467 | - if ($id_parent != 0) { |
|
| 468 | - // sous-rubriques : pas de choix de langue |
|
| 469 | - return false; |
|
| 470 | - } |
|
| 471 | - } |
|
| 472 | - } |
|
| 473 | - } else { |
|
| 474 | - return false; |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 437 | + $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 438 | + $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 439 | + $table = table_objet_sql($type); |
|
| 440 | + if (in_array($table, $multi_objets) |
|
| 441 | + or in_array($table, $gerer_trad_objets)) { // affichage du formulaire si la configuration l'accepte |
|
| 442 | + $multi_secteurs = lire_config('multi_secteurs'); |
|
| 443 | + $champs = objet_info($type, 'field'); |
|
| 444 | + if ($multi_secteurs == 'oui' |
|
| 445 | + and array_key_exists('id_rubrique', $champs)) { |
|
| 446 | + // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 447 | + $primary = id_table_objet($type); |
|
| 448 | + if ($table != 'spip_rubriques') { |
|
| 449 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 450 | + } else { |
|
| 451 | + $id_rubrique = $id; |
|
| 452 | + } |
|
| 453 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 454 | + if (!$id_secteur > 0) { |
|
| 455 | + $id_secteur = $id_rubrique; |
|
| 456 | + } |
|
| 457 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 458 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 459 | + if ($langue_secteur != $langue_objet) { |
|
| 460 | + // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 461 | + return true; |
|
| 462 | + } |
|
| 463 | + if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 464 | + return false; |
|
| 465 | + } else { |
|
| 466 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 467 | + if ($id_parent != 0) { |
|
| 468 | + // sous-rubriques : pas de choix de langue |
|
| 469 | + return false; |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | + } else { |
|
| 474 | + return false; |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | /** |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | * @return bool true s'il a le droit, false sinon |
| 489 | 489 | **/ |
| 490 | 490 | function autoriser_changertraduction_dist($faire, $type, $id, $qui, $opt) { |
| 491 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 491 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | /** |
@@ -502,41 +502,41 @@ discard block |
||
| 502 | 502 | * @return bool true s'il a le droit, false sinon |
| 503 | 503 | **/ |
| 504 | 504 | function autoriser_dater_dist($faire, $type, $id, $qui, $opt) { |
| 505 | - $table = table_objet($type); |
|
| 506 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 507 | - $desc = $trouver_table($table); |
|
| 508 | - if (!$desc) { |
|
| 509 | - return false; |
|
| 510 | - } |
|
| 505 | + $table = table_objet($type); |
|
| 506 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 507 | + $desc = $trouver_table($table); |
|
| 508 | + if (!$desc) { |
|
| 509 | + return false; |
|
| 510 | + } |
|
| 511 | 511 | |
| 512 | - if (!isset($opt['statut'])) { |
|
| 513 | - if (isset($desc['field']['statut'])) { |
|
| 514 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 515 | - } else { |
|
| 516 | - $statut = 'publie'; |
|
| 517 | - } // pas de statut => publie |
|
| 518 | - } else { |
|
| 519 | - $statut = $opt['statut']; |
|
| 520 | - } |
|
| 512 | + if (!isset($opt['statut'])) { |
|
| 513 | + if (isset($desc['field']['statut'])) { |
|
| 514 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 515 | + } else { |
|
| 516 | + $statut = 'publie'; |
|
| 517 | + } // pas de statut => publie |
|
| 518 | + } else { |
|
| 519 | + $statut = $opt['statut']; |
|
| 520 | + } |
|
| 521 | 521 | |
| 522 | - // Liste des statuts publiés pour cet objet |
|
| 523 | - if (isset($desc['statut'][0]['publie'])) { |
|
| 524 | - $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 525 | - } |
|
| 526 | - // Sinon en dur le statut "publie" |
|
| 527 | - else { |
|
| 528 | - $statuts_publies = array('publie'); |
|
| 529 | - } |
|
| 522 | + // Liste des statuts publiés pour cet objet |
|
| 523 | + if (isset($desc['statut'][0]['publie'])) { |
|
| 524 | + $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 525 | + } |
|
| 526 | + // Sinon en dur le statut "publie" |
|
| 527 | + else { |
|
| 528 | + $statuts_publies = array('publie'); |
|
| 529 | + } |
|
| 530 | 530 | |
| 531 | - if ( |
|
| 532 | - in_array($statut, $statuts_publies) |
|
| 533 | - // Ou cas particulier géré en dur ici pour les articles |
|
| 534 | - or ($statut == 'prop' and $type == 'article' and $GLOBALS['meta']['post_dates'] == 'non') |
|
| 535 | - ) { |
|
| 536 | - return autoriser('modifier', $type, $id); |
|
| 537 | - } |
|
| 531 | + if ( |
|
| 532 | + in_array($statut, $statuts_publies) |
|
| 533 | + // Ou cas particulier géré en dur ici pour les articles |
|
| 534 | + or ($statut == 'prop' and $type == 'article' and $GLOBALS['meta']['post_dates'] == 'non') |
|
| 535 | + ) { |
|
| 536 | + return autoriser('modifier', $type, $id); |
|
| 537 | + } |
|
| 538 | 538 | |
| 539 | - return false; |
|
| 539 | + return false; |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | * @return bool true s'il a le droit, false sinon |
| 554 | 554 | **/ |
| 555 | 555 | function autoriser_instituer_dist($faire, $type, $id, $qui, $opt) { |
| 556 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 556 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | /** |
@@ -569,12 +569,12 @@ discard block |
||
| 569 | 569 | * @return bool true s'il a le droit, false sinon |
| 570 | 570 | **/ |
| 571 | 571 | function autoriser_rubrique_publierdans_dist($faire, $type, $id, $qui, $opt) { |
| 572 | - return |
|
| 573 | - ($qui['statut'] == '0minirezo') |
|
| 574 | - and ( |
|
| 575 | - !$qui['restreint'] or !$id |
|
| 576 | - or in_array($id, $qui['restreint']) |
|
| 577 | - ); |
|
| 572 | + return |
|
| 573 | + ($qui['statut'] == '0minirezo') |
|
| 574 | + and ( |
|
| 575 | + !$qui['restreint'] or !$id |
|
| 576 | + or in_array($id, $qui['restreint']) |
|
| 577 | + ); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | /** |
@@ -590,10 +590,10 @@ discard block |
||
| 590 | 590 | * @return bool true s'il a le droit, false sinon |
| 591 | 591 | **/ |
| 592 | 592 | function autoriser_rubrique_creer_dist($faire, $type, $id, $qui, $opt) { |
| 593 | - return |
|
| 594 | - ((!$id and autoriser('defaut', null, null, $qui, $opt)) |
|
| 595 | - or $id and autoriser('creerrubriquedans', 'rubrique', $id, $qui, $opt) |
|
| 596 | - ); |
|
| 593 | + return |
|
| 594 | + ((!$id and autoriser('defaut', null, null, $qui, $opt)) |
|
| 595 | + or $id and autoriser('creerrubriquedans', 'rubrique', $id, $qui, $opt) |
|
| 596 | + ); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | /** |
@@ -609,10 +609,10 @@ discard block |
||
| 609 | 609 | * @return bool true s'il a le droit, false sinon |
| 610 | 610 | **/ |
| 611 | 611 | function autoriser_rubrique_creerrubriquedans_dist($faire, $type, $id, $qui, $opt) { |
| 612 | - return |
|
| 613 | - ($id or ($qui['statut'] == '0minirezo' and !$qui['restreint'])) |
|
| 614 | - and autoriser('voir', 'rubrique', $id) |
|
| 615 | - and autoriser('publierdans', 'rubrique', $id); |
|
| 612 | + return |
|
| 613 | + ($id or ($qui['statut'] == '0minirezo' and !$qui['restreint'])) |
|
| 614 | + and autoriser('voir', 'rubrique', $id) |
|
| 615 | + and autoriser('publierdans', 'rubrique', $id); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | /** |
@@ -628,10 +628,10 @@ discard block |
||
| 628 | 628 | * @return bool true s'il a le droit, false sinon |
| 629 | 629 | **/ |
| 630 | 630 | function autoriser_rubrique_creerarticledans_dist($faire, $type, $id, $qui, $opt) { |
| 631 | - return |
|
| 632 | - $id |
|
| 633 | - and autoriser('voir', 'rubrique', $id) |
|
| 634 | - and autoriser('creer', 'article'); |
|
| 631 | + return |
|
| 632 | + $id |
|
| 633 | + and autoriser('voir', 'rubrique', $id) |
|
| 634 | + and autoriser('creer', 'article'); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | |
@@ -648,8 +648,8 @@ discard block |
||
| 648 | 648 | * @return bool true s'il a le droit, false sinon |
| 649 | 649 | **/ |
| 650 | 650 | function autoriser_rubrique_modifier_dist($faire, $type, $id, $qui, $opt) { |
| 651 | - return |
|
| 652 | - autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 651 | + return |
|
| 652 | + autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | /** |
@@ -665,29 +665,29 @@ discard block |
||
| 665 | 665 | * @return bool true s'il a le droit, false sinon |
| 666 | 666 | **/ |
| 667 | 667 | function autoriser_rubrique_supprimer_dist($faire, $type, $id, $qui, $opt) { |
| 668 | - if (!$id = intval($id)) { |
|
| 669 | - return false; |
|
| 670 | - } |
|
| 668 | + if (!$id = intval($id)) { |
|
| 669 | + return false; |
|
| 670 | + } |
|
| 671 | 671 | |
| 672 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 673 | - return false; |
|
| 674 | - } |
|
| 672 | + if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 673 | + return false; |
|
| 674 | + } |
|
| 675 | 675 | |
| 676 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 677 | - return false; |
|
| 678 | - } |
|
| 676 | + if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 677 | + return false; |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | - $compte = pipeline( |
|
| 681 | - 'objet_compte_enfants', |
|
| 682 | - array('args' => array('objet' => 'rubrique', 'id_objet' => $id), 'data' => array()) |
|
| 683 | - ); |
|
| 684 | - foreach ($compte as $objet => $n) { |
|
| 685 | - if ($n) { |
|
| 686 | - return false; |
|
| 687 | - } |
|
| 688 | - } |
|
| 680 | + $compte = pipeline( |
|
| 681 | + 'objet_compte_enfants', |
|
| 682 | + array('args' => array('objet' => 'rubrique', 'id_objet' => $id), 'data' => array()) |
|
| 683 | + ); |
|
| 684 | + foreach ($compte as $objet => $n) { |
|
| 685 | + if ($n) { |
|
| 686 | + return false; |
|
| 687 | + } |
|
| 688 | + } |
|
| 689 | 689 | |
| 690 | - return autoriser('modifier', 'rubrique', $id); |
|
| 690 | + return autoriser('modifier', 'rubrique', $id); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | |
@@ -705,20 +705,20 @@ discard block |
||
| 705 | 705 | * @return bool true s'il a le droit, false sinon |
| 706 | 706 | **/ |
| 707 | 707 | function autoriser_article_modifier_dist($faire, $type, $id, $qui, $opt) { |
| 708 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 708 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 709 | 709 | |
| 710 | - return |
|
| 711 | - $r |
|
| 712 | - and |
|
| 713 | - ( |
|
| 714 | - autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 715 | - or ( |
|
| 716 | - (!isset($opt['statut']) or $opt['statut'] !== 'publie') |
|
| 717 | - and in_array($qui['statut'], array('0minirezo', '1comite')) |
|
| 718 | - and in_array($r['statut'], array('prop', 'prepa', 'poubelle')) |
|
| 719 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 720 | - ) |
|
| 721 | - ); |
|
| 710 | + return |
|
| 711 | + $r |
|
| 712 | + and |
|
| 713 | + ( |
|
| 714 | + autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 715 | + or ( |
|
| 716 | + (!isset($opt['statut']) or $opt['statut'] !== 'publie') |
|
| 717 | + and in_array($qui['statut'], array('0minirezo', '1comite')) |
|
| 718 | + and in_array($r['statut'], array('prop', 'prepa', 'poubelle')) |
|
| 719 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 720 | + ) |
|
| 721 | + ); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | /** |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | * @return bool true s'il a le droit, false sinon |
| 735 | 735 | **/ |
| 736 | 736 | function autoriser_article_creer_dist($faire, $type, $id, $qui, $opt) { |
| 737 | - return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], array('0minirezo', '1comite'))); |
|
| 737 | + return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], array('0minirezo', '1comite'))); |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | /** |
@@ -754,28 +754,28 @@ discard block |
||
| 754 | 754 | * @return bool true s'il a le droit, false sinon |
| 755 | 755 | */ |
| 756 | 756 | function autoriser_article_voir_dist($faire, $type, $id, $qui, $opt) { |
| 757 | - if ($qui['statut'] == '0minirezo') { |
|
| 758 | - return true; |
|
| 759 | - } |
|
| 760 | - // cas des articles : depend du statut de l'article et de l'auteur |
|
| 761 | - if (isset($opt['statut'])) { |
|
| 762 | - $statut = $opt['statut']; |
|
| 763 | - } else { |
|
| 764 | - if (!$id) { |
|
| 765 | - return false; |
|
| 766 | - } |
|
| 767 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 768 | - } |
|
| 769 | - |
|
| 770 | - return |
|
| 771 | - // si on est pas auteur de l'article, |
|
| 772 | - // seuls les propose et publies sont visibles |
|
| 773 | - in_array($statut, array('prop', 'publie')) |
|
| 774 | - // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 775 | - or |
|
| 776 | - ($id |
|
| 777 | - and $qui['id_auteur'] |
|
| 778 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 757 | + if ($qui['statut'] == '0minirezo') { |
|
| 758 | + return true; |
|
| 759 | + } |
|
| 760 | + // cas des articles : depend du statut de l'article et de l'auteur |
|
| 761 | + if (isset($opt['statut'])) { |
|
| 762 | + $statut = $opt['statut']; |
|
| 763 | + } else { |
|
| 764 | + if (!$id) { |
|
| 765 | + return false; |
|
| 766 | + } |
|
| 767 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 768 | + } |
|
| 769 | + |
|
| 770 | + return |
|
| 771 | + // si on est pas auteur de l'article, |
|
| 772 | + // seuls les propose et publies sont visibles |
|
| 773 | + in_array($statut, array('prop', 'publie')) |
|
| 774 | + // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 775 | + or |
|
| 776 | + ($id |
|
| 777 | + and $qui['id_auteur'] |
|
| 778 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | |
@@ -792,22 +792,22 @@ discard block |
||
| 792 | 792 | * @return bool true s'il a le droit, false sinon |
| 793 | 793 | **/ |
| 794 | 794 | function autoriser_voir_dist($faire, $type, $id, $qui, $opt) { |
| 795 | - # securite, mais on aurait pas du arriver ici ! |
|
| 796 | - if (function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 797 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist')) { |
|
| 798 | - return $f($faire, $type, $id, $qui, $opt); |
|
| 799 | - } |
|
| 795 | + # securite, mais on aurait pas du arriver ici ! |
|
| 796 | + if (function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 797 | + or function_exists($f = 'autoriser_' . $type . '_voir_dist')) { |
|
| 798 | + return $f($faire, $type, $id, $qui, $opt); |
|
| 799 | + } |
|
| 800 | 800 | |
| 801 | - if ($qui['statut'] == '0minirezo') { |
|
| 802 | - return true; |
|
| 803 | - } |
|
| 804 | - // admins et redacteurs peuvent voir un auteur |
|
| 805 | - if ($type == 'auteur') { |
|
| 806 | - return in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 807 | - } |
|
| 808 | - // sinon par defaut tout est visible |
|
| 809 | - // sauf cas particuliers traites separemment (ie article) |
|
| 810 | - return true; |
|
| 801 | + if ($qui['statut'] == '0minirezo') { |
|
| 802 | + return true; |
|
| 803 | + } |
|
| 804 | + // admins et redacteurs peuvent voir un auteur |
|
| 805 | + if ($type == 'auteur') { |
|
| 806 | + return in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 807 | + } |
|
| 808 | + // sinon par defaut tout est visible |
|
| 809 | + // sauf cas particuliers traites separemment (ie article) |
|
| 810 | + return true; |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | |
@@ -828,12 +828,12 @@ discard block |
||
| 828 | 828 | * @return bool true s'il a le droit, false sinon |
| 829 | 829 | **/ |
| 830 | 830 | function autoriser_webmestre_dist($faire, $type, $id, $qui, $opt) { |
| 831 | - return |
|
| 832 | - (defined('_ID_WEBMESTRES') ? |
|
| 833 | - in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 834 | - : $qui['webmestre'] == 'oui') |
|
| 835 | - and $qui['statut'] == '0minirezo' |
|
| 836 | - and !$qui['restreint']; |
|
| 831 | + return |
|
| 832 | + (defined('_ID_WEBMESTRES') ? |
|
| 833 | + in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 834 | + : $qui['webmestre'] == 'oui') |
|
| 835 | + and $qui['statut'] == '0minirezo' |
|
| 836 | + and !$qui['restreint']; |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
@@ -849,9 +849,9 @@ discard block |
||
| 849 | 849 | * @return bool true s'il a le droit, false sinon |
| 850 | 850 | **/ |
| 851 | 851 | function autoriser_configurer_dist($faire, $type, $id, $qui, $opt) { |
| 852 | - return |
|
| 853 | - $qui['statut'] == '0minirezo' |
|
| 854 | - and !$qui['restreint']; |
|
| 852 | + return |
|
| 853 | + $qui['statut'] == '0minirezo' |
|
| 854 | + and !$qui['restreint']; |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /** |
@@ -867,8 +867,8 @@ discard block |
||
| 867 | 867 | * @return bool true s'il a le droit, false sinon |
| 868 | 868 | **/ |
| 869 | 869 | function autoriser_sauvegarder_dist($faire, $type, $id, $qui, $opt) { |
| 870 | - return |
|
| 871 | - $qui['statut'] == '0minirezo'; |
|
| 870 | + return |
|
| 871 | + $qui['statut'] == '0minirezo'; |
|
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | /** |
@@ -884,8 +884,8 @@ discard block |
||
| 884 | 884 | * @return bool true s'il a le droit, false sinon |
| 885 | 885 | **/ |
| 886 | 886 | function autoriser_detruire_dist($faire, $type, $id, $qui, $opt) { |
| 887 | - return |
|
| 888 | - autoriser('webmestre', null, null, $qui, $opt); |
|
| 887 | + return |
|
| 888 | + autoriser('webmestre', null, null, $qui, $opt); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | /** |
@@ -902,20 +902,20 @@ discard block |
||
| 902 | 902 | * @return bool true s'il a le droit, false sinon |
| 903 | 903 | **/ |
| 904 | 904 | function autoriser_auteur_previsualiser_dist($faire, $type, $id, $qui, $opt) { |
| 905 | - // les admins peuvent "previsualiser" une page auteur |
|
| 906 | - if ($qui['statut'] == '0minirezo' |
|
| 907 | - and !$qui['restreint'] |
|
| 908 | - ) { |
|
| 909 | - return true; |
|
| 910 | - } |
|
| 911 | - // "Voir en ligne" si l'auteur a un article publie |
|
| 912 | - $n = sql_fetsel( |
|
| 913 | - 'A.id_article', |
|
| 914 | - 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 915 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 916 | - ); |
|
| 905 | + // les admins peuvent "previsualiser" une page auteur |
|
| 906 | + if ($qui['statut'] == '0minirezo' |
|
| 907 | + and !$qui['restreint'] |
|
| 908 | + ) { |
|
| 909 | + return true; |
|
| 910 | + } |
|
| 911 | + // "Voir en ligne" si l'auteur a un article publie |
|
| 912 | + $n = sql_fetsel( |
|
| 913 | + 'A.id_article', |
|
| 914 | + 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 915 | + "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 916 | + ); |
|
| 917 | 917 | |
| 918 | - return $n ? true : false; |
|
| 918 | + return $n ? true : false; |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | |
@@ -943,7 +943,7 @@ discard block |
||
| 943 | 943 | * @return bool true s'il a le droit, false sinon |
| 944 | 944 | **/ |
| 945 | 945 | function autoriser_auteur_creer_dist($faire, $type, $id, $qui, $opt) { |
| 946 | - return ($qui['statut'] == '0minirezo'); |
|
| 946 | + return ($qui['statut'] == '0minirezo'); |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | |
@@ -963,78 +963,78 @@ discard block |
||
| 963 | 963 | **/ |
| 964 | 964 | function autoriser_auteur_modifier_dist($faire, $type, $id, $qui, $opt) { |
| 965 | 965 | |
| 966 | - // Ni admin ni redacteur => non |
|
| 967 | - if (!in_array($qui['statut'], array('0minirezo', '1comite'))) { |
|
| 968 | - return false; |
|
| 969 | - } |
|
| 970 | - |
|
| 971 | - // Un redacteur peut modifier ses propres donnees mais ni son login/email |
|
| 972 | - // ni son statut (qui sont le cas echeant passes comme option) |
|
| 973 | - if ($qui['statut'] == '1comite') { |
|
| 974 | - if (!empty($opt['webmestre'])) { |
|
| 975 | - return false; |
|
| 976 | - } elseif ( |
|
| 977 | - !empty($opt['statut']) |
|
| 978 | - or !empty($opt['restreintes']) |
|
| 979 | - or !empty($opt['email']) |
|
| 980 | - ) { |
|
| 981 | - return false; |
|
| 982 | - } elseif ($id == $qui['id_auteur']) { |
|
| 983 | - return true; |
|
| 984 | - } else { |
|
| 985 | - return false; |
|
| 986 | - } |
|
| 987 | - } |
|
| 988 | - |
|
| 989 | - // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 990 | - // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 991 | - if ($qui['restreint']) { |
|
| 992 | - if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 993 | - return false; |
|
| 994 | - } elseif ((isset($opt['statut']) and ($opt['statut'] == '0minirezo')) |
|
| 995 | - or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 996 | - ) { |
|
| 997 | - return false; |
|
| 998 | - } else { |
|
| 999 | - if ($id == $qui['id_auteur']) { |
|
| 1000 | - if (isset($opt['statut']) and $opt['statut']) { |
|
| 1001 | - return false; |
|
| 1002 | - } else { |
|
| 1003 | - return true; |
|
| 1004 | - } |
|
| 1005 | - } else { |
|
| 1006 | - if ($id_auteur = intval($id)) { |
|
| 1007 | - $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1008 | - if ($t and $t['statut'] != '0minirezo') { |
|
| 1009 | - return true; |
|
| 1010 | - } else { |
|
| 1011 | - return false; |
|
| 1012 | - } |
|
| 1013 | - } // id = 0 => creation |
|
| 1014 | - else { |
|
| 1015 | - return true; |
|
| 1016 | - } |
|
| 1017 | - } |
|
| 1018 | - } |
|
| 1019 | - } |
|
| 1020 | - |
|
| 1021 | - // Un admin complet fait ce qu'il veut |
|
| 1022 | - // sauf se degrader |
|
| 1023 | - if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1024 | - return false; |
|
| 1025 | - } elseif (isset($opt['webmestre']) |
|
| 1026 | - and $opt['webmestre'] |
|
| 1027 | - and (defined('_ID_WEBMESTRES') |
|
| 1028 | - or !autoriser('webmestre'))) { |
|
| 1029 | - // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1030 | - // ou si les webmestres sont fixes par constante (securite) |
|
| 1031 | - return false; |
|
| 1032 | - } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1033 | - elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) { |
|
| 1034 | - return false; |
|
| 1035 | - } else { |
|
| 1036 | - return true; |
|
| 1037 | - } |
|
| 966 | + // Ni admin ni redacteur => non |
|
| 967 | + if (!in_array($qui['statut'], array('0minirezo', '1comite'))) { |
|
| 968 | + return false; |
|
| 969 | + } |
|
| 970 | + |
|
| 971 | + // Un redacteur peut modifier ses propres donnees mais ni son login/email |
|
| 972 | + // ni son statut (qui sont le cas echeant passes comme option) |
|
| 973 | + if ($qui['statut'] == '1comite') { |
|
| 974 | + if (!empty($opt['webmestre'])) { |
|
| 975 | + return false; |
|
| 976 | + } elseif ( |
|
| 977 | + !empty($opt['statut']) |
|
| 978 | + or !empty($opt['restreintes']) |
|
| 979 | + or !empty($opt['email']) |
|
| 980 | + ) { |
|
| 981 | + return false; |
|
| 982 | + } elseif ($id == $qui['id_auteur']) { |
|
| 983 | + return true; |
|
| 984 | + } else { |
|
| 985 | + return false; |
|
| 986 | + } |
|
| 987 | + } |
|
| 988 | + |
|
| 989 | + // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 990 | + // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 991 | + if ($qui['restreint']) { |
|
| 992 | + if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 993 | + return false; |
|
| 994 | + } elseif ((isset($opt['statut']) and ($opt['statut'] == '0minirezo')) |
|
| 995 | + or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 996 | + ) { |
|
| 997 | + return false; |
|
| 998 | + } else { |
|
| 999 | + if ($id == $qui['id_auteur']) { |
|
| 1000 | + if (isset($opt['statut']) and $opt['statut']) { |
|
| 1001 | + return false; |
|
| 1002 | + } else { |
|
| 1003 | + return true; |
|
| 1004 | + } |
|
| 1005 | + } else { |
|
| 1006 | + if ($id_auteur = intval($id)) { |
|
| 1007 | + $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1008 | + if ($t and $t['statut'] != '0minirezo') { |
|
| 1009 | + return true; |
|
| 1010 | + } else { |
|
| 1011 | + return false; |
|
| 1012 | + } |
|
| 1013 | + } // id = 0 => creation |
|
| 1014 | + else { |
|
| 1015 | + return true; |
|
| 1016 | + } |
|
| 1017 | + } |
|
| 1018 | + } |
|
| 1019 | + } |
|
| 1020 | + |
|
| 1021 | + // Un admin complet fait ce qu'il veut |
|
| 1022 | + // sauf se degrader |
|
| 1023 | + if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1024 | + return false; |
|
| 1025 | + } elseif (isset($opt['webmestre']) |
|
| 1026 | + and $opt['webmestre'] |
|
| 1027 | + and (defined('_ID_WEBMESTRES') |
|
| 1028 | + or !autoriser('webmestre'))) { |
|
| 1029 | + // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1030 | + // ou si les webmestres sont fixes par constante (securite) |
|
| 1031 | + return false; |
|
| 1032 | + } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1033 | + elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) { |
|
| 1034 | + return false; |
|
| 1035 | + } else { |
|
| 1036 | + return true; |
|
| 1037 | + } |
|
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | 1040 | |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | * @return bool true s'il a le droit, false sinon |
| 1052 | 1052 | **/ |
| 1053 | 1053 | function autoriser_associerauteurs_dist($faire, $type, $id, $qui, $opt) { |
| 1054 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1054 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | 1057 | |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | * @return bool true s'il a le droit, false sinon |
| 1069 | 1069 | **/ |
| 1070 | 1070 | function autoriser_chargerftp_dist($faire, $type, $id, $qui, $opt) { |
| 1071 | - return $qui['statut'] == '0minirezo'; |
|
| 1071 | + return $qui['statut'] == '0minirezo'; |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | /** |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | * @return bool true s'il a le droit, false sinon |
| 1085 | 1085 | **/ |
| 1086 | 1086 | function autoriser_debug_dist($faire, $type, $id, $qui, $opt) { |
| 1087 | - return $qui['statut'] == '0minirezo'; |
|
| 1087 | + return $qui['statut'] == '0minirezo'; |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | /** |
@@ -1101,52 +1101,52 @@ discard block |
||
| 1101 | 1101 | * @return array Liste des rubriques |
| 1102 | 1102 | **/ |
| 1103 | 1103 | function liste_rubriques_auteur($id_auteur, $raz = false) { |
| 1104 | - static $restreint = array(); |
|
| 1105 | - |
|
| 1106 | - if (!$id_auteur = intval($id_auteur)) { |
|
| 1107 | - return array(); |
|
| 1108 | - } |
|
| 1109 | - if ($raz) { |
|
| 1110 | - unset($restreint[$id_auteur]); |
|
| 1111 | - } elseif (isset($restreint[$id_auteur])) { |
|
| 1112 | - return $restreint[$id_auteur]; |
|
| 1113 | - } |
|
| 1114 | - |
|
| 1115 | - $rubriques = array(); |
|
| 1116 | - if ((!isset($GLOBALS['meta']['version_installee']) |
|
| 1117 | - or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1118 | - and $r = sql_allfetsel( |
|
| 1119 | - 'id_objet', |
|
| 1120 | - 'spip_auteurs_liens', |
|
| 1121 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1122 | - ) |
|
| 1123 | - and count($r) |
|
| 1124 | - ) { |
|
| 1125 | - $r = array_column($r, 'id_objet'); |
|
| 1126 | - |
|
| 1127 | - // recuperer toute la branche, au format chaine enumeration |
|
| 1128 | - include_spip('inc/rubriques'); |
|
| 1129 | - $r = calcul_branche_in($r); |
|
| 1130 | - $r = explode(',', $r); |
|
| 1131 | - |
|
| 1132 | - // passer les rubriques en index, elimine les doublons |
|
| 1133 | - $r = array_flip($r); |
|
| 1134 | - // recuperer les index seuls |
|
| 1135 | - $r = array_keys($r); |
|
| 1136 | - // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1137 | - // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1138 | - $rubriques = array_combine($r, $r); |
|
| 1139 | - } |
|
| 1140 | - |
|
| 1141 | - // Affecter l'auteur session le cas echeant |
|
| 1142 | - if (isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1143 | - and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1144 | - ) { |
|
| 1145 | - $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1146 | - } |
|
| 1147 | - |
|
| 1148 | - |
|
| 1149 | - return $restreint[$id_auteur] = $rubriques; |
|
| 1104 | + static $restreint = array(); |
|
| 1105 | + |
|
| 1106 | + if (!$id_auteur = intval($id_auteur)) { |
|
| 1107 | + return array(); |
|
| 1108 | + } |
|
| 1109 | + if ($raz) { |
|
| 1110 | + unset($restreint[$id_auteur]); |
|
| 1111 | + } elseif (isset($restreint[$id_auteur])) { |
|
| 1112 | + return $restreint[$id_auteur]; |
|
| 1113 | + } |
|
| 1114 | + |
|
| 1115 | + $rubriques = array(); |
|
| 1116 | + if ((!isset($GLOBALS['meta']['version_installee']) |
|
| 1117 | + or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1118 | + and $r = sql_allfetsel( |
|
| 1119 | + 'id_objet', |
|
| 1120 | + 'spip_auteurs_liens', |
|
| 1121 | + 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1122 | + ) |
|
| 1123 | + and count($r) |
|
| 1124 | + ) { |
|
| 1125 | + $r = array_column($r, 'id_objet'); |
|
| 1126 | + |
|
| 1127 | + // recuperer toute la branche, au format chaine enumeration |
|
| 1128 | + include_spip('inc/rubriques'); |
|
| 1129 | + $r = calcul_branche_in($r); |
|
| 1130 | + $r = explode(',', $r); |
|
| 1131 | + |
|
| 1132 | + // passer les rubriques en index, elimine les doublons |
|
| 1133 | + $r = array_flip($r); |
|
| 1134 | + // recuperer les index seuls |
|
| 1135 | + $r = array_keys($r); |
|
| 1136 | + // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1137 | + // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1138 | + $rubriques = array_combine($r, $r); |
|
| 1139 | + } |
|
| 1140 | + |
|
| 1141 | + // Affecter l'auteur session le cas echeant |
|
| 1142 | + if (isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1143 | + and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1144 | + ) { |
|
| 1145 | + $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1146 | + } |
|
| 1147 | + |
|
| 1148 | + |
|
| 1149 | + return $restreint[$id_auteur] = $rubriques; |
|
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | /** |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | * @return bool true s'il a le droit, false sinon |
| 1163 | 1163 | **/ |
| 1164 | 1164 | function autoriser_rubrique_previsualiser_dist($faire, $type, $id, $qui, $opt) { |
| 1165 | - return autoriser('previsualiser'); |
|
| 1165 | + return autoriser('previsualiser'); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | /** |
@@ -1178,7 +1178,7 @@ discard block |
||
| 1178 | 1178 | * @return bool true s'il a le droit, false sinon |
| 1179 | 1179 | **/ |
| 1180 | 1180 | function autoriser_rubrique_iconifier_dist($faire, $type, $id, $qui, $opt) { |
| 1181 | - return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1181 | + return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1182 | 1182 | } |
| 1183 | 1183 | |
| 1184 | 1184 | /** |
@@ -1194,8 +1194,8 @@ discard block |
||
| 1194 | 1194 | * @return bool true s'il a le droit, false sinon |
| 1195 | 1195 | **/ |
| 1196 | 1196 | function autoriser_auteur_iconifier_dist($faire, $type, $id, $qui, $opt) { |
| 1197 | - return (($id == $qui['id_auteur']) or |
|
| 1198 | - (($qui['statut'] == '0minirezo') and !$qui['restreint'])); |
|
| 1197 | + return (($id == $qui['id_auteur']) or |
|
| 1198 | + (($qui['statut'] == '0minirezo') and !$qui['restreint'])); |
|
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | 1201 | /** |
@@ -1211,8 +1211,8 @@ discard block |
||
| 1211 | 1211 | * @return bool true s'il a le droit, false sinon |
| 1212 | 1212 | **/ |
| 1213 | 1213 | function autoriser_iconifier_dist($faire, $type, $id, $qui, $opt) { |
| 1214 | - // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1215 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1214 | + // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1215 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | |
@@ -1230,7 +1230,7 @@ discard block |
||
| 1230 | 1230 | * @return bool true |
| 1231 | 1231 | **/ |
| 1232 | 1232 | function autoriser_ok_dist($faire, $type, $id, $qui, $opt) { |
| 1233 | - return true; |
|
| 1233 | + return true; |
|
| 1234 | 1234 | } |
| 1235 | 1235 | |
| 1236 | 1236 | /** |
@@ -1247,7 +1247,7 @@ discard block |
||
| 1247 | 1247 | * @return bool false |
| 1248 | 1248 | **/ |
| 1249 | 1249 | function autoriser_niet_dist($faire, $type, $id, $qui, $opt) { |
| 1250 | - return false; |
|
| 1250 | + return false; |
|
| 1251 | 1251 | } |
| 1252 | 1252 | |
| 1253 | 1253 | /** |
@@ -1263,11 +1263,11 @@ discard block |
||
| 1263 | 1263 | * @return bool false |
| 1264 | 1264 | **/ |
| 1265 | 1265 | function autoriser_base_reparer_dist($faire, $type, $id, $qui, $opt) { |
| 1266 | - if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1267 | - return false; |
|
| 1268 | - } |
|
| 1266 | + if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1267 | + return false; |
|
| 1268 | + } |
|
| 1269 | 1269 | |
| 1270 | - return true; |
|
| 1270 | + return true; |
|
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | 1273 | /** |
@@ -1283,7 +1283,7 @@ discard block |
||
| 1283 | 1283 | * @return bool true s'il a le droit, false sinon |
| 1284 | 1284 | **/ |
| 1285 | 1285 | function autoriser_infosperso_dist($faire, $type, $id, $qui, $opt) { |
| 1286 | - return true; |
|
| 1286 | + return true; |
|
| 1287 | 1287 | } |
| 1288 | 1288 | |
| 1289 | 1289 | /** |
@@ -1299,7 +1299,7 @@ discard block |
||
| 1299 | 1299 | * @return bool true s'il a le droit, false sinon |
| 1300 | 1300 | **/ |
| 1301 | 1301 | function autoriser_langage_configurer_dist($faire, $type, $id, $qui, $opt) { |
| 1302 | - return true; |
|
| 1302 | + return true; |
|
| 1303 | 1303 | } |
| 1304 | 1304 | |
| 1305 | 1305 | /** |
@@ -1315,7 +1315,7 @@ discard block |
||
| 1315 | 1315 | * @return bool true s'il a le droit, false sinon |
| 1316 | 1316 | **/ |
| 1317 | 1317 | function autoriser_configurerlangage_dist($faire, $type, $id, $qui, $opt) { |
| 1318 | - return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1318 | + return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | 1321 | /** |
@@ -1331,7 +1331,7 @@ discard block |
||
| 1331 | 1331 | * @return bool true s'il a le droit, false sinon |
| 1332 | 1332 | **/ |
| 1333 | 1333 | function autoriser_preferences_configurer_dist($faire, $type, $id, $qui, $opt) { |
| 1334 | - return true; |
|
| 1334 | + return true; |
|
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | 1337 | /** |
@@ -1347,7 +1347,7 @@ discard block |
||
| 1347 | 1347 | * @return bool true s'il a le droit, false sinon |
| 1348 | 1348 | **/ |
| 1349 | 1349 | function autoriser_configurerpreferences_dist($faire, $type, $id, $qui, $opt) { |
| 1350 | - return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1350 | + return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1351 | 1351 | } |
| 1352 | 1352 | |
| 1353 | 1353 | /** |
@@ -1363,8 +1363,8 @@ discard block |
||
| 1363 | 1363 | * @return bool true s'il a le droit, false sinon |
| 1364 | 1364 | **/ |
| 1365 | 1365 | function autoriser_menudeveloppement_menugrandeentree_dist($faire, $type, $id, $qui, $opt) { |
| 1366 | - return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1367 | - and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] == 'oui'); |
|
| 1366 | + return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1367 | + and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] == 'oui'); |
|
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | 1370 | /** |
@@ -1381,7 +1381,7 @@ discard block |
||
| 1381 | 1381 | * @return bool true s'il a le droit, false sinon |
| 1382 | 1382 | **/ |
| 1383 | 1383 | function autoriser_menugrandeentree_dist($faire, $type, $id, $qui, $opt) { |
| 1384 | - return true; |
|
| 1384 | + return true; |
|
| 1385 | 1385 | } |
| 1386 | 1386 | |
| 1387 | 1387 | /** |
@@ -1397,7 +1397,7 @@ discard block |
||
| 1397 | 1397 | * @return bool true s'il a le droit, false sinon |
| 1398 | 1398 | **/ |
| 1399 | 1399 | function autoriser_auteurs_voir_dist($faire, $type, $id, $qui, $opt) { |
| 1400 | - return true; |
|
| 1400 | + return true; |
|
| 1401 | 1401 | } |
| 1402 | 1402 | |
| 1403 | 1403 | /** |
@@ -1413,7 +1413,7 @@ discard block |
||
| 1413 | 1413 | * @return bool true s'il a le droit, false sinon |
| 1414 | 1414 | **/ |
| 1415 | 1415 | function autoriser_auteurs_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1416 | - return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1416 | + return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | /** |
@@ -1429,7 +1429,7 @@ discard block |
||
| 1429 | 1429 | * @return bool true s'il a le droit, false sinon |
| 1430 | 1430 | **/ |
| 1431 | 1431 | function autoriser_articles_voir_dist($faire, $type, $id, $qui, $opt) { |
| 1432 | - return true; |
|
| 1432 | + return true; |
|
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | 1435 | /** |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | * @return bool true s'il a le droit, false sinon |
| 1446 | 1446 | **/ |
| 1447 | 1447 | function autoriser_articles_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1448 | - return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1448 | + return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | 1451 | /** |
@@ -1461,7 +1461,7 @@ discard block |
||
| 1461 | 1461 | * @return bool true s'il a le droit, false sinon |
| 1462 | 1462 | **/ |
| 1463 | 1463 | function autoriser_rubriques_voir_dist($faire, $type, $id, $qui, $opt) { |
| 1464 | - return true; |
|
| 1464 | + return true; |
|
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | 1467 | /** |
@@ -1477,7 +1477,7 @@ discard block |
||
| 1477 | 1477 | * @return bool true s'il a le droit, false sinon |
| 1478 | 1478 | **/ |
| 1479 | 1479 | function autoriser_rubriques_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1480 | - return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1480 | + return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | 1483 | /** |
@@ -1493,7 +1493,7 @@ discard block |
||
| 1493 | 1493 | * @return bool true s'il a le droit, false sinon |
| 1494 | 1494 | **/ |
| 1495 | 1495 | function autoriser_articlecreer_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1496 | - return verifier_table_non_vide(); |
|
| 1496 | + return verifier_table_non_vide(); |
|
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | 1499 | |
@@ -1512,7 +1512,7 @@ discard block |
||
| 1512 | 1512 | * @return bool true s'il a le droit, false sinon |
| 1513 | 1513 | **/ |
| 1514 | 1514 | function autoriser_auteurcreer_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1515 | - return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1515 | + return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1516 | 1516 | } |
| 1517 | 1517 | |
| 1518 | 1518 | /** |
@@ -1528,13 +1528,13 @@ discard block |
||
| 1528 | 1528 | * @return bool true s'il a le droit, false sinon |
| 1529 | 1529 | **/ |
| 1530 | 1530 | function autoriser_visiteurs_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1531 | - include_spip('base/abstract_sql'); |
|
| 1532 | - return |
|
| 1533 | - $qui['statut'] == '0minirezo' and !$qui['restreint'] |
|
| 1534 | - and ( |
|
| 1535 | - $GLOBALS['meta']["accepter_visiteurs"] != 'non' |
|
| 1536 | - or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1537 | - ); |
|
| 1531 | + include_spip('base/abstract_sql'); |
|
| 1532 | + return |
|
| 1533 | + $qui['statut'] == '0minirezo' and !$qui['restreint'] |
|
| 1534 | + and ( |
|
| 1535 | + $GLOBALS['meta']["accepter_visiteurs"] != 'non' |
|
| 1536 | + or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1537 | + ); |
|
| 1538 | 1538 | } |
| 1539 | 1539 | |
| 1540 | 1540 | /** |
@@ -1550,7 +1550,7 @@ discard block |
||
| 1550 | 1550 | * @return bool true s'il a le droit, false sinon |
| 1551 | 1551 | **/ |
| 1552 | 1552 | function autoriser_suiviedito_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1553 | - return $qui['statut'] == '0minirezo'; |
|
| 1553 | + return $qui['statut'] == '0minirezo'; |
|
| 1554 | 1554 | } |
| 1555 | 1555 | |
| 1556 | 1556 | /** |
@@ -1566,7 +1566,7 @@ discard block |
||
| 1566 | 1566 | * @return bool true s'il a le droit, false sinon |
| 1567 | 1567 | **/ |
| 1568 | 1568 | function autoriser_synchro_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1569 | - return $qui['statut'] == '0minirezo'; |
|
| 1569 | + return $qui['statut'] == '0minirezo'; |
|
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | 1572 | /** |
@@ -1694,7 +1694,7 @@ discard block |
||
| 1694 | 1694 | * @return bool true s'il a le droit, false sinon |
| 1695 | 1695 | **/ |
| 1696 | 1696 | function autoriser_queue_purger_dist($faire, $type, $id, $qui, $opt) { |
| 1697 | - return autoriser('webmestre'); |
|
| 1697 | + return autoriser('webmestre'); |
|
| 1698 | 1698 | } |
| 1699 | 1699 | |
| 1700 | 1700 | |
@@ -1712,11 +1712,11 @@ discard block |
||
| 1712 | 1712 | * @return bool true s'il a le droit, false sinon |
| 1713 | 1713 | **/ |
| 1714 | 1714 | function autoriser_echafauder_dist($faire, $type, $id, $qui, $opt) { |
| 1715 | - if (test_espace_prive()) { |
|
| 1716 | - return intval($qui['id_auteur']) ? true : false; |
|
| 1717 | - } else { |
|
| 1718 | - return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1719 | - } |
|
| 1715 | + if (test_espace_prive()) { |
|
| 1716 | + return intval($qui['id_auteur']) ? true : false; |
|
| 1717 | + } else { |
|
| 1718 | + return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1719 | + } |
|
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | 1722 | |
@@ -1731,27 +1731,27 @@ discard block |
||
| 1731 | 1731 | * Identifiants d'auteurs |
| 1732 | 1732 | */ |
| 1733 | 1733 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1734 | - $objet = objet_type($objet); |
|
| 1735 | - $where = array( |
|
| 1736 | - 'objet=' . sql_quote($objet), |
|
| 1737 | - 'id_objet=' . intval($id_objet) |
|
| 1738 | - ); |
|
| 1739 | - if (!empty($cond)) { |
|
| 1740 | - if (is_array($cond)) { |
|
| 1741 | - $where = array_merge($where, $cond); |
|
| 1742 | - } else { |
|
| 1743 | - $where[] = $cond; |
|
| 1744 | - } |
|
| 1745 | - } |
|
| 1746 | - $auteurs = sql_allfetsel( |
|
| 1747 | - 'id_auteur', |
|
| 1748 | - 'spip_auteurs_liens', |
|
| 1749 | - $where |
|
| 1750 | - ); |
|
| 1751 | - if (is_array($auteurs)) { |
|
| 1752 | - return array_column($auteurs, 'id_auteur'); |
|
| 1753 | - } |
|
| 1754 | - return array(); |
|
| 1734 | + $objet = objet_type($objet); |
|
| 1735 | + $where = array( |
|
| 1736 | + 'objet=' . sql_quote($objet), |
|
| 1737 | + 'id_objet=' . intval($id_objet) |
|
| 1738 | + ); |
|
| 1739 | + if (!empty($cond)) { |
|
| 1740 | + if (is_array($cond)) { |
|
| 1741 | + $where = array_merge($where, $cond); |
|
| 1742 | + } else { |
|
| 1743 | + $where[] = $cond; |
|
| 1744 | + } |
|
| 1745 | + } |
|
| 1746 | + $auteurs = sql_allfetsel( |
|
| 1747 | + 'id_auteur', |
|
| 1748 | + 'spip_auteurs_liens', |
|
| 1749 | + $where |
|
| 1750 | + ); |
|
| 1751 | + if (is_array($auteurs)) { |
|
| 1752 | + return array_column($auteurs, 'id_auteur'); |
|
| 1753 | + } |
|
| 1754 | + return array(); |
|
| 1755 | 1755 | } |
| 1756 | 1756 | |
| 1757 | 1757 | /** |
@@ -1765,11 +1765,11 @@ discard block |
||
| 1765 | 1765 | * - false : serveur SQL indisponible |
| 1766 | 1766 | */ |
| 1767 | 1767 | function auteurs_article($id_article, $cond = '') { |
| 1768 | - return sql_allfetsel( |
|
| 1769 | - 'id_auteur', |
|
| 1770 | - 'spip_auteurs_liens', |
|
| 1771 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1772 | - ); |
|
| 1768 | + return sql_allfetsel( |
|
| 1769 | + 'id_auteur', |
|
| 1770 | + 'spip_auteurs_liens', |
|
| 1771 | + "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1772 | + ); |
|
| 1773 | 1773 | } |
| 1774 | 1774 | |
| 1775 | 1775 | |
@@ -1783,7 +1783,7 @@ discard block |
||
| 1783 | 1783 | */ |
| 1784 | 1784 | function acces_restreint_rubrique($id_rubrique) { |
| 1785 | 1785 | |
| 1786 | - return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1786 | + return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1787 | 1787 | } |
| 1788 | 1788 | |
| 1789 | 1789 | |
@@ -1796,12 +1796,12 @@ discard block |
||
| 1796 | 1796 | * @return bool true si un parent existe |
| 1797 | 1797 | */ |
| 1798 | 1798 | function verifier_table_non_vide($table = 'spip_rubriques') { |
| 1799 | - static $done = array(); |
|
| 1800 | - if (!isset($done[$table])) { |
|
| 1801 | - $done[$table] = sql_countsel($table) > 0; |
|
| 1802 | - } |
|
| 1799 | + static $done = array(); |
|
| 1800 | + if (!isset($done[$table])) { |
|
| 1801 | + $done[$table] = sql_countsel($table) > 0; |
|
| 1802 | + } |
|
| 1803 | 1803 | |
| 1804 | - return $done[$table]; |
|
| 1804 | + return $done[$table]; |
|
| 1805 | 1805 | } |
| 1806 | 1806 | |
| 1807 | 1807 | /** |
@@ -1826,15 +1826,15 @@ discard block |
||
| 1826 | 1826 | */ |
| 1827 | 1827 | function autoriser_inscrireauteur_dist($faire, $quoi, $id, $qui, $opt) { |
| 1828 | 1828 | |
| 1829 | - $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 1830 | - switch ($s) { |
|
| 1831 | - case 'info_redacteurs': |
|
| 1832 | - return ($GLOBALS['meta']['accepter_inscriptions'] == 'oui'); |
|
| 1833 | - case 'info_visiteurs': |
|
| 1834 | - return ($GLOBALS['meta']['accepter_visiteurs'] == 'oui' or $GLOBALS['meta']['forums_publics'] == 'abo'); |
|
| 1835 | - } |
|
| 1829 | + $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 1830 | + switch ($s) { |
|
| 1831 | + case 'info_redacteurs': |
|
| 1832 | + return ($GLOBALS['meta']['accepter_inscriptions'] == 'oui'); |
|
| 1833 | + case 'info_visiteurs': |
|
| 1834 | + return ($GLOBALS['meta']['accepter_visiteurs'] == 'oui' or $GLOBALS['meta']['forums_publics'] == 'abo'); |
|
| 1835 | + } |
|
| 1836 | 1836 | |
| 1837 | - return false; |
|
| 1837 | + return false; |
|
| 1838 | 1838 | } |
| 1839 | 1839 | |
| 1840 | 1840 | /** |
@@ -1850,7 +1850,7 @@ discard block |
||
| 1850 | 1850 | * @return bool false |
| 1851 | 1851 | **/ |
| 1852 | 1852 | function autoriser_inscription_relancer_dist($faire, $type, $id, $qui, $opt) { |
| 1853 | - return $qui['statut'] == '0minirezo' and !$qui['restreint']; |
|
| 1853 | + return $qui['statut'] == '0minirezo' and !$qui['restreint']; |
|
| 1854 | 1854 | } |
| 1855 | 1855 | |
| 1856 | 1856 | /** |
@@ -1866,5 +1866,5 @@ discard block |
||
| 1866 | 1866 | * @return bool true s'il a le droit, false sinon |
| 1867 | 1867 | **/ |
| 1868 | 1868 | function autoriser_phpinfos_dist($faire, $type, $id, $qui, $opt) { |
| 1869 | - return autoriser('webmestre'); |
|
| 1869 | + return autoriser('webmestre'); |
|
| 1870 | 1870 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | // mais apres la fonction autoriser() |
| 115 | 115 | if ($f = find_in_path('mes_fonctions.php')) { |
| 116 | 116 | global $dossier_squelettes; |
| 117 | - include_once(_ROOT_CWD . $f); |
|
| 117 | + include_once(_ROOT_CWD.$f); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : array(); |
| 149 | 149 | $qui = array_merge(array('statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'), $qui); |
| 150 | 150 | } elseif (is_numeric($qui)) { |
| 151 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 151 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.$qui); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // Admins restreints, on construit ici (pas generique mais...) |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | spip_log( |
| 161 | - "autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ') ?', |
|
| 162 | - 'autoriser' . _LOG_DEBUG |
|
| 161 | + "autoriser $faire $type $id (".(isset($qui['nom']) ? $qui['nom'] : '').') ?', |
|
| 162 | + 'autoriser'._LOG_DEBUG |
|
| 163 | 163 | ); |
| 164 | 164 | |
| 165 | 165 | // passer par objet_type pour avoir les alias |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | if ((isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
| 171 | 171 | or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
| 172 | 172 | ) { |
| 173 | - spip_log("autoriser ($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 173 | + spip_log("autoriser ($faire, $type, $id, ".(isset($qui['nom']) ? $qui['nom'] : '').') : OK Exception', 'autoriser'._LOG_DEBUG); |
|
| 174 | 174 | return true; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -179,18 +179,18 @@ discard block |
||
| 179 | 179 | // autoriser_faire[_dist], autoriser_defaut[_dist] |
| 180 | 180 | $fonctions = $type |
| 181 | 181 | ? array( |
| 182 | - 'autoriser_' . $type . '_' . $faire, |
|
| 183 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 184 | - 'autoriser_' . $type, |
|
| 185 | - 'autoriser_' . $type . '_dist', |
|
| 186 | - 'autoriser_' . $faire, |
|
| 187 | - 'autoriser_' . $faire . '_dist', |
|
| 182 | + 'autoriser_'.$type.'_'.$faire, |
|
| 183 | + 'autoriser_'.$type.'_'.$faire.'_dist', |
|
| 184 | + 'autoriser_'.$type, |
|
| 185 | + 'autoriser_'.$type.'_dist', |
|
| 186 | + 'autoriser_'.$faire, |
|
| 187 | + 'autoriser_'.$faire.'_dist', |
|
| 188 | 188 | 'autoriser_defaut', |
| 189 | 189 | 'autoriser_defaut_dist' |
| 190 | 190 | ) |
| 191 | 191 | : array( |
| 192 | - 'autoriser_' . $faire, |
|
| 193 | - 'autoriser_' . $faire . '_dist', |
|
| 192 | + 'autoriser_'.$faire, |
|
| 193 | + 'autoriser_'.$faire.'_dist', |
|
| 194 | 194 | 'autoriser_defaut', |
| 195 | 195 | 'autoriser_defaut_dist' |
| 196 | 196 | ); |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | spip_log( |
| 206 | - "$f($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 207 | - 'autoriser' . _LOG_DEBUG |
|
| 206 | + "$f($faire, $type, $id, ".(isset($qui['nom']) ? $qui['nom'] : '').') : '.($a ? 'OK' : 'niet'), |
|
| 207 | + 'autoriser'._LOG_DEBUG |
|
| 208 | 208 | ); |
| 209 | 209 | |
| 210 | 210 | return $a; |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | function autoriser_previsualiser_dist($faire, $type, $id, $qui, $opt) { |
| 333 | 333 | |
| 334 | 334 | // Le visiteur a-t-il un statut prevu par la config ? |
| 335 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 335 | + if (strpos($GLOBALS['meta']['preview'], ','.$qui['statut'].',') !== false) { |
|
| 336 | 336 | return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
| 337 | 337 | } |
| 338 | 338 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | } // pas de champ passe a la demande => NIET |
| 390 | 390 | $previsu = explode(',', $c['previsu']); |
| 391 | 391 | // regarder si ce statut est autorise pour l'auteur |
| 392 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 392 | + if (in_array($opt[$champ].'/auteur', $previsu)) { |
|
| 393 | 393 | |
| 394 | 394 | // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
| 395 | 395 | // sinon l’auteur en session |
@@ -404,11 +404,11 @@ discard block |
||
| 404 | 404 | |
| 405 | 405 | if (!$id_auteur) { |
| 406 | 406 | return false; |
| 407 | - } elseif(autoriser('previsualiser' . $opt[$champ], $type, '', $id_auteur)) { |
|
| 407 | + } elseif (autoriser('previsualiser'.$opt[$champ], $type, '', $id_auteur)) { |
|
| 408 | 408 | // dans ce cas (admin en general), pas de filtrage sur ce statut |
| 409 | 409 | } elseif (!sql_countsel( |
| 410 | 410 | 'spip_auteurs_liens', |
| 411 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 411 | + 'id_auteur='.intval($id_auteur).' AND objet='.sql_quote($type).' AND id_objet='.intval($id) |
|
| 412 | 412 | )) { |
| 413 | 413 | return false; |
| 414 | 414 | } // pas auteur de cet objet => NIET |
@@ -446,16 +446,16 @@ discard block |
||
| 446 | 446 | // multilinguisme par secteur et objet rattaché à une rubrique |
| 447 | 447 | $primary = id_table_objet($type); |
| 448 | 448 | if ($table != 'spip_rubriques') { |
| 449 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 449 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=".intval($id)); |
|
| 450 | 450 | } else { |
| 451 | 451 | $id_rubrique = $id; |
| 452 | 452 | } |
| 453 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 453 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 454 | 454 | if (!$id_secteur > 0) { |
| 455 | 455 | $id_secteur = $id_rubrique; |
| 456 | 456 | } |
| 457 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 458 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 457 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_secteur)); |
|
| 458 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=".intval($id)); |
|
| 459 | 459 | if ($langue_secteur != $langue_objet) { |
| 460 | 460 | // configuration incohérente, on laisse l'utilisateur corriger la situation |
| 461 | 461 | return true; |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
| 464 | 464 | return false; |
| 465 | 465 | } else { |
| 466 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 466 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique='.intval($id)); |
|
| 467 | 467 | if ($id_parent != 0) { |
| 468 | 468 | // sous-rubriques : pas de choix de langue |
| 469 | 469 | return false; |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | |
| 512 | 512 | if (!isset($opt['statut'])) { |
| 513 | 513 | if (isset($desc['field']['statut'])) { |
| 514 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 514 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type).'='.intval($id)); |
|
| 515 | 515 | } else { |
| 516 | 516 | $statut = 'publie'; |
| 517 | 517 | } // pas de statut => publie |
@@ -669,11 +669,11 @@ discard block |
||
| 669 | 669 | return false; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 672 | + if (sql_countsel('spip_rubriques', 'id_parent='.intval($id))) { |
|
| 673 | 673 | return false; |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 676 | + if (sql_countsel('spip_articles', 'id_rubrique='.intval($id)." AND (statut<>'poubelle')")) { |
|
| 677 | 677 | return false; |
| 678 | 678 | } |
| 679 | 679 | |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | * @return bool true s'il a le droit, false sinon |
| 706 | 706 | **/ |
| 707 | 707 | function autoriser_article_modifier_dist($faire, $type, $id, $qui, $opt) { |
| 708 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 708 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article='.sql_quote($id)); |
|
| 709 | 709 | |
| 710 | 710 | return |
| 711 | 711 | $r |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | (!isset($opt['statut']) or $opt['statut'] !== 'publie') |
| 717 | 717 | and in_array($qui['statut'], array('0minirezo', '1comite')) |
| 718 | 718 | and in_array($r['statut'], array('prop', 'prepa', 'poubelle')) |
| 719 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 719 | + and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur']) |
|
| 720 | 720 | ) |
| 721 | 721 | ); |
| 722 | 722 | } |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | if (!$id) { |
| 765 | 765 | return false; |
| 766 | 766 | } |
| 767 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 767 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article='.intval($id)); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | return |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | or |
| 776 | 776 | ($id |
| 777 | 777 | and $qui['id_auteur'] |
| 778 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 778 | + and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur'])); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | |
@@ -793,8 +793,8 @@ discard block |
||
| 793 | 793 | **/ |
| 794 | 794 | function autoriser_voir_dist($faire, $type, $id, $qui, $opt) { |
| 795 | 795 | # securite, mais on aurait pas du arriver ici ! |
| 796 | - if (function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 797 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist')) { |
|
| 796 | + if (function_exists($f = 'autoriser_'.$type.'_voir') |
|
| 797 | + or function_exists($f = 'autoriser_'.$type.'_voir_dist')) { |
|
| 798 | 798 | return $f($faire, $type, $id, $qui, $opt); |
| 799 | 799 | } |
| 800 | 800 | |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | $n = sql_fetsel( |
| 913 | 913 | 'A.id_article', |
| 914 | 914 | 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
| 915 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 915 | + "A.statut='publie' AND L.id_auteur=".sql_quote($id) |
|
| 916 | 916 | ); |
| 917 | 917 | |
| 918 | 918 | return $n ? true : false; |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | and $r = sql_allfetsel( |
| 1119 | 1119 | 'id_objet', |
| 1120 | 1120 | 'spip_auteurs_liens', |
| 1121 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1121 | + 'id_auteur='.intval($id_auteur)." AND objet='rubrique' AND id_objet!=0" |
|
| 1122 | 1122 | ) |
| 1123 | 1123 | and count($r) |
| 1124 | 1124 | ) { |
@@ -1733,8 +1733,8 @@ discard block |
||
| 1733 | 1733 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1734 | 1734 | $objet = objet_type($objet); |
| 1735 | 1735 | $where = array( |
| 1736 | - 'objet=' . sql_quote($objet), |
|
| 1737 | - 'id_objet=' . intval($id_objet) |
|
| 1736 | + 'objet='.sql_quote($objet), |
|
| 1737 | + 'id_objet='.intval($id_objet) |
|
| 1738 | 1738 | ); |
| 1739 | 1739 | if (!empty($cond)) { |
| 1740 | 1740 | if (is_array($cond)) { |
@@ -1768,7 +1768,7 @@ discard block |
||
| 1768 | 1768 | return sql_allfetsel( |
| 1769 | 1769 | 'id_auteur', |
| 1770 | 1770 | 'spip_auteurs_liens', |
| 1771 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1771 | + "objet='article' AND id_objet=".intval($id_article).($cond ? " AND $cond" : '') |
|
| 1772 | 1772 | ); |
| 1773 | 1773 | } |
| 1774 | 1774 | |
@@ -237,8 +237,7 @@ |
||
| 237 | 237 | if ($id === '*') { |
| 238 | 238 | unset($GLOBALS['autoriser_exception'][$faire][$type]); |
| 239 | 239 | unset($autorisation[$faire][$type]); |
| 240 | - } |
|
| 241 | - else { |
|
| 240 | + } else { |
|
| 242 | 241 | unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
| 243 | 242 | unset($autorisation[$faire][$type][$id]); |
| 244 | 243 | } |