@@ -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 | - // white list |
|
| 140 | - objet_info('rubrique', 'champs_editables'), |
|
| 141 | - // black 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 | + // white list |
|
| 140 | + objet_info('rubrique', 'champs_editables'), |
|
| 141 | + // black 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'] != 'new') { |
|
| 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); |
|
| 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'] != 'new') { |
|
| 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); |
|
| 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 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -30,36 +30,36 @@ discard block |
||
| 30 | 30 | * `on` ou `off` |
| 31 | 31 | */ |
| 32 | 32 | function logo_supprimer($objet, $id_objet, $etat) { |
| 33 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 34 | - $objet = objet_type($objet); |
|
| 35 | - $primary = id_table_objet($objet); |
|
| 36 | - include_spip('inc/chercher_logo'); |
|
| 37 | - |
|
| 38 | - // existe-t-il deja un logo ? |
|
| 39 | - $logo = $chercher_logo($id_objet, $primary, $etat); |
|
| 40 | - if ($logo) { |
|
| 41 | - # TODO : deprecated, a supprimer -> anciens logos IMG/artonxx.png pas en base |
|
| 42 | - if ((is_countable($logo) ? count($logo) : 0) < 6) { |
|
| 43 | - spip_log("Supprimer ancien logo $logo", 'logo'); |
|
| 44 | - spip_unlink($logo[0]); |
|
| 45 | - } |
|
| 46 | - elseif ( |
|
| 47 | - $doc = $logo[5] |
|
| 48 | - and isset($doc['id_document']) |
|
| 49 | - and $id_document = $doc['id_document'] |
|
| 50 | - ) { |
|
| 51 | - include_spip('action/editer_liens'); |
|
| 52 | - // supprimer le lien dans la base |
|
| 53 | - objet_dissocier(['document' => $id_document], [$objet => $id_objet], ['role' => '*']); |
|
| 54 | - |
|
| 55 | - // verifier si il reste des liens avec d'autres objets et sinon supprimer |
|
| 56 | - $liens = objet_trouver_liens(['document' => $id_document], '*'); |
|
| 57 | - if (!count($liens)) { |
|
| 58 | - $supprimer_document = charger_fonction('supprimer_document', 'action'); |
|
| 59 | - $supprimer_document($doc['id_document']); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - } |
|
| 33 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 34 | + $objet = objet_type($objet); |
|
| 35 | + $primary = id_table_objet($objet); |
|
| 36 | + include_spip('inc/chercher_logo'); |
|
| 37 | + |
|
| 38 | + // existe-t-il deja un logo ? |
|
| 39 | + $logo = $chercher_logo($id_objet, $primary, $etat); |
|
| 40 | + if ($logo) { |
|
| 41 | + # TODO : deprecated, a supprimer -> anciens logos IMG/artonxx.png pas en base |
|
| 42 | + if ((is_countable($logo) ? count($logo) : 0) < 6) { |
|
| 43 | + spip_log("Supprimer ancien logo $logo", 'logo'); |
|
| 44 | + spip_unlink($logo[0]); |
|
| 45 | + } |
|
| 46 | + elseif ( |
|
| 47 | + $doc = $logo[5] |
|
| 48 | + and isset($doc['id_document']) |
|
| 49 | + and $id_document = $doc['id_document'] |
|
| 50 | + ) { |
|
| 51 | + include_spip('action/editer_liens'); |
|
| 52 | + // supprimer le lien dans la base |
|
| 53 | + objet_dissocier(['document' => $id_document], [$objet => $id_objet], ['role' => '*']); |
|
| 54 | + |
|
| 55 | + // verifier si il reste des liens avec d'autres objets et sinon supprimer |
|
| 56 | + $liens = objet_trouver_liens(['document' => $id_document], '*'); |
|
| 57 | + if (!count($liens)) { |
|
| 58 | + $supprimer_document = charger_fonction('supprimer_document', 'action'); |
|
| 59 | + $supprimer_document($doc['id_document']); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -76,177 +76,177 @@ discard block |
||
| 76 | 76 | * Erreur, sinon '' |
| 77 | 77 | */ |
| 78 | 78 | function logo_modifier($objet, $id_objet, $etat, $source) { |
| 79 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 80 | - $objet = objet_type($objet); |
|
| 81 | - $primary = id_table_objet($objet); |
|
| 82 | - include_spip('inc/chercher_logo'); |
|
| 83 | - |
|
| 84 | - $mode = preg_replace(',\W,', '', $etat); |
|
| 85 | - if (!$mode) { |
|
| 86 | - spip_log("logo_modifier : etat $etat invalide", 'logo'); |
|
| 87 | - $erreur = 'etat invalide'; |
|
| 88 | - |
|
| 89 | - return $erreur; |
|
| 90 | - } |
|
| 91 | - // chercher dans la base |
|
| 92 | - $mode_document = 'logo' . $mode; |
|
| 93 | - |
|
| 94 | - include_spip('inc/documents'); |
|
| 95 | - $erreur = ''; |
|
| 96 | - |
|
| 97 | - if (!$source) { |
|
| 98 | - spip_log('spip_image_ajouter : source inconnue', 'logo'); |
|
| 99 | - $erreur = 'source inconnue'; |
|
| 100 | - |
|
| 101 | - return $erreur; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - // fichier dans upload/ |
|
| 105 | - if (is_string($source)) { |
|
| 106 | - $tmp_name = false; |
|
| 107 | - if (file_exists($source)) { |
|
| 108 | - $tmp_name = $source; |
|
| 109 | - } elseif (file_exists($f = determine_upload() . $source)) { |
|
| 110 | - $tmp_name = $f; |
|
| 111 | - } |
|
| 112 | - if (!$tmp_name) { |
|
| 113 | - spip_log('spip_image_ajouter : source inconnue', 'logo'); |
|
| 114 | - $erreur = 'source inconnue'; |
|
| 115 | - |
|
| 116 | - return $erreur; |
|
| 117 | - } |
|
| 118 | - $source = [ |
|
| 119 | - 'tmp_name' => $tmp_name, |
|
| 120 | - 'name' => basename($tmp_name), |
|
| 121 | - ]; |
|
| 122 | - } elseif ($erreur = check_upload_error($source['error'], '', true)) { |
|
| 123 | - return $erreur; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // supprimer le logo eventueel existant |
|
| 127 | - // TODO : si un logo existe, le modifier plutot que supprimer + reinserer (mais il faut gerer le cas ou il est utilise par plusieurs objets, donc pas si simple) |
|
| 128 | - // mais de toute facon l'interface actuelle oblige a supprimer + reinserer |
|
| 129 | - logo_supprimer($objet, $id_objet, $etat); |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - include_spip('inc/autoriser'); |
|
| 133 | - $source['mode'] = $mode_document; |
|
| 134 | - $ajouter_documents = charger_fonction('ajouter_documents', 'action'); |
|
| 135 | - autoriser_exception('associerdocuments', $objet, $id_objet); |
|
| 136 | - $ajoutes = $ajouter_documents('new', [$source], $objet, $id_objet, $mode_document); |
|
| 137 | - autoriser_exception('associerdocuments', $objet, $id_objet, false); |
|
| 138 | - |
|
| 139 | - $id_document = reset($ajoutes); |
|
| 140 | - |
|
| 141 | - if (!is_numeric($id_document)) { |
|
| 142 | - $erreur = ($id_document ?: 'Erreur inconnue'); |
|
| 143 | - spip_log("Erreur ajout logo : $erreur pour source=" . json_encode($source, JSON_THROW_ON_ERROR), 'logo'); |
|
| 144 | - return $erreur; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - return ''; // tout est bon, pas d'erreur |
|
| 79 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 80 | + $objet = objet_type($objet); |
|
| 81 | + $primary = id_table_objet($objet); |
|
| 82 | + include_spip('inc/chercher_logo'); |
|
| 83 | + |
|
| 84 | + $mode = preg_replace(',\W,', '', $etat); |
|
| 85 | + if (!$mode) { |
|
| 86 | + spip_log("logo_modifier : etat $etat invalide", 'logo'); |
|
| 87 | + $erreur = 'etat invalide'; |
|
| 88 | + |
|
| 89 | + return $erreur; |
|
| 90 | + } |
|
| 91 | + // chercher dans la base |
|
| 92 | + $mode_document = 'logo' . $mode; |
|
| 93 | + |
|
| 94 | + include_spip('inc/documents'); |
|
| 95 | + $erreur = ''; |
|
| 96 | + |
|
| 97 | + if (!$source) { |
|
| 98 | + spip_log('spip_image_ajouter : source inconnue', 'logo'); |
|
| 99 | + $erreur = 'source inconnue'; |
|
| 100 | + |
|
| 101 | + return $erreur; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + // fichier dans upload/ |
|
| 105 | + if (is_string($source)) { |
|
| 106 | + $tmp_name = false; |
|
| 107 | + if (file_exists($source)) { |
|
| 108 | + $tmp_name = $source; |
|
| 109 | + } elseif (file_exists($f = determine_upload() . $source)) { |
|
| 110 | + $tmp_name = $f; |
|
| 111 | + } |
|
| 112 | + if (!$tmp_name) { |
|
| 113 | + spip_log('spip_image_ajouter : source inconnue', 'logo'); |
|
| 114 | + $erreur = 'source inconnue'; |
|
| 115 | + |
|
| 116 | + return $erreur; |
|
| 117 | + } |
|
| 118 | + $source = [ |
|
| 119 | + 'tmp_name' => $tmp_name, |
|
| 120 | + 'name' => basename($tmp_name), |
|
| 121 | + ]; |
|
| 122 | + } elseif ($erreur = check_upload_error($source['error'], '', true)) { |
|
| 123 | + return $erreur; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // supprimer le logo eventueel existant |
|
| 127 | + // TODO : si un logo existe, le modifier plutot que supprimer + reinserer (mais il faut gerer le cas ou il est utilise par plusieurs objets, donc pas si simple) |
|
| 128 | + // mais de toute facon l'interface actuelle oblige a supprimer + reinserer |
|
| 129 | + logo_supprimer($objet, $id_objet, $etat); |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + include_spip('inc/autoriser'); |
|
| 133 | + $source['mode'] = $mode_document; |
|
| 134 | + $ajouter_documents = charger_fonction('ajouter_documents', 'action'); |
|
| 135 | + autoriser_exception('associerdocuments', $objet, $id_objet); |
|
| 136 | + $ajoutes = $ajouter_documents('new', [$source], $objet, $id_objet, $mode_document); |
|
| 137 | + autoriser_exception('associerdocuments', $objet, $id_objet, false); |
|
| 138 | + |
|
| 139 | + $id_document = reset($ajoutes); |
|
| 140 | + |
|
| 141 | + if (!is_numeric($id_document)) { |
|
| 142 | + $erreur = ($id_document ?: 'Erreur inconnue'); |
|
| 143 | + spip_log("Erreur ajout logo : $erreur pour source=" . json_encode($source, JSON_THROW_ON_ERROR), 'logo'); |
|
| 144 | + return $erreur; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + return ''; // tout est bon, pas d'erreur |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | function logo_migrer_en_base($objet, $time_limit) { |
| 151 | 151 | |
| 152 | - $dir_logos_erreurs = sous_repertoire(_DIR_IMG, 'logo_erreurs'); |
|
| 153 | - $dir_logos = sous_repertoire(_DIR_IMG, 'logo'); |
|
| 154 | - $formats_logos = ['jpg', 'png', 'svg', 'gif']; |
|
| 155 | - if (isset($GLOBALS['formats_logos'])) { |
|
| 156 | - $formats_logos = $GLOBALS['formats_logos']; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 161 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 162 | - include_spip('inc/chercher_logo'); |
|
| 163 | - $_id_objet = id_table_objet($objet); |
|
| 164 | - $table = table_objet_sql($objet); |
|
| 165 | - $type = type_du_logo($_id_objet); |
|
| 166 | - $desc = $trouver_table($table); |
|
| 167 | - |
|
| 168 | - foreach (['on', 'off'] as $mode) { |
|
| 169 | - $nom_base = $type . $mode; |
|
| 170 | - $dir = (defined('_DIR_LOGOS') ? _DIR_LOGOS : _DIR_IMG); |
|
| 171 | - |
|
| 172 | - $files = glob($dir . $nom_base . '*'); |
|
| 173 | - // est-ce que c'est une nouvelle tentative de migration ? |
|
| 174 | - // dans ce cas les logos sont deja dans IMG/logo/ |
|
| 175 | - if (!(is_countable($files) ? count($files) : 0)) { |
|
| 176 | - $files = glob($dir_logos . $nom_base . '*'); |
|
| 177 | - if (is_countable($files) ? count($files) : 0) { |
|
| 178 | - // mais il faut verifier si ils ont pas deja ete migres pour tout ou partie |
|
| 179 | - $filescheck = []; |
|
| 180 | - foreach ($files as $file) { |
|
| 181 | - $short = basename(dirname($file)) . DIRECTORY_SEPARATOR . basename($file); |
|
| 182 | - $filescheck[$short] = $file; |
|
| 183 | - } |
|
| 184 | - // trouver ceux deja migres |
|
| 185 | - $deja = sql_allfetsel('fichier', 'spip_documents', sql_in('fichier', array_keys($filescheck)) . " AND mode LIKE 'logo%'"); |
|
| 186 | - if (is_countable($deja) ? count($deja) : 0) { |
|
| 187 | - $deja = array_column($deja, 'fichier'); |
|
| 188 | - $restant = array_diff(array_keys($filescheck), $deja); |
|
| 189 | - $files = []; |
|
| 190 | - if (count($restant)) { |
|
| 191 | - foreach ($restant as $r) { |
|
| 192 | - $files[] = $filescheck[$r]; |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - // et si il en reste on peut y aller... |
|
| 197 | - // mais il faut modifier $dir qui sert de base dans la suite |
|
| 198 | - if (is_countable($files) ? count($files) : 0) { |
|
| 199 | - $dir = $dir_logos; |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - spip_log("logo_migrer_en_base $objet $mode : " . (is_countable($files) ? count($files) : 0) . ' logos restant', 'maj' . _LOG_INFO_IMPORTANTE); |
|
| 205 | - |
|
| 206 | - $deja = []; |
|
| 207 | - foreach ($files as $file) { |
|
| 208 | - $logo = substr($file, strlen($dir . $nom_base)); |
|
| 209 | - $logo = explode('.', $logo); |
|
| 210 | - if ( |
|
| 211 | - is_numeric($logo[0]) |
|
| 212 | - and ($id_objet = intval($logo[0]) or in_array($objet, ['site', 'rubrique'])) |
|
| 213 | - ) { |
|
| 214 | - if (!isset($deja[$id_objet])) { |
|
| 215 | - $logo = $chercher_logo($id_objet, $_id_objet, $mode); |
|
| 216 | - // if no logo in base |
|
| 217 | - if (!$logo or (is_countable($logo) ? count($logo) : 0) < 6) { |
|
| 218 | - foreach ($formats_logos as $format) { |
|
| 219 | - if (@file_exists($d = ($dir . ($nom = $nom_base . intval($id_objet) . '.' . $format)))) { |
|
| 220 | - if (isset($desc['field']['date_modif'])) { |
|
| 221 | - $date_modif = sql_getfetsel('date_modif', $table, "$_id_objet=$id_objet"); |
|
| 222 | - } else { |
|
| 223 | - $date_modif = null; |
|
| 224 | - } |
|
| 225 | - // logo_modifier commence par supprimer le logo existant, donc on le deplace pour pas le perdre |
|
| 226 | - @rename($d, $dir_logos . $nom); |
|
| 227 | - // et on le declare comme nouveau logo |
|
| 228 | - logo_modifier($objet, $id_objet, $mode, $dir_logos . $nom); |
|
| 229 | - if ($date_modif) { |
|
| 230 | - sql_updateq($table, ['date_modif' => $date_modif], "$_id_objet=$id_objet"); |
|
| 231 | - } |
|
| 232 | - break; |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - } |
|
| 236 | - $deja[$id_objet] = true; |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - // si le fichier est encore la on le move : rien a faire ici |
|
| 240 | - // (sauf si c'est une re-migration : il est deja dans logo/ donc il bouge pas) |
|
| 241 | - if ($dir !== $dir_logos and file_exists($file)) { |
|
| 242 | - @rename($file, $dir_logos_erreurs . basename($file)); |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - if ($time_limit and time() > $time_limit) { |
|
| 246 | - effacer_meta('drapeau_edition'); |
|
| 247 | - return; |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - effacer_meta('drapeau_edition'); |
|
| 152 | + $dir_logos_erreurs = sous_repertoire(_DIR_IMG, 'logo_erreurs'); |
|
| 153 | + $dir_logos = sous_repertoire(_DIR_IMG, 'logo'); |
|
| 154 | + $formats_logos = ['jpg', 'png', 'svg', 'gif']; |
|
| 155 | + if (isset($GLOBALS['formats_logos'])) { |
|
| 156 | + $formats_logos = $GLOBALS['formats_logos']; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 161 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 162 | + include_spip('inc/chercher_logo'); |
|
| 163 | + $_id_objet = id_table_objet($objet); |
|
| 164 | + $table = table_objet_sql($objet); |
|
| 165 | + $type = type_du_logo($_id_objet); |
|
| 166 | + $desc = $trouver_table($table); |
|
| 167 | + |
|
| 168 | + foreach (['on', 'off'] as $mode) { |
|
| 169 | + $nom_base = $type . $mode; |
|
| 170 | + $dir = (defined('_DIR_LOGOS') ? _DIR_LOGOS : _DIR_IMG); |
|
| 171 | + |
|
| 172 | + $files = glob($dir . $nom_base . '*'); |
|
| 173 | + // est-ce que c'est une nouvelle tentative de migration ? |
|
| 174 | + // dans ce cas les logos sont deja dans IMG/logo/ |
|
| 175 | + if (!(is_countable($files) ? count($files) : 0)) { |
|
| 176 | + $files = glob($dir_logos . $nom_base . '*'); |
|
| 177 | + if (is_countable($files) ? count($files) : 0) { |
|
| 178 | + // mais il faut verifier si ils ont pas deja ete migres pour tout ou partie |
|
| 179 | + $filescheck = []; |
|
| 180 | + foreach ($files as $file) { |
|
| 181 | + $short = basename(dirname($file)) . DIRECTORY_SEPARATOR . basename($file); |
|
| 182 | + $filescheck[$short] = $file; |
|
| 183 | + } |
|
| 184 | + // trouver ceux deja migres |
|
| 185 | + $deja = sql_allfetsel('fichier', 'spip_documents', sql_in('fichier', array_keys($filescheck)) . " AND mode LIKE 'logo%'"); |
|
| 186 | + if (is_countable($deja) ? count($deja) : 0) { |
|
| 187 | + $deja = array_column($deja, 'fichier'); |
|
| 188 | + $restant = array_diff(array_keys($filescheck), $deja); |
|
| 189 | + $files = []; |
|
| 190 | + if (count($restant)) { |
|
| 191 | + foreach ($restant as $r) { |
|
| 192 | + $files[] = $filescheck[$r]; |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + // et si il en reste on peut y aller... |
|
| 197 | + // mais il faut modifier $dir qui sert de base dans la suite |
|
| 198 | + if (is_countable($files) ? count($files) : 0) { |
|
| 199 | + $dir = $dir_logos; |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + spip_log("logo_migrer_en_base $objet $mode : " . (is_countable($files) ? count($files) : 0) . ' logos restant', 'maj' . _LOG_INFO_IMPORTANTE); |
|
| 205 | + |
|
| 206 | + $deja = []; |
|
| 207 | + foreach ($files as $file) { |
|
| 208 | + $logo = substr($file, strlen($dir . $nom_base)); |
|
| 209 | + $logo = explode('.', $logo); |
|
| 210 | + if ( |
|
| 211 | + is_numeric($logo[0]) |
|
| 212 | + and ($id_objet = intval($logo[0]) or in_array($objet, ['site', 'rubrique'])) |
|
| 213 | + ) { |
|
| 214 | + if (!isset($deja[$id_objet])) { |
|
| 215 | + $logo = $chercher_logo($id_objet, $_id_objet, $mode); |
|
| 216 | + // if no logo in base |
|
| 217 | + if (!$logo or (is_countable($logo) ? count($logo) : 0) < 6) { |
|
| 218 | + foreach ($formats_logos as $format) { |
|
| 219 | + if (@file_exists($d = ($dir . ($nom = $nom_base . intval($id_objet) . '.' . $format)))) { |
|
| 220 | + if (isset($desc['field']['date_modif'])) { |
|
| 221 | + $date_modif = sql_getfetsel('date_modif', $table, "$_id_objet=$id_objet"); |
|
| 222 | + } else { |
|
| 223 | + $date_modif = null; |
|
| 224 | + } |
|
| 225 | + // logo_modifier commence par supprimer le logo existant, donc on le deplace pour pas le perdre |
|
| 226 | + @rename($d, $dir_logos . $nom); |
|
| 227 | + // et on le declare comme nouveau logo |
|
| 228 | + logo_modifier($objet, $id_objet, $mode, $dir_logos . $nom); |
|
| 229 | + if ($date_modif) { |
|
| 230 | + sql_updateq($table, ['date_modif' => $date_modif], "$_id_objet=$id_objet"); |
|
| 231 | + } |
|
| 232 | + break; |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | + $deja[$id_objet] = true; |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + // si le fichier est encore la on le move : rien a faire ici |
|
| 240 | + // (sauf si c'est une re-migration : il est deja dans logo/ donc il bouge pas) |
|
| 241 | + if ($dir !== $dir_logos and file_exists($file)) { |
|
| 242 | + @rename($file, $dir_logos_erreurs . basename($file)); |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + if ($time_limit and time() > $time_limit) { |
|
| 246 | + effacer_meta('drapeau_edition'); |
|
| 247 | + return; |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + effacer_meta('drapeau_edition'); |
|
| 252 | 252 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Inscription |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -39,70 +39,70 @@ discard block |
||
| 39 | 39 | * @return array|string |
| 40 | 40 | */ |
| 41 | 41 | function action_inscrire_auteur_dist($statut, $mail_complet, $nom, $options = []) { |
| 42 | - if (!is_array($options)) { |
|
| 43 | - $options = ['id' => $options]; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - if (function_exists('test_inscription')) { |
|
| 47 | - $f = 'test_inscription'; |
|
| 48 | - } else { |
|
| 49 | - $f = 'test_inscription_dist'; |
|
| 50 | - } |
|
| 51 | - $desc = $f($statut, $mail_complet, $nom, $options); |
|
| 52 | - |
|
| 53 | - // erreur ? |
|
| 54 | - if (!is_array($desc)) { |
|
| 55 | - return _T($desc); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - include_spip('base/abstract_sql'); |
|
| 59 | - $res = sql_select('statut, id_auteur, login, email', 'spip_auteurs', 'email=' . sql_quote($desc['email'])); |
|
| 60 | - // erreur ? |
|
| 61 | - if (!$res) { |
|
| 62 | - return _T('titre_probleme_technique'); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - $row = sql_fetch($res); |
|
| 66 | - sql_free($res); |
|
| 67 | - if ($row) { |
|
| 68 | - if (isset($options['force_nouveau']) and $options['force_nouveau'] == true) { |
|
| 69 | - $desc['id_auteur'] = $row['id_auteur']; |
|
| 70 | - $desc = inscription_nouveau($desc); |
|
| 71 | - } else { |
|
| 72 | - $desc = $row; |
|
| 73 | - } |
|
| 74 | - } else // s'il n'existe pas deja, creer les identifiants |
|
| 75 | - { |
|
| 76 | - $desc = inscription_nouveau($desc); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // erreur ? |
|
| 80 | - if (!is_array($desc)) { |
|
| 81 | - return $desc; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - // generer le mot de passe (ou le refaire si compte inutilise) |
|
| 86 | - $desc['pass'] = creer_pass_pour_auteur($desc['id_auteur']); |
|
| 87 | - |
|
| 88 | - // attribuer un jeton pour confirmation par clic sur un lien |
|
| 89 | - $desc['jeton'] = auteur_attribuer_jeton($desc['id_auteur']); |
|
| 90 | - |
|
| 91 | - // charger de suite cette fonction, pour ses utilitaires |
|
| 92 | - $envoyer_inscription = charger_fonction('envoyer_inscription', ''); |
|
| 93 | - [$sujet, $msg, $from, $head] = $envoyer_inscription($desc, $nom, $statut, $options); |
|
| 94 | - |
|
| 95 | - $notifications = charger_fonction('notifications', 'inc'); |
|
| 96 | - notifications_envoyer_mails($mail_complet, $msg, $sujet, $from, $head); |
|
| 97 | - |
|
| 98 | - // Notifications |
|
| 99 | - $notifications( |
|
| 100 | - 'inscription', |
|
| 101 | - $desc['id_auteur'], |
|
| 102 | - ['nom' => $desc['nom'], 'email' => $desc['email']] |
|
| 103 | - ); |
|
| 104 | - |
|
| 105 | - return $desc; |
|
| 42 | + if (!is_array($options)) { |
|
| 43 | + $options = ['id' => $options]; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + if (function_exists('test_inscription')) { |
|
| 47 | + $f = 'test_inscription'; |
|
| 48 | + } else { |
|
| 49 | + $f = 'test_inscription_dist'; |
|
| 50 | + } |
|
| 51 | + $desc = $f($statut, $mail_complet, $nom, $options); |
|
| 52 | + |
|
| 53 | + // erreur ? |
|
| 54 | + if (!is_array($desc)) { |
|
| 55 | + return _T($desc); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + include_spip('base/abstract_sql'); |
|
| 59 | + $res = sql_select('statut, id_auteur, login, email', 'spip_auteurs', 'email=' . sql_quote($desc['email'])); |
|
| 60 | + // erreur ? |
|
| 61 | + if (!$res) { |
|
| 62 | + return _T('titre_probleme_technique'); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + $row = sql_fetch($res); |
|
| 66 | + sql_free($res); |
|
| 67 | + if ($row) { |
|
| 68 | + if (isset($options['force_nouveau']) and $options['force_nouveau'] == true) { |
|
| 69 | + $desc['id_auteur'] = $row['id_auteur']; |
|
| 70 | + $desc = inscription_nouveau($desc); |
|
| 71 | + } else { |
|
| 72 | + $desc = $row; |
|
| 73 | + } |
|
| 74 | + } else // s'il n'existe pas deja, creer les identifiants |
|
| 75 | + { |
|
| 76 | + $desc = inscription_nouveau($desc); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // erreur ? |
|
| 80 | + if (!is_array($desc)) { |
|
| 81 | + return $desc; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + // generer le mot de passe (ou le refaire si compte inutilise) |
|
| 86 | + $desc['pass'] = creer_pass_pour_auteur($desc['id_auteur']); |
|
| 87 | + |
|
| 88 | + // attribuer un jeton pour confirmation par clic sur un lien |
|
| 89 | + $desc['jeton'] = auteur_attribuer_jeton($desc['id_auteur']); |
|
| 90 | + |
|
| 91 | + // charger de suite cette fonction, pour ses utilitaires |
|
| 92 | + $envoyer_inscription = charger_fonction('envoyer_inscription', ''); |
|
| 93 | + [$sujet, $msg, $from, $head] = $envoyer_inscription($desc, $nom, $statut, $options); |
|
| 94 | + |
|
| 95 | + $notifications = charger_fonction('notifications', 'inc'); |
|
| 96 | + notifications_envoyer_mails($mail_complet, $msg, $sujet, $from, $head); |
|
| 97 | + |
|
| 98 | + // Notifications |
|
| 99 | + $notifications( |
|
| 100 | + 'inscription', |
|
| 101 | + $desc['id_auteur'], |
|
| 102 | + ['nom' => $desc['nom'], 'email' => $desc['email']] |
|
| 103 | + ); |
|
| 104 | + |
|
| 105 | + return $desc; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
@@ -125,23 +125,23 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | */ |
| 127 | 127 | function test_inscription_dist($statut, $mail, $nom, $options) { |
| 128 | - include_spip('inc/filtres'); |
|
| 129 | - if (!$r = email_valide($mail)) { |
|
| 130 | - return 'info_email_invalide'; |
|
| 131 | - } |
|
| 132 | - $nom = trim(corriger_caracteres($nom)); |
|
| 133 | - $res = ['email' => $r, 'nom' => $nom, 'prefs' => $statut]; |
|
| 134 | - if (isset($options['login'])) { |
|
| 135 | - $login = trim(corriger_caracteres($options['login'])); |
|
| 136 | - if ((strlen($login) >= _LOGIN_TROP_COURT) and (strlen($nom) <= 64)) { |
|
| 137 | - $res['login'] = $login; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - if (!isset($res['login']) and ((strlen($nom) < _LOGIN_TROP_COURT) or (strlen($nom) > 64))) { |
|
| 141 | - return 'ecrire:info_login_trop_court'; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - return $res; |
|
| 128 | + include_spip('inc/filtres'); |
|
| 129 | + if (!$r = email_valide($mail)) { |
|
| 130 | + return 'info_email_invalide'; |
|
| 131 | + } |
|
| 132 | + $nom = trim(corriger_caracteres($nom)); |
|
| 133 | + $res = ['email' => $r, 'nom' => $nom, 'prefs' => $statut]; |
|
| 134 | + if (isset($options['login'])) { |
|
| 135 | + $login = trim(corriger_caracteres($options['login'])); |
|
| 136 | + if ((strlen($login) >= _LOGIN_TROP_COURT) and (strlen($nom) <= 64)) { |
|
| 137 | + $res['login'] = $login; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + if (!isset($res['login']) and ((strlen($nom) < _LOGIN_TROP_COURT) or (strlen($nom) > 64))) { |
|
| 141 | + return 'ecrire:info_login_trop_court'; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + return $res; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | |
@@ -154,33 +154,33 @@ discard block |
||
| 154 | 154 | * @return mixed|string |
| 155 | 155 | */ |
| 156 | 156 | function inscription_nouveau($desc) { |
| 157 | - if (!isset($desc['login']) or !strlen($desc['login'])) { |
|
| 158 | - $desc['login'] = test_login($desc['nom'], $desc['email']); |
|
| 159 | - } |
|
| 157 | + if (!isset($desc['login']) or !strlen($desc['login'])) { |
|
| 158 | + $desc['login'] = test_login($desc['nom'], $desc['email']); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - $desc['statut'] = 'nouveau'; |
|
| 162 | - include_spip('action/editer_auteur'); |
|
| 163 | - if (isset($desc['id_auteur'])) { |
|
| 164 | - $id_auteur = $desc['id_auteur']; |
|
| 165 | - } else { |
|
| 166 | - $id_auteur = auteur_inserer(); |
|
| 167 | - } |
|
| 161 | + $desc['statut'] = 'nouveau'; |
|
| 162 | + include_spip('action/editer_auteur'); |
|
| 163 | + if (isset($desc['id_auteur'])) { |
|
| 164 | + $id_auteur = $desc['id_auteur']; |
|
| 165 | + } else { |
|
| 166 | + $id_auteur = auteur_inserer(); |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - if (!$id_auteur) { |
|
| 170 | - return _T('titre_probleme_technique'); |
|
| 171 | - } |
|
| 169 | + if (!$id_auteur) { |
|
| 170 | + return _T('titre_probleme_technique'); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - $desc['lang'] = $GLOBALS['spip_lang']; |
|
| 173 | + $desc['lang'] = $GLOBALS['spip_lang']; |
|
| 174 | 174 | |
| 175 | - include_spip('inc/autoriser'); |
|
| 176 | - // lever l'autorisation pour pouvoir modifier le statut |
|
| 177 | - autoriser_exception('modifier', 'auteur', $id_auteur); |
|
| 178 | - auteur_modifier($id_auteur, $desc); |
|
| 179 | - autoriser_exception('modifier', 'auteur', $id_auteur, false); |
|
| 175 | + include_spip('inc/autoriser'); |
|
| 176 | + // lever l'autorisation pour pouvoir modifier le statut |
|
| 177 | + autoriser_exception('modifier', 'auteur', $id_auteur); |
|
| 178 | + auteur_modifier($id_auteur, $desc); |
|
| 179 | + autoriser_exception('modifier', 'auteur', $id_auteur, false); |
|
| 180 | 180 | |
| 181 | - $desc['id_auteur'] = $id_auteur; |
|
| 181 | + $desc['id_auteur'] = $id_auteur; |
|
| 182 | 182 | |
| 183 | - return $desc; |
|
| 183 | + return $desc; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
@@ -192,29 +192,29 @@ discard block |
||
| 192 | 192 | * @return string |
| 193 | 193 | */ |
| 194 | 194 | function test_login($nom, $mail) { |
| 195 | - include_spip('inc/charsets'); |
|
| 196 | - $nom = strtolower(translitteration($nom)); |
|
| 197 | - $login_base = preg_replace('/[^\w\d_]/', '_', $nom); |
|
| 198 | - |
|
| 199 | - // il faut eviter que le login soit vraiment trop court |
|
| 200 | - if (strlen($login_base) < 3) { |
|
| 201 | - $mail = strtolower(translitteration(preg_replace('/@.*/', '', $mail))); |
|
| 202 | - $login_base = preg_replace('/[^\w\d]/', '_', $mail); |
|
| 203 | - } |
|
| 204 | - if (strlen($login_base) < 3) { |
|
| 205 | - $login_base = 'user'; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - $login = $login_base; |
|
| 209 | - |
|
| 210 | - for ($i = 1;; $i++) { |
|
| 211 | - if (!sql_countsel('spip_auteurs', "login='$login'")) { |
|
| 212 | - return $login; |
|
| 213 | - } |
|
| 214 | - $login = $login_base . $i; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - return $login; |
|
| 195 | + include_spip('inc/charsets'); |
|
| 196 | + $nom = strtolower(translitteration($nom)); |
|
| 197 | + $login_base = preg_replace('/[^\w\d_]/', '_', $nom); |
|
| 198 | + |
|
| 199 | + // il faut eviter que le login soit vraiment trop court |
|
| 200 | + if (strlen($login_base) < 3) { |
|
| 201 | + $mail = strtolower(translitteration(preg_replace('/@.*/', '', $mail))); |
|
| 202 | + $login_base = preg_replace('/[^\w\d]/', '_', $mail); |
|
| 203 | + } |
|
| 204 | + if (strlen($login_base) < 3) { |
|
| 205 | + $login_base = 'user'; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + $login = $login_base; |
|
| 209 | + |
|
| 210 | + for ($i = 1;; $i++) { |
|
| 211 | + if (!sql_countsel('spip_auteurs', "login='$login'")) { |
|
| 212 | + return $login; |
|
| 213 | + } |
|
| 214 | + $login = $login_base . $i; |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + return $login; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | |
@@ -232,26 +232,26 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | function envoyer_inscription_dist($desc, $nom, $mode, $options = []) { |
| 234 | 234 | |
| 235 | - $contexte = array_merge($desc, $options); |
|
| 236 | - $contexte['nom'] = $nom; |
|
| 237 | - $contexte['mode'] = $mode; |
|
| 238 | - $contexte['url_confirm'] = generer_url_action('confirmer_inscription', '', true, true); |
|
| 239 | - $contexte['url_confirm'] = parametre_url($contexte['url_confirm'], 'email', $desc['email']); |
|
| 240 | - $contexte['url_confirm'] = parametre_url($contexte['url_confirm'], 'jeton', $desc['jeton']); |
|
| 241 | - // S'il y a l'option redirect, on l'ajoute directement ici |
|
| 242 | - if (isset($options['redirect'])) { |
|
| 243 | - $contexte['url_confirm'] = parametre_url($contexte['url_confirm'], 'redirect', $options['redirect']); |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - $modele_mail = 'modeles/mail_inscription'; |
|
| 247 | - if (isset($options['modele_mail']) and $options['modele_mail']) { |
|
| 248 | - $modele_mail = $options['modele_mail']; |
|
| 249 | - } |
|
| 250 | - $message = recuperer_fond($modele_mail, $contexte); |
|
| 251 | - $from = ($options['from'] ?? null); |
|
| 252 | - $head = null; |
|
| 253 | - |
|
| 254 | - return ['', $message, $from, $head]; |
|
| 235 | + $contexte = array_merge($desc, $options); |
|
| 236 | + $contexte['nom'] = $nom; |
|
| 237 | + $contexte['mode'] = $mode; |
|
| 238 | + $contexte['url_confirm'] = generer_url_action('confirmer_inscription', '', true, true); |
|
| 239 | + $contexte['url_confirm'] = parametre_url($contexte['url_confirm'], 'email', $desc['email']); |
|
| 240 | + $contexte['url_confirm'] = parametre_url($contexte['url_confirm'], 'jeton', $desc['jeton']); |
|
| 241 | + // S'il y a l'option redirect, on l'ajoute directement ici |
|
| 242 | + if (isset($options['redirect'])) { |
|
| 243 | + $contexte['url_confirm'] = parametre_url($contexte['url_confirm'], 'redirect', $options['redirect']); |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + $modele_mail = 'modeles/mail_inscription'; |
|
| 247 | + if (isset($options['modele_mail']) and $options['modele_mail']) { |
|
| 248 | + $modele_mail = $options['modele_mail']; |
|
| 249 | + } |
|
| 250 | + $message = recuperer_fond($modele_mail, $contexte); |
|
| 251 | + $from = ($options['from'] ?? null); |
|
| 252 | + $head = null; |
|
| 253 | + |
|
| 254 | + return ['', $message, $from, $head]; |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | * @return string |
| 263 | 263 | */ |
| 264 | 264 | function creer_pass_pour_auteur($id_auteur) { |
| 265 | - include_spip('inc/acces'); |
|
| 266 | - $pass = creer_pass_aleatoire(max(_PASS_LONGUEUR_MINI, 16), $id_auteur); |
|
| 267 | - include_spip('action/editer_auteur'); |
|
| 268 | - auteur_instituer($id_auteur, ['pass' => $pass]); |
|
| 265 | + include_spip('inc/acces'); |
|
| 266 | + $pass = creer_pass_aleatoire(max(_PASS_LONGUEUR_MINI, 16), $id_auteur); |
|
| 267 | + include_spip('action/editer_auteur'); |
|
| 268 | + auteur_instituer($id_auteur, ['pass' => $pass]); |
|
| 269 | 269 | |
| 270 | - return $pass; |
|
| 270 | + return $pass; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -280,17 +280,17 @@ discard block |
||
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | 282 | function tester_statut_inscription($statut_tmp, $id) { |
| 283 | - include_spip('inc/autoriser'); |
|
| 284 | - if ($statut_tmp) { |
|
| 285 | - return autoriser('inscrireauteur', $statut_tmp, $id) ? $statut_tmp : ''; |
|
| 286 | - } elseif ( |
|
| 287 | - autoriser('inscrireauteur', $statut_tmp = '1comite', $id) |
|
| 288 | - or autoriser('inscrireauteur', $statut_tmp = '6forum', $id) |
|
| 289 | - ) { |
|
| 290 | - return $statut_tmp; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - return ''; |
|
| 283 | + include_spip('inc/autoriser'); |
|
| 284 | + if ($statut_tmp) { |
|
| 285 | + return autoriser('inscrireauteur', $statut_tmp, $id) ? $statut_tmp : ''; |
|
| 286 | + } elseif ( |
|
| 287 | + autoriser('inscrireauteur', $statut_tmp = '1comite', $id) |
|
| 288 | + or autoriser('inscrireauteur', $statut_tmp = '6forum', $id) |
|
| 289 | + ) { |
|
| 290 | + return $statut_tmp; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + return ''; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | |
@@ -304,35 +304,35 @@ discard block |
||
| 304 | 304 | * @return array |
| 305 | 305 | */ |
| 306 | 306 | function confirmer_statut_inscription($auteur) { |
| 307 | - // securite |
|
| 308 | - if ($auteur['statut'] != 'nouveau') { |
|
| 309 | - return $auteur; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - $s = $auteur['prefs']; |
|
| 313 | - // securite, au cas ou prefs aurait ete corrompu (ou deja ecrase par un tableau serialize) |
|
| 314 | - if (!preg_match(',^\w+$,', $s)) { |
|
| 315 | - $s = '6forum'; |
|
| 316 | - } |
|
| 317 | - include_spip('inc/autoriser'); |
|
| 318 | - if (!autoriser('inscrireauteur', $s)) { |
|
| 319 | - return $auteur; |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - include_spip('inc/autoriser'); |
|
| 323 | - // accorder l'autorisation de modif du statut auteur |
|
| 324 | - autoriser_exception('modifier', 'auteur', $auteur['id_auteur']); |
|
| 325 | - include_spip('action/editer_auteur'); |
|
| 326 | - // changer le statut |
|
| 327 | - auteur_modifier($auteur['id_auteur'], ['statut' => $s]); |
|
| 328 | - unset($_COOKIE['spip_session']); // forcer la maj de la session |
|
| 329 | - // lever l'autorisation de modif du statut auteur |
|
| 330 | - autoriser_exception('modifier', 'auteur', $auteur['id_auteur'], false); |
|
| 331 | - |
|
| 332 | - // mettre a jour le statut |
|
| 333 | - $auteur['statut'] = $s; |
|
| 334 | - |
|
| 335 | - return $auteur; |
|
| 307 | + // securite |
|
| 308 | + if ($auteur['statut'] != 'nouveau') { |
|
| 309 | + return $auteur; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + $s = $auteur['prefs']; |
|
| 313 | + // securite, au cas ou prefs aurait ete corrompu (ou deja ecrase par un tableau serialize) |
|
| 314 | + if (!preg_match(',^\w+$,', $s)) { |
|
| 315 | + $s = '6forum'; |
|
| 316 | + } |
|
| 317 | + include_spip('inc/autoriser'); |
|
| 318 | + if (!autoriser('inscrireauteur', $s)) { |
|
| 319 | + return $auteur; |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + include_spip('inc/autoriser'); |
|
| 323 | + // accorder l'autorisation de modif du statut auteur |
|
| 324 | + autoriser_exception('modifier', 'auteur', $auteur['id_auteur']); |
|
| 325 | + include_spip('action/editer_auteur'); |
|
| 326 | + // changer le statut |
|
| 327 | + auteur_modifier($auteur['id_auteur'], ['statut' => $s]); |
|
| 328 | + unset($_COOKIE['spip_session']); // forcer la maj de la session |
|
| 329 | + // lever l'autorisation de modif du statut auteur |
|
| 330 | + autoriser_exception('modifier', 'auteur', $auteur['id_auteur'], false); |
|
| 331 | + |
|
| 332 | + // mettre a jour le statut |
|
| 333 | + $auteur['statut'] = $s; |
|
| 334 | + |
|
| 335 | + return $auteur; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | |
@@ -344,14 +344,14 @@ discard block |
||
| 344 | 344 | * @return string |
| 345 | 345 | */ |
| 346 | 346 | function auteur_attribuer_jeton($id_auteur) { |
| 347 | - include_spip('inc/acces'); |
|
| 348 | - // s'assurer de l'unicite du jeton pour le couple (email,cookie) |
|
| 349 | - do { |
|
| 350 | - $jeton = creer_uniqid(); |
|
| 351 | - sql_updateq('spip_auteurs', ['cookie_oubli' => $jeton], 'id_auteur=' . intval($id_auteur)); |
|
| 352 | - } while (sql_countsel('spip_auteurs', 'cookie_oubli=' . sql_quote($jeton)) > 1); |
|
| 353 | - |
|
| 354 | - return $jeton; |
|
| 347 | + include_spip('inc/acces'); |
|
| 348 | + // s'assurer de l'unicite du jeton pour le couple (email,cookie) |
|
| 349 | + do { |
|
| 350 | + $jeton = creer_uniqid(); |
|
| 351 | + sql_updateq('spip_auteurs', ['cookie_oubli' => $jeton], 'id_auteur=' . intval($id_auteur)); |
|
| 352 | + } while (sql_countsel('spip_auteurs', 'cookie_oubli=' . sql_quote($jeton)) > 1); |
|
| 353 | + |
|
| 354 | + return $jeton; |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | /** |
@@ -361,15 +361,15 @@ discard block |
||
| 361 | 361 | * @return array|bool |
| 362 | 362 | */ |
| 363 | 363 | function auteur_verifier_jeton($jeton) { |
| 364 | - // refuser un jeton corrompu |
|
| 365 | - if (preg_match(',[^0-9a-f.],i', $jeton)) { |
|
| 366 | - return false; |
|
| 367 | - } |
|
| 364 | + // refuser un jeton corrompu |
|
| 365 | + if (preg_match(',[^0-9a-f.],i', $jeton)) { |
|
| 366 | + return false; |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - // on peut tomber sur un jeton compose uniquement de chiffres, il faut forcer le $type pour sql_quote pour eviter de planter |
|
| 370 | - $desc = sql_fetsel('*', 'spip_auteurs', 'cookie_oubli=' . sql_quote($jeton, '', 'string')); |
|
| 369 | + // on peut tomber sur un jeton compose uniquement de chiffres, il faut forcer le $type pour sql_quote pour eviter de planter |
|
| 370 | + $desc = sql_fetsel('*', 'spip_auteurs', 'cookie_oubli=' . sql_quote($jeton, '', 'string')); |
|
| 371 | 371 | |
| 372 | - return $desc; |
|
| 372 | + return $desc; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -379,5 +379,5 @@ discard block |
||
| 379 | 379 | * @return bool |
| 380 | 380 | */ |
| 381 | 381 | function auteur_effacer_jeton($id_auteur) { |
| 382 | - return sql_updateq('spip_auteurs', ['cookie_oubli' => ''], 'id_auteur=' . intval($id_auteur)); |
|
| 382 | + return sql_updateq('spip_auteurs', ['cookie_oubli' => ''], 'id_auteur=' . intval($id_auteur)); |
|
| 383 | 383 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | * @return void |
| 36 | 36 | */ |
| 37 | 37 | function action_supprimer_lien_dist($arg = null) { |
| 38 | - if (is_null($arg)) { |
|
| 39 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 40 | - $arg = $securiser_action(); |
|
| 41 | - } |
|
| 38 | + if (is_null($arg)) { |
|
| 39 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 40 | + $arg = $securiser_action(); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $arg = explode('-', $arg); |
|
| 44 | - [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 43 | + $arg = explode('-', $arg); |
|
| 44 | + [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 45 | 45 | |
| 46 | - include_spip('action/editer_liens'); |
|
| 47 | - objet_dissocier([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 46 | + include_spip('action/editer_liens'); |
|
| 47 | + objet_dissocier([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 48 | 48 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | include_spip('inc/headers'); |
| 24 | 24 | |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | * Sortie du buffer |
| 36 | 36 | **/ |
| 37 | 37 | function action_tester_taille_error_handler($output) { |
| 38 | - // on est ici, donc echec lors de la creation de l'image |
|
| 39 | - if (!empty($GLOBALS['redirect'])) { |
|
| 40 | - return redirige_formulaire($GLOBALS['redirect']); |
|
| 41 | - } |
|
| 38 | + // on est ici, donc echec lors de la creation de l'image |
|
| 39 | + if (!empty($GLOBALS['redirect'])) { |
|
| 40 | + return redirige_formulaire($GLOBALS['redirect']); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - return $output; |
|
| 43 | + return $output; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -58,77 +58,77 @@ discard block |
||
| 58 | 58 | **/ |
| 59 | 59 | function action_tester_taille_dist() { |
| 60 | 60 | |
| 61 | - if (!autoriser('configurer')) { |
|
| 62 | - return; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - $taille = _request('arg'); |
|
| 66 | - $taille = explode('-', $taille); |
|
| 67 | - |
|
| 68 | - $GLOBALS['taille_max'] = end($taille); |
|
| 69 | - $GLOBALS['taille_min'] = 0; |
|
| 70 | - if (count($taille) > 1) { |
|
| 71 | - $GLOBALS['taille_min'] = reset($taille); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - // si l'intervalle est assez petit, on garde la valeur min |
|
| 75 | - if ($GLOBALS['taille_max'] * $GLOBALS['taille_max'] - $GLOBALS['taille_min'] * $GLOBALS['taille_min'] < 50000) { |
|
| 76 | - $t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']); |
|
| 77 | - if ($GLOBALS['taille_min'] !== $GLOBALS['taille_max']) { |
|
| 78 | - $t = $t * 0.9; // marge de securite |
|
| 79 | - echo round($t / 1_000_000, 3) . ' Mpx'; |
|
| 80 | - } else { |
|
| 81 | - // c'est un cas "on a reussi la borne max initiale, donc on a pas de limite connue" |
|
| 82 | - $t = 0; |
|
| 83 | - echo '∞'; |
|
| 84 | - } |
|
| 85 | - ecrire_meta('max_taille_vignettes', $t, 'non'); |
|
| 86 | - die(); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max'] + $GLOBALS['taille_min']) / 2); |
|
| 90 | - |
|
| 91 | - include_spip('inc/filtres'); |
|
| 92 | - // des inclusions representatives d'un hit prive et/ou public pour la conso memoire |
|
| 93 | - include_spip('public/assembler'); |
|
| 94 | - include_spip('public/balises'); |
|
| 95 | - include_spip('public/boucles'); |
|
| 96 | - include_spip('public/cacher'); |
|
| 97 | - include_spip('public/compiler'); |
|
| 98 | - include_spip('public/composer'); |
|
| 99 | - include_spip('public/criteres'); |
|
| 100 | - include_spip('public/interfaces'); |
|
| 101 | - include_spip('public/parametrer'); |
|
| 102 | - include_spip('public/phraser_html'); |
|
| 103 | - include_spip('public/references'); |
|
| 104 | - |
|
| 105 | - include_spip('inc/presentation'); |
|
| 106 | - include_spip('inc/charsets'); |
|
| 107 | - include_spip('inc/documents'); |
|
| 108 | - include_spip('inc/header'); |
|
| 109 | - propre('<doc1>'); // charger propre avec le trairement d'un modele |
|
| 110 | - |
|
| 111 | - $i = _request('i') + 1; |
|
| 112 | - $image_source = chemin_image('test.png'); |
|
| 113 | - $GLOBALS['redirect'] = generer_url_action( |
|
| 114 | - 'tester_taille', |
|
| 115 | - "i=$i&arg=" . $GLOBALS['taille_min'] . '-' . $GLOBALS['taille_test'] |
|
| 116 | - ); |
|
| 117 | - |
|
| 118 | - ob_start('action_tester_taille_error_handler'); |
|
| 119 | - filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 120 | - $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 121 | - |
|
| 122 | - // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee |
|
| 123 | - // si $GLOBALS['taille_min']==0 (car on est au premier coup) |
|
| 124 | - if ($GLOBALS['taille_min'] == 0) { |
|
| 125 | - $taille = $GLOBALS['taille_max']; |
|
| 126 | - filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 127 | - $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 128 | - } |
|
| 129 | - ob_end_clean(); |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - // on est ici, donc pas de plantage |
|
| 133 | - echo redirige_formulaire($GLOBALS['redirect']); |
|
| 61 | + if (!autoriser('configurer')) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + $taille = _request('arg'); |
|
| 66 | + $taille = explode('-', $taille); |
|
| 67 | + |
|
| 68 | + $GLOBALS['taille_max'] = end($taille); |
|
| 69 | + $GLOBALS['taille_min'] = 0; |
|
| 70 | + if (count($taille) > 1) { |
|
| 71 | + $GLOBALS['taille_min'] = reset($taille); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + // si l'intervalle est assez petit, on garde la valeur min |
|
| 75 | + if ($GLOBALS['taille_max'] * $GLOBALS['taille_max'] - $GLOBALS['taille_min'] * $GLOBALS['taille_min'] < 50000) { |
|
| 76 | + $t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']); |
|
| 77 | + if ($GLOBALS['taille_min'] !== $GLOBALS['taille_max']) { |
|
| 78 | + $t = $t * 0.9; // marge de securite |
|
| 79 | + echo round($t / 1_000_000, 3) . ' Mpx'; |
|
| 80 | + } else { |
|
| 81 | + // c'est un cas "on a reussi la borne max initiale, donc on a pas de limite connue" |
|
| 82 | + $t = 0; |
|
| 83 | + echo '∞'; |
|
| 84 | + } |
|
| 85 | + ecrire_meta('max_taille_vignettes', $t, 'non'); |
|
| 86 | + die(); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max'] + $GLOBALS['taille_min']) / 2); |
|
| 90 | + |
|
| 91 | + include_spip('inc/filtres'); |
|
| 92 | + // des inclusions representatives d'un hit prive et/ou public pour la conso memoire |
|
| 93 | + include_spip('public/assembler'); |
|
| 94 | + include_spip('public/balises'); |
|
| 95 | + include_spip('public/boucles'); |
|
| 96 | + include_spip('public/cacher'); |
|
| 97 | + include_spip('public/compiler'); |
|
| 98 | + include_spip('public/composer'); |
|
| 99 | + include_spip('public/criteres'); |
|
| 100 | + include_spip('public/interfaces'); |
|
| 101 | + include_spip('public/parametrer'); |
|
| 102 | + include_spip('public/phraser_html'); |
|
| 103 | + include_spip('public/references'); |
|
| 104 | + |
|
| 105 | + include_spip('inc/presentation'); |
|
| 106 | + include_spip('inc/charsets'); |
|
| 107 | + include_spip('inc/documents'); |
|
| 108 | + include_spip('inc/header'); |
|
| 109 | + propre('<doc1>'); // charger propre avec le trairement d'un modele |
|
| 110 | + |
|
| 111 | + $i = _request('i') + 1; |
|
| 112 | + $image_source = chemin_image('test.png'); |
|
| 113 | + $GLOBALS['redirect'] = generer_url_action( |
|
| 114 | + 'tester_taille', |
|
| 115 | + "i=$i&arg=" . $GLOBALS['taille_min'] . '-' . $GLOBALS['taille_test'] |
|
| 116 | + ); |
|
| 117 | + |
|
| 118 | + ob_start('action_tester_taille_error_handler'); |
|
| 119 | + filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 120 | + $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 121 | + |
|
| 122 | + // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee |
|
| 123 | + // si $GLOBALS['taille_min']==0 (car on est au premier coup) |
|
| 124 | + if ($GLOBALS['taille_min'] == 0) { |
|
| 125 | + $taille = $GLOBALS['taille_max']; |
|
| 126 | + filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 127 | + $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 128 | + } |
|
| 129 | + ob_end_clean(); |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + // on est ici, donc pas de plantage |
|
| 133 | + echo redirige_formulaire($GLOBALS['redirect']); |
|
| 134 | 134 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -40,36 +40,36 @@ discard block |
||
| 40 | 40 | * Liste (identifiant de l'article, Texte d'erreur éventuel) |
| 41 | 41 | */ |
| 42 | 42 | function action_editer_article_dist($arg = null) { |
| 43 | - include_spip('inc/autoriser'); |
|
| 44 | - $err = ''; |
|
| 45 | - if (is_null($arg)) { |
|
| 46 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 47 | - $arg = $securiser_action(); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - // si id_article n'est pas un nombre, c'est une creation |
|
| 51 | - // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 52 | - if (!$id_article = intval($arg)) { |
|
| 53 | - $id_parent = _request('id_parent'); |
|
| 54 | - if (!$id_parent) { |
|
| 55 | - $err = _L("creation interdite d'un article sans rubrique"); |
|
| 56 | - } elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) { |
|
| 57 | - $err = _T('info_creerdansrubrique_non_autorise'); |
|
| 58 | - } else { |
|
| 59 | - $id_article = article_inserer($id_parent); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // Enregistre l'envoi dans la BD |
|
| 64 | - if ($id_article > 0) { |
|
| 65 | - $err = article_modifier($id_article); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - if ($err) { |
|
| 69 | - spip_log("echec editeur article: $err", _LOG_ERREUR); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - return [$id_article, $err]; |
|
| 43 | + include_spip('inc/autoriser'); |
|
| 44 | + $err = ''; |
|
| 45 | + if (is_null($arg)) { |
|
| 46 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 47 | + $arg = $securiser_action(); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + // si id_article n'est pas un nombre, c'est une creation |
|
| 51 | + // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 52 | + if (!$id_article = intval($arg)) { |
|
| 53 | + $id_parent = _request('id_parent'); |
|
| 54 | + if (!$id_parent) { |
|
| 55 | + $err = _L("creation interdite d'un article sans rubrique"); |
|
| 56 | + } elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) { |
|
| 57 | + $err = _T('info_creerdansrubrique_non_autorise'); |
|
| 58 | + } else { |
|
| 59 | + $id_article = article_inserer($id_parent); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // Enregistre l'envoi dans la BD |
|
| 64 | + if ($id_article > 0) { |
|
| 65 | + $err = article_modifier($id_article); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + if ($err) { |
|
| 69 | + spip_log("echec editeur article: $err", _LOG_ERREUR); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + return [$id_article, $err]; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -91,50 +91,50 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | function article_modifier($id_article, $set = null) { |
| 93 | 93 | |
| 94 | - // unifier $texte en cas de texte trop long |
|
| 95 | - trop_longs_articles(); |
|
| 96 | - |
|
| 97 | - include_spip('inc/modifier'); |
|
| 98 | - include_spip('inc/filtres'); |
|
| 99 | - $c = collecter_requests( |
|
| 100 | - // white list |
|
| 101 | - objet_info('article', 'champs_editables'), |
|
| 102 | - // black list |
|
| 103 | - ['date', 'statut', 'id_parent'], |
|
| 104 | - // donnees eventuellement fournies |
|
| 105 | - $set |
|
| 106 | - ); |
|
| 107 | - |
|
| 108 | - // Si l'article est publie, invalider les caches et demander sa reindexation |
|
| 109 | - $t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id_article)); |
|
| 110 | - $invalideur = $indexation = false; |
|
| 111 | - if ($t == 'publie') { |
|
| 112 | - $invalideur = "id='article/$id_article'"; |
|
| 113 | - $indexation = true; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - if ( |
|
| 117 | - $err = objet_modifier_champs( |
|
| 118 | - 'article', |
|
| 119 | - $id_article, |
|
| 120 | - [ |
|
| 121 | - 'data' => $set, |
|
| 122 | - 'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article], |
|
| 123 | - 'invalideur' => $invalideur, |
|
| 124 | - 'indexation' => $indexation, |
|
| 125 | - 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 126 | - ], |
|
| 127 | - $c |
|
| 128 | - ) |
|
| 129 | - ) { |
|
| 130 | - return $err; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // Modification de statut, changement de rubrique ? |
|
| 134 | - $c = collecter_requests(['date', 'statut', 'id_parent'], [], $set); |
|
| 135 | - $err = article_instituer($id_article, $c); |
|
| 136 | - |
|
| 137 | - return $err; |
|
| 94 | + // unifier $texte en cas de texte trop long |
|
| 95 | + trop_longs_articles(); |
|
| 96 | + |
|
| 97 | + include_spip('inc/modifier'); |
|
| 98 | + include_spip('inc/filtres'); |
|
| 99 | + $c = collecter_requests( |
|
| 100 | + // white list |
|
| 101 | + objet_info('article', 'champs_editables'), |
|
| 102 | + // black list |
|
| 103 | + ['date', 'statut', 'id_parent'], |
|
| 104 | + // donnees eventuellement fournies |
|
| 105 | + $set |
|
| 106 | + ); |
|
| 107 | + |
|
| 108 | + // Si l'article est publie, invalider les caches et demander sa reindexation |
|
| 109 | + $t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id_article)); |
|
| 110 | + $invalideur = $indexation = false; |
|
| 111 | + if ($t == 'publie') { |
|
| 112 | + $invalideur = "id='article/$id_article'"; |
|
| 113 | + $indexation = true; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + if ( |
|
| 117 | + $err = objet_modifier_champs( |
|
| 118 | + 'article', |
|
| 119 | + $id_article, |
|
| 120 | + [ |
|
| 121 | + 'data' => $set, |
|
| 122 | + 'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article], |
|
| 123 | + 'invalideur' => $invalideur, |
|
| 124 | + 'indexation' => $indexation, |
|
| 125 | + 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 126 | + ], |
|
| 127 | + $c |
|
| 128 | + ) |
|
| 129 | + ) { |
|
| 130 | + return $err; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // Modification de statut, changement de rubrique ? |
|
| 134 | + $c = collecter_requests(['date', 'statut', 'id_parent'], [], $set); |
|
| 135 | + $err = article_instituer($id_article, $c); |
|
| 136 | + |
|
| 137 | + return $err; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -170,98 +170,98 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | function article_inserer($id_rubrique, $set = null) { |
| 172 | 172 | |
| 173 | - // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article |
|
| 174 | - // dans la premiere rubrique racine |
|
| 175 | - if (!$id_rubrique = intval($id_rubrique)) { |
|
| 176 | - $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 177 | - $id_rubrique = $row['id_rubrique']; |
|
| 178 | - } else { |
|
| 179 | - $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue |
|
| 183 | - // cas de id_rubrique = -1 par exemple avec plugin "pages" |
|
| 184 | - $id_secteur = $row['id_secteur'] ?? 0; |
|
| 185 | - $lang_rub = $row['lang'] ?? ''; |
|
| 186 | - |
|
| 187 | - $lang = ''; |
|
| 188 | - $choisie = 'non'; |
|
| 189 | - // La langue a la creation : si les liens de traduction sont autorises |
|
| 190 | - // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 191 | - // ou a defaut celle de la rubrique |
|
| 192 | - // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 193 | - if ( |
|
| 194 | - !empty($GLOBALS['meta']['multi_objets']) and in_array( |
|
| 195 | - 'spip_articles', |
|
| 196 | - explode(',', $GLOBALS['meta']['multi_objets']) |
|
| 197 | - ) |
|
| 198 | - ) { |
|
| 199 | - lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 200 | - if ( |
|
| 201 | - in_array( |
|
| 202 | - $GLOBALS['spip_lang'], |
|
| 203 | - explode(',', $GLOBALS['meta']['langues_multilingue']) |
|
| 204 | - ) |
|
| 205 | - ) { |
|
| 206 | - $lang = $GLOBALS['spip_lang']; |
|
| 207 | - $choisie = 'oui'; |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - if (!$lang) { |
|
| 212 | - $choisie = 'non'; |
|
| 213 | - $lang = $lang_rub ?: $GLOBALS['meta']['langue_site']; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - $champs = [ |
|
| 217 | - 'id_rubrique' => $id_rubrique, |
|
| 218 | - 'id_secteur' => $id_secteur, |
|
| 219 | - 'statut' => 'prepa', |
|
| 220 | - 'date' => date('Y-m-d H:i:s'), |
|
| 221 | - 'lang' => $lang, |
|
| 222 | - 'langue_choisie' => $choisie |
|
| 223 | - ]; |
|
| 224 | - |
|
| 225 | - if ($set) { |
|
| 226 | - $champs = array_merge($champs, $set); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - // Envoyer aux plugins |
|
| 230 | - $champs = pipeline( |
|
| 231 | - 'pre_insertion', |
|
| 232 | - [ |
|
| 233 | - 'args' => [ |
|
| 234 | - 'table' => 'spip_articles', |
|
| 235 | - ], |
|
| 236 | - 'data' => $champs |
|
| 237 | - ] |
|
| 238 | - ); |
|
| 239 | - |
|
| 240 | - $id_article = sql_insertq('spip_articles', $champs); |
|
| 241 | - |
|
| 242 | - // controler si le serveur n'a pas renvoye une erreur |
|
| 243 | - if ($id_article > 0) { |
|
| 244 | - $id_auteur = ((is_null(_request('id_auteur')) and isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 245 | - $GLOBALS['visiteur_session']['id_auteur'] |
|
| 246 | - : _request('id_auteur')); |
|
| 247 | - if ($id_auteur) { |
|
| 248 | - include_spip('action/editer_auteur'); |
|
| 249 | - auteur_associer($id_auteur, ['article' => $id_article]); |
|
| 250 | - } |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - pipeline( |
|
| 254 | - 'post_insertion', |
|
| 255 | - [ |
|
| 256 | - 'args' => [ |
|
| 257 | - 'table' => 'spip_articles', |
|
| 258 | - 'id_objet' => $id_article |
|
| 259 | - ], |
|
| 260 | - 'data' => $champs |
|
| 261 | - ] |
|
| 262 | - ); |
|
| 263 | - |
|
| 264 | - return $id_article; |
|
| 173 | + // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article |
|
| 174 | + // dans la premiere rubrique racine |
|
| 175 | + if (!$id_rubrique = intval($id_rubrique)) { |
|
| 176 | + $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 177 | + $id_rubrique = $row['id_rubrique']; |
|
| 178 | + } else { |
|
| 179 | + $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue |
|
| 183 | + // cas de id_rubrique = -1 par exemple avec plugin "pages" |
|
| 184 | + $id_secteur = $row['id_secteur'] ?? 0; |
|
| 185 | + $lang_rub = $row['lang'] ?? ''; |
|
| 186 | + |
|
| 187 | + $lang = ''; |
|
| 188 | + $choisie = 'non'; |
|
| 189 | + // La langue a la creation : si les liens de traduction sont autorises |
|
| 190 | + // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 191 | + // ou a defaut celle de la rubrique |
|
| 192 | + // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 193 | + if ( |
|
| 194 | + !empty($GLOBALS['meta']['multi_objets']) and in_array( |
|
| 195 | + 'spip_articles', |
|
| 196 | + explode(',', $GLOBALS['meta']['multi_objets']) |
|
| 197 | + ) |
|
| 198 | + ) { |
|
| 199 | + lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 200 | + if ( |
|
| 201 | + in_array( |
|
| 202 | + $GLOBALS['spip_lang'], |
|
| 203 | + explode(',', $GLOBALS['meta']['langues_multilingue']) |
|
| 204 | + ) |
|
| 205 | + ) { |
|
| 206 | + $lang = $GLOBALS['spip_lang']; |
|
| 207 | + $choisie = 'oui'; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + if (!$lang) { |
|
| 212 | + $choisie = 'non'; |
|
| 213 | + $lang = $lang_rub ?: $GLOBALS['meta']['langue_site']; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + $champs = [ |
|
| 217 | + 'id_rubrique' => $id_rubrique, |
|
| 218 | + 'id_secteur' => $id_secteur, |
|
| 219 | + 'statut' => 'prepa', |
|
| 220 | + 'date' => date('Y-m-d H:i:s'), |
|
| 221 | + 'lang' => $lang, |
|
| 222 | + 'langue_choisie' => $choisie |
|
| 223 | + ]; |
|
| 224 | + |
|
| 225 | + if ($set) { |
|
| 226 | + $champs = array_merge($champs, $set); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + // Envoyer aux plugins |
|
| 230 | + $champs = pipeline( |
|
| 231 | + 'pre_insertion', |
|
| 232 | + [ |
|
| 233 | + 'args' => [ |
|
| 234 | + 'table' => 'spip_articles', |
|
| 235 | + ], |
|
| 236 | + 'data' => $champs |
|
| 237 | + ] |
|
| 238 | + ); |
|
| 239 | + |
|
| 240 | + $id_article = sql_insertq('spip_articles', $champs); |
|
| 241 | + |
|
| 242 | + // controler si le serveur n'a pas renvoye une erreur |
|
| 243 | + if ($id_article > 0) { |
|
| 244 | + $id_auteur = ((is_null(_request('id_auteur')) and isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 245 | + $GLOBALS['visiteur_session']['id_auteur'] |
|
| 246 | + : _request('id_auteur')); |
|
| 247 | + if ($id_auteur) { |
|
| 248 | + include_spip('action/editer_auteur'); |
|
| 249 | + auteur_associer($id_auteur, ['article' => $id_article]); |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + pipeline( |
|
| 254 | + 'post_insertion', |
|
| 255 | + [ |
|
| 256 | + 'args' => [ |
|
| 257 | + 'table' => 'spip_articles', |
|
| 258 | + 'id_objet' => $id_article |
|
| 259 | + ], |
|
| 260 | + 'data' => $champs |
|
| 261 | + ] |
|
| 262 | + ); |
|
| 263 | + |
|
| 264 | + return $id_article; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | |
@@ -289,125 +289,125 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | function article_instituer($id_article, $c, $calcul_rub = true) { |
| 291 | 291 | |
| 292 | - include_spip('inc/autoriser'); |
|
| 293 | - include_spip('inc/rubriques'); |
|
| 294 | - include_spip('inc/modifier'); |
|
| 295 | - |
|
| 296 | - $row = sql_fetsel('statut, date, id_rubrique', 'spip_articles', "id_article=$id_article"); |
|
| 297 | - $id_rubrique = $row['id_rubrique']; |
|
| 298 | - $statut_ancien = $statut = $row['statut']; |
|
| 299 | - $date_ancienne = $date = $row['date']; |
|
| 300 | - $champs = []; |
|
| 301 | - |
|
| 302 | - $d = $c['date'] ?? null; |
|
| 303 | - $s = $c['statut'] ?? $statut; |
|
| 304 | - |
|
| 305 | - // cf autorisations dans inc/instituer_article |
|
| 306 | - if ($s != $statut or ($d and $d != $date)) { |
|
| 307 | - if (autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 308 | - $statut = $champs['statut'] = $s; |
|
| 309 | - } elseif (autoriser('modifier', 'article', $id_article) and $s != 'publie') { |
|
| 310 | - $statut = $champs['statut'] = $s; |
|
| 311 | - } else { |
|
| 312 | - spip_log("editer_article $id_article refus " . join(' ', $c)); |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - // En cas de publication, fixer la date a "maintenant" |
|
| 316 | - // sauf si $c commande autre chose |
|
| 317 | - // ou si l'article est deja date dans le futur |
|
| 318 | - // En cas de proposition d'un article (mais pas depublication), idem |
|
| 319 | - if ( |
|
| 320 | - $champs['statut'] == 'publie' |
|
| 321 | - or ($champs['statut'] == 'prop' and ($d or !in_array($statut_ancien, ['publie', 'prop']))) |
|
| 322 | - ) { |
|
| 323 | - if ($d or strtotime($d = $date) > time()) { |
|
| 324 | - $champs['date'] = $date = $d; |
|
| 325 | - } else { |
|
| 326 | - $champs['date'] = $date = date('Y-m-d H:i:s'); |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - // Verifier que la rubrique demandee existe et est differente |
|
| 332 | - // de la rubrique actuelle |
|
| 333 | - if ( |
|
| 334 | - isset($c['id_parent']) |
|
| 335 | - and $id_parent = $c['id_parent'] |
|
| 336 | - and $id_parent != $id_rubrique |
|
| 337 | - and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . intval($id_parent))) |
|
| 338 | - ) { |
|
| 339 | - $champs['id_rubrique'] = $id_parent; |
|
| 340 | - |
|
| 341 | - // si l'article etait publie |
|
| 342 | - // et que le demandeur n'est pas admin de la rubrique de destination |
|
| 343 | - // repasser l'article en statut 'propose'. |
|
| 344 | - if ( |
|
| 345 | - $statut == 'publie' |
|
| 346 | - and !autoriser('publierdans', 'rubrique', $id_parent) |
|
| 347 | - ) { |
|
| 348 | - $champs['statut'] = 'prop'; |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - // Envoyer aux plugins |
|
| 353 | - $champs = pipeline( |
|
| 354 | - 'pre_edition', |
|
| 355 | - [ |
|
| 356 | - 'args' => [ |
|
| 357 | - 'table' => 'spip_articles', |
|
| 358 | - 'id_objet' => $id_article, |
|
| 359 | - 'action' => 'instituer', |
|
| 360 | - 'statut_ancien' => $statut_ancien, |
|
| 361 | - 'date_ancienne' => $date_ancienne, |
|
| 362 | - ], |
|
| 363 | - 'data' => $champs |
|
| 364 | - ] |
|
| 365 | - ); |
|
| 366 | - |
|
| 367 | - if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 368 | - return ''; |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - // Envoyer les modifs. |
|
| 372 | - editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 373 | - |
|
| 374 | - // Invalider les caches |
|
| 375 | - include_spip('inc/invalideur'); |
|
| 376 | - suivre_invalideur("id='article/$id_article'"); |
|
| 377 | - |
|
| 378 | - if ($date) { |
|
| 379 | - $t = strtotime($date); |
|
| 380 | - $p = @$GLOBALS['meta']['date_prochain_postdate']; |
|
| 381 | - if ($t > time() and (!$p or ($t < $p))) { |
|
| 382 | - ecrire_meta('date_prochain_postdate', $t); |
|
| 383 | - } |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - // Pipeline |
|
| 387 | - pipeline( |
|
| 388 | - 'post_edition', |
|
| 389 | - [ |
|
| 390 | - 'args' => [ |
|
| 391 | - 'table' => 'spip_articles', |
|
| 392 | - 'id_objet' => $id_article, |
|
| 393 | - 'action' => 'instituer', |
|
| 394 | - 'statut_ancien' => $statut_ancien, |
|
| 395 | - 'date_ancienne' => $date_ancienne, |
|
| 396 | - ], |
|
| 397 | - 'data' => $champs |
|
| 398 | - ] |
|
| 399 | - ); |
|
| 400 | - |
|
| 401 | - // Notifications |
|
| 402 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 403 | - $notifications( |
|
| 404 | - 'instituerarticle', |
|
| 405 | - $id_article, |
|
| 406 | - ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 407 | - ); |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - return ''; // pas d'erreur |
|
| 292 | + include_spip('inc/autoriser'); |
|
| 293 | + include_spip('inc/rubriques'); |
|
| 294 | + include_spip('inc/modifier'); |
|
| 295 | + |
|
| 296 | + $row = sql_fetsel('statut, date, id_rubrique', 'spip_articles', "id_article=$id_article"); |
|
| 297 | + $id_rubrique = $row['id_rubrique']; |
|
| 298 | + $statut_ancien = $statut = $row['statut']; |
|
| 299 | + $date_ancienne = $date = $row['date']; |
|
| 300 | + $champs = []; |
|
| 301 | + |
|
| 302 | + $d = $c['date'] ?? null; |
|
| 303 | + $s = $c['statut'] ?? $statut; |
|
| 304 | + |
|
| 305 | + // cf autorisations dans inc/instituer_article |
|
| 306 | + if ($s != $statut or ($d and $d != $date)) { |
|
| 307 | + if (autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 308 | + $statut = $champs['statut'] = $s; |
|
| 309 | + } elseif (autoriser('modifier', 'article', $id_article) and $s != 'publie') { |
|
| 310 | + $statut = $champs['statut'] = $s; |
|
| 311 | + } else { |
|
| 312 | + spip_log("editer_article $id_article refus " . join(' ', $c)); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + // En cas de publication, fixer la date a "maintenant" |
|
| 316 | + // sauf si $c commande autre chose |
|
| 317 | + // ou si l'article est deja date dans le futur |
|
| 318 | + // En cas de proposition d'un article (mais pas depublication), idem |
|
| 319 | + if ( |
|
| 320 | + $champs['statut'] == 'publie' |
|
| 321 | + or ($champs['statut'] == 'prop' and ($d or !in_array($statut_ancien, ['publie', 'prop']))) |
|
| 322 | + ) { |
|
| 323 | + if ($d or strtotime($d = $date) > time()) { |
|
| 324 | + $champs['date'] = $date = $d; |
|
| 325 | + } else { |
|
| 326 | + $champs['date'] = $date = date('Y-m-d H:i:s'); |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + // Verifier que la rubrique demandee existe et est differente |
|
| 332 | + // de la rubrique actuelle |
|
| 333 | + if ( |
|
| 334 | + isset($c['id_parent']) |
|
| 335 | + and $id_parent = $c['id_parent'] |
|
| 336 | + and $id_parent != $id_rubrique |
|
| 337 | + and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . intval($id_parent))) |
|
| 338 | + ) { |
|
| 339 | + $champs['id_rubrique'] = $id_parent; |
|
| 340 | + |
|
| 341 | + // si l'article etait publie |
|
| 342 | + // et que le demandeur n'est pas admin de la rubrique de destination |
|
| 343 | + // repasser l'article en statut 'propose'. |
|
| 344 | + if ( |
|
| 345 | + $statut == 'publie' |
|
| 346 | + and !autoriser('publierdans', 'rubrique', $id_parent) |
|
| 347 | + ) { |
|
| 348 | + $champs['statut'] = 'prop'; |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + // Envoyer aux plugins |
|
| 353 | + $champs = pipeline( |
|
| 354 | + 'pre_edition', |
|
| 355 | + [ |
|
| 356 | + 'args' => [ |
|
| 357 | + 'table' => 'spip_articles', |
|
| 358 | + 'id_objet' => $id_article, |
|
| 359 | + 'action' => 'instituer', |
|
| 360 | + 'statut_ancien' => $statut_ancien, |
|
| 361 | + 'date_ancienne' => $date_ancienne, |
|
| 362 | + ], |
|
| 363 | + 'data' => $champs |
|
| 364 | + ] |
|
| 365 | + ); |
|
| 366 | + |
|
| 367 | + if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 368 | + return ''; |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + // Envoyer les modifs. |
|
| 372 | + editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 373 | + |
|
| 374 | + // Invalider les caches |
|
| 375 | + include_spip('inc/invalideur'); |
|
| 376 | + suivre_invalideur("id='article/$id_article'"); |
|
| 377 | + |
|
| 378 | + if ($date) { |
|
| 379 | + $t = strtotime($date); |
|
| 380 | + $p = @$GLOBALS['meta']['date_prochain_postdate']; |
|
| 381 | + if ($t > time() and (!$p or ($t < $p))) { |
|
| 382 | + ecrire_meta('date_prochain_postdate', $t); |
|
| 383 | + } |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + // Pipeline |
|
| 387 | + pipeline( |
|
| 388 | + 'post_edition', |
|
| 389 | + [ |
|
| 390 | + 'args' => [ |
|
| 391 | + 'table' => 'spip_articles', |
|
| 392 | + 'id_objet' => $id_article, |
|
| 393 | + 'action' => 'instituer', |
|
| 394 | + 'statut_ancien' => $statut_ancien, |
|
| 395 | + 'date_ancienne' => $date_ancienne, |
|
| 396 | + ], |
|
| 397 | + 'data' => $champs |
|
| 398 | + ] |
|
| 399 | + ); |
|
| 400 | + |
|
| 401 | + // Notifications |
|
| 402 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 403 | + $notifications( |
|
| 404 | + 'instituerarticle', |
|
| 405 | + $id_article, |
|
| 406 | + ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 407 | + ); |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + return ''; // pas d'erreur |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
@@ -432,37 +432,37 @@ discard block |
||
| 432 | 432 | */ |
| 433 | 433 | function editer_article_heritage($id_article, $id_rubrique, $statut, $champs, $cond = true) { |
| 434 | 434 | |
| 435 | - // Si on deplace l'article |
|
| 436 | - // changer aussi son secteur et sa langue (si heritee) |
|
| 437 | - if (isset($champs['id_rubrique'])) { |
|
| 438 | - $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 439 | - |
|
| 440 | - $langue = $row_rub['lang']; |
|
| 441 | - $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 442 | - if ( |
|
| 443 | - sql_fetsel( |
|
| 444 | - '1', |
|
| 445 | - 'spip_articles', |
|
| 446 | - 'id_article=' . intval($id_article) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 447 | - ) |
|
| 448 | - ) { |
|
| 449 | - $champs['lang'] = $langue; |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - if (!$champs) { |
|
| 454 | - return; |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - sql_updateq('spip_articles', $champs, 'id_article=' . intval($id_article)); |
|
| 458 | - |
|
| 459 | - // Changer le statut des rubriques concernees |
|
| 460 | - |
|
| 461 | - if ($cond) { |
|
| 462 | - include_spip('inc/rubriques'); |
|
| 463 | - $postdate = ($GLOBALS['meta']['post_dates'] == 'non' and isset($champs['date']) and (strtotime($champs['date']) < time())) ? $champs['date'] : false; |
|
| 464 | - calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate); |
|
| 465 | - } |
|
| 435 | + // Si on deplace l'article |
|
| 436 | + // changer aussi son secteur et sa langue (si heritee) |
|
| 437 | + if (isset($champs['id_rubrique'])) { |
|
| 438 | + $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 439 | + |
|
| 440 | + $langue = $row_rub['lang']; |
|
| 441 | + $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 442 | + if ( |
|
| 443 | + sql_fetsel( |
|
| 444 | + '1', |
|
| 445 | + 'spip_articles', |
|
| 446 | + 'id_article=' . intval($id_article) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 447 | + ) |
|
| 448 | + ) { |
|
| 449 | + $champs['lang'] = $langue; |
|
| 450 | + } |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + if (!$champs) { |
|
| 454 | + return; |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + sql_updateq('spip_articles', $champs, 'id_article=' . intval($id_article)); |
|
| 458 | + |
|
| 459 | + // Changer le statut des rubriques concernees |
|
| 460 | + |
|
| 461 | + if ($cond) { |
|
| 462 | + include_spip('inc/rubriques'); |
|
| 463 | + $postdate = ($GLOBALS['meta']['post_dates'] == 'non' and isset($champs['date']) and (strtotime($champs['date']) < time())) ? $champs['date'] : false; |
|
| 464 | + calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate); |
|
| 465 | + } |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | /** |
@@ -471,10 +471,10 @@ discard block |
||
| 471 | 471 | * @return void |
| 472 | 472 | */ |
| 473 | 473 | function trop_longs_articles() { |
| 474 | - if (is_array($plus = _request('texte_plus'))) { |
|
| 475 | - foreach ($plus as $n => $t) { |
|
| 476 | - $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', $t); |
|
| 477 | - } |
|
| 478 | - set_request('texte', join('', $plus) . _request('texte')); |
|
| 479 | - } |
|
| 474 | + if (is_array($plus = _request('texte_plus'))) { |
|
| 475 | + foreach ($plus as $n => $t) { |
|
| 476 | + $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', $t); |
|
| 477 | + } |
|
| 478 | + set_request('texte', join('', $plus) . _request('texte')); |
|
| 479 | + } |
|
| 480 | 480 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -34,14 +34,14 @@ discard block |
||
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | 36 | function action_ajouter_lien_dist($arg = null) { |
| 37 | - if (is_null($arg)) { |
|
| 38 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 39 | - $arg = $securiser_action(); |
|
| 40 | - } |
|
| 37 | + if (is_null($arg)) { |
|
| 38 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 39 | + $arg = $securiser_action(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $arg = explode('-', $arg); |
|
| 43 | - [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 42 | + $arg = explode('-', $arg); |
|
| 43 | + [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 44 | 44 | |
| 45 | - include_spip('action/editer_liens'); |
|
| 46 | - objet_associer([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 45 | + include_spip('action/editer_liens'); |
|
| 46 | + objet_associer([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 47 | 47 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function action_debloquer_edition_dist() { |
| 33 | 33 | |
| 34 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | - $arg = $securiser_action(); |
|
| 34 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | + $arg = $securiser_action(); |
|
| 36 | 36 | |
| 37 | - if ($arg) { |
|
| 38 | - include_spip('inc/drapeau_edition'); |
|
| 39 | - if ($arg == 'tous') { |
|
| 40 | - debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 41 | - } else { |
|
| 42 | - $arg = explode('-', $arg); |
|
| 43 | - [$objet, $id_objet] = $arg; |
|
| 44 | - debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 45 | - } |
|
| 46 | - } |
|
| 37 | + if ($arg) { |
|
| 38 | + include_spip('inc/drapeau_edition'); |
|
| 39 | + if ($arg == 'tous') { |
|
| 40 | + debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 41 | + } else { |
|
| 42 | + $arg = explode('-', $arg); |
|
| 43 | + [$objet, $id_objet] = $arg; |
|
| 44 | + debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/actions'); |
@@ -33,93 +33,93 @@ discard block |
||
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | 35 | function action_cookie_dist($set_cookie_admin = null, $change_session = null) { |
| 36 | - $redirect_echec = $redirect = null; |
|
| 37 | - $test_echec_cookie = null; |
|
| 38 | - $url = ''; |
|
| 39 | - if (is_null($set_cookie_admin)) { |
|
| 40 | - $set_cookie_admin = _request('cookie_admin'); |
|
| 41 | - $change_session = _request('change_session'); |
|
| 42 | - $test_echec_cookie = _request('test_echec_cookie'); |
|
| 36 | + $redirect_echec = $redirect = null; |
|
| 37 | + $test_echec_cookie = null; |
|
| 38 | + $url = ''; |
|
| 39 | + if (is_null($set_cookie_admin)) { |
|
| 40 | + $set_cookie_admin = _request('cookie_admin'); |
|
| 41 | + $change_session = _request('change_session'); |
|
| 42 | + $test_echec_cookie = _request('test_echec_cookie'); |
|
| 43 | 43 | |
| 44 | - // La cible de notre operation de connexion |
|
| 45 | - $url = securiser_redirect_action(_request('url')); |
|
| 46 | - $redirect = $url ?: generer_url_ecrire('accueil'); |
|
| 47 | - $redirect_echec = _request('url_echec'); |
|
| 48 | - if (!isset($redirect_echec)) { |
|
| 49 | - if (strpos($redirect, (string) _DIR_RESTREINT_ABS) !== false) { |
|
| 50 | - $redirect_echec = generer_url_public('login', '', true); |
|
| 51 | - } else { |
|
| 52 | - $redirect_echec = $redirect; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - } |
|
| 44 | + // La cible de notre operation de connexion |
|
| 45 | + $url = securiser_redirect_action(_request('url')); |
|
| 46 | + $redirect = $url ?: generer_url_ecrire('accueil'); |
|
| 47 | + $redirect_echec = _request('url_echec'); |
|
| 48 | + if (!isset($redirect_echec)) { |
|
| 49 | + if (strpos($redirect, (string) _DIR_RESTREINT_ABS) !== false) { |
|
| 50 | + $redirect_echec = generer_url_public('login', '', true); |
|
| 51 | + } else { |
|
| 52 | + $redirect_echec = $redirect; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | - // rejoue le cookie pour renouveler spip_session |
|
| 59 | - if ($change_session == 'oui') { |
|
| 60 | - $session = charger_fonction('session', 'inc'); |
|
| 61 | - $session(true); |
|
| 62 | - spip_log('statut 204 pour ' . $_SERVER['REQUEST_URI']); |
|
| 63 | - http_response_code(204); // No Content |
|
| 64 | - return; |
|
| 65 | - } |
|
| 58 | + // rejoue le cookie pour renouveler spip_session |
|
| 59 | + if ($change_session == 'oui') { |
|
| 60 | + $session = charger_fonction('session', 'inc'); |
|
| 61 | + $session(true); |
|
| 62 | + spip_log('statut 204 pour ' . $_SERVER['REQUEST_URI']); |
|
| 63 | + http_response_code(204); // No Content |
|
| 64 | + return; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - // tentative de connexion en auth_http |
|
| 68 | - if (_request('essai_auth_http') and !$GLOBALS['ignore_auth_http']) { |
|
| 69 | - include_spip('inc/auth'); |
|
| 70 | - if ( |
|
| 71 | - @$_SERVER['PHP_AUTH_USER'] |
|
| 72 | - and @$_SERVER['PHP_AUTH_PW'] |
|
| 73 | - and $auteur = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) |
|
| 74 | - ) { |
|
| 75 | - auth_loger($auteur); |
|
| 76 | - redirige_par_entete(parametre_url($redirect, 't', time(), '&')); |
|
| 77 | - } else { |
|
| 78 | - ask_php_auth( |
|
| 79 | - _T('info_connexion_refusee'), |
|
| 80 | - _T('login_login_pass_incorrect'), |
|
| 81 | - _T('login_retour_site'), |
|
| 82 | - 'url=' . rawurlencode($redirect), |
|
| 83 | - _T('login_nouvelle_tentative'), |
|
| 84 | - (strpos($url, (string) _DIR_RESTREINT_ABS) !== false) |
|
| 85 | - ); |
|
| 86 | - } |
|
| 87 | - } else { |
|
| 88 | - // en cas de login sur bonjour=oui, on tente de poser un cookie |
|
| 89 | - // puis de passer au login qui diagnostiquera l'echec de cookie |
|
| 90 | - // le cas echeant. |
|
| 91 | - if ($test_echec_cookie == 'oui') { |
|
| 92 | - spip_setcookie('spip_session', 'test_echec_cookie'); |
|
| 93 | - if ($redirect) { |
|
| 94 | - $redirect = parametre_url( |
|
| 95 | - parametre_url($redirect_echec, 'var_echec_cookie', 'oui', '&'), |
|
| 96 | - 'url', |
|
| 97 | - rawurlencode($redirect), |
|
| 98 | - '&' |
|
| 99 | - ); |
|
| 100 | - } |
|
| 101 | - } else { |
|
| 102 | - $cook = $_COOKIE['spip_admin'] ?? ''; |
|
| 103 | - // Suppression cookie d'admin ? |
|
| 104 | - if ($set_cookie_admin == 'non') { |
|
| 105 | - if ($cook) { |
|
| 106 | - spip_setcookie('spip_admin', $cook, [ |
|
| 107 | - 'expires' => time() - 3600 * 24 |
|
| 108 | - ]); |
|
| 109 | - } |
|
| 110 | - } // Ajout de cookie d'admin |
|
| 111 | - else { |
|
| 112 | - if ($set_cookie_admin and _DUREE_COOKIE_ADMIN) { |
|
| 113 | - spip_setcookie('spip_admin', $set_cookie_admin, [ |
|
| 114 | - 'expires' => time() + max(_DUREE_COOKIE_ADMIN, 2 * _RENOUVELLE_ALEA) |
|
| 115 | - ]); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - } |
|
| 67 | + // tentative de connexion en auth_http |
|
| 68 | + if (_request('essai_auth_http') and !$GLOBALS['ignore_auth_http']) { |
|
| 69 | + include_spip('inc/auth'); |
|
| 70 | + if ( |
|
| 71 | + @$_SERVER['PHP_AUTH_USER'] |
|
| 72 | + and @$_SERVER['PHP_AUTH_PW'] |
|
| 73 | + and $auteur = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) |
|
| 74 | + ) { |
|
| 75 | + auth_loger($auteur); |
|
| 76 | + redirige_par_entete(parametre_url($redirect, 't', time(), '&')); |
|
| 77 | + } else { |
|
| 78 | + ask_php_auth( |
|
| 79 | + _T('info_connexion_refusee'), |
|
| 80 | + _T('login_login_pass_incorrect'), |
|
| 81 | + _T('login_retour_site'), |
|
| 82 | + 'url=' . rawurlencode($redirect), |
|
| 83 | + _T('login_nouvelle_tentative'), |
|
| 84 | + (strpos($url, (string) _DIR_RESTREINT_ABS) !== false) |
|
| 85 | + ); |
|
| 86 | + } |
|
| 87 | + } else { |
|
| 88 | + // en cas de login sur bonjour=oui, on tente de poser un cookie |
|
| 89 | + // puis de passer au login qui diagnostiquera l'echec de cookie |
|
| 90 | + // le cas echeant. |
|
| 91 | + if ($test_echec_cookie == 'oui') { |
|
| 92 | + spip_setcookie('spip_session', 'test_echec_cookie'); |
|
| 93 | + if ($redirect) { |
|
| 94 | + $redirect = parametre_url( |
|
| 95 | + parametre_url($redirect_echec, 'var_echec_cookie', 'oui', '&'), |
|
| 96 | + 'url', |
|
| 97 | + rawurlencode($redirect), |
|
| 98 | + '&' |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | + } else { |
|
| 102 | + $cook = $_COOKIE['spip_admin'] ?? ''; |
|
| 103 | + // Suppression cookie d'admin ? |
|
| 104 | + if ($set_cookie_admin == 'non') { |
|
| 105 | + if ($cook) { |
|
| 106 | + spip_setcookie('spip_admin', $cook, [ |
|
| 107 | + 'expires' => time() - 3600 * 24 |
|
| 108 | + ]); |
|
| 109 | + } |
|
| 110 | + } // Ajout de cookie d'admin |
|
| 111 | + else { |
|
| 112 | + if ($set_cookie_admin and _DUREE_COOKIE_ADMIN) { |
|
| 113 | + spip_setcookie('spip_admin', $set_cookie_admin, [ |
|
| 114 | + 'expires' => time() + max(_DUREE_COOKIE_ADMIN, 2 * _RENOUVELLE_ALEA) |
|
| 115 | + ]); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - // Redirection finale |
|
| 122 | - if ($redirect) { |
|
| 123 | - redirige_par_entete($redirect, true); |
|
| 124 | - } |
|
| 121 | + // Redirection finale |
|
| 122 | + if ($redirect) { |
|
| 123 | + redirige_par_entete($redirect, true); |
|
| 124 | + } |
|
| 125 | 125 | } |