@@ -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,25 +193,25 @@ 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_countsel('spip_breves', "id_rubrique=$id_rubrique")) { |
|
| 197 | - return true; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - if (empty($c['confirme_deplace']) or $c['confirme_deplace'] != 'oui') { |
|
| 201 | - return false; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - if ( |
|
| 205 | - $id_secteur = sql_getfetsel( |
|
| 206 | - 'id_secteur', |
|
| 207 | - 'spip_rubriques', |
|
| 208 | - "id_rubrique=$id_parent" |
|
| 209 | - ) |
|
| 210 | - ) { |
|
| 211 | - sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique"); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - return true; |
|
| 196 | + if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique")) { |
|
| 197 | + return true; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + if (empty($c['confirme_deplace']) or $c['confirme_deplace'] != 'oui') { |
|
| 201 | + return false; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + if ( |
|
| 205 | + $id_secteur = sql_getfetsel( |
|
| 206 | + 'id_secteur', |
|
| 207 | + 'spip_rubriques', |
|
| 208 | + "id_rubrique=$id_parent" |
|
| 209 | + ) |
|
| 210 | + ) { |
|
| 211 | + sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique"); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + return true; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
@@ -233,50 +233,50 @@ discard block |
||
| 233 | 233 | * Chaîne : Texte du message d'erreur |
| 234 | 234 | */ |
| 235 | 235 | function rubrique_instituer($id_rubrique, $c) { |
| 236 | - // traitement de la rubrique parente |
|
| 237 | - // interdiction de deplacer vers ou a partir d'une rubrique |
|
| 238 | - // qu'on n'administre pas. |
|
| 239 | - |
|
| 240 | - if (null !== ($id_parent = $c['id_parent'])) { |
|
| 241 | - $id_parent = intval($id_parent); |
|
| 242 | - $filles = calcul_branche_in($id_rubrique); |
|
| 243 | - if (strpos(",$id_parent,", (string) ",$filles,") !== false) { |
|
| 244 | - spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent"); |
|
| 245 | - } else { |
|
| 246 | - $s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 247 | - $old_parent = $s['id_parent']; |
|
| 248 | - |
|
| 249 | - if ( |
|
| 250 | - !($id_parent != $old_parent |
|
| 251 | - and autoriser('publierdans', 'rubrique', $id_parent) |
|
| 252 | - and autoriser('creerrubriquedans', 'rubrique', $id_parent) |
|
| 253 | - and autoriser('publierdans', 'rubrique', $old_parent) |
|
| 254 | - ) |
|
| 255 | - ) { |
|
| 256 | - if ($s['statut'] != 'prepa') { |
|
| 257 | - spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 258 | - } |
|
| 259 | - } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
|
| 260 | - $statut_ancien = $s['statut']; |
|
| 261 | - sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique"); |
|
| 262 | - |
|
| 263 | - |
|
| 264 | - propager_les_secteurs(); |
|
| 265 | - |
|
| 266 | - // Deplacement d'une rubrique publiee ==> chgt general de leur statut |
|
| 267 | - if ($statut_ancien == 'publie') { |
|
| 268 | - calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]); |
|
| 269 | - } |
|
| 270 | - // Creation ou deplacement d'une rubrique non publiee |
|
| 271 | - // invalider le cache de leur menu |
|
| 272 | - elseif (!$statut_ancien || $old_parent != $id_parent) { |
|
| 273 | - effacer_meta('date_calcul_rubriques'); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - calculer_langues_rubriques(); |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - return ''; // pas d'erreur |
|
| 236 | + // traitement de la rubrique parente |
|
| 237 | + // interdiction de deplacer vers ou a partir d'une rubrique |
|
| 238 | + // qu'on n'administre pas. |
|
| 239 | + |
|
| 240 | + if (null !== ($id_parent = $c['id_parent'])) { |
|
| 241 | + $id_parent = intval($id_parent); |
|
| 242 | + $filles = calcul_branche_in($id_rubrique); |
|
| 243 | + if (strpos(",$id_parent,", (string) ",$filles,") !== false) { |
|
| 244 | + spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent"); |
|
| 245 | + } else { |
|
| 246 | + $s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 247 | + $old_parent = $s['id_parent']; |
|
| 248 | + |
|
| 249 | + if ( |
|
| 250 | + !($id_parent != $old_parent |
|
| 251 | + and autoriser('publierdans', 'rubrique', $id_parent) |
|
| 252 | + and autoriser('creerrubriquedans', 'rubrique', $id_parent) |
|
| 253 | + and autoriser('publierdans', 'rubrique', $old_parent) |
|
| 254 | + ) |
|
| 255 | + ) { |
|
| 256 | + if ($s['statut'] != 'prepa') { |
|
| 257 | + spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 258 | + } |
|
| 259 | + } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
|
| 260 | + $statut_ancien = $s['statut']; |
|
| 261 | + sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique"); |
|
| 262 | + |
|
| 263 | + |
|
| 264 | + propager_les_secteurs(); |
|
| 265 | + |
|
| 266 | + // Deplacement d'une rubrique publiee ==> chgt general de leur statut |
|
| 267 | + if ($statut_ancien == 'publie') { |
|
| 268 | + calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]); |
|
| 269 | + } |
|
| 270 | + // Creation ou deplacement d'une rubrique non publiee |
|
| 271 | + // invalider le cache de leur menu |
|
| 272 | + elseif (!$statut_ancien || $old_parent != $id_parent) { |
|
| 273 | + effacer_meta('date_calcul_rubriques'); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + calculer_langues_rubriques(); |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + return ''; // pas d'erreur |
|
| 282 | 282 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | $id_rubrique, |
| 151 | 151 | [ |
| 152 | 152 | 'data' => $set, |
| 153 | - 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique] |
|
| 153 | + 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique').' '._T('info_numero_abbreviation').$id_rubrique] |
|
| 154 | 154 | ], |
| 155 | 155 | $c |
| 156 | 156 | ) |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | ) |
| 255 | 255 | ) { |
| 256 | 256 | if ($s['statut'] != 'prepa') { |
| 257 | - spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 257 | + spip_log("deplacement de $id_rubrique vers $id_parent refuse a ".$GLOBALS['visiteur_session']['id_auteur'].' '.$GLOBALS['visiteur_session']['statut']); |
|
| 258 | 258 | } |
| 259 | 259 | } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
| 260 | 260 | $statut_ancien = $s['statut']; |