@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Rubriques\Edition |
| 17 | 17 | */ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/rubriques'); |
@@ -38,34 +38,34 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | function action_editer_rubrique_dist($arg = null) { |
| 40 | 40 | |
| 41 | - if (is_null($arg)) { |
|
| 42 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 43 | - $arg = $securiser_action(); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - if (!$id_rubrique = intval($arg)) { |
|
| 47 | - if ($arg != 'oui') { |
|
| 48 | - include_spip('inc/headers'); |
|
| 49 | - redirige_url_ecrire(); |
|
| 50 | - } |
|
| 51 | - $id_rubrique = rubrique_inserer(_request('id_parent')); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - $err = rubrique_modifier($id_rubrique); |
|
| 55 | - |
|
| 56 | - if (_request('redirect')) { |
|
| 57 | - $redirect = parametre_url( |
|
| 58 | - urldecode(_request('redirect')), |
|
| 59 | - 'id_rubrique', |
|
| 60 | - $id_rubrique, |
|
| 61 | - '&' |
|
| 62 | - ); |
|
| 63 | - |
|
| 64 | - include_spip('inc/headers'); |
|
| 65 | - redirige_par_entete($redirect); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - return [$id_rubrique, $err]; |
|
| 41 | + if (is_null($arg)) { |
|
| 42 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 43 | + $arg = $securiser_action(); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + if (!$id_rubrique = intval($arg)) { |
|
| 47 | + if ($arg != 'oui') { |
|
| 48 | + include_spip('inc/headers'); |
|
| 49 | + redirige_url_ecrire(); |
|
| 50 | + } |
|
| 51 | + $id_rubrique = rubrique_inserer(_request('id_parent')); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + $err = rubrique_modifier($id_rubrique); |
|
| 55 | + |
|
| 56 | + if (_request('redirect')) { |
|
| 57 | + $redirect = parametre_url( |
|
| 58 | + urldecode(_request('redirect')), |
|
| 59 | + 'id_rubrique', |
|
| 60 | + $id_rubrique, |
|
| 61 | + '&' |
|
| 62 | + ); |
|
| 63 | + |
|
| 64 | + include_spip('inc/headers'); |
|
| 65 | + redirige_par_entete($redirect); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + return [$id_rubrique, $err]; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
@@ -80,42 +80,42 @@ discard block |
||
| 80 | 80 | * Identifiant de la rubrique crée |
| 81 | 81 | */ |
| 82 | 82 | function rubrique_inserer($id_parent, $set = null) { |
| 83 | - $champs = [ |
|
| 84 | - 'titre' => _T('item_nouvelle_rubrique'), |
|
| 85 | - 'id_parent' => intval($id_parent), |
|
| 86 | - 'statut' => 'prepa' |
|
| 87 | - ]; |
|
| 88 | - |
|
| 89 | - if ($set) { |
|
| 90 | - $champs = array_merge($champs, $set); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // Envoyer aux plugins |
|
| 94 | - $champs = pipeline( |
|
| 95 | - 'pre_insertion', |
|
| 96 | - [ |
|
| 97 | - 'args' => [ |
|
| 98 | - 'table' => 'spip_rubriques', |
|
| 99 | - ], |
|
| 100 | - 'data' => $champs |
|
| 101 | - ] |
|
| 102 | - ); |
|
| 103 | - |
|
| 104 | - $id_rubrique = sql_insertq('spip_rubriques', $champs); |
|
| 105 | - pipeline( |
|
| 106 | - 'post_insertion', |
|
| 107 | - [ |
|
| 108 | - 'args' => [ |
|
| 109 | - 'table' => 'spip_rubriques', |
|
| 110 | - 'id_objet' => $id_rubrique |
|
| 111 | - ], |
|
| 112 | - 'data' => $champs |
|
| 113 | - ] |
|
| 114 | - ); |
|
| 115 | - propager_les_secteurs(); |
|
| 116 | - calculer_langues_rubriques(); |
|
| 117 | - |
|
| 118 | - return $id_rubrique; |
|
| 83 | + $champs = [ |
|
| 84 | + 'titre' => _T('item_nouvelle_rubrique'), |
|
| 85 | + 'id_parent' => intval($id_parent), |
|
| 86 | + 'statut' => 'prepa' |
|
| 87 | + ]; |
|
| 88 | + |
|
| 89 | + if ($set) { |
|
| 90 | + $champs = array_merge($champs, $set); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // Envoyer aux plugins |
|
| 94 | + $champs = pipeline( |
|
| 95 | + 'pre_insertion', |
|
| 96 | + [ |
|
| 97 | + 'args' => [ |
|
| 98 | + 'table' => 'spip_rubriques', |
|
| 99 | + ], |
|
| 100 | + 'data' => $champs |
|
| 101 | + ] |
|
| 102 | + ); |
|
| 103 | + |
|
| 104 | + $id_rubrique = sql_insertq('spip_rubriques', $champs); |
|
| 105 | + pipeline( |
|
| 106 | + 'post_insertion', |
|
| 107 | + [ |
|
| 108 | + 'args' => [ |
|
| 109 | + 'table' => 'spip_rubriques', |
|
| 110 | + 'id_objet' => $id_rubrique |
|
| 111 | + ], |
|
| 112 | + 'data' => $champs |
|
| 113 | + ] |
|
| 114 | + ); |
|
| 115 | + propager_les_secteurs(); |
|
| 116 | + calculer_langues_rubriques(); |
|
| 117 | + |
|
| 118 | + return $id_rubrique; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -131,46 +131,46 @@ discard block |
||
| 131 | 131 | * - chaîne : texte d'un message d'erreur |
| 132 | 132 | */ |
| 133 | 133 | function rubrique_modifier($id_rubrique, $set = null) { |
| 134 | - include_spip('inc/autoriser'); |
|
| 135 | - include_spip('inc/filtres'); |
|
| 136 | - |
|
| 137 | - include_spip('inc/modifier'); |
|
| 138 | - $c = collecter_requests( |
|
| 139 | - // include list |
|
| 140 | - objet_info('rubrique', 'champs_editables'), |
|
| 141 | - // exclude list |
|
| 142 | - ['id_parent', 'confirme_deplace'], |
|
| 143 | - // donnees eventuellement fournies |
|
| 144 | - $set |
|
| 145 | - ); |
|
| 146 | - |
|
| 147 | - if ( |
|
| 148 | - $err = objet_modifier_champs( |
|
| 149 | - 'rubrique', |
|
| 150 | - $id_rubrique, |
|
| 151 | - [ |
|
| 152 | - 'data' => $set, |
|
| 153 | - 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique] |
|
| 154 | - ], |
|
| 155 | - $c |
|
| 156 | - ) |
|
| 157 | - ) { |
|
| 158 | - return $err; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - $c = collecter_requests(['id_parent', 'confirme_deplace'], [], $set); |
|
| 162 | - // Deplacer la rubrique |
|
| 163 | - if (isset($c['id_parent'])) { |
|
| 164 | - $err = rubrique_instituer($id_rubrique, $c); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // invalider les caches marques de cette rubrique |
|
| 168 | - include_spip('inc/invalideur'); |
|
| 169 | - suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 170 | - // et celui de menu_rubriques |
|
| 171 | - effacer_meta('date_calcul_rubriques'); |
|
| 172 | - |
|
| 173 | - return $err; |
|
| 134 | + include_spip('inc/autoriser'); |
|
| 135 | + include_spip('inc/filtres'); |
|
| 136 | + |
|
| 137 | + include_spip('inc/modifier'); |
|
| 138 | + $c = collecter_requests( |
|
| 139 | + // include list |
|
| 140 | + objet_info('rubrique', 'champs_editables'), |
|
| 141 | + // exclude list |
|
| 142 | + ['id_parent', 'confirme_deplace'], |
|
| 143 | + // donnees eventuellement fournies |
|
| 144 | + $set |
|
| 145 | + ); |
|
| 146 | + |
|
| 147 | + if ( |
|
| 148 | + $err = objet_modifier_champs( |
|
| 149 | + 'rubrique', |
|
| 150 | + $id_rubrique, |
|
| 151 | + [ |
|
| 152 | + 'data' => $set, |
|
| 153 | + 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique] |
|
| 154 | + ], |
|
| 155 | + $c |
|
| 156 | + ) |
|
| 157 | + ) { |
|
| 158 | + return $err; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + $c = collecter_requests(['id_parent', 'confirme_deplace'], [], $set); |
|
| 162 | + // Deplacer la rubrique |
|
| 163 | + if (isset($c['id_parent'])) { |
|
| 164 | + $err = rubrique_instituer($id_rubrique, $c); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // invalider les caches marques de cette rubrique |
|
| 168 | + include_spip('inc/invalideur'); |
|
| 169 | + suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 170 | + // et celui de menu_rubriques |
|
| 171 | + effacer_meta('date_calcul_rubriques'); |
|
| 172 | + |
|
| 173 | + return $err; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -193,29 +193,29 @@ discard block |
||
| 193 | 193 | * false si la confirmation du déplacement n'est pas présente |
| 194 | 194 | */ |
| 195 | 195 | function editer_rubrique_breves($id_rubrique, $id_parent, $c = []) { |
| 196 | - if (!sql_table_exists('spip_breves')) { |
|
| 197 | - return true; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique")) { |
|
| 201 | - return true; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - if (empty($c['confirme_deplace']) or $c['confirme_deplace'] != 'oui') { |
|
| 205 | - return false; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - if ( |
|
| 209 | - $id_secteur = sql_getfetsel( |
|
| 210 | - 'id_secteur', |
|
| 211 | - 'spip_rubriques', |
|
| 212 | - "id_rubrique=$id_parent" |
|
| 213 | - ) |
|
| 214 | - ) { |
|
| 215 | - sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique"); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - return true; |
|
| 196 | + if (!sql_table_exists('spip_breves')) { |
|
| 197 | + return true; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique")) { |
|
| 201 | + return true; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + if (empty($c['confirme_deplace']) or $c['confirme_deplace'] != 'oui') { |
|
| 205 | + return false; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + if ( |
|
| 209 | + $id_secteur = sql_getfetsel( |
|
| 210 | + 'id_secteur', |
|
| 211 | + 'spip_rubriques', |
|
| 212 | + "id_rubrique=$id_parent" |
|
| 213 | + ) |
|
| 214 | + ) { |
|
| 215 | + sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique"); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + return true; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | |
@@ -237,50 +237,50 @@ discard block |
||
| 237 | 237 | * Chaîne : texte du message d'erreur |
| 238 | 238 | */ |
| 239 | 239 | function rubrique_instituer($id_rubrique, $c) { |
| 240 | - // traitement de la rubrique parente |
|
| 241 | - // interdiction de deplacer vers ou a partir d'une rubrique |
|
| 242 | - // qu'on n'administre pas. |
|
| 243 | - |
|
| 244 | - if (null !== ($id_parent = $c['id_parent'])) { |
|
| 245 | - $id_parent = intval($id_parent); |
|
| 246 | - $filles = calcul_branche_in($id_rubrique); |
|
| 247 | - if (strpos(",$id_parent,", (string) ",$filles,") !== false) { |
|
| 248 | - spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent"); |
|
| 249 | - } else { |
|
| 250 | - $s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 251 | - $old_parent = $s['id_parent']; |
|
| 252 | - |
|
| 253 | - if ( |
|
| 254 | - !($id_parent != $old_parent |
|
| 255 | - and autoriser('publierdans', 'rubrique', $id_parent) |
|
| 256 | - and autoriser('creerrubriquedans', 'rubrique', $id_parent) |
|
| 257 | - and autoriser('publierdans', 'rubrique', $old_parent) |
|
| 258 | - ) |
|
| 259 | - ) { |
|
| 260 | - if ($s['statut'] != 'prepa') { |
|
| 261 | - spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 262 | - } |
|
| 263 | - } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
|
| 264 | - $statut_ancien = $s['statut']; |
|
| 265 | - sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique"); |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - propager_les_secteurs(); |
|
| 269 | - |
|
| 270 | - // Deplacement d'une rubrique publiee ==> chgt general de leur statut |
|
| 271 | - if ($statut_ancien == 'publie') { |
|
| 272 | - calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]); |
|
| 273 | - } |
|
| 274 | - // Creation ou deplacement d'une rubrique non publiee |
|
| 275 | - // invalider le cache de leur menu |
|
| 276 | - elseif (!$statut_ancien || $old_parent != $id_parent) { |
|
| 277 | - effacer_meta('date_calcul_rubriques'); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - calculer_langues_rubriques(); |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - return ''; // pas d'erreur |
|
| 240 | + // traitement de la rubrique parente |
|
| 241 | + // interdiction de deplacer vers ou a partir d'une rubrique |
|
| 242 | + // qu'on n'administre pas. |
|
| 243 | + |
|
| 244 | + if (null !== ($id_parent = $c['id_parent'])) { |
|
| 245 | + $id_parent = intval($id_parent); |
|
| 246 | + $filles = calcul_branche_in($id_rubrique); |
|
| 247 | + if (strpos(",$id_parent,", (string) ",$filles,") !== false) { |
|
| 248 | + spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent"); |
|
| 249 | + } else { |
|
| 250 | + $s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 251 | + $old_parent = $s['id_parent']; |
|
| 252 | + |
|
| 253 | + if ( |
|
| 254 | + !($id_parent != $old_parent |
|
| 255 | + and autoriser('publierdans', 'rubrique', $id_parent) |
|
| 256 | + and autoriser('creerrubriquedans', 'rubrique', $id_parent) |
|
| 257 | + and autoriser('publierdans', 'rubrique', $old_parent) |
|
| 258 | + ) |
|
| 259 | + ) { |
|
| 260 | + if ($s['statut'] != 'prepa') { |
|
| 261 | + spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 262 | + } |
|
| 263 | + } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
|
| 264 | + $statut_ancien = $s['statut']; |
|
| 265 | + sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique"); |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + propager_les_secteurs(); |
|
| 269 | + |
|
| 270 | + // Deplacement d'une rubrique publiee ==> chgt general de leur statut |
|
| 271 | + if ($statut_ancien == 'publie') { |
|
| 272 | + calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]); |
|
| 273 | + } |
|
| 274 | + // Creation ou deplacement d'une rubrique non publiee |
|
| 275 | + // invalider le cache de leur menu |
|
| 276 | + elseif (!$statut_ancien || $old_parent != $id_parent) { |
|
| 277 | + effacer_meta('date_calcul_rubriques'); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + calculer_langues_rubriques(); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + return ''; // pas d'erreur |
|
| 286 | 286 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | */ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/filtres_boites'); |
@@ -41,25 +41,25 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function parametres_css_prive() { |
| 43 | 43 | |
| 44 | - $args = []; |
|
| 45 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 44 | + $args = []; |
|
| 45 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 51 | 51 | |
| 52 | - $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 52 | + $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 53 | 53 | |
| 54 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | - parse_str($couleurs($c), $c); |
|
| 56 | - $args = array_merge($args, $c); |
|
| 54 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | + parse_str($couleurs($c), $c); |
|
| 56 | + $args = array_merge($args, $c); |
|
| 57 | 57 | |
| 58 | - if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | - $args['var_mode'] = 'recalcul'; |
|
| 60 | - } |
|
| 58 | + if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | + $args['var_mode'] = 'recalcul'; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return http_build_query($args); |
|
| 62 | + return http_build_query($args); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -82,95 +82,95 @@ discard block |
||
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | 84 | function chercher_rubrique( |
| 85 | - $titre, |
|
| 86 | - $id_objet, |
|
| 87 | - $id_parent, |
|
| 88 | - $objet, |
|
| 89 | - $id_secteur, |
|
| 90 | - $restreint, |
|
| 91 | - $actionable = false, |
|
| 92 | - $retour_sans_cadre = false |
|
| 85 | + $titre, |
|
| 86 | + $id_objet, |
|
| 87 | + $id_parent, |
|
| 88 | + $objet, |
|
| 89 | + $id_secteur, |
|
| 90 | + $restreint, |
|
| 91 | + $actionable = false, |
|
| 92 | + $retour_sans_cadre = false |
|
| 93 | 93 | ) { |
| 94 | 94 | |
| 95 | - include_spip('inc/autoriser'); |
|
| 96 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | - return ''; |
|
| 98 | - } |
|
| 99 | - if (!sql_countsel('spip_rubriques')) { |
|
| 100 | - return ''; |
|
| 101 | - } |
|
| 102 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | - |
|
| 105 | - if ($id_parent == 0) { |
|
| 106 | - $logo = 'racine-24.png'; |
|
| 107 | - } elseif ($id_secteur == $id_parent) { |
|
| 108 | - $logo = 'secteur-24.png'; |
|
| 109 | - } else { |
|
| 110 | - $logo = 'rubrique-24.png'; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $confirm = ''; |
|
| 114 | - if ($objet == 'rubrique') { |
|
| 115 | - // FIXME: Migration plus adapté vers le plugin Brèves ? |
|
| 116 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 117 | - // confirmation du deplacement |
|
| 118 | - if ( |
|
| 119 | - sql_table_exists('spip_breves') |
|
| 120 | - and ($contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet))) |
|
| 121 | - and ($contient_breves > 0) |
|
| 122 | - ) { |
|
| 123 | - // FIXME: utiliser singulier_ou_pluriel, migrer dans plugin Brèves |
|
| 124 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 125 | - $scb = _T( |
|
| 126 | - 'avis_deplacement_rubrique', |
|
| 127 | - [ |
|
| 128 | - 'contient_breves' => $contient_breves, |
|
| 129 | - 'scb' => $scb |
|
| 130 | - ] |
|
| 131 | - ); |
|
| 132 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 133 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 134 | - . $scb . |
|
| 135 | - "</label></div></div>\n"; |
|
| 136 | - } else { |
|
| 137 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - $form .= $confirm; |
|
| 141 | - if ($actionable) { |
|
| 142 | - if (strpos($form, '<select') !== false) { |
|
| 143 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 144 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 145 | - . '</div>'; |
|
| 146 | - } |
|
| 147 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 148 | - if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 149 | - $form = generer_action_auteur( |
|
| 150 | - "editer_$objet", |
|
| 151 | - $id_objet, |
|
| 152 | - self(), |
|
| 153 | - $form, |
|
| 154 | - " method='post' class='submit_plongeur'" |
|
| 155 | - ); |
|
| 156 | - } else { |
|
| 157 | - $form = generer_action_auteur( |
|
| 158 | - 'editer_objet', |
|
| 159 | - "$objet/$id_objet", |
|
| 160 | - self(), |
|
| 161 | - $form, |
|
| 162 | - " method='post' class='submit_plongeur'" |
|
| 163 | - ); |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - if ($retour_sans_cadre) { |
|
| 168 | - return $form; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - include_spip('inc/presentation'); |
|
| 172 | - |
|
| 173 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 95 | + include_spip('inc/autoriser'); |
|
| 96 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | + return ''; |
|
| 98 | + } |
|
| 99 | + if (!sql_countsel('spip_rubriques')) { |
|
| 100 | + return ''; |
|
| 101 | + } |
|
| 102 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | + |
|
| 105 | + if ($id_parent == 0) { |
|
| 106 | + $logo = 'racine-24.png'; |
|
| 107 | + } elseif ($id_secteur == $id_parent) { |
|
| 108 | + $logo = 'secteur-24.png'; |
|
| 109 | + } else { |
|
| 110 | + $logo = 'rubrique-24.png'; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $confirm = ''; |
|
| 114 | + if ($objet == 'rubrique') { |
|
| 115 | + // FIXME: Migration plus adapté vers le plugin Brèves ? |
|
| 116 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 117 | + // confirmation du deplacement |
|
| 118 | + if ( |
|
| 119 | + sql_table_exists('spip_breves') |
|
| 120 | + and ($contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet))) |
|
| 121 | + and ($contient_breves > 0) |
|
| 122 | + ) { |
|
| 123 | + // FIXME: utiliser singulier_ou_pluriel, migrer dans plugin Brèves |
|
| 124 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 125 | + $scb = _T( |
|
| 126 | + 'avis_deplacement_rubrique', |
|
| 127 | + [ |
|
| 128 | + 'contient_breves' => $contient_breves, |
|
| 129 | + 'scb' => $scb |
|
| 130 | + ] |
|
| 131 | + ); |
|
| 132 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 133 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 134 | + . $scb . |
|
| 135 | + "</label></div></div>\n"; |
|
| 136 | + } else { |
|
| 137 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + $form .= $confirm; |
|
| 141 | + if ($actionable) { |
|
| 142 | + if (strpos($form, '<select') !== false) { |
|
| 143 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 144 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 145 | + . '</div>'; |
|
| 146 | + } |
|
| 147 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 148 | + if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 149 | + $form = generer_action_auteur( |
|
| 150 | + "editer_$objet", |
|
| 151 | + $id_objet, |
|
| 152 | + self(), |
|
| 153 | + $form, |
|
| 154 | + " method='post' class='submit_plongeur'" |
|
| 155 | + ); |
|
| 156 | + } else { |
|
| 157 | + $form = generer_action_auteur( |
|
| 158 | + 'editer_objet', |
|
| 159 | + "$objet/$id_objet", |
|
| 160 | + self(), |
|
| 161 | + $form, |
|
| 162 | + " method='post' class='submit_plongeur'" |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + if ($retour_sans_cadre) { |
|
| 168 | + return $form; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + include_spip('inc/presentation'); |
|
| 172 | + |
|
| 173 | + return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | |
@@ -184,24 +184,24 @@ discard block |
||
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | 186 | function avoir_visiteurs($past = false, $accepter = true) { |
| 187 | - if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 188 | - return true; |
|
| 189 | - } |
|
| 190 | - if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 191 | - return true; |
|
| 192 | - } |
|
| 193 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 194 | - return true; |
|
| 195 | - } |
|
| 196 | - if (!$past) { |
|
| 197 | - return false; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - return sql_countsel( |
|
| 201 | - 'spip_auteurs', |
|
| 202 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 187 | + if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 188 | + return true; |
|
| 189 | + } |
|
| 190 | + if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 191 | + return true; |
|
| 192 | + } |
|
| 193 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 194 | + return true; |
|
| 195 | + } |
|
| 196 | + if (!$past) { |
|
| 197 | + return false; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + return sql_countsel( |
|
| 201 | + 'spip_auteurs', |
|
| 202 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 203 | 203 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))" |
| 204 | - ); |
|
| 204 | + ); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -217,18 +217,18 @@ discard block |
||
| 217 | 217 | * @return array |
| 218 | 218 | */ |
| 219 | 219 | function statuts_articles_visibles($statut_auteur) { |
| 220 | - static $auth = []; |
|
| 221 | - if (!isset($auth[$statut_auteur])) { |
|
| 222 | - $auth[$statut_auteur] = []; |
|
| 223 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 224 | - foreach ($statuts as $s) { |
|
| 225 | - if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 226 | - $auth[$statut_auteur][] = $s; |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - return $auth[$statut_auteur]; |
|
| 220 | + static $auth = []; |
|
| 221 | + if (!isset($auth[$statut_auteur])) { |
|
| 222 | + $auth[$statut_auteur] = []; |
|
| 223 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 224 | + foreach ($statuts as $s) { |
|
| 225 | + if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 226 | + $auth[$statut_auteur][] = $s; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + return $auth[$statut_auteur]; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -242,38 +242,38 @@ discard block |
||
| 242 | 242 | * @return string |
| 243 | 243 | */ |
| 244 | 244 | function traduire_statut_auteur($statut, $attente = '') { |
| 245 | - $plus = ''; |
|
| 246 | - if ($statut == 'nouveau') { |
|
| 247 | - if ($attente) { |
|
| 248 | - $statut = $attente; |
|
| 249 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 250 | - } else { |
|
| 251 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - $recom = [ |
|
| 256 | - 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 257 | - 'info_redacteurs' => _T('intem_redacteur'), |
|
| 258 | - 'info_visiteurs' => _T('item_visiteur'), |
|
| 259 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 260 | - ]; |
|
| 261 | - if (isset($recom[$statut])) { |
|
| 262 | - return $recom[$statut] . $plus; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - // retrouver directement par le statut sinon |
|
| 266 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 267 | - if (isset($recom[$t])) { |
|
| 268 | - return $recom[$t] . $plus; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - return _T($t) . $plus; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 275 | - // c'est toujours plus informatif que rien du tout |
|
| 276 | - return $statut; |
|
| 245 | + $plus = ''; |
|
| 246 | + if ($statut == 'nouveau') { |
|
| 247 | + if ($attente) { |
|
| 248 | + $statut = $attente; |
|
| 249 | + $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 250 | + } else { |
|
| 251 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + $recom = [ |
|
| 256 | + 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 257 | + 'info_redacteurs' => _T('intem_redacteur'), |
|
| 258 | + 'info_visiteurs' => _T('item_visiteur'), |
|
| 259 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 260 | + ]; |
|
| 261 | + if (isset($recom[$statut])) { |
|
| 262 | + return $recom[$statut] . $plus; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + // retrouver directement par le statut sinon |
|
| 266 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 267 | + if (isset($recom[$t])) { |
|
| 268 | + return $recom[$t] . $plus; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + return _T($t) . $plus; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 275 | + // c'est toujours plus informatif que rien du tout |
|
| 276 | + return $statut; |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -284,29 +284,29 @@ discard block |
||
| 284 | 284 | * @return string |
| 285 | 285 | */ |
| 286 | 286 | function afficher_qui_edite($id_objet, $objet): string { |
| 287 | - static $qui = []; |
|
| 288 | - if (isset($qui[$objet][$id_objet])) { |
|
| 289 | - return $qui[$objet][$id_objet]; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - include_spip('inc/config'); |
|
| 293 | - if (lire_config('articles_modif', 'non') === 'non') { |
|
| 294 | - return $qui[$objet][$id_objet] = ''; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - include_spip('inc/drapeau_edition'); |
|
| 298 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 299 | - if (!$modif) { |
|
| 300 | - return $qui[$objet][$id_objet] = ''; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - include_spip('base/objets'); |
|
| 304 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 305 | - if (isset($infos['texte_signale_edition'])) { |
|
| 306 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 287 | + static $qui = []; |
|
| 288 | + if (isset($qui[$objet][$id_objet])) { |
|
| 289 | + return $qui[$objet][$id_objet]; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + include_spip('inc/config'); |
|
| 293 | + if (lire_config('articles_modif', 'non') === 'non') { |
|
| 294 | + return $qui[$objet][$id_objet] = ''; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + include_spip('inc/drapeau_edition'); |
|
| 298 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 299 | + if (!$modif) { |
|
| 300 | + return $qui[$objet][$id_objet] = ''; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + include_spip('base/objets'); |
|
| 304 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 305 | + if (isset($infos['texte_signale_edition'])) { |
|
| 306 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -324,53 +324,53 @@ discard block |
||
| 324 | 324 | * @return array |
| 325 | 325 | */ |
| 326 | 326 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array { |
| 327 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 328 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - switch ($quoi) { |
|
| 332 | - case 'redacteurs': |
|
| 333 | - $statut = AUTEURS_MIN_REDAC; |
|
| 334 | - $statut = explode(',', $statut); |
|
| 335 | - if ($en_base) { |
|
| 336 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 337 | - $retire = array_diff($statut, $check); |
|
| 338 | - $statut = array_diff($statut, $retire); |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - return array_unique($statut); |
|
| 342 | - |
|
| 343 | - case 'visiteurs': |
|
| 344 | - $statut = []; |
|
| 345 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 346 | - $exclus = explode(',', $exclus); |
|
| 347 | - if (!$en_base) { |
|
| 348 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 349 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 350 | - } |
|
| 351 | - $s_complement = array_column( |
|
| 352 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 353 | - 'statut' |
|
| 354 | - ); |
|
| 355 | - |
|
| 356 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 357 | - |
|
| 358 | - default: |
|
| 359 | - case 'tous': |
|
| 360 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 361 | - $s_complement = array_column( |
|
| 362 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 363 | - 'statut' |
|
| 364 | - ); |
|
| 365 | - $statut = array_merge($statut, $s_complement); |
|
| 366 | - if ($en_base) { |
|
| 367 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 368 | - $retire = array_diff($statut, $check); |
|
| 369 | - $statut = array_diff($statut, $retire); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - return array_unique($statut); |
|
| 373 | - } |
|
| 327 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 328 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + switch ($quoi) { |
|
| 332 | + case 'redacteurs': |
|
| 333 | + $statut = AUTEURS_MIN_REDAC; |
|
| 334 | + $statut = explode(',', $statut); |
|
| 335 | + if ($en_base) { |
|
| 336 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 337 | + $retire = array_diff($statut, $check); |
|
| 338 | + $statut = array_diff($statut, $retire); |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + return array_unique($statut); |
|
| 342 | + |
|
| 343 | + case 'visiteurs': |
|
| 344 | + $statut = []; |
|
| 345 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 346 | + $exclus = explode(',', $exclus); |
|
| 347 | + if (!$en_base) { |
|
| 348 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 349 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 350 | + } |
|
| 351 | + $s_complement = array_column( |
|
| 352 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 353 | + 'statut' |
|
| 354 | + ); |
|
| 355 | + |
|
| 356 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 357 | + |
|
| 358 | + default: |
|
| 359 | + case 'tous': |
|
| 360 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 361 | + $s_complement = array_column( |
|
| 362 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 363 | + 'statut' |
|
| 364 | + ); |
|
| 365 | + $statut = array_merge($statut, $s_complement); |
|
| 366 | + if ($en_base) { |
|
| 367 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 368 | + $retire = array_diff($statut, $check); |
|
| 369 | + $statut = array_diff($statut, $retire); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + return array_unique($statut); |
|
| 373 | + } |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /** |
@@ -386,28 +386,28 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 388 | 388 | |
| 389 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 390 | - $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 391 | - ? '' |
|
| 392 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 393 | - |
|
| 394 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 395 | - if ($objet == 'rubrique') { |
|
| 396 | - $id_rubrique = 0; |
|
| 397 | - } else { |
|
| 398 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 402 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 403 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 404 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 405 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - return $id_rubrique; |
|
| 389 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 390 | + $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 391 | + ? '' |
|
| 392 | + : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 393 | + |
|
| 394 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 395 | + if ($objet == 'rubrique') { |
|
| 396 | + $id_rubrique = 0; |
|
| 397 | + } else { |
|
| 398 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 402 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 403 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 404 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 405 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + return $id_rubrique; |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
@@ -418,12 +418,12 @@ discard block |
||
| 418 | 418 | * @return string |
| 419 | 419 | */ |
| 420 | 420 | function lien_article_virtuel($virtuel) { |
| 421 | - include_spip('inc/lien'); |
|
| 422 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 423 | - return ''; |
|
| 424 | - } |
|
| 421 | + include_spip('inc/lien'); |
|
| 422 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 423 | + return ''; |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | - return propre('[->' . $virtuel . ']'); |
|
| 426 | + return propre('[->' . $virtuel . ']'); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | |
@@ -446,11 +446,11 @@ discard block |
||
| 446 | 446 | * @filtre |
| 447 | 447 | */ |
| 448 | 448 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 449 | - include_spip('inc/acces'); |
|
| 450 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 449 | + include_spip('inc/acces'); |
|
| 450 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 451 | 451 | |
| 452 | - $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 453 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 452 | + $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 453 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | |
@@ -462,76 +462,76 @@ discard block |
||
| 462 | 462 | */ |
| 463 | 463 | function alertes_auteur($id_auteur): string { |
| 464 | 464 | |
| 465 | - $alertes = []; |
|
| 466 | - |
|
| 467 | - if ( |
|
| 468 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 469 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 470 | - ) { |
|
| 471 | - include_spip('genie/maintenance'); |
|
| 472 | - if ($msg = message_crash_tables()) { |
|
| 473 | - $alertes[] = $msg; |
|
| 474 | - } |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - if ( |
|
| 478 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 479 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 480 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 481 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 482 | - ) { |
|
| 483 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 484 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 488 | - if ( |
|
| 489 | - $a |
|
| 490 | - and is_array($a = unserialize($a)) |
|
| 491 | - and count($a) |
|
| 492 | - ) { |
|
| 493 | - $update = false; |
|
| 494 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 495 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 496 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 497 | - $update = true; |
|
| 498 | - } |
|
| 499 | - if (isset($a[''])) { |
|
| 500 | - $alertes = array_merge($alertes, $a['']); |
|
| 501 | - unset($a['']); |
|
| 502 | - $update = true; |
|
| 503 | - } |
|
| 504 | - if ($update) { |
|
| 505 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 506 | - } |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - if ( |
|
| 510 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 511 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 512 | - ) { |
|
| 513 | - include_spip('inc/plugin'); |
|
| 514 | - $alertes[] = plugin_donne_erreurs(); |
|
| 515 | - } |
|
| 516 | - |
|
| 517 | - $alertes = pipeline( |
|
| 518 | - 'alertes_auteur', |
|
| 519 | - [ |
|
| 520 | - 'args' => [ |
|
| 521 | - 'id_auteur' => $id_auteur, |
|
| 522 | - 'exec' => _request('exec'), |
|
| 523 | - ], |
|
| 524 | - 'data' => $alertes |
|
| 525 | - ] |
|
| 526 | - ); |
|
| 527 | - |
|
| 528 | - if ($alertes = array_filter($alertes)) { |
|
| 529 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 530 | - join(' | ', $alertes) |
|
| 531 | - . '</div></div>'; |
|
| 532 | - } |
|
| 533 | - |
|
| 534 | - return ''; |
|
| 465 | + $alertes = []; |
|
| 466 | + |
|
| 467 | + if ( |
|
| 468 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 469 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 470 | + ) { |
|
| 471 | + include_spip('genie/maintenance'); |
|
| 472 | + if ($msg = message_crash_tables()) { |
|
| 473 | + $alertes[] = $msg; |
|
| 474 | + } |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + if ( |
|
| 478 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 479 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 480 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 481 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 482 | + ) { |
|
| 483 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 484 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 488 | + if ( |
|
| 489 | + $a |
|
| 490 | + and is_array($a = unserialize($a)) |
|
| 491 | + and count($a) |
|
| 492 | + ) { |
|
| 493 | + $update = false; |
|
| 494 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 495 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 496 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 497 | + $update = true; |
|
| 498 | + } |
|
| 499 | + if (isset($a[''])) { |
|
| 500 | + $alertes = array_merge($alertes, $a['']); |
|
| 501 | + unset($a['']); |
|
| 502 | + $update = true; |
|
| 503 | + } |
|
| 504 | + if ($update) { |
|
| 505 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 506 | + } |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + if ( |
|
| 510 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 511 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 512 | + ) { |
|
| 513 | + include_spip('inc/plugin'); |
|
| 514 | + $alertes[] = plugin_donne_erreurs(); |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + $alertes = pipeline( |
|
| 518 | + 'alertes_auteur', |
|
| 519 | + [ |
|
| 520 | + 'args' => [ |
|
| 521 | + 'id_auteur' => $id_auteur, |
|
| 522 | + 'exec' => _request('exec'), |
|
| 523 | + ], |
|
| 524 | + 'data' => $alertes |
|
| 525 | + ] |
|
| 526 | + ); |
|
| 527 | + |
|
| 528 | + if ($alertes = array_filter($alertes)) { |
|
| 529 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 530 | + join(' | ', $alertes) |
|
| 531 | + . '</div></div>'; |
|
| 532 | + } |
|
| 533 | + |
|
| 534 | + return ''; |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | /** |
@@ -541,9 +541,9 @@ discard block |
||
| 541 | 541 | * @return string |
| 542 | 542 | */ |
| 543 | 543 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 544 | - include_spip('inc/presenter_enfants'); |
|
| 544 | + include_spip('inc/presenter_enfants'); |
|
| 545 | 545 | |
| 546 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 546 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -561,15 +561,15 @@ discard block |
||
| 561 | 561 | * @return string |
| 562 | 562 | */ |
| 563 | 563 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 564 | - $titre = attribut_html($titre); |
|
| 565 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 566 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 567 | - |
|
| 568 | - if (!$titre_lien) { |
|
| 569 | - return $icone; |
|
| 570 | - } else { |
|
| 571 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 572 | - } |
|
| 564 | + $titre = attribut_html($titre); |
|
| 565 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 566 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 567 | + |
|
| 568 | + if (!$titre_lien) { |
|
| 569 | + return $icone; |
|
| 570 | + } else { |
|
| 571 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 572 | + } |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | |
@@ -588,22 +588,22 @@ discard block |
||
| 588 | 588 | * @return array |
| 589 | 589 | */ |
| 590 | 590 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 591 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 592 | - if (!(is_countable($res) ? count($res) : 0)) { |
|
| 593 | - return []; |
|
| 594 | - } |
|
| 595 | - $r = reset($res); |
|
| 596 | - if (isset($r['rang_lien'])) { |
|
| 597 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 598 | - asort($l); |
|
| 599 | - $l = array_keys($l); |
|
| 600 | - } else { |
|
| 601 | - // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 602 | - // Sinon c'est dans "id_objet" |
|
| 603 | - $l = array_column( |
|
| 604 | - $res, |
|
| 605 | - $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 606 | - ); |
|
| 607 | - } |
|
| 608 | - return $l; |
|
| 591 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 592 | + if (!(is_countable($res) ? count($res) : 0)) { |
|
| 593 | + return []; |
|
| 594 | + } |
|
| 595 | + $r = reset($res); |
|
| 596 | + if (isset($r['rang_lien'])) { |
|
| 597 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 598 | + asort($l); |
|
| 599 | + $l = array_keys($l); |
|
| 600 | + } else { |
|
| 601 | + // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 602 | + // Sinon c'est dans "id_objet" |
|
| 603 | + $l = array_column( |
|
| 604 | + $res, |
|
| 605 | + $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 606 | + ); |
|
| 607 | + } |
|
| 608 | + return $l; |
|
| 609 | 609 | } |