@@ -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,81 +38,81 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | // mes_fonctions peut aussi declarer des autorisations, donc il faut donc le charger |
| 40 | 40 | if ($f = find_in_path('mes_fonctions.php')) { |
| 41 | - global $dossier_squelettes; |
|
| 42 | - include_once(_ROOT_CWD . $f); |
|
| 41 | + global $dossier_squelettes; |
|
| 42 | + include_once(_ROOT_CWD . $f); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | if (!function_exists('autoriser')) { |
| 47 | - /** |
|
| 48 | - * Autoriser une action |
|
| 49 | - * |
|
| 50 | - * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 51 | - * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 52 | - * les autorisations. |
|
| 53 | - * |
|
| 54 | - * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 55 | - * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 56 | - * dans cet ordre : |
|
| 57 | - * |
|
| 58 | - * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 59 | - * - autoriser_{type}, sinon avec _dist |
|
| 60 | - * - autoriser_{faire}, sinon avec _dist |
|
| 61 | - * - autoriser_{defaut}, sinon avec _dist |
|
| 62 | - * |
|
| 63 | - * Seul le premier argument est obligatoire. |
|
| 64 | - * |
|
| 65 | - * @note |
|
| 66 | - * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 67 | - * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 68 | - * cette valeur. |
|
| 69 | - * |
|
| 70 | - * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 71 | - * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 72 | - * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 73 | - * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 74 | - * |
|
| 75 | - * @note |
|
| 76 | - * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 77 | - * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 78 | - * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 79 | - * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 80 | - * quel serait le type, quel serait l'action ? |
|
| 81 | - * |
|
| 82 | - * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 83 | - * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 84 | - * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 85 | - * |
|
| 86 | - * @api |
|
| 87 | - * @see autoriser_dist() |
|
| 88 | - * |
|
| 89 | - * @param string $faire |
|
| 90 | - * une action ('modifier', 'publier'...) |
|
| 91 | - * @param string $type |
|
| 92 | - * type d'objet ou nom de table ('article') |
|
| 93 | - * @param int $id |
|
| 94 | - * id de l'objet sur lequel on veut agir |
|
| 95 | - * @param null|int|array $qui |
|
| 96 | - * - si null on prend alors visiteur_session |
|
| 97 | - * - un id_auteur (on regarde dans la base) |
|
| 98 | - * - un tableau auteur complet, y compris [restreint] |
|
| 99 | - * @param null|array $opt |
|
| 100 | - * options sous forme de tableau associatif |
|
| 101 | - * @return bool |
|
| 102 | - * true si la personne peut effectuer l'action |
|
| 103 | - */ |
|
| 104 | - function autoriser($faire, $type = '', $id = 0, $qui = null, $opt = null) { |
|
| 105 | - // Charger les fonctions d'autorisation supplementaires |
|
| 106 | - static $pipe; |
|
| 107 | - if (!isset($pipe)) { |
|
| 108 | - $pipe = 1; |
|
| 109 | - pipeline('autoriser'); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $args = func_get_args(); |
|
| 113 | - |
|
| 114 | - return call_user_func_array('autoriser_dist', $args); |
|
| 115 | - } |
|
| 47 | + /** |
|
| 48 | + * Autoriser une action |
|
| 49 | + * |
|
| 50 | + * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 51 | + * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 52 | + * les autorisations. |
|
| 53 | + * |
|
| 54 | + * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 55 | + * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 56 | + * dans cet ordre : |
|
| 57 | + * |
|
| 58 | + * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 59 | + * - autoriser_{type}, sinon avec _dist |
|
| 60 | + * - autoriser_{faire}, sinon avec _dist |
|
| 61 | + * - autoriser_{defaut}, sinon avec _dist |
|
| 62 | + * |
|
| 63 | + * Seul le premier argument est obligatoire. |
|
| 64 | + * |
|
| 65 | + * @note |
|
| 66 | + * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 67 | + * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 68 | + * cette valeur. |
|
| 69 | + * |
|
| 70 | + * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 71 | + * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 72 | + * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 73 | + * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 74 | + * |
|
| 75 | + * @note |
|
| 76 | + * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 77 | + * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 78 | + * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 79 | + * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 80 | + * quel serait le type, quel serait l'action ? |
|
| 81 | + * |
|
| 82 | + * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 83 | + * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 84 | + * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 85 | + * |
|
| 86 | + * @api |
|
| 87 | + * @see autoriser_dist() |
|
| 88 | + * |
|
| 89 | + * @param string $faire |
|
| 90 | + * une action ('modifier', 'publier'...) |
|
| 91 | + * @param string $type |
|
| 92 | + * type d'objet ou nom de table ('article') |
|
| 93 | + * @param int $id |
|
| 94 | + * id de l'objet sur lequel on veut agir |
|
| 95 | + * @param null|int|array $qui |
|
| 96 | + * - si null on prend alors visiteur_session |
|
| 97 | + * - un id_auteur (on regarde dans la base) |
|
| 98 | + * - un tableau auteur complet, y compris [restreint] |
|
| 99 | + * @param null|array $opt |
|
| 100 | + * options sous forme de tableau associatif |
|
| 101 | + * @return bool |
|
| 102 | + * true si la personne peut effectuer l'action |
|
| 103 | + */ |
|
| 104 | + function autoriser($faire, $type = '', $id = 0, $qui = null, $opt = null) { |
|
| 105 | + // Charger les fonctions d'autorisation supplementaires |
|
| 106 | + static $pipe; |
|
| 107 | + if (!isset($pipe)) { |
|
| 108 | + $pipe = 1; |
|
| 109 | + pipeline('autoriser'); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $args = func_get_args(); |
|
| 113 | + |
|
| 114 | + return call_user_func_array('autoriser_dist', $args); |
|
| 115 | + } |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
@@ -140,72 +140,72 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | function autoriser_dist($faire, $type = '', $id = 0, $qui = null, $opt = null) { |
| 142 | 142 | |
| 143 | - // Qui ? visiteur_session ? |
|
| 144 | - // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 145 | - if ($qui === null or $qui === '') { |
|
| 146 | - $qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : array(); |
|
| 147 | - $qui = array_merge(array('statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'), $qui); |
|
| 148 | - } elseif (is_numeric($qui)) { |
|
| 149 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - // Admins restreints, on construit ici (pas generique mais...) |
|
| 153 | - // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 154 | - if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 155 | - $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : array(); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - spip_log( |
|
| 159 | - "autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ') ?', |
|
| 160 | - 'autoriser' . _LOG_DEBUG |
|
| 161 | - ); |
|
| 162 | - |
|
| 163 | - // passer par objet_type pour avoir les alias |
|
| 164 | - // et supprimer les _ |
|
| 165 | - $type = str_replace('_', '', strncmp($type, '_', 1) == 0 ? $type : objet_type($type, false)); |
|
| 166 | - |
|
| 167 | - // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 168 | - if (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) |
|
| 169 | - and autoriser_exception($faire, $type, $id, 'verifier') |
|
| 170 | - ) { |
|
| 171 | - spip_log("autoriser ($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 172 | - return true; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - // Chercher une fonction d'autorisation |
|
| 176 | - // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 177 | - // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 178 | - $fonctions = $type |
|
| 179 | - ? array( |
|
| 180 | - 'autoriser_' . $type . '_' . $faire, |
|
| 181 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 182 | - 'autoriser_' . $type, |
|
| 183 | - 'autoriser_' . $type . '_dist', |
|
| 184 | - 'autoriser_' . $faire, |
|
| 185 | - 'autoriser_' . $faire . '_dist', |
|
| 186 | - 'autoriser_defaut', |
|
| 187 | - 'autoriser_defaut_dist' |
|
| 188 | - ) |
|
| 189 | - : array( |
|
| 190 | - 'autoriser_' . $faire, |
|
| 191 | - 'autoriser_' . $faire . '_dist', |
|
| 192 | - 'autoriser_defaut', |
|
| 193 | - 'autoriser_defaut_dist' |
|
| 194 | - ); |
|
| 195 | - |
|
| 196 | - foreach ($fonctions as $f) { |
|
| 197 | - if (function_exists($f)) { |
|
| 198 | - $a = $f($faire, $type, $id, $qui, $opt); |
|
| 199 | - break; |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - spip_log( |
|
| 204 | - "$f($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 205 | - 'autoriser' . _LOG_DEBUG |
|
| 206 | - ); |
|
| 207 | - |
|
| 208 | - return $a; |
|
| 143 | + // Qui ? visiteur_session ? |
|
| 144 | + // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 145 | + if ($qui === null or $qui === '') { |
|
| 146 | + $qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : array(); |
|
| 147 | + $qui = array_merge(array('statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'), $qui); |
|
| 148 | + } elseif (is_numeric($qui)) { |
|
| 149 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + // Admins restreints, on construit ici (pas generique mais...) |
|
| 153 | + // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 154 | + if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 155 | + $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : array(); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + spip_log( |
|
| 159 | + "autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ') ?', |
|
| 160 | + 'autoriser' . _LOG_DEBUG |
|
| 161 | + ); |
|
| 162 | + |
|
| 163 | + // passer par objet_type pour avoir les alias |
|
| 164 | + // et supprimer les _ |
|
| 165 | + $type = str_replace('_', '', strncmp($type, '_', 1) == 0 ? $type : objet_type($type, false)); |
|
| 166 | + |
|
| 167 | + // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 168 | + if (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) |
|
| 169 | + and autoriser_exception($faire, $type, $id, 'verifier') |
|
| 170 | + ) { |
|
| 171 | + spip_log("autoriser ($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 172 | + return true; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + // Chercher une fonction d'autorisation |
|
| 176 | + // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 177 | + // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 178 | + $fonctions = $type |
|
| 179 | + ? array( |
|
| 180 | + 'autoriser_' . $type . '_' . $faire, |
|
| 181 | + 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 182 | + 'autoriser_' . $type, |
|
| 183 | + 'autoriser_' . $type . '_dist', |
|
| 184 | + 'autoriser_' . $faire, |
|
| 185 | + 'autoriser_' . $faire . '_dist', |
|
| 186 | + 'autoriser_defaut', |
|
| 187 | + 'autoriser_defaut_dist' |
|
| 188 | + ) |
|
| 189 | + : array( |
|
| 190 | + 'autoriser_' . $faire, |
|
| 191 | + 'autoriser_' . $faire . '_dist', |
|
| 192 | + 'autoriser_defaut', |
|
| 193 | + 'autoriser_defaut_dist' |
|
| 194 | + ); |
|
| 195 | + |
|
| 196 | + foreach ($fonctions as $f) { |
|
| 197 | + if (function_exists($f)) { |
|
| 198 | + $a = $f($faire, $type, $id, $qui, $opt); |
|
| 199 | + break; |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + spip_log( |
|
| 204 | + "$f($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 205 | + 'autoriser' . _LOG_DEBUG |
|
| 206 | + ); |
|
| 207 | + |
|
| 208 | + return $a; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | // une globale pour aller au plus vite dans la fonction generique ci dessus |
@@ -223,20 +223,20 @@ discard block |
||
| 223 | 223 | * @return bool |
| 224 | 224 | */ |
| 225 | 225 | function autoriser_exception($faire, $type, $id, $autoriser = true) { |
| 226 | - // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 227 | - static $autorisation; |
|
| 228 | - if ($autoriser === 'verifier') { |
|
| 229 | - return isset($autorisation[$faire][$type][$id]); |
|
| 230 | - } |
|
| 231 | - if ($autoriser === true) { |
|
| 232 | - $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 233 | - } |
|
| 234 | - if ($autoriser === false) { |
|
| 235 | - unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 236 | - unset($autorisation[$faire][$type][$id]); |
|
| 237 | - } |
|
| 226 | + // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 227 | + static $autorisation; |
|
| 228 | + if ($autoriser === 'verifier') { |
|
| 229 | + return isset($autorisation[$faire][$type][$id]); |
|
| 230 | + } |
|
| 231 | + if ($autoriser === true) { |
|
| 232 | + $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 233 | + } |
|
| 234 | + if ($autoriser === false) { |
|
| 235 | + unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 236 | + unset($autorisation[$faire][$type][$id]); |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - return false; |
|
| 239 | + return false; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | * @return bool true s'il a le droit, false sinon |
| 254 | 254 | **/ |
| 255 | 255 | function autoriser_defaut_dist($faire, $type, $id, $qui, $opt) { |
| 256 | - return |
|
| 257 | - $qui['statut'] == '0minirezo' |
|
| 258 | - and !$qui['restreint']; |
|
| 256 | + return |
|
| 257 | + $qui['statut'] == '0minirezo' |
|
| 258 | + and !$qui['restreint']; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | * @return bool |
| 272 | 272 | */ |
| 273 | 273 | function autoriser_loger_dist($faire, $type, $id, $qui, $opt) { |
| 274 | - if ($qui['statut'] == '5poubelle') { |
|
| 275 | - return false; |
|
| 276 | - } |
|
| 277 | - return true; |
|
| 274 | + if ($qui['statut'] == '5poubelle') { |
|
| 275 | + return false; |
|
| 276 | + } |
|
| 277 | + return true; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * @return bool true s'il a le droit, false sinon |
| 289 | 289 | **/ |
| 290 | 290 | function autoriser_ecrire_dist($faire, $type, $id, $qui, $opt) { |
| 291 | - return isset($qui['statut']) and in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 291 | + return isset($qui['statut']) and in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | * @return bool true s'il a le droit, false sinon |
| 306 | 306 | **/ |
| 307 | 307 | function autoriser_creer_dist($faire, $type, $id, $qui, $opt) { |
| 308 | - return in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 308 | + return in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -323,18 +323,18 @@ discard block |
||
| 323 | 323 | **/ |
| 324 | 324 | function autoriser_previsualiser_dist($faire, $type, $id, $qui, $opt) { |
| 325 | 325 | |
| 326 | - // Le visiteur a-t-il un statut prevu par la config ? |
|
| 327 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 328 | - return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 329 | - } |
|
| 326 | + // Le visiteur a-t-il un statut prevu par la config ? |
|
| 327 | + if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 328 | + return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - // A-t-on un token de prévisualisation valable ? |
|
| 332 | - include_spip('inc/securiser_action'); |
|
| 333 | - if (decrire_token_previsu()) { |
|
| 334 | - return true; |
|
| 335 | - } |
|
| 331 | + // A-t-on un token de prévisualisation valable ? |
|
| 332 | + include_spip('inc/securiser_action'); |
|
| 333 | + if (decrire_token_previsu()) { |
|
| 334 | + return true; |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - return false; |
|
| 337 | + return false; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -362,57 +362,57 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | function test_previsualiser_objet_champ($type = null, $id = 0, $qui = array(), $opt = array()) { |
| 364 | 364 | |
| 365 | - // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 366 | - if (!$type) { |
|
| 367 | - return true; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - include_spip('base/objets'); |
|
| 371 | - $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 372 | - if (isset($infos['statut'])) { |
|
| 373 | - foreach ($infos['statut'] as $c) { |
|
| 374 | - if (isset($c['publie'])) { |
|
| 375 | - if (!isset($c['previsu'])) { |
|
| 376 | - return false; |
|
| 377 | - } // pas de previsu definie => NIET |
|
| 378 | - $champ = $c['champ']; |
|
| 379 | - if (!isset($opt[$champ])) { |
|
| 380 | - return false; |
|
| 381 | - } // pas de champ passe a la demande => NIET |
|
| 382 | - $previsu = explode(',', $c['previsu']); |
|
| 383 | - // regarder si ce statut est autorise pour l'auteur |
|
| 384 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 385 | - |
|
| 386 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 387 | - // sinon l’auteur en session |
|
| 388 | - include_spip('inc/securiser_action'); |
|
| 389 | - if ($desc = decrire_token_previsu()) { |
|
| 390 | - $id_auteur = $desc['id_auteur']; |
|
| 391 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 392 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 393 | - } else { |
|
| 394 | - $id_auteur = null; |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - if (!$id_auteur) { |
|
| 398 | - return false; |
|
| 399 | - } elseif(autoriser('previsualiser' . $opt[$champ], $type, '', $id_auteur)) { |
|
| 400 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 401 | - } elseif (!sql_countsel( |
|
| 402 | - 'spip_auteurs_liens', |
|
| 403 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 404 | - )) { |
|
| 405 | - return false; |
|
| 406 | - } // pas auteur de cet objet => NIET |
|
| 407 | - } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 408 | - // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 409 | - return false; |
|
| 410 | - } |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - return true; |
|
| 365 | + // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 366 | + if (!$type) { |
|
| 367 | + return true; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + include_spip('base/objets'); |
|
| 371 | + $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 372 | + if (isset($infos['statut'])) { |
|
| 373 | + foreach ($infos['statut'] as $c) { |
|
| 374 | + if (isset($c['publie'])) { |
|
| 375 | + if (!isset($c['previsu'])) { |
|
| 376 | + return false; |
|
| 377 | + } // pas de previsu definie => NIET |
|
| 378 | + $champ = $c['champ']; |
|
| 379 | + if (!isset($opt[$champ])) { |
|
| 380 | + return false; |
|
| 381 | + } // pas de champ passe a la demande => NIET |
|
| 382 | + $previsu = explode(',', $c['previsu']); |
|
| 383 | + // regarder si ce statut est autorise pour l'auteur |
|
| 384 | + if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 385 | + |
|
| 386 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 387 | + // sinon l’auteur en session |
|
| 388 | + include_spip('inc/securiser_action'); |
|
| 389 | + if ($desc = decrire_token_previsu()) { |
|
| 390 | + $id_auteur = $desc['id_auteur']; |
|
| 391 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 392 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 393 | + } else { |
|
| 394 | + $id_auteur = null; |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + if (!$id_auteur) { |
|
| 398 | + return false; |
|
| 399 | + } elseif(autoriser('previsualiser' . $opt[$champ], $type, '', $id_auteur)) { |
|
| 400 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 401 | + } elseif (!sql_countsel( |
|
| 402 | + 'spip_auteurs_liens', |
|
| 403 | + 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 404 | + )) { |
|
| 405 | + return false; |
|
| 406 | + } // pas auteur de cet objet => NIET |
|
| 407 | + } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 408 | + // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 409 | + return false; |
|
| 410 | + } |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + return true; |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -426,47 +426,47 @@ discard block |
||
| 426 | 426 | * @return bool true s'il a le droit, false sinon |
| 427 | 427 | **/ |
| 428 | 428 | function autoriser_changerlangue_dist($faire, $type, $id, $qui, $opt) { |
| 429 | - $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 430 | - $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 431 | - $table = table_objet_sql($type); |
|
| 432 | - if (in_array($table, $multi_objets) |
|
| 433 | - or in_array($table, $gerer_trad_objets)) { // affichage du formulaire si la configuration l'accepte |
|
| 434 | - $multi_secteurs = lire_config('multi_secteurs'); |
|
| 435 | - $champs = objet_info($type, 'field'); |
|
| 436 | - if ($multi_secteurs == 'oui' |
|
| 437 | - and array_key_exists('id_rubrique', $champs)) { |
|
| 438 | - // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 439 | - $primary = id_table_objet($type); |
|
| 440 | - if ($table != 'spip_rubriques') { |
|
| 441 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 442 | - } else { |
|
| 443 | - $id_rubrique = $id; |
|
| 444 | - } |
|
| 445 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 446 | - if (!$id_secteur > 0) { |
|
| 447 | - $id_secteur = $id_rubrique; |
|
| 448 | - } |
|
| 449 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 450 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 451 | - if ($langue_secteur != $langue_objet) { |
|
| 452 | - // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 453 | - return true; |
|
| 454 | - } |
|
| 455 | - if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 456 | - return false; |
|
| 457 | - } else { |
|
| 458 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 459 | - if ($id_parent != 0) { |
|
| 460 | - // sous-rubriques : pas de choix de langue |
|
| 461 | - return false; |
|
| 462 | - } |
|
| 463 | - } |
|
| 464 | - } |
|
| 465 | - } else { |
|
| 466 | - return false; |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 429 | + $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 430 | + $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 431 | + $table = table_objet_sql($type); |
|
| 432 | + if (in_array($table, $multi_objets) |
|
| 433 | + or in_array($table, $gerer_trad_objets)) { // affichage du formulaire si la configuration l'accepte |
|
| 434 | + $multi_secteurs = lire_config('multi_secteurs'); |
|
| 435 | + $champs = objet_info($type, 'field'); |
|
| 436 | + if ($multi_secteurs == 'oui' |
|
| 437 | + and array_key_exists('id_rubrique', $champs)) { |
|
| 438 | + // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 439 | + $primary = id_table_objet($type); |
|
| 440 | + if ($table != 'spip_rubriques') { |
|
| 441 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 442 | + } else { |
|
| 443 | + $id_rubrique = $id; |
|
| 444 | + } |
|
| 445 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 446 | + if (!$id_secteur > 0) { |
|
| 447 | + $id_secteur = $id_rubrique; |
|
| 448 | + } |
|
| 449 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 450 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 451 | + if ($langue_secteur != $langue_objet) { |
|
| 452 | + // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 453 | + return true; |
|
| 454 | + } |
|
| 455 | + if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 456 | + return false; |
|
| 457 | + } else { |
|
| 458 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 459 | + if ($id_parent != 0) { |
|
| 460 | + // sous-rubriques : pas de choix de langue |
|
| 461 | + return false; |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | + } else { |
|
| 466 | + return false; |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /** |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | * @return bool true s'il a le droit, false sinon |
| 481 | 481 | **/ |
| 482 | 482 | function autoriser_changertraduction_dist($faire, $type, $id, $qui, $opt) { |
| 483 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 483 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -494,28 +494,28 @@ discard block |
||
| 494 | 494 | * @return bool true s'il a le droit, false sinon |
| 495 | 495 | **/ |
| 496 | 496 | function autoriser_dater_dist($faire, $type, $id, $qui, $opt) { |
| 497 | - if (!isset($opt['statut'])) { |
|
| 498 | - $table = table_objet($type); |
|
| 499 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 500 | - $desc = $trouver_table($table); |
|
| 501 | - if (!$desc) { |
|
| 502 | - return false; |
|
| 503 | - } |
|
| 504 | - if (isset($desc['field']['statut'])) { |
|
| 505 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 506 | - } else { |
|
| 507 | - $statut = 'publie'; |
|
| 508 | - } // pas de statut => publie |
|
| 509 | - } else { |
|
| 510 | - $statut = $opt['statut']; |
|
| 511 | - } |
|
| 512 | - |
|
| 513 | - if ($statut == 'publie' |
|
| 514 | - or ($statut == 'prop' and $type == 'article' and $GLOBALS['meta']['post_dates'] == 'non')) { |
|
| 515 | - return autoriser('modifier', $type, $id); |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - return false; |
|
| 497 | + if (!isset($opt['statut'])) { |
|
| 498 | + $table = table_objet($type); |
|
| 499 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 500 | + $desc = $trouver_table($table); |
|
| 501 | + if (!$desc) { |
|
| 502 | + return false; |
|
| 503 | + } |
|
| 504 | + if (isset($desc['field']['statut'])) { |
|
| 505 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 506 | + } else { |
|
| 507 | + $statut = 'publie'; |
|
| 508 | + } // pas de statut => publie |
|
| 509 | + } else { |
|
| 510 | + $statut = $opt['statut']; |
|
| 511 | + } |
|
| 512 | + |
|
| 513 | + if ($statut == 'publie' |
|
| 514 | + or ($statut == 'prop' and $type == 'article' and $GLOBALS['meta']['post_dates'] == 'non')) { |
|
| 515 | + return autoriser('modifier', $type, $id); |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + return false; |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | /** |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | * @return bool true s'il a le droit, false sinon |
| 533 | 533 | **/ |
| 534 | 534 | function autoriser_instituer_dist($faire, $type, $id, $qui, $opt) { |
| 535 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 535 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
@@ -548,12 +548,12 @@ discard block |
||
| 548 | 548 | * @return bool true s'il a le droit, false sinon |
| 549 | 549 | **/ |
| 550 | 550 | function autoriser_rubrique_publierdans_dist($faire, $type, $id, $qui, $opt) { |
| 551 | - return |
|
| 552 | - ($qui['statut'] == '0minirezo') |
|
| 553 | - and ( |
|
| 554 | - !$qui['restreint'] or !$id |
|
| 555 | - or in_array($id, $qui['restreint']) |
|
| 556 | - ); |
|
| 551 | + return |
|
| 552 | + ($qui['statut'] == '0minirezo') |
|
| 553 | + and ( |
|
| 554 | + !$qui['restreint'] or !$id |
|
| 555 | + or in_array($id, $qui['restreint']) |
|
| 556 | + ); |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | /** |
@@ -569,10 +569,10 @@ discard block |
||
| 569 | 569 | * @return bool true s'il a le droit, false sinon |
| 570 | 570 | **/ |
| 571 | 571 | function autoriser_rubrique_creer_dist($faire, $type, $id, $qui, $opt) { |
| 572 | - return |
|
| 573 | - ((!$id and autoriser('defaut', null, null, $qui, $opt)) |
|
| 574 | - or $id and autoriser('creerrubriquedans', 'rubrique', $id, $qui, $opt) |
|
| 575 | - ); |
|
| 572 | + return |
|
| 573 | + ((!$id and autoriser('defaut', null, null, $qui, $opt)) |
|
| 574 | + or $id and autoriser('creerrubriquedans', 'rubrique', $id, $qui, $opt) |
|
| 575 | + ); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | /** |
@@ -588,10 +588,10 @@ discard block |
||
| 588 | 588 | * @return bool true s'il a le droit, false sinon |
| 589 | 589 | **/ |
| 590 | 590 | function autoriser_rubrique_creerrubriquedans_dist($faire, $type, $id, $qui, $opt) { |
| 591 | - return |
|
| 592 | - ($id or ($qui['statut'] == '0minirezo' and !$qui['restreint'])) |
|
| 593 | - and autoriser('voir', 'rubrique', $id) |
|
| 594 | - and autoriser('publierdans', 'rubrique', $id); |
|
| 591 | + return |
|
| 592 | + ($id or ($qui['statut'] == '0minirezo' and !$qui['restreint'])) |
|
| 593 | + and autoriser('voir', 'rubrique', $id) |
|
| 594 | + and autoriser('publierdans', 'rubrique', $id); |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | /** |
@@ -607,10 +607,10 @@ discard block |
||
| 607 | 607 | * @return bool true s'il a le droit, false sinon |
| 608 | 608 | **/ |
| 609 | 609 | function autoriser_rubrique_creerarticledans_dist($faire, $type, $id, $qui, $opt) { |
| 610 | - return |
|
| 611 | - $id |
|
| 612 | - and autoriser('voir', 'rubrique', $id) |
|
| 613 | - and autoriser('creer', 'article'); |
|
| 610 | + return |
|
| 611 | + $id |
|
| 612 | + and autoriser('voir', 'rubrique', $id) |
|
| 613 | + and autoriser('creer', 'article'); |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | |
@@ -627,8 +627,8 @@ discard block |
||
| 627 | 627 | * @return bool true s'il a le droit, false sinon |
| 628 | 628 | **/ |
| 629 | 629 | function autoriser_rubrique_modifier_dist($faire, $type, $id, $qui, $opt) { |
| 630 | - return |
|
| 631 | - autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 630 | + return |
|
| 631 | + autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | /** |
@@ -644,29 +644,29 @@ discard block |
||
| 644 | 644 | * @return bool true s'il a le droit, false sinon |
| 645 | 645 | **/ |
| 646 | 646 | function autoriser_rubrique_supprimer_dist($faire, $type, $id, $qui, $opt) { |
| 647 | - if (!$id = intval($id)) { |
|
| 648 | - return false; |
|
| 649 | - } |
|
| 647 | + if (!$id = intval($id)) { |
|
| 648 | + return false; |
|
| 649 | + } |
|
| 650 | 650 | |
| 651 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 652 | - return false; |
|
| 653 | - } |
|
| 651 | + if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 652 | + return false; |
|
| 653 | + } |
|
| 654 | 654 | |
| 655 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 656 | - return false; |
|
| 657 | - } |
|
| 655 | + if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 656 | + return false; |
|
| 657 | + } |
|
| 658 | 658 | |
| 659 | - $compte = pipeline( |
|
| 660 | - 'objet_compte_enfants', |
|
| 661 | - array('args' => array('objet' => 'rubrique', 'id_objet' => $id), 'data' => array()) |
|
| 662 | - ); |
|
| 663 | - foreach ($compte as $objet => $n) { |
|
| 664 | - if ($n) { |
|
| 665 | - return false; |
|
| 666 | - } |
|
| 667 | - } |
|
| 659 | + $compte = pipeline( |
|
| 660 | + 'objet_compte_enfants', |
|
| 661 | + array('args' => array('objet' => 'rubrique', 'id_objet' => $id), 'data' => array()) |
|
| 662 | + ); |
|
| 663 | + foreach ($compte as $objet => $n) { |
|
| 664 | + if ($n) { |
|
| 665 | + return false; |
|
| 666 | + } |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | - return autoriser('modifier', 'rubrique', $id); |
|
| 669 | + return autoriser('modifier', 'rubrique', $id); |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | |
@@ -684,20 +684,20 @@ discard block |
||
| 684 | 684 | * @return bool true s'il a le droit, false sinon |
| 685 | 685 | **/ |
| 686 | 686 | function autoriser_article_modifier_dist($faire, $type, $id, $qui, $opt) { |
| 687 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 687 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 688 | 688 | |
| 689 | - return |
|
| 690 | - $r |
|
| 691 | - and |
|
| 692 | - ( |
|
| 693 | - autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 694 | - or ( |
|
| 695 | - (!isset($opt['statut']) or $opt['statut'] !== 'publie') |
|
| 696 | - and in_array($qui['statut'], array('0minirezo', '1comite')) |
|
| 697 | - and in_array($r['statut'], array('prop', 'prepa', 'poubelle')) |
|
| 698 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 699 | - ) |
|
| 700 | - ); |
|
| 689 | + return |
|
| 690 | + $r |
|
| 691 | + and |
|
| 692 | + ( |
|
| 693 | + autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 694 | + or ( |
|
| 695 | + (!isset($opt['statut']) or $opt['statut'] !== 'publie') |
|
| 696 | + and in_array($qui['statut'], array('0minirezo', '1comite')) |
|
| 697 | + and in_array($r['statut'], array('prop', 'prepa', 'poubelle')) |
|
| 698 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 699 | + ) |
|
| 700 | + ); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | * @return bool true s'il a le droit, false sinon |
| 714 | 714 | **/ |
| 715 | 715 | function autoriser_article_creer_dist($faire, $type, $id, $qui, $opt) { |
| 716 | - return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], array('0minirezo', '1comite'))); |
|
| 716 | + return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], array('0minirezo', '1comite'))); |
|
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | /** |
@@ -733,28 +733,28 @@ discard block |
||
| 733 | 733 | * @return bool true s'il a le droit, false sinon |
| 734 | 734 | */ |
| 735 | 735 | function autoriser_article_voir_dist($faire, $type, $id, $qui, $opt) { |
| 736 | - if ($qui['statut'] == '0minirezo') { |
|
| 737 | - return true; |
|
| 738 | - } |
|
| 739 | - // cas des articles : depend du statut de l'article et de l'auteur |
|
| 740 | - if (isset($opt['statut'])) { |
|
| 741 | - $statut = $opt['statut']; |
|
| 742 | - } else { |
|
| 743 | - if (!$id) { |
|
| 744 | - return false; |
|
| 745 | - } |
|
| 746 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 747 | - } |
|
| 748 | - |
|
| 749 | - return |
|
| 750 | - // si on est pas auteur de l'article, |
|
| 751 | - // seuls les propose et publies sont visibles |
|
| 752 | - in_array($statut, array('prop', 'publie')) |
|
| 753 | - // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 754 | - or |
|
| 755 | - ($id |
|
| 756 | - and $qui['id_auteur'] |
|
| 757 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 736 | + if ($qui['statut'] == '0minirezo') { |
|
| 737 | + return true; |
|
| 738 | + } |
|
| 739 | + // cas des articles : depend du statut de l'article et de l'auteur |
|
| 740 | + if (isset($opt['statut'])) { |
|
| 741 | + $statut = $opt['statut']; |
|
| 742 | + } else { |
|
| 743 | + if (!$id) { |
|
| 744 | + return false; |
|
| 745 | + } |
|
| 746 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 747 | + } |
|
| 748 | + |
|
| 749 | + return |
|
| 750 | + // si on est pas auteur de l'article, |
|
| 751 | + // seuls les propose et publies sont visibles |
|
| 752 | + in_array($statut, array('prop', 'publie')) |
|
| 753 | + // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 754 | + or |
|
| 755 | + ($id |
|
| 756 | + and $qui['id_auteur'] |
|
| 757 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | |
@@ -771,22 +771,22 @@ discard block |
||
| 771 | 771 | * @return bool true s'il a le droit, false sinon |
| 772 | 772 | **/ |
| 773 | 773 | function autoriser_voir_dist($faire, $type, $id, $qui, $opt) { |
| 774 | - # securite, mais on aurait pas du arriver ici ! |
|
| 775 | - if (function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 776 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist')) { |
|
| 777 | - return $f($faire, $type, $id, $qui, $opt); |
|
| 778 | - } |
|
| 774 | + # securite, mais on aurait pas du arriver ici ! |
|
| 775 | + if (function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 776 | + or function_exists($f = 'autoriser_' . $type . '_voir_dist')) { |
|
| 777 | + return $f($faire, $type, $id, $qui, $opt); |
|
| 778 | + } |
|
| 779 | 779 | |
| 780 | - if ($qui['statut'] == '0minirezo') { |
|
| 781 | - return true; |
|
| 782 | - } |
|
| 783 | - // admins et redacteurs peuvent voir un auteur |
|
| 784 | - if ($type == 'auteur') { |
|
| 785 | - return in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 786 | - } |
|
| 787 | - // sinon par defaut tout est visible |
|
| 788 | - // sauf cas particuliers traites separemment (ie article) |
|
| 789 | - return true; |
|
| 780 | + if ($qui['statut'] == '0minirezo') { |
|
| 781 | + return true; |
|
| 782 | + } |
|
| 783 | + // admins et redacteurs peuvent voir un auteur |
|
| 784 | + if ($type == 'auteur') { |
|
| 785 | + return in_array($qui['statut'], array('0minirezo', '1comite')); |
|
| 786 | + } |
|
| 787 | + // sinon par defaut tout est visible |
|
| 788 | + // sauf cas particuliers traites separemment (ie article) |
|
| 789 | + return true; |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | |
@@ -807,12 +807,12 @@ discard block |
||
| 807 | 807 | * @return bool true s'il a le droit, false sinon |
| 808 | 808 | **/ |
| 809 | 809 | function autoriser_webmestre_dist($faire, $type, $id, $qui, $opt) { |
| 810 | - return |
|
| 811 | - (defined('_ID_WEBMESTRES') ? |
|
| 812 | - in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 813 | - : $qui['webmestre'] == 'oui') |
|
| 814 | - and $qui['statut'] == '0minirezo' |
|
| 815 | - and !$qui['restreint']; |
|
| 810 | + return |
|
| 811 | + (defined('_ID_WEBMESTRES') ? |
|
| 812 | + in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 813 | + : $qui['webmestre'] == 'oui') |
|
| 814 | + and $qui['statut'] == '0minirezo' |
|
| 815 | + and !$qui['restreint']; |
|
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | /** |
@@ -828,9 +828,9 @@ discard block |
||
| 828 | 828 | * @return bool true s'il a le droit, false sinon |
| 829 | 829 | **/ |
| 830 | 830 | function autoriser_configurer_dist($faire, $type, $id, $qui, $opt) { |
| 831 | - return |
|
| 832 | - $qui['statut'] == '0minirezo' |
|
| 833 | - and !$qui['restreint']; |
|
| 831 | + return |
|
| 832 | + $qui['statut'] == '0minirezo' |
|
| 833 | + and !$qui['restreint']; |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | /** |
@@ -846,8 +846,8 @@ discard block |
||
| 846 | 846 | * @return bool true s'il a le droit, false sinon |
| 847 | 847 | **/ |
| 848 | 848 | function autoriser_sauvegarder_dist($faire, $type, $id, $qui, $opt) { |
| 849 | - return |
|
| 850 | - $qui['statut'] == '0minirezo'; |
|
| 849 | + return |
|
| 850 | + $qui['statut'] == '0minirezo'; |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | /** |
@@ -863,8 +863,8 @@ discard block |
||
| 863 | 863 | * @return bool true s'il a le droit, false sinon |
| 864 | 864 | **/ |
| 865 | 865 | function autoriser_detruire_dist($faire, $type, $id, $qui, $opt) { |
| 866 | - return |
|
| 867 | - autoriser('webmestre', null, null, $qui, $opt); |
|
| 866 | + return |
|
| 867 | + autoriser('webmestre', null, null, $qui, $opt); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | /** |
@@ -881,20 +881,20 @@ discard block |
||
| 881 | 881 | * @return bool true s'il a le droit, false sinon |
| 882 | 882 | **/ |
| 883 | 883 | function autoriser_auteur_previsualiser_dist($faire, $type, $id, $qui, $opt) { |
| 884 | - // les admins peuvent "previsualiser" une page auteur |
|
| 885 | - if ($qui['statut'] == '0minirezo' |
|
| 886 | - and !$qui['restreint'] |
|
| 887 | - ) { |
|
| 888 | - return true; |
|
| 889 | - } |
|
| 890 | - // "Voir en ligne" si l'auteur a un article publie |
|
| 891 | - $n = sql_fetsel( |
|
| 892 | - 'A.id_article', |
|
| 893 | - 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 894 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 895 | - ); |
|
| 884 | + // les admins peuvent "previsualiser" une page auteur |
|
| 885 | + if ($qui['statut'] == '0minirezo' |
|
| 886 | + and !$qui['restreint'] |
|
| 887 | + ) { |
|
| 888 | + return true; |
|
| 889 | + } |
|
| 890 | + // "Voir en ligne" si l'auteur a un article publie |
|
| 891 | + $n = sql_fetsel( |
|
| 892 | + 'A.id_article', |
|
| 893 | + 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 894 | + "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 895 | + ); |
|
| 896 | 896 | |
| 897 | - return $n ? true : false; |
|
| 897 | + return $n ? true : false; |
|
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | * @return bool true s'il a le droit, false sinon |
| 923 | 923 | **/ |
| 924 | 924 | function autoriser_auteur_creer_dist($faire, $type, $id, $qui, $opt) { |
| 925 | - return ($qui['statut'] == '0minirezo'); |
|
| 925 | + return ($qui['statut'] == '0minirezo'); |
|
| 926 | 926 | } |
| 927 | 927 | |
| 928 | 928 | |
@@ -942,78 +942,78 @@ discard block |
||
| 942 | 942 | **/ |
| 943 | 943 | function autoriser_auteur_modifier_dist($faire, $type, $id, $qui, $opt) { |
| 944 | 944 | |
| 945 | - // Ni admin ni redacteur => non |
|
| 946 | - if (!in_array($qui['statut'], array('0minirezo', '1comite'))) { |
|
| 947 | - return false; |
|
| 948 | - } |
|
| 949 | - |
|
| 950 | - // Un redacteur peut modifier ses propres donnees mais ni son login/email |
|
| 951 | - // ni son statut (qui sont le cas echeant passes comme option) |
|
| 952 | - if ($qui['statut'] == '1comite') { |
|
| 953 | - if (!empty($opt['webmestre'])) { |
|
| 954 | - return false; |
|
| 955 | - } elseif ( |
|
| 956 | - !empty($opt['statut']) |
|
| 957 | - or !empty($opt['restreintes']) |
|
| 958 | - or !empty($opt['email']) |
|
| 959 | - ) { |
|
| 960 | - return false; |
|
| 961 | - } elseif ($id == $qui['id_auteur']) { |
|
| 962 | - return true; |
|
| 963 | - } else { |
|
| 964 | - return false; |
|
| 965 | - } |
|
| 966 | - } |
|
| 967 | - |
|
| 968 | - // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 969 | - // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 970 | - if ($qui['restreint']) { |
|
| 971 | - if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 972 | - return false; |
|
| 973 | - } elseif ((isset($opt['statut']) and ($opt['statut'] == '0minirezo')) |
|
| 974 | - or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 975 | - ) { |
|
| 976 | - return false; |
|
| 977 | - } else { |
|
| 978 | - if ($id == $qui['id_auteur']) { |
|
| 979 | - if (isset($opt['statut']) and $opt['statut']) { |
|
| 980 | - return false; |
|
| 981 | - } else { |
|
| 982 | - return true; |
|
| 983 | - } |
|
| 984 | - } else { |
|
| 985 | - if ($id_auteur = intval($id)) { |
|
| 986 | - $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 987 | - if ($t and $t['statut'] != '0minirezo') { |
|
| 988 | - return true; |
|
| 989 | - } else { |
|
| 990 | - return false; |
|
| 991 | - } |
|
| 992 | - } // id = 0 => creation |
|
| 993 | - else { |
|
| 994 | - return true; |
|
| 995 | - } |
|
| 996 | - } |
|
| 997 | - } |
|
| 998 | - } |
|
| 999 | - |
|
| 1000 | - // Un admin complet fait ce qu'il veut |
|
| 1001 | - // sauf se degrader |
|
| 1002 | - if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1003 | - return false; |
|
| 1004 | - } elseif (isset($opt['webmestre']) |
|
| 1005 | - and $opt['webmestre'] |
|
| 1006 | - and (defined('_ID_WEBMESTRES') |
|
| 1007 | - or !autoriser('webmestre'))) { |
|
| 1008 | - // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1009 | - // ou si les webmestres sont fixes par constante (securite) |
|
| 1010 | - return false; |
|
| 1011 | - } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1012 | - elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) { |
|
| 1013 | - return false; |
|
| 1014 | - } else { |
|
| 1015 | - return true; |
|
| 1016 | - } |
|
| 945 | + // Ni admin ni redacteur => non |
|
| 946 | + if (!in_array($qui['statut'], array('0minirezo', '1comite'))) { |
|
| 947 | + return false; |
|
| 948 | + } |
|
| 949 | + |
|
| 950 | + // Un redacteur peut modifier ses propres donnees mais ni son login/email |
|
| 951 | + // ni son statut (qui sont le cas echeant passes comme option) |
|
| 952 | + if ($qui['statut'] == '1comite') { |
|
| 953 | + if (!empty($opt['webmestre'])) { |
|
| 954 | + return false; |
|
| 955 | + } elseif ( |
|
| 956 | + !empty($opt['statut']) |
|
| 957 | + or !empty($opt['restreintes']) |
|
| 958 | + or !empty($opt['email']) |
|
| 959 | + ) { |
|
| 960 | + return false; |
|
| 961 | + } elseif ($id == $qui['id_auteur']) { |
|
| 962 | + return true; |
|
| 963 | + } else { |
|
| 964 | + return false; |
|
| 965 | + } |
|
| 966 | + } |
|
| 967 | + |
|
| 968 | + // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 969 | + // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 970 | + if ($qui['restreint']) { |
|
| 971 | + if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 972 | + return false; |
|
| 973 | + } elseif ((isset($opt['statut']) and ($opt['statut'] == '0minirezo')) |
|
| 974 | + or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 975 | + ) { |
|
| 976 | + return false; |
|
| 977 | + } else { |
|
| 978 | + if ($id == $qui['id_auteur']) { |
|
| 979 | + if (isset($opt['statut']) and $opt['statut']) { |
|
| 980 | + return false; |
|
| 981 | + } else { |
|
| 982 | + return true; |
|
| 983 | + } |
|
| 984 | + } else { |
|
| 985 | + if ($id_auteur = intval($id)) { |
|
| 986 | + $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 987 | + if ($t and $t['statut'] != '0minirezo') { |
|
| 988 | + return true; |
|
| 989 | + } else { |
|
| 990 | + return false; |
|
| 991 | + } |
|
| 992 | + } // id = 0 => creation |
|
| 993 | + else { |
|
| 994 | + return true; |
|
| 995 | + } |
|
| 996 | + } |
|
| 997 | + } |
|
| 998 | + } |
|
| 999 | + |
|
| 1000 | + // Un admin complet fait ce qu'il veut |
|
| 1001 | + // sauf se degrader |
|
| 1002 | + if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1003 | + return false; |
|
| 1004 | + } elseif (isset($opt['webmestre']) |
|
| 1005 | + and $opt['webmestre'] |
|
| 1006 | + and (defined('_ID_WEBMESTRES') |
|
| 1007 | + or !autoriser('webmestre'))) { |
|
| 1008 | + // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1009 | + // ou si les webmestres sont fixes par constante (securite) |
|
| 1010 | + return false; |
|
| 1011 | + } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1012 | + elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) { |
|
| 1013 | + return false; |
|
| 1014 | + } else { |
|
| 1015 | + return true; |
|
| 1016 | + } |
|
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | * @return bool true s'il a le droit, false sinon |
| 1031 | 1031 | **/ |
| 1032 | 1032 | function autoriser_associerauteurs_dist($faire, $type, $id, $qui, $opt) { |
| 1033 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1033 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | * @return bool true s'il a le droit, false sinon |
| 1048 | 1048 | **/ |
| 1049 | 1049 | function autoriser_chargerftp_dist($faire, $type, $id, $qui, $opt) { |
| 1050 | - return $qui['statut'] == '0minirezo'; |
|
| 1050 | + return $qui['statut'] == '0minirezo'; |
|
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | /** |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | * @return bool true s'il a le droit, false sinon |
| 1064 | 1064 | **/ |
| 1065 | 1065 | function autoriser_debug_dist($faire, $type, $id, $qui, $opt) { |
| 1066 | - return $qui['statut'] == '0minirezo'; |
|
| 1066 | + return $qui['statut'] == '0minirezo'; |
|
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | /** |
@@ -1080,52 +1080,52 @@ discard block |
||
| 1080 | 1080 | * @return array Liste des rubriques |
| 1081 | 1081 | **/ |
| 1082 | 1082 | function liste_rubriques_auteur($id_auteur, $raz = false) { |
| 1083 | - static $restreint = array(); |
|
| 1084 | - |
|
| 1085 | - if (!$id_auteur = intval($id_auteur)) { |
|
| 1086 | - return array(); |
|
| 1087 | - } |
|
| 1088 | - if ($raz) { |
|
| 1089 | - unset($restreint[$id_auteur]); |
|
| 1090 | - } elseif (isset($restreint[$id_auteur])) { |
|
| 1091 | - return $restreint[$id_auteur]; |
|
| 1092 | - } |
|
| 1093 | - |
|
| 1094 | - $rubriques = array(); |
|
| 1095 | - if ((!isset($GLOBALS['meta']['version_installee']) |
|
| 1096 | - or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1097 | - and $r = sql_allfetsel( |
|
| 1098 | - 'id_objet', |
|
| 1099 | - 'spip_auteurs_liens', |
|
| 1100 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1101 | - ) |
|
| 1102 | - and count($r) |
|
| 1103 | - ) { |
|
| 1104 | - $r = array_map('reset', $r); |
|
| 1105 | - |
|
| 1106 | - // recuperer toute la branche, au format chaine enumeration |
|
| 1107 | - include_spip('inc/rubriques'); |
|
| 1108 | - $r = calcul_branche_in($r); |
|
| 1109 | - $r = explode(',', $r); |
|
| 1110 | - |
|
| 1111 | - // passer les rubriques en index, elimine les doublons |
|
| 1112 | - $r = array_flip($r); |
|
| 1113 | - // recuperer les index seuls |
|
| 1114 | - $r = array_keys($r); |
|
| 1115 | - // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1116 | - // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1117 | - $rubriques = array_combine($r, $r); |
|
| 1118 | - } |
|
| 1119 | - |
|
| 1120 | - // Affecter l'auteur session le cas echeant |
|
| 1121 | - if (isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1122 | - and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1123 | - ) { |
|
| 1124 | - $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1125 | - } |
|
| 1126 | - |
|
| 1127 | - |
|
| 1128 | - return $restreint[$id_auteur] = $rubriques; |
|
| 1083 | + static $restreint = array(); |
|
| 1084 | + |
|
| 1085 | + if (!$id_auteur = intval($id_auteur)) { |
|
| 1086 | + return array(); |
|
| 1087 | + } |
|
| 1088 | + if ($raz) { |
|
| 1089 | + unset($restreint[$id_auteur]); |
|
| 1090 | + } elseif (isset($restreint[$id_auteur])) { |
|
| 1091 | + return $restreint[$id_auteur]; |
|
| 1092 | + } |
|
| 1093 | + |
|
| 1094 | + $rubriques = array(); |
|
| 1095 | + if ((!isset($GLOBALS['meta']['version_installee']) |
|
| 1096 | + or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1097 | + and $r = sql_allfetsel( |
|
| 1098 | + 'id_objet', |
|
| 1099 | + 'spip_auteurs_liens', |
|
| 1100 | + 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1101 | + ) |
|
| 1102 | + and count($r) |
|
| 1103 | + ) { |
|
| 1104 | + $r = array_map('reset', $r); |
|
| 1105 | + |
|
| 1106 | + // recuperer toute la branche, au format chaine enumeration |
|
| 1107 | + include_spip('inc/rubriques'); |
|
| 1108 | + $r = calcul_branche_in($r); |
|
| 1109 | + $r = explode(',', $r); |
|
| 1110 | + |
|
| 1111 | + // passer les rubriques en index, elimine les doublons |
|
| 1112 | + $r = array_flip($r); |
|
| 1113 | + // recuperer les index seuls |
|
| 1114 | + $r = array_keys($r); |
|
| 1115 | + // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1116 | + // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1117 | + $rubriques = array_combine($r, $r); |
|
| 1118 | + } |
|
| 1119 | + |
|
| 1120 | + // Affecter l'auteur session le cas echeant |
|
| 1121 | + if (isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1122 | + and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1123 | + ) { |
|
| 1124 | + $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1125 | + } |
|
| 1126 | + |
|
| 1127 | + |
|
| 1128 | + return $restreint[$id_auteur] = $rubriques; |
|
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | 1131 | /** |
@@ -1141,7 +1141,7 @@ discard block |
||
| 1141 | 1141 | * @return bool true s'il a le droit, false sinon |
| 1142 | 1142 | **/ |
| 1143 | 1143 | function autoriser_modifierurl_dist($faire, $type, $id, $qui, $opt) { |
| 1144 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1144 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | /** |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | * @return bool true s'il a le droit, false sinon |
| 1158 | 1158 | **/ |
| 1159 | 1159 | function autoriser_rubrique_previsualiser_dist($faire, $type, $id, $qui, $opt) { |
| 1160 | - return autoriser('previsualiser'); |
|
| 1160 | + return autoriser('previsualiser'); |
|
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | /** |
@@ -1173,7 +1173,7 @@ discard block |
||
| 1173 | 1173 | * @return bool true s'il a le droit, false sinon |
| 1174 | 1174 | **/ |
| 1175 | 1175 | function autoriser_rubrique_iconifier_dist($faire, $type, $id, $qui, $opt) { |
| 1176 | - return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1176 | + return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | /** |
@@ -1189,8 +1189,8 @@ discard block |
||
| 1189 | 1189 | * @return bool true s'il a le droit, false sinon |
| 1190 | 1190 | **/ |
| 1191 | 1191 | function autoriser_auteur_iconifier_dist($faire, $type, $id, $qui, $opt) { |
| 1192 | - return (($id == $qui['id_auteur']) or |
|
| 1193 | - (($qui['statut'] == '0minirezo') and !$qui['restreint'])); |
|
| 1192 | + return (($id == $qui['id_auteur']) or |
|
| 1193 | + (($qui['statut'] == '0minirezo') and !$qui['restreint'])); |
|
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | 1196 | /** |
@@ -1206,8 +1206,8 @@ discard block |
||
| 1206 | 1206 | * @return bool true s'il a le droit, false sinon |
| 1207 | 1207 | **/ |
| 1208 | 1208 | function autoriser_iconifier_dist($faire, $type, $id, $qui, $opt) { |
| 1209 | - // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1210 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1209 | + // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1210 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1211 | 1211 | } |
| 1212 | 1212 | |
| 1213 | 1213 | |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | * @return bool true |
| 1226 | 1226 | **/ |
| 1227 | 1227 | function autoriser_ok_dist($faire, $type, $id, $qui, $opt) { |
| 1228 | - return true; |
|
| 1228 | + return true; |
|
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | /** |
@@ -1242,7 +1242,7 @@ discard block |
||
| 1242 | 1242 | * @return bool false |
| 1243 | 1243 | **/ |
| 1244 | 1244 | function autoriser_niet_dist($faire, $type, $id, $qui, $opt) { |
| 1245 | - return false; |
|
| 1245 | + return false; |
|
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | /** |
@@ -1258,11 +1258,11 @@ discard block |
||
| 1258 | 1258 | * @return bool false |
| 1259 | 1259 | **/ |
| 1260 | 1260 | function autoriser_base_reparer_dist($faire, $type, $id, $qui, $opt) { |
| 1261 | - if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1262 | - return false; |
|
| 1263 | - } |
|
| 1261 | + if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1262 | + return false; |
|
| 1263 | + } |
|
| 1264 | 1264 | |
| 1265 | - return true; |
|
| 1265 | + return true; |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | /** |
@@ -1278,7 +1278,7 @@ discard block |
||
| 1278 | 1278 | * @return bool true s'il a le droit, false sinon |
| 1279 | 1279 | **/ |
| 1280 | 1280 | function autoriser_infosperso_dist($faire, $type, $id, $qui, $opt) { |
| 1281 | - return true; |
|
| 1281 | + return true; |
|
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | 1284 | /** |
@@ -1294,7 +1294,7 @@ discard block |
||
| 1294 | 1294 | * @return bool true s'il a le droit, false sinon |
| 1295 | 1295 | **/ |
| 1296 | 1296 | function autoriser_langage_configurer_dist($faire, $type, $id, $qui, $opt) { |
| 1297 | - return true; |
|
| 1297 | + return true; |
|
| 1298 | 1298 | } |
| 1299 | 1299 | |
| 1300 | 1300 | /** |
@@ -1310,7 +1310,7 @@ discard block |
||
| 1310 | 1310 | * @return bool true s'il a le droit, false sinon |
| 1311 | 1311 | **/ |
| 1312 | 1312 | function autoriser_configurerlangage_dist($faire, $type, $id, $qui, $opt) { |
| 1313 | - return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1313 | + return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | /** |
@@ -1326,7 +1326,7 @@ discard block |
||
| 1326 | 1326 | * @return bool true s'il a le droit, false sinon |
| 1327 | 1327 | **/ |
| 1328 | 1328 | function autoriser_preferences_configurer_dist($faire, $type, $id, $qui, $opt) { |
| 1329 | - return true; |
|
| 1329 | + return true; |
|
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | 1332 | /** |
@@ -1342,7 +1342,7 @@ discard block |
||
| 1342 | 1342 | * @return bool true s'il a le droit, false sinon |
| 1343 | 1343 | **/ |
| 1344 | 1344 | function autoriser_configurerpreferences_dist($faire, $type, $id, $qui, $opt) { |
| 1345 | - return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1345 | + return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | /** |
@@ -1358,8 +1358,8 @@ discard block |
||
| 1358 | 1358 | * @return bool true s'il a le droit, false sinon |
| 1359 | 1359 | **/ |
| 1360 | 1360 | function autoriser_menudeveloppement_menugrandeentree_dist($faire, $type, $id, $qui, $opt) { |
| 1361 | - return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1362 | - and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] == 'oui'); |
|
| 1361 | + return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1362 | + and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] == 'oui'); |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | /** |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | * @return bool true s'il a le droit, false sinon |
| 1377 | 1377 | **/ |
| 1378 | 1378 | function autoriser_menugrandeentree_dist($faire, $type, $id, $qui, $opt) { |
| 1379 | - return true; |
|
| 1379 | + return true; |
|
| 1380 | 1380 | } |
| 1381 | 1381 | |
| 1382 | 1382 | /** |
@@ -1392,7 +1392,7 @@ discard block |
||
| 1392 | 1392 | * @return bool true s'il a le droit, false sinon |
| 1393 | 1393 | **/ |
| 1394 | 1394 | function autoriser_auteurs_voir_dist($faire, $type, $id, $qui, $opt) { |
| 1395 | - return true; |
|
| 1395 | + return true; |
|
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | /** |
@@ -1408,7 +1408,7 @@ discard block |
||
| 1408 | 1408 | * @return bool true s'il a le droit, false sinon |
| 1409 | 1409 | **/ |
| 1410 | 1410 | function autoriser_auteurs_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1411 | - return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1411 | + return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | 1414 | /** |
@@ -1424,7 +1424,7 @@ discard block |
||
| 1424 | 1424 | * @return bool true s'il a le droit, false sinon |
| 1425 | 1425 | **/ |
| 1426 | 1426 | function autoriser_articles_voir_dist($faire, $type, $id, $qui, $opt) { |
| 1427 | - return true; |
|
| 1427 | + return true; |
|
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | 1430 | /** |
@@ -1440,7 +1440,7 @@ discard block |
||
| 1440 | 1440 | * @return bool true s'il a le droit, false sinon |
| 1441 | 1441 | **/ |
| 1442 | 1442 | function autoriser_articles_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1443 | - return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1443 | + return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | 1446 | /** |
@@ -1456,7 +1456,7 @@ discard block |
||
| 1456 | 1456 | * @return bool true s'il a le droit, false sinon |
| 1457 | 1457 | **/ |
| 1458 | 1458 | function autoriser_rubriques_voir_dist($faire, $type, $id, $qui, $opt) { |
| 1459 | - return true; |
|
| 1459 | + return true; |
|
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | 1462 | /** |
@@ -1472,7 +1472,7 @@ discard block |
||
| 1472 | 1472 | * @return bool true s'il a le droit, false sinon |
| 1473 | 1473 | **/ |
| 1474 | 1474 | function autoriser_rubriques_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1475 | - return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1475 | + return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1476 | 1476 | } |
| 1477 | 1477 | |
| 1478 | 1478 | /** |
@@ -1488,7 +1488,7 @@ discard block |
||
| 1488 | 1488 | * @return bool true s'il a le droit, false sinon |
| 1489 | 1489 | **/ |
| 1490 | 1490 | function autoriser_articlecreer_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1491 | - return verifier_table_non_vide(); |
|
| 1491 | + return verifier_table_non_vide(); |
|
| 1492 | 1492 | } |
| 1493 | 1493 | |
| 1494 | 1494 | |
@@ -1507,7 +1507,7 @@ discard block |
||
| 1507 | 1507 | * @return bool true s'il a le droit, false sinon |
| 1508 | 1508 | **/ |
| 1509 | 1509 | function autoriser_auteurcreer_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1510 | - return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1510 | + return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | 1513 | /** |
@@ -1523,13 +1523,13 @@ discard block |
||
| 1523 | 1523 | * @return bool true s'il a le droit, false sinon |
| 1524 | 1524 | **/ |
| 1525 | 1525 | function autoriser_visiteurs_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1526 | - include_spip('base/abstract_sql'); |
|
| 1527 | - return |
|
| 1528 | - $qui['statut'] == '0minirezo' and !$qui['restreint'] |
|
| 1529 | - and ( |
|
| 1530 | - $GLOBALS['meta']["accepter_visiteurs"] != 'non' |
|
| 1531 | - or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1532 | - ); |
|
| 1526 | + include_spip('base/abstract_sql'); |
|
| 1527 | + return |
|
| 1528 | + $qui['statut'] == '0minirezo' and !$qui['restreint'] |
|
| 1529 | + and ( |
|
| 1530 | + $GLOBALS['meta']["accepter_visiteurs"] != 'non' |
|
| 1531 | + or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1532 | + ); |
|
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | /** |
@@ -1545,7 +1545,7 @@ discard block |
||
| 1545 | 1545 | * @return bool true s'il a le droit, false sinon |
| 1546 | 1546 | **/ |
| 1547 | 1547 | function autoriser_suiviedito_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1548 | - return $qui['statut'] == '0minirezo'; |
|
| 1548 | + return $qui['statut'] == '0minirezo'; |
|
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | 1551 | /** |
@@ -1561,7 +1561,7 @@ discard block |
||
| 1561 | 1561 | * @return bool true s'il a le droit, false sinon |
| 1562 | 1562 | **/ |
| 1563 | 1563 | function autoriser_synchro_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1564 | - return $qui['statut'] == '0minirezo'; |
|
| 1564 | + return $qui['statut'] == '0minirezo'; |
|
| 1565 | 1565 | } |
| 1566 | 1566 | |
| 1567 | 1567 | /** |
@@ -1689,7 +1689,7 @@ discard block |
||
| 1689 | 1689 | * @return bool true s'il a le droit, false sinon |
| 1690 | 1690 | **/ |
| 1691 | 1691 | function autoriser_queue_purger_dist($faire, $type, $id, $qui, $opt) { |
| 1692 | - return autoriser('webmestre'); |
|
| 1692 | + return autoriser('webmestre'); |
|
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | 1695 | |
@@ -1707,11 +1707,11 @@ discard block |
||
| 1707 | 1707 | * @return bool true s'il a le droit, false sinon |
| 1708 | 1708 | **/ |
| 1709 | 1709 | function autoriser_echafauder_dist($faire, $type, $id, $qui, $opt) { |
| 1710 | - if (test_espace_prive()) { |
|
| 1711 | - return intval($qui['id_auteur']) ? true : false; |
|
| 1712 | - } else { |
|
| 1713 | - return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1714 | - } |
|
| 1710 | + if (test_espace_prive()) { |
|
| 1711 | + return intval($qui['id_auteur']) ? true : false; |
|
| 1712 | + } else { |
|
| 1713 | + return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1714 | + } |
|
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | 1717 | |
@@ -1726,27 +1726,27 @@ discard block |
||
| 1726 | 1726 | * Identifiants d'auteurs |
| 1727 | 1727 | */ |
| 1728 | 1728 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1729 | - $objet = objet_type($objet); |
|
| 1730 | - $where = array( |
|
| 1731 | - 'objet=' . sql_quote($objet), |
|
| 1732 | - 'id_objet=' . intval($id_objet) |
|
| 1733 | - ); |
|
| 1734 | - if (!empty($cond)) { |
|
| 1735 | - if (is_array($cond)) { |
|
| 1736 | - $where = array_merge($where, $cond); |
|
| 1737 | - } else { |
|
| 1738 | - $where[] = $cond; |
|
| 1739 | - } |
|
| 1740 | - } |
|
| 1741 | - $auteurs = sql_allfetsel( |
|
| 1742 | - 'id_auteur', |
|
| 1743 | - 'spip_auteurs_liens', |
|
| 1744 | - $where |
|
| 1745 | - ); |
|
| 1746 | - if (is_array($auteurs)) { |
|
| 1747 | - return array_map('reset', $auteurs); |
|
| 1748 | - } |
|
| 1749 | - return array(); |
|
| 1729 | + $objet = objet_type($objet); |
|
| 1730 | + $where = array( |
|
| 1731 | + 'objet=' . sql_quote($objet), |
|
| 1732 | + 'id_objet=' . intval($id_objet) |
|
| 1733 | + ); |
|
| 1734 | + if (!empty($cond)) { |
|
| 1735 | + if (is_array($cond)) { |
|
| 1736 | + $where = array_merge($where, $cond); |
|
| 1737 | + } else { |
|
| 1738 | + $where[] = $cond; |
|
| 1739 | + } |
|
| 1740 | + } |
|
| 1741 | + $auteurs = sql_allfetsel( |
|
| 1742 | + 'id_auteur', |
|
| 1743 | + 'spip_auteurs_liens', |
|
| 1744 | + $where |
|
| 1745 | + ); |
|
| 1746 | + if (is_array($auteurs)) { |
|
| 1747 | + return array_map('reset', $auteurs); |
|
| 1748 | + } |
|
| 1749 | + return array(); |
|
| 1750 | 1750 | } |
| 1751 | 1751 | |
| 1752 | 1752 | /** |
@@ -1760,11 +1760,11 @@ discard block |
||
| 1760 | 1760 | * - false : serveur SQL indisponible |
| 1761 | 1761 | */ |
| 1762 | 1762 | function auteurs_article($id_article, $cond = '') { |
| 1763 | - return sql_allfetsel( |
|
| 1764 | - 'id_auteur', |
|
| 1765 | - 'spip_auteurs_liens', |
|
| 1766 | - "objet='article' AND id_objet=$id_article" . ($cond ? " AND $cond" : '') |
|
| 1767 | - ); |
|
| 1763 | + return sql_allfetsel( |
|
| 1764 | + 'id_auteur', |
|
| 1765 | + 'spip_auteurs_liens', |
|
| 1766 | + "objet='article' AND id_objet=$id_article" . ($cond ? " AND $cond" : '') |
|
| 1767 | + ); |
|
| 1768 | 1768 | } |
| 1769 | 1769 | |
| 1770 | 1770 | |
@@ -1778,7 +1778,7 @@ discard block |
||
| 1778 | 1778 | */ |
| 1779 | 1779 | function acces_restreint_rubrique($id_rubrique) { |
| 1780 | 1780 | |
| 1781 | - return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1781 | + return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1782 | 1782 | } |
| 1783 | 1783 | |
| 1784 | 1784 | |
@@ -1791,12 +1791,12 @@ discard block |
||
| 1791 | 1791 | * @return bool true si un parent existe |
| 1792 | 1792 | */ |
| 1793 | 1793 | function verifier_table_non_vide($table = 'spip_rubriques') { |
| 1794 | - static $done = array(); |
|
| 1795 | - if (!isset($done[$table])) { |
|
| 1796 | - $done[$table] = sql_countsel($table) > 0; |
|
| 1797 | - } |
|
| 1794 | + static $done = array(); |
|
| 1795 | + if (!isset($done[$table])) { |
|
| 1796 | + $done[$table] = sql_countsel($table) > 0; |
|
| 1797 | + } |
|
| 1798 | 1798 | |
| 1799 | - return $done[$table]; |
|
| 1799 | + return $done[$table]; |
|
| 1800 | 1800 | } |
| 1801 | 1801 | |
| 1802 | 1802 | /** |
@@ -1821,15 +1821,15 @@ discard block |
||
| 1821 | 1821 | */ |
| 1822 | 1822 | function autoriser_inscrireauteur_dist($faire, $quoi, $id, $qui, $opt) { |
| 1823 | 1823 | |
| 1824 | - $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 1825 | - switch ($s) { |
|
| 1826 | - case 'info_redacteurs': |
|
| 1827 | - return ($GLOBALS['meta']['accepter_inscriptions'] == 'oui'); |
|
| 1828 | - case 'info_visiteurs': |
|
| 1829 | - return ($GLOBALS['meta']['accepter_visiteurs'] == 'oui' or $GLOBALS['meta']['forums_publics'] == 'abo'); |
|
| 1830 | - } |
|
| 1824 | + $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 1825 | + switch ($s) { |
|
| 1826 | + case 'info_redacteurs': |
|
| 1827 | + return ($GLOBALS['meta']['accepter_inscriptions'] == 'oui'); |
|
| 1828 | + case 'info_visiteurs': |
|
| 1829 | + return ($GLOBALS['meta']['accepter_visiteurs'] == 'oui' or $GLOBALS['meta']['forums_publics'] == 'abo'); |
|
| 1830 | + } |
|
| 1831 | 1831 | |
| 1832 | - return false; |
|
| 1832 | + return false; |
|
| 1833 | 1833 | } |
| 1834 | 1834 | |
| 1835 | 1835 | |
@@ -1846,5 +1846,5 @@ discard block |
||
| 1846 | 1846 | * @return bool true s'il a le droit, false sinon |
| 1847 | 1847 | **/ |
| 1848 | 1848 | function autoriser_phpinfos($faire, $type, $id, $qui, $opt) { |
| 1849 | - return autoriser('webmestre'); |
|
| 1849 | + return autoriser('webmestre'); |
|
| 1850 | 1850 | } |