@@ -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 | |
| 24 | 24 | /** |
@@ -36,56 +36,56 @@ discard block |
||
| 36 | 36 | * ``` |
| 37 | 37 | **/ |
| 38 | 38 | function action_redirect_dist() { |
| 39 | - $type = _request('type'); |
|
| 40 | - $id = intval(_request('id')); |
|
| 41 | - $page = false; |
|
| 39 | + $type = _request('type'); |
|
| 40 | + $id = intval(_request('id')); |
|
| 41 | + $page = false; |
|
| 42 | 42 | |
| 43 | - // verifier le type ou page transmis |
|
| 44 | - if (!preg_match('/^\w+$/', $type)) { |
|
| 45 | - $page = _request('page'); |
|
| 46 | - if (!preg_match('/^\w+$/', $page)) { |
|
| 47 | - return; |
|
| 48 | - } |
|
| 49 | - } |
|
| 43 | + // verifier le type ou page transmis |
|
| 44 | + if (!preg_match('/^\w+$/', $type)) { |
|
| 45 | + $page = _request('page'); |
|
| 46 | + if (!preg_match('/^\w+$/', $page)) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if ($var_mode = _request('var_mode')) { |
|
| 52 | - // forcer la mise a jour de l'url de cet objet ! |
|
| 53 | - if (!defined('_VAR_URLS')) { |
|
| 54 | - define('_VAR_URLS', true); |
|
| 55 | - } |
|
| 56 | - } |
|
| 51 | + if ($var_mode = _request('var_mode')) { |
|
| 52 | + // forcer la mise a jour de l'url de cet objet ! |
|
| 53 | + if (!defined('_VAR_URLS')) { |
|
| 54 | + define('_VAR_URLS', true); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - if ($page) { |
|
| 59 | - $url = generer_url_public($page, '', true); |
|
| 60 | - } else { |
|
| 61 | - $url = calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 62 | - } |
|
| 58 | + if ($page) { |
|
| 59 | + $url = generer_url_public($page, '', true); |
|
| 60 | + } else { |
|
| 61 | + $url = calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $status = '302'; |
|
| 65 | - if ($url) { |
|
| 66 | - if ($var_mode) { |
|
| 67 | - $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 68 | - } |
|
| 64 | + $status = '302'; |
|
| 65 | + if ($url) { |
|
| 66 | + if ($var_mode) { |
|
| 67 | + $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - if ( |
|
| 71 | - $var_mode == 'preview' |
|
| 72 | - and defined('_PREVIEW_TOKEN') |
|
| 73 | - and _PREVIEW_TOKEN |
|
| 74 | - and autoriser('previsualiser') |
|
| 75 | - ) { |
|
| 76 | - include_spip('inc/securiser_action'); |
|
| 77 | - $token = calculer_token_previsu($url); |
|
| 78 | - $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 79 | - } |
|
| 70 | + if ( |
|
| 71 | + $var_mode == 'preview' |
|
| 72 | + and defined('_PREVIEW_TOKEN') |
|
| 73 | + and _PREVIEW_TOKEN |
|
| 74 | + and autoriser('previsualiser') |
|
| 75 | + ) { |
|
| 76 | + include_spip('inc/securiser_action'); |
|
| 77 | + $token = calculer_token_previsu($url); |
|
| 78 | + $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if (_request('status') and _request('status') == '301') { |
|
| 82 | - $status = '301'; |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - $url = generer_url_public('404', '', true); |
|
| 86 | - } |
|
| 81 | + if (_request('status') and _request('status') == '301') { |
|
| 82 | + $status = '301'; |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + $url = generer_url_public('404', '', true); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - redirige_par_entete(str_replace('&', '&', $url), '', $status); |
|
| 88 | + redirige_par_entete(str_replace('&', '&', $url), '', $status); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -100,35 +100,35 @@ discard block |
||
| 100 | 100 | * @return string|null |
| 101 | 101 | */ |
| 102 | 102 | function calculer_url_redirect_entite($type, $id, $var_mode) { |
| 103 | - $desc = null; |
|
| 104 | - $publie = null; |
|
| 105 | - $url = null; |
|
| 106 | - // invalider le cache à chaque modif en bdd |
|
| 107 | - $date = 0; |
|
| 108 | - if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 109 | - $date = $GLOBALS['meta']['derniere_modif']; |
|
| 110 | - } |
|
| 111 | - $key = "url-$date-$type-$id"; |
|
| 103 | + $desc = null; |
|
| 104 | + $publie = null; |
|
| 105 | + $url = null; |
|
| 106 | + // invalider le cache à chaque modif en bdd |
|
| 107 | + $date = 0; |
|
| 108 | + if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 109 | + $date = $GLOBALS['meta']['derniere_modif']; |
|
| 110 | + } |
|
| 111 | + $key = "url-$date-$type-$id"; |
|
| 112 | 112 | |
| 113 | - // Obtenir l’url et si elle est publié du cache memoization |
|
| 114 | - if (function_exists('cache_get') and $desc = cache_get($key)) { |
|
| 115 | - [$url, $publie] = $desc; |
|
| 116 | - } |
|
| 117 | - // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 118 | - if (empty($desc) or $var_mode) { |
|
| 119 | - $publie = objet_test_si_publie($type, $id); |
|
| 120 | - $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 121 | - if (function_exists('cache_set')) { |
|
| 122 | - cache_set($key, [$url, $publie], 3600); |
|
| 123 | - } |
|
| 124 | - } |
|
| 113 | + // Obtenir l’url et si elle est publié du cache memoization |
|
| 114 | + if (function_exists('cache_get') and $desc = cache_get($key)) { |
|
| 115 | + [$url, $publie] = $desc; |
|
| 116 | + } |
|
| 117 | + // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 118 | + if (empty($desc) or $var_mode) { |
|
| 119 | + $publie = objet_test_si_publie($type, $id); |
|
| 120 | + $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 121 | + if (function_exists('cache_set')) { |
|
| 122 | + cache_set($key, [$url, $publie], 3600); |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 127 | - if ($publie) { |
|
| 128 | - return $url; |
|
| 129 | - } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) { |
|
| 130 | - return $url; |
|
| 131 | - } |
|
| 126 | + // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 127 | + if ($publie) { |
|
| 128 | + return $url; |
|
| 129 | + } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) { |
|
| 130 | + return $url; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return; |
|
| 133 | + return; |
|
| 134 | 134 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | ) { |
| 204 | 204 | $r = nettoyer_url_page($url, $contexte); |
| 205 | 205 | if ($r) { |
| 206 | - [$contexte, $type, , , $suite] = $r; |
|
| 206 | + [$contexte, $type,,, $suite] = $r; |
|
| 207 | 207 | $_id = id_table_objet($type); |
| 208 | 208 | $id_objet = $contexte[$_id]; |
| 209 | 209 | $url_propre = generer_objet_url($id_objet, $type); |
@@ -274,9 +274,9 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | function nettoyer_url_page($url, $contexte = []) { |
| 276 | 276 | $url_objets = urls_liste_objets(); |
| 277 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 277 | + $raccourci_url_page_html = ',^(?:[^?]*/)?('.$url_objets.')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | + $raccourci_url_page_id = ',^(?:[^?]*/)?('.$url_objets.')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?]('.$url_objets.')([0-9]+)=?(&.*)?$,'; |
|
| 280 | 280 | |
| 281 | 281 | if ( |
| 282 | 282 | preg_match($raccourci_url_page_html, $url, $regs) |
@@ -314,11 +314,11 @@ discard block |
||
| 314 | 314 | $id = intval($id); |
| 315 | 315 | if (!isset($furls[$objet])) { |
| 316 | 316 | if ( |
| 317 | - function_exists($f = 'generer_' . $objet . '_url_ecrire') |
|
| 317 | + function_exists($f = 'generer_'.$objet.'_url_ecrire') |
|
| 318 | 318 | // ou definie par un plugin |
| 319 | 319 | or $f = charger_fonction($f, 'urls', true) |
| 320 | 320 | // deprecated |
| 321 | - or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true) |
|
| 321 | + or function_exists($f = 'generer_url_ecrire_'.$objet) or $f = charger_fonction($f, 'urls', true) |
|
| 322 | 322 | ) { |
| 323 | 323 | $furls[$objet] = $f; |
| 324 | 324 | } else { |
@@ -336,12 +336,12 @@ discard block |
||
| 336 | 336 | if ($public or $connect) { |
| 337 | 337 | return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect); |
| 338 | 338 | } |
| 339 | - $a = id_table_objet($objet) . '=' . intval($id); |
|
| 339 | + $a = id_table_objet($objet).'='.intval($id); |
|
| 340 | 340 | if (!function_exists('objet_info')) { |
| 341 | 341 | include_spip('inc/filtres'); |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 344 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a.($args ? "&$args" : '')).($ancre ? "#$ancre" : ''); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -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 | include_spip('base/objets'); |
| 23 | 23 | |
@@ -57,106 +57,106 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | */ |
| 59 | 59 | function urls_decoder_url($url, $fond = '', $contexte = [], $assembler = false) { |
| 60 | - static $current_base = null; |
|
| 60 | + static $current_base = null; |
|
| 61 | 61 | |
| 62 | - // les anciennes fonctions modifient directement les globales |
|
| 63 | - // on les sauve avant l'appel, et on les retablit apres ! |
|
| 64 | - $save = [ |
|
| 65 | - $GLOBALS['fond'] ?? null, |
|
| 66 | - $GLOBALS['contexte'] ?? null, |
|
| 67 | - $_SERVER['REDIRECT_url_propre'] ?? null, |
|
| 68 | - $_ENV['url_propre'] ?? null, |
|
| 69 | - $GLOBALS['profondeur_url'] |
|
| 70 | - ]; |
|
| 62 | + // les anciennes fonctions modifient directement les globales |
|
| 63 | + // on les sauve avant l'appel, et on les retablit apres ! |
|
| 64 | + $save = [ |
|
| 65 | + $GLOBALS['fond'] ?? null, |
|
| 66 | + $GLOBALS['contexte'] ?? null, |
|
| 67 | + $_SERVER['REDIRECT_url_propre'] ?? null, |
|
| 68 | + $_ENV['url_propre'] ?? null, |
|
| 69 | + $GLOBALS['profondeur_url'] |
|
| 70 | + ]; |
|
| 71 | 71 | |
| 72 | - if (is_null($current_base)) { |
|
| 73 | - include_spip('inc/filtres_mini'); |
|
| 74 | - // le decodage des urls se fait toujours par rapport au site public |
|
| 75 | - $current_base = url_absolue(_DIR_RACINE ?: './'); |
|
| 76 | - } |
|
| 77 | - if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 78 | - $url = substr($url, strlen($current_base)); |
|
| 79 | - } |
|
| 72 | + if (is_null($current_base)) { |
|
| 73 | + include_spip('inc/filtres_mini'); |
|
| 74 | + // le decodage des urls se fait toujours par rapport au site public |
|
| 75 | + $current_base = url_absolue(_DIR_RACINE ?: './'); |
|
| 76 | + } |
|
| 77 | + if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 78 | + $url = substr($url, strlen($current_base)); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // si on est en train d'assembler la page principale, |
|
| 82 | - // recuperer l'url depuis les globales url propres si fournies |
|
| 83 | - // sinon extraire la bonne portion d'url |
|
| 84 | - if ($assembler) { |
|
| 85 | - if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 86 | - $url = $_SERVER['REDIRECT_url_propre']; |
|
| 87 | - } elseif (isset($_ENV['url_propre'])) { |
|
| 88 | - $url = $_ENV['url_propre']; |
|
| 89 | - } else { |
|
| 90 | - $qs = explode('?', $url); |
|
| 91 | - // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 92 | - $url = ltrim($qs[0], '/'); |
|
| 93 | - $url = explode('/', $url); |
|
| 94 | - while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 95 | - array_shift($url); |
|
| 96 | - } |
|
| 97 | - $qs[0] = implode('/', $url); |
|
| 98 | - $url = implode('?', $qs); |
|
| 99 | - } |
|
| 100 | - } |
|
| 81 | + // si on est en train d'assembler la page principale, |
|
| 82 | + // recuperer l'url depuis les globales url propres si fournies |
|
| 83 | + // sinon extraire la bonne portion d'url |
|
| 84 | + if ($assembler) { |
|
| 85 | + if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 86 | + $url = $_SERVER['REDIRECT_url_propre']; |
|
| 87 | + } elseif (isset($_ENV['url_propre'])) { |
|
| 88 | + $url = $_ENV['url_propre']; |
|
| 89 | + } else { |
|
| 90 | + $qs = explode('?', $url); |
|
| 91 | + // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 92 | + $url = ltrim($qs[0], '/'); |
|
| 93 | + $url = explode('/', $url); |
|
| 94 | + while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 95 | + array_shift($url); |
|
| 96 | + } |
|
| 97 | + $qs[0] = implode('/', $url); |
|
| 98 | + $url = implode('?', $qs); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - unset($_SERVER['REDIRECT_url_propre']); |
|
| 103 | - unset($_ENV['url_propre']); |
|
| 104 | - include_spip('inc/filtres_mini'); |
|
| 105 | - if (strpos($url, '://') === false) { |
|
| 106 | - $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 107 | - } else { |
|
| 108 | - $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/')); |
|
| 109 | - } |
|
| 102 | + unset($_SERVER['REDIRECT_url_propre']); |
|
| 103 | + unset($_ENV['url_propre']); |
|
| 104 | + include_spip('inc/filtres_mini'); |
|
| 105 | + if (strpos($url, '://') === false) { |
|
| 106 | + $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 107 | + } else { |
|
| 108 | + $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/')); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - $url_redirect = ''; |
|
| 112 | - $decoder = charger_fonction_url('decoder'); |
|
| 113 | - if ($decoder) { |
|
| 114 | - $a = $decoder($url, $fond, $contexte); |
|
| 115 | - if (is_array($a)) { |
|
| 116 | - [$ncontexte, $type, $url_redirect, $nfond] = array_pad($a, 4, null); |
|
| 117 | - $url_redirect ??= ''; |
|
| 118 | - if ($url_redirect === $url) { |
|
| 119 | - $url_redirect = ''; |
|
| 120 | - } // securite pour eviter une redirection infinie |
|
| 121 | - if ($assembler and strlen($url_redirect)) { |
|
| 122 | - spip_log("Redirige $url vers $url_redirect"); |
|
| 123 | - include_spip('inc/headers'); |
|
| 124 | - redirige_par_entete($url_redirect, '', 301); |
|
| 125 | - } |
|
| 126 | - if (isset($nfond)) { |
|
| 127 | - $fond = $nfond; |
|
| 128 | - } else { |
|
| 129 | - if ( |
|
| 130 | - $fond == '' |
|
| 131 | - or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 132 | - ) { |
|
| 133 | - $fond = $type; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - if (isset($ncontexte)) { |
|
| 137 | - $contexte = $ncontexte; |
|
| 138 | - } |
|
| 139 | - if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 140 | - $contexte['type'] = $type; |
|
| 141 | - } |
|
| 142 | - if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 143 | - $contexte['type-page'] = $type; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - } |
|
| 111 | + $url_redirect = ''; |
|
| 112 | + $decoder = charger_fonction_url('decoder'); |
|
| 113 | + if ($decoder) { |
|
| 114 | + $a = $decoder($url, $fond, $contexte); |
|
| 115 | + if (is_array($a)) { |
|
| 116 | + [$ncontexte, $type, $url_redirect, $nfond] = array_pad($a, 4, null); |
|
| 117 | + $url_redirect ??= ''; |
|
| 118 | + if ($url_redirect === $url) { |
|
| 119 | + $url_redirect = ''; |
|
| 120 | + } // securite pour eviter une redirection infinie |
|
| 121 | + if ($assembler and strlen($url_redirect)) { |
|
| 122 | + spip_log("Redirige $url vers $url_redirect"); |
|
| 123 | + include_spip('inc/headers'); |
|
| 124 | + redirige_par_entete($url_redirect, '', 301); |
|
| 125 | + } |
|
| 126 | + if (isset($nfond)) { |
|
| 127 | + $fond = $nfond; |
|
| 128 | + } else { |
|
| 129 | + if ( |
|
| 130 | + $fond == '' |
|
| 131 | + or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 132 | + ) { |
|
| 133 | + $fond = $type; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + if (isset($ncontexte)) { |
|
| 137 | + $contexte = $ncontexte; |
|
| 138 | + } |
|
| 139 | + if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 140 | + $contexte['type'] = $type; |
|
| 141 | + } |
|
| 142 | + if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 143 | + $contexte['type-page'] = $type; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - // retablir les globales |
|
| 149 | - [$GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']] = $save; |
|
| 148 | + // retablir les globales |
|
| 149 | + [$GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']] = $save; |
|
| 150 | 150 | |
| 151 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 152 | - // d'inversion url => objet |
|
| 153 | - // maintenir pour compat ? |
|
| 154 | - #if ($assembler) { |
|
| 155 | - # unset($_SERVER['REDIRECT_url_propre']); |
|
| 156 | - # unset($_ENV['url_propre']); |
|
| 157 | - #} |
|
| 151 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 152 | + // d'inversion url => objet |
|
| 153 | + // maintenir pour compat ? |
|
| 154 | + #if ($assembler) { |
|
| 155 | + # unset($_SERVER['REDIRECT_url_propre']); |
|
| 156 | + # unset($_ENV['url_propre']); |
|
| 157 | + #} |
|
| 158 | 158 | |
| 159 | - return [$fond, $contexte, $url_redirect]; |
|
| 159 | + return [$fond, $contexte, $url_redirect]; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -169,20 +169,20 @@ discard block |
||
| 169 | 169 | * @return array|false|string |
| 170 | 170 | */ |
| 171 | 171 | function urls_transition_retrouver_anciennes_url_propres(string $url_propre, string $entite, array $contexte = []): array { |
| 172 | - if ($url_propre) { |
|
| 173 | - if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 174 | - $urls_anciennes = charger_fonction_url('decoder', 'propres'); |
|
| 175 | - } else { |
|
| 176 | - $urls_anciennes = charger_fonction_url('decoder', 'arbo'); |
|
| 177 | - } |
|
| 172 | + if ($url_propre) { |
|
| 173 | + if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 174 | + $urls_anciennes = charger_fonction_url('decoder', 'propres'); |
|
| 175 | + } else { |
|
| 176 | + $urls_anciennes = charger_fonction_url('decoder', 'arbo'); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - if ($urls_anciennes) { |
|
| 180 | - $urls_anciennes = $urls_anciennes($url_propre, $entite, $contexte); |
|
| 181 | - } |
|
| 182 | - return $urls_anciennes ?: []; |
|
| 183 | - } |
|
| 179 | + if ($urls_anciennes) { |
|
| 180 | + $urls_anciennes = $urls_anciennes($url_propre, $entite, $contexte); |
|
| 181 | + } |
|
| 182 | + return $urls_anciennes ?: []; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - return []; |
|
| 185 | + return []; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -195,41 +195,41 @@ discard block |
||
| 195 | 195 | * @return array|false|string |
| 196 | 196 | */ |
| 197 | 197 | function urls_transition_retrouver_anciennes_url_html(string $url, string $entite, array $contexte = []): array { |
| 198 | - // Migration depuis anciennes URLs ? |
|
| 199 | - // traiter les injections domain.tld/spip.php/n/importe/quoi/rubrique23 |
|
| 200 | - if ( |
|
| 201 | - $url |
|
| 202 | - and $GLOBALS['profondeur_url'] <= 0 |
|
| 203 | - ) { |
|
| 204 | - $r = nettoyer_url_page($url, $contexte); |
|
| 205 | - if ($r) { |
|
| 206 | - [$contexte, $type, , , $suite] = $r; |
|
| 207 | - $_id = id_table_objet($type); |
|
| 208 | - $id_objet = $contexte[$_id]; |
|
| 209 | - $url_propre = generer_objet_url($id_objet, $type); |
|
| 210 | - if ( |
|
| 211 | - strlen($url_propre) |
|
| 212 | - and !strstr($url, (string) $url_propre) |
|
| 213 | - and ( |
|
| 214 | - objet_test_si_publie($type, $id_objet) |
|
| 215 | - or (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id_objet)) |
|
| 216 | - ) |
|
| 217 | - ) { |
|
| 218 | - [, $hash] = array_pad(explode('#', $url_propre), 2, ''); |
|
| 219 | - $args = []; |
|
| 220 | - foreach (array_filter(explode('&', $suite ?? '')) as $fragment) { |
|
| 221 | - if ($fragment != "$_id=$id_objet") { |
|
| 222 | - $args[] = $fragment; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - $url_redirect = generer_objet_url($id_objet, $type, join('&', array_filter($args)), $hash); |
|
| 198 | + // Migration depuis anciennes URLs ? |
|
| 199 | + // traiter les injections domain.tld/spip.php/n/importe/quoi/rubrique23 |
|
| 200 | + if ( |
|
| 201 | + $url |
|
| 202 | + and $GLOBALS['profondeur_url'] <= 0 |
|
| 203 | + ) { |
|
| 204 | + $r = nettoyer_url_page($url, $contexte); |
|
| 205 | + if ($r) { |
|
| 206 | + [$contexte, $type, , , $suite] = $r; |
|
| 207 | + $_id = id_table_objet($type); |
|
| 208 | + $id_objet = $contexte[$_id]; |
|
| 209 | + $url_propre = generer_objet_url($id_objet, $type); |
|
| 210 | + if ( |
|
| 211 | + strlen($url_propre) |
|
| 212 | + and !strstr($url, (string) $url_propre) |
|
| 213 | + and ( |
|
| 214 | + objet_test_si_publie($type, $id_objet) |
|
| 215 | + or (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id_objet)) |
|
| 216 | + ) |
|
| 217 | + ) { |
|
| 218 | + [, $hash] = array_pad(explode('#', $url_propre), 2, ''); |
|
| 219 | + $args = []; |
|
| 220 | + foreach (array_filter(explode('&', $suite ?? '')) as $fragment) { |
|
| 221 | + if ($fragment != "$_id=$id_objet") { |
|
| 222 | + $args[] = $fragment; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + $url_redirect = generer_objet_url($id_objet, $type, join('&', array_filter($args)), $hash); |
|
| 226 | 226 | |
| 227 | - return [$contexte, $type, $url_redirect, $type]; |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - /* Fin compatibilite anciennes urls */ |
|
| 232 | - return []; |
|
| 227 | + return [$contexte, $type, $url_redirect, $type]; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + /* Fin compatibilite anciennes urls */ |
|
| 232 | + return []; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -242,24 +242,24 @@ discard block |
||
| 242 | 242 | * @return string|array |
| 243 | 243 | */ |
| 244 | 244 | function urls_liste_objets($preg = true) { |
| 245 | - static $url_objets = null; |
|
| 246 | - if (is_null($url_objets)) { |
|
| 247 | - $url_objets = []; |
|
| 248 | - // recuperer les tables_objets_sql declarees |
|
| 249 | - $tables_objets = lister_tables_objets_sql(); |
|
| 250 | - foreach ($tables_objets as $t => $infos) { |
|
| 251 | - if ($infos['page']) { |
|
| 252 | - $url_objets[] = $infos['type']; |
|
| 253 | - $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 257 | - } |
|
| 258 | - if (!$preg) { |
|
| 259 | - return $url_objets; |
|
| 260 | - } |
|
| 245 | + static $url_objets = null; |
|
| 246 | + if (is_null($url_objets)) { |
|
| 247 | + $url_objets = []; |
|
| 248 | + // recuperer les tables_objets_sql declarees |
|
| 249 | + $tables_objets = lister_tables_objets_sql(); |
|
| 250 | + foreach ($tables_objets as $t => $infos) { |
|
| 251 | + if ($infos['page']) { |
|
| 252 | + $url_objets[] = $infos['type']; |
|
| 253 | + $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 257 | + } |
|
| 258 | + if (!$preg) { |
|
| 259 | + return $url_objets; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - return implode('|', array_map('preg_quote', $url_objets)); |
|
| 262 | + return implode('|', array_map('preg_quote', $url_objets)); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -273,26 +273,26 @@ discard block |
||
| 273 | 273 | * @return array |
| 274 | 274 | */ |
| 275 | 275 | function nettoyer_url_page($url, $contexte = []) { |
| 276 | - $url_objets = urls_liste_objets(); |
|
| 277 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 276 | + $url_objets = urls_liste_objets(); |
|
| 277 | + $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | + $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 280 | 280 | |
| 281 | - if ( |
|
| 282 | - preg_match($raccourci_url_page_html, $url, $regs) |
|
| 283 | - or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 284 | - or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 285 | - ) { |
|
| 286 | - $regs = array_pad($regs, 4, null); |
|
| 287 | - $type = objet_type($regs[1]); |
|
| 288 | - $_id = id_table_objet($type); |
|
| 289 | - $contexte[$_id] = $regs[2]; |
|
| 290 | - $suite = $regs[3]; |
|
| 281 | + if ( |
|
| 282 | + preg_match($raccourci_url_page_html, $url, $regs) |
|
| 283 | + or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 284 | + or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 285 | + ) { |
|
| 286 | + $regs = array_pad($regs, 4, null); |
|
| 287 | + $type = objet_type($regs[1]); |
|
| 288 | + $_id = id_table_objet($type); |
|
| 289 | + $contexte[$_id] = $regs[2]; |
|
| 290 | + $suite = $regs[3]; |
|
| 291 | 291 | |
| 292 | - return [$contexte, $type, null, $type, $suite]; |
|
| 293 | - } |
|
| 292 | + return [$contexte, $type, null, $type, $suite]; |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | - return []; |
|
| 295 | + return []; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -310,38 +310,38 @@ discard block |
||
| 310 | 310 | * @return string |
| 311 | 311 | */ |
| 312 | 312 | function generer_objet_url_ecrire($id, string $objet, string $args = '', string $ancre = '', ?bool $public = null, string $connect = ''): string { |
| 313 | - static $furls = []; |
|
| 314 | - $id = intval($id); |
|
| 315 | - if (!isset($furls[$objet])) { |
|
| 316 | - if ( |
|
| 317 | - function_exists($f = 'generer_' . $objet . '_url_ecrire') |
|
| 318 | - // ou definie par un plugin |
|
| 319 | - or $f = charger_fonction($f, 'urls', true) |
|
| 320 | - // deprecated |
|
| 321 | - or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true) |
|
| 322 | - ) { |
|
| 323 | - $furls[$objet] = $f; |
|
| 324 | - } else { |
|
| 325 | - $furls[$objet] = ''; |
|
| 326 | - } |
|
| 327 | - } |
|
| 328 | - if ($furls[$objet]) { |
|
| 329 | - return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 330 | - } |
|
| 331 | - // si pas de flag public fourni |
|
| 332 | - // le calculer en fonction de la declaration de statut |
|
| 333 | - if (is_null($public) and !$connect) { |
|
| 334 | - $public = objet_test_si_publie($objet, $id, $connect); |
|
| 335 | - } |
|
| 336 | - if ($public or $connect) { |
|
| 337 | - return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect); |
|
| 338 | - } |
|
| 339 | - $a = id_table_objet($objet) . '=' . intval($id); |
|
| 340 | - if (!function_exists('objet_info')) { |
|
| 341 | - include_spip('inc/filtres'); |
|
| 342 | - } |
|
| 313 | + static $furls = []; |
|
| 314 | + $id = intval($id); |
|
| 315 | + if (!isset($furls[$objet])) { |
|
| 316 | + if ( |
|
| 317 | + function_exists($f = 'generer_' . $objet . '_url_ecrire') |
|
| 318 | + // ou definie par un plugin |
|
| 319 | + or $f = charger_fonction($f, 'urls', true) |
|
| 320 | + // deprecated |
|
| 321 | + or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true) |
|
| 322 | + ) { |
|
| 323 | + $furls[$objet] = $f; |
|
| 324 | + } else { |
|
| 325 | + $furls[$objet] = ''; |
|
| 326 | + } |
|
| 327 | + } |
|
| 328 | + if ($furls[$objet]) { |
|
| 329 | + return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 330 | + } |
|
| 331 | + // si pas de flag public fourni |
|
| 332 | + // le calculer en fonction de la declaration de statut |
|
| 333 | + if (is_null($public) and !$connect) { |
|
| 334 | + $public = objet_test_si_publie($objet, $id, $connect); |
|
| 335 | + } |
|
| 336 | + if ($public or $connect) { |
|
| 337 | + return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect); |
|
| 338 | + } |
|
| 339 | + $a = id_table_objet($objet) . '=' . intval($id); |
|
| 340 | + if (!function_exists('objet_info')) { |
|
| 341 | + include_spip('inc/filtres'); |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 344 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -349,5 +349,5 @@ discard block |
||
| 349 | 349 | * @see generer_objet_url_ecrire |
| 350 | 350 | */ |
| 351 | 351 | function generer_url_ecrire_objet($objet, $id, $args = '', $ancre = '', $public = null, string $connect = '') { |
| 352 | - return generer_objet_url_ecrire($id, $objet, $args, $ancre, $public, $connect); |
|
| 352 | + return generer_objet_url_ecrire($id, $objet, $args, $ancre, $public, $connect); |
|
| 353 | 353 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/charsets'); |
| 17 | 17 | |
@@ -27,90 +27,90 @@ discard block |
||
| 27 | 27 | * @return string |
| 28 | 28 | */ |
| 29 | 29 | function plugins_afficher_liste_dist( |
| 30 | - $url_page, |
|
| 31 | - $liste_plugins, |
|
| 32 | - $liste_plugins_checked, |
|
| 33 | - $liste_plugins_actifs, |
|
| 34 | - $dir_plugins = _DIR_PLUGINS, |
|
| 35 | - $afficher_un = 'afficher_plugin' |
|
| 30 | + $url_page, |
|
| 31 | + $liste_plugins, |
|
| 32 | + $liste_plugins_checked, |
|
| 33 | + $liste_plugins_actifs, |
|
| 34 | + $dir_plugins = _DIR_PLUGINS, |
|
| 35 | + $afficher_un = 'afficher_plugin' |
|
| 36 | 36 | ) { |
| 37 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 38 | - $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 37 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 38 | + $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 39 | 39 | |
| 40 | - $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 40 | + $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 41 | 41 | |
| 42 | - $all_infos = pipeline( |
|
| 43 | - 'filtrer_liste_plugins', |
|
| 44 | - [ |
|
| 45 | - 'args' => [ |
|
| 46 | - 'liste_plugins' => $liste_plugins, |
|
| 47 | - 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | - 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | - 'dir_plugins' => $dir_plugins |
|
| 50 | - ], |
|
| 51 | - 'data' => $all_infos |
|
| 52 | - ] |
|
| 53 | - ); |
|
| 42 | + $all_infos = pipeline( |
|
| 43 | + 'filtrer_liste_plugins', |
|
| 44 | + [ |
|
| 45 | + 'args' => [ |
|
| 46 | + 'liste_plugins' => $liste_plugins, |
|
| 47 | + 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | + 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | + 'dir_plugins' => $dir_plugins |
|
| 50 | + ], |
|
| 51 | + 'data' => $all_infos |
|
| 52 | + ] |
|
| 53 | + ); |
|
| 54 | 54 | |
| 55 | - $liste_plugins = array_flip($liste_plugins); |
|
| 56 | - foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | - // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | - if (isset($all_infos[$chemin])) { |
|
| 59 | - $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | - } else { |
|
| 61 | - unset($liste_plugins[$chemin]); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - asort($liste_plugins); |
|
| 65 | - $exposed = urldecode(_request('plugin') ?? ''); |
|
| 55 | + $liste_plugins = array_flip($liste_plugins); |
|
| 56 | + foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | + // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | + if (isset($all_infos[$chemin])) { |
|
| 59 | + $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | + } else { |
|
| 61 | + unset($liste_plugins[$chemin]); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + asort($liste_plugins); |
|
| 65 | + $exposed = urldecode(_request('plugin') ?? ''); |
|
| 66 | 66 | |
| 67 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | - $fast_liste_plugins_actifs = []; |
|
| 69 | - $fast_liste_plugins_checked = []; |
|
| 70 | - if (is_array($liste_plugins_actifs)) { |
|
| 71 | - $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | - } |
|
| 73 | - if (is_array($liste_plugins_checked)) { |
|
| 74 | - $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | - } |
|
| 67 | + $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | + $fast_liste_plugins_actifs = []; |
|
| 69 | + $fast_liste_plugins_checked = []; |
|
| 70 | + if (is_array($liste_plugins_actifs)) { |
|
| 71 | + $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | + } |
|
| 73 | + if (is_array($liste_plugins_checked)) { |
|
| 74 | + $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $res = ''; |
|
| 78 | - $block = ''; |
|
| 79 | - $initiale = ''; |
|
| 80 | - $block_actif = false; |
|
| 81 | - foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | - if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | - $initiale = $i; |
|
| 85 | - $block = ''; |
|
| 86 | - $block_actif = false; |
|
| 87 | - } |
|
| 88 | - // le rep suivant |
|
| 89 | - $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | - $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | - $block_actif = $block_actif | $actif; |
|
| 92 | - $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr( |
|
| 93 | - $dir_plugins, |
|
| 94 | - strlen(_DIR_RACINE) |
|
| 95 | - ) . $plug)); |
|
| 96 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 97 | - } |
|
| 98 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 99 | - $class = basename($dir_plugins); |
|
| 77 | + $res = ''; |
|
| 78 | + $block = ''; |
|
| 79 | + $initiale = ''; |
|
| 80 | + $block_actif = false; |
|
| 81 | + foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | + if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | + $initiale = $i; |
|
| 85 | + $block = ''; |
|
| 86 | + $block_actif = false; |
|
| 87 | + } |
|
| 88 | + // le rep suivant |
|
| 89 | + $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | + $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | + $block_actif = $block_actif | $actif; |
|
| 92 | + $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr( |
|
| 93 | + $dir_plugins, |
|
| 94 | + strlen(_DIR_RACINE) |
|
| 95 | + ) . $plug)); |
|
| 96 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 97 | + } |
|
| 98 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 99 | + $class = basename($dir_plugins); |
|
| 100 | 100 | |
| 101 | - return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 101 | + return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | function affiche_block_initiale($initiale, $block, $block_actif) { |
| 106 | - if (strlen($block)) { |
|
| 107 | - return "<li class='item'>" |
|
| 108 | - . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 109 | - . debut_block_depliable($block_actif) |
|
| 110 | - . "<ul>$block</ul>" |
|
| 111 | - . fin_block() |
|
| 112 | - . '</li>'; |
|
| 113 | - } |
|
| 106 | + if (strlen($block)) { |
|
| 107 | + return "<li class='item'>" |
|
| 108 | + . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 109 | + . debut_block_depliable($block_actif) |
|
| 110 | + . "<ul>$block</ul>" |
|
| 111 | + . fin_block() |
|
| 112 | + . '</li>'; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - return ''; |
|
| 115 | + return ''; |
|
| 116 | 116 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | asort($liste_plugins); |
| 65 | 65 | $exposed = urldecode(_request('plugin') ?? ''); |
| 66 | 66 | |
| 67 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 67 | + $block_par_lettre = false; //count($liste_plugins)>10; |
|
| 68 | 68 | $fast_liste_plugins_actifs = []; |
| 69 | 69 | $fast_liste_plugins_checked = []; |
| 70 | 70 | if (is_array($liste_plugins_actifs)) { |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | $actif = isset($fast_liste_plugins_actifs[$plug]); |
| 90 | 90 | $checked = isset($fast_liste_plugins_checked[$plug]); |
| 91 | 91 | $block_actif = $block_actif | $actif; |
| 92 | - $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr( |
|
| 92 | + $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins.$plug or $exposed == substr( |
|
| 93 | 93 | $dir_plugins, |
| 94 | 94 | strlen(_DIR_RACINE) |
| 95 | - ) . $plug)); |
|
| 96 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 95 | + ).$plug)); |
|
| 96 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins)."\n"; |
|
| 97 | 97 | } |
| 98 | 98 | $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
| 99 | 99 | $class = basename($dir_plugins); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | unset($erreurs['new_login']); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 173 | + $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur='.intval($id_auteur)); |
|
| 174 | 174 | $auth_methode = ($auth_methode ?: 'spip'); |
| 175 | 175 | include_spip('inc/auth'); |
| 176 | 176 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | !autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?']) |
| 187 | 187 | and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
| 188 | 188 | and !strlen(trim($email)) |
| 189 | - and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 189 | + and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.intval($id_auteur))) |
|
| 190 | 190 | ) { |
| 191 | 191 | $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email')); |
| 192 | 192 | } else { |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | #Nouvel auteur |
| 202 | 202 | if (intval($id_auteur) == 0) { |
| 203 | 203 | #Un auteur existe deja avec cette adresse ? |
| 204 | - if (sql_countsel('spip_auteurs', 'email=' . sql_quote($email)) > 0) { |
|
| 204 | + if (sql_countsel('spip_auteurs', 'email='.sql_quote($email)) > 0) { |
|
| 205 | 205 | $erreurs['email'] = _T('erreur_email_deja_existant'); |
| 206 | 206 | } |
| 207 | 207 | } else { |
@@ -209,11 +209,11 @@ discard block |
||
| 209 | 209 | if ( |
| 210 | 210 | (sql_countsel( |
| 211 | 211 | 'spip_auteurs', |
| 212 | - 'email=' . sql_quote($email) |
|
| 212 | + 'email='.sql_quote($email) |
|
| 213 | 213 | ) > 0) and ($id_auteur != ($id_auteur_ancien = sql_getfetsel( |
| 214 | 214 | 'id_auteur', |
| 215 | 215 | 'spip_auteurs', |
| 216 | - 'email=' . sql_quote($email) |
|
| 216 | + 'email='.sql_quote($email) |
|
| 217 | 217 | ))) |
| 218 | 218 | ) { |
| 219 | 219 | $erreurs['email'] = _T('erreur_email_deja_existant'); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | // corriger un cas si frequent : www.example.org sans le http:// qui precede |
| 232 | 232 | if ($url = _request('url_site') and !tester_url_absolue($url)) { |
| 233 | 233 | if (strpos($url, ':') === false and strncasecmp($url, 'www.', 4) === 0) { |
| 234 | - $url = 'http://' . $url; |
|
| 234 | + $url = 'http://'.$url; |
|
| 235 | 235 | set_request('url_site', $url); |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -248,11 +248,11 @@ discard block |
||
| 248 | 248 | } |
| 249 | 249 | elseif ( |
| 250 | 250 | ($login = _request('new_login')) and |
| 251 | - $login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)) |
|
| 251 | + $login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur='.intval($id_auteur)) |
|
| 252 | 252 | ) { |
| 253 | 253 | // on verifie la meme chose que dans auteurs_edit_config() |
| 254 | 254 | if ( |
| 255 | - ! auth_autoriser_modifier_login($auth_methode) |
|
| 255 | + !auth_autoriser_modifier_login($auth_methode) |
|
| 256 | 256 | or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['login' => true]) |
| 257 | 257 | // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email |
| 258 | 258 | or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['email' => true]) |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | if ( |
| 360 | 360 | $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
| 361 | 361 | and $email_nouveau != |
| 362 | - ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 362 | + ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.intval($id_auteur))) |
|
| 363 | 363 | ) { |
| 364 | 364 | $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
| 365 | 365 | $texte = _T( |
@@ -393,12 +393,12 @@ discard block |
||
| 393 | 393 | if (isset($erreurs['message_ok'])) { |
| 394 | 394 | if (!isset($res['message_ok'])) { $res['message_ok'] = ''; |
| 395 | 395 | } |
| 396 | - $res['message_ok'] = trim($res['message_ok'] . ' ' . $erreurs['message_ok']); |
|
| 396 | + $res['message_ok'] = trim($res['message_ok'].' '.$erreurs['message_ok']); |
|
| 397 | 397 | } |
| 398 | 398 | if (isset($erreurs['message_erreur']) and $erreurs['message_erreur']) { |
| 399 | 399 | if (!isset($res['message_erreur'])) { $res['message_erreur'] = ''; |
| 400 | 400 | } |
| 401 | - $res['message_erreur'] = trim($res['message_erreur'] . ' ' . $erreurs['message_erreur']); |
|
| 401 | + $res['message_erreur'] = trim($res['message_erreur'].' '.$erreurs['message_erreur']); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | |
| 426 | 426 | |
| 427 | 427 | function auteur_reset_password($id_auteur, $erreurs = []) { |
| 428 | - $auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 428 | + $auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.intval($id_auteur)); |
|
| 429 | 429 | $config = auteurs_edit_config($auteur); |
| 430 | 430 | |
| 431 | 431 | if ($config['edit_pass']) { |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | include_spip('action/editer_auteur'); |
| 461 | 461 | auteur_modifier($id_auteur, $set); |
| 462 | 462 | |
| 463 | - $row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 463 | + $row = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.intval($id_auteur)); |
|
| 464 | 464 | include_spip('inc/filtres'); |
| 465 | 465 | if ( |
| 466 | 466 | $notifier |
@@ -245,8 +245,7 @@ discard block |
||
| 245 | 245 | if (_request('login')) { |
| 246 | 246 | // on n'est jamais cense poster le name 'login' |
| 247 | 247 | $erreurs['login'] = _T('info_non_modifiable'); |
| 248 | - } |
|
| 249 | - elseif ( |
|
| 248 | + } elseif ( |
|
| 250 | 249 | ($login = _request('new_login')) and |
| 251 | 250 | $login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)) |
| 252 | 251 | ) { |
@@ -483,8 +482,7 @@ discard block |
||
| 483 | 482 | if (!isset($contexte['lang']) or !$contexte['lang']) { |
| 484 | 483 | if (isset($row['lang']) and $row['lang']) { |
| 485 | 484 | $contexte['lang'] = $row['lang']; |
| 486 | - } |
|
| 487 | - else { |
|
| 485 | + } else { |
|
| 488 | 486 | $contexte['lang'] = $GLOBALS['meta']['langue_site']; |
| 489 | 487 | } |
| 490 | 488 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | **/ |
| 8 | 8 | |
| 9 | 9 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 10 | - return; |
|
| 10 | + return; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | include_spip('inc/actions'); |
@@ -38,24 +38,24 @@ discard block |
||
| 38 | 38 | * Environnement du formulaire |
| 39 | 39 | **/ |
| 40 | 40 | function formulaires_editer_auteur_charger_dist( |
| 41 | - $id_auteur = 'new', |
|
| 42 | - $retour = '', |
|
| 43 | - $associer_objet = '', |
|
| 44 | - $config_fonc = 'auteurs_edit_config', |
|
| 45 | - $row = [], |
|
| 46 | - $hidden = '' |
|
| 41 | + $id_auteur = 'new', |
|
| 42 | + $retour = '', |
|
| 43 | + $associer_objet = '', |
|
| 44 | + $config_fonc = 'auteurs_edit_config', |
|
| 45 | + $row = [], |
|
| 46 | + $hidden = '' |
|
| 47 | 47 | ) { |
| 48 | - $valeurs = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 49 | - $valeurs['new_login'] = $valeurs['login']; |
|
| 48 | + $valeurs = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 49 | + $valeurs['new_login'] = $valeurs['login']; |
|
| 50 | 50 | |
| 51 | - // S'il n'y a pas la langue, on prend la langue du site |
|
| 52 | - $valeurs['langue'] = $valeurs['langue'] ?: $GLOBALS['meta']['langue_site']; |
|
| 51 | + // S'il n'y a pas la langue, on prend la langue du site |
|
| 52 | + $valeurs['langue'] = $valeurs['langue'] ?: $GLOBALS['meta']['langue_site']; |
|
| 53 | 53 | |
| 54 | - if (!autoriser('modifier', 'auteur', intval($id_auteur))) { |
|
| 55 | - $valeurs['editable'] = ''; |
|
| 56 | - } |
|
| 54 | + if (!autoriser('modifier', 'auteur', intval($id_auteur))) { |
|
| 55 | + $valeurs['editable'] = ''; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - return $valeurs; |
|
| 58 | + return $valeurs; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | * Hash du formulaire |
| 80 | 80 | */ |
| 81 | 81 | function formulaires_editer_auteur_identifier_dist( |
| 82 | - $id_auteur = 'new', |
|
| 83 | - $retour = '', |
|
| 84 | - $associer_objet = '', |
|
| 85 | - $config_fonc = 'auteurs_edit_config', |
|
| 86 | - $row = [], |
|
| 87 | - $hidden = '' |
|
| 82 | + $id_auteur = 'new', |
|
| 83 | + $retour = '', |
|
| 84 | + $associer_objet = '', |
|
| 85 | + $config_fonc = 'auteurs_edit_config', |
|
| 86 | + $row = [], |
|
| 87 | + $hidden = '' |
|
| 88 | 88 | ) { |
| 89 | - return serialize([intval($id_auteur), $associer_objet]); |
|
| 89 | + return serialize([intval($id_auteur), $associer_objet]); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | |
@@ -100,27 +100,27 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | function auteurs_edit_config(array $row): array { |
| 102 | 102 | |
| 103 | - $config = []; |
|
| 104 | - $config['lignes'] = 8; |
|
| 105 | - $config['langue'] = $GLOBALS['spip_lang']; |
|
| 106 | - |
|
| 107 | - // pour instituer_auteur |
|
| 108 | - $config['auteur'] = $row; |
|
| 109 | - |
|
| 110 | - //$config['restreint'] = ($row['statut'] == 'publie'); |
|
| 111 | - $auth_methode = $row['source']; |
|
| 112 | - include_spip('inc/auth'); |
|
| 113 | - $config['edit_login'] = |
|
| 114 | - (auth_autoriser_modifier_login($auth_methode) |
|
| 115 | - and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['login' => true]) |
|
| 116 | - // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email |
|
| 117 | - and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['email' => true]) |
|
| 118 | - ); |
|
| 119 | - $config['edit_pass'] = |
|
| 120 | - (auth_autoriser_modifier_pass($auth_methode) |
|
| 121 | - and autoriser('modifier', 'auteur', $row['id_auteur'])); |
|
| 122 | - |
|
| 123 | - return $config; |
|
| 103 | + $config = []; |
|
| 104 | + $config['lignes'] = 8; |
|
| 105 | + $config['langue'] = $GLOBALS['spip_lang']; |
|
| 106 | + |
|
| 107 | + // pour instituer_auteur |
|
| 108 | + $config['auteur'] = $row; |
|
| 109 | + |
|
| 110 | + //$config['restreint'] = ($row['statut'] == 'publie'); |
|
| 111 | + $auth_methode = $row['source']; |
|
| 112 | + include_spip('inc/auth'); |
|
| 113 | + $config['edit_login'] = |
|
| 114 | + (auth_autoriser_modifier_login($auth_methode) |
|
| 115 | + and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['login' => true]) |
|
| 116 | + // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email |
|
| 117 | + and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['email' => true]) |
|
| 118 | + ); |
|
| 119 | + $config['edit_pass'] = |
|
| 120 | + (auth_autoriser_modifier_pass($auth_methode) |
|
| 121 | + and autoriser('modifier', 'auteur', $row['id_auteur'])); |
|
| 122 | + |
|
| 123 | + return $config; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -150,143 +150,143 @@ discard block |
||
| 150 | 150 | * Erreurs des saisies |
| 151 | 151 | **/ |
| 152 | 152 | function formulaires_editer_auteur_verifier_dist( |
| 153 | - $id_auteur = 'new', |
|
| 154 | - $retour = '', |
|
| 155 | - $associer_objet = '', |
|
| 156 | - $config_fonc = 'auteurs_edit_config', |
|
| 157 | - $row = [], |
|
| 158 | - $hidden = '' |
|
| 153 | + $id_auteur = 'new', |
|
| 154 | + $retour = '', |
|
| 155 | + $associer_objet = '', |
|
| 156 | + $config_fonc = 'auteurs_edit_config', |
|
| 157 | + $row = [], |
|
| 158 | + $hidden = '' |
|
| 159 | 159 | ) { |
| 160 | - // auto-renseigner le nom si il n'existe pas, sans couper |
|
| 161 | - titre_automatique('nom', ['email', 'login'], 255); |
|
| 162 | - |
|
| 163 | - $oblis = ['nom']; |
|
| 164 | - // si on veut renvoyer des identifiants il faut un email et un login |
|
| 165 | - if (_request('reset_password')) { |
|
| 166 | - $oblis[] = 'email'; |
|
| 167 | - $oblis[] = 'new_login'; |
|
| 168 | - } |
|
| 169 | - // mais il reste obligatoire si on a rien trouve |
|
| 170 | - $erreurs = formulaires_editer_objet_verifier('auteur', $id_auteur, $oblis); |
|
| 171 | - if (isset($erreurs['new_login'])) { |
|
| 172 | - $erreurs['login'] = $erreurs['new_login']; |
|
| 173 | - unset($erreurs['new_login']); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 177 | - $auth_methode = ($auth_methode ?: 'spip'); |
|
| 178 | - include_spip('inc/auth'); |
|
| 179 | - |
|
| 180 | - if (!nom_acceptable(_request('nom'))) { |
|
| 181 | - $erreurs['nom'] = _T('info_nom_pas_conforme'); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if ($email = _request('email')) { |
|
| 185 | - include_spip('inc/filtres'); |
|
| 186 | - include_spip('inc/autoriser'); |
|
| 187 | - // un redacteur qui modifie son email n'a pas le droit de le vider si il y en avait un |
|
| 188 | - if ( |
|
| 189 | - !autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?']) |
|
| 190 | - and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 191 | - and !strlen(trim($email)) |
|
| 192 | - and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 193 | - ) { |
|
| 194 | - $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email')); |
|
| 195 | - } else { |
|
| 196 | - if (!email_valide($email)) { |
|
| 197 | - $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email')); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - # Ne pas autoriser d'avoir deux auteurs avec le même email |
|
| 201 | - # cette fonctionalité nécessite que la base soit clean à l'activation : pas de |
|
| 202 | - # doublon sur la requête select email,count(*) from spip_auteurs group by email ; |
|
| 203 | - if (defined('_INTERDIRE_AUTEUR_MEME_EMAIL')) { |
|
| 204 | - #Nouvel auteur |
|
| 205 | - if (intval($id_auteur) == 0) { |
|
| 206 | - #Un auteur existe deja avec cette adresse ? |
|
| 207 | - if (sql_countsel('spip_auteurs', 'email=' . sql_quote($email)) > 0) { |
|
| 208 | - $erreurs['email'] = _T('erreur_email_deja_existant'); |
|
| 209 | - } |
|
| 210 | - } else { |
|
| 211 | - #Un auteur existe deja avec cette adresse ? et n'est pas le user courant. |
|
| 212 | - if ( |
|
| 213 | - (sql_countsel( |
|
| 214 | - 'spip_auteurs', |
|
| 215 | - 'email=' . sql_quote($email) |
|
| 216 | - ) > 0) and ($id_auteur != ($id_auteur_ancien = sql_getfetsel( |
|
| 217 | - 'id_auteur', |
|
| 218 | - 'spip_auteurs', |
|
| 219 | - 'email=' . sql_quote($email) |
|
| 220 | - ))) |
|
| 221 | - ) { |
|
| 222 | - $erreurs['email'] = _T('erreur_email_deja_existant'); |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // quand c'est un auteur existant on fait le reset password ici |
|
| 229 | - if (!(is_countable($erreurs) ? count($erreurs) : 0) and _request('reset_password') and intval($id_auteur)) { |
|
| 230 | - $erreurs = auteur_reset_password($id_auteur, $erreurs); |
|
| 231 | - return $erreurs; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - // corriger un cas si frequent : www.example.org sans le http:// qui precede |
|
| 235 | - if ($url = _request('url_site') and !tester_url_absolue($url)) { |
|
| 236 | - if (strpos($url, ':') === false and strncasecmp($url, 'www.', 4) === 0) { |
|
| 237 | - $url = 'http://' . $url; |
|
| 238 | - set_request('url_site', $url); |
|
| 239 | - } |
|
| 240 | - } |
|
| 241 | - // traiter les liens implicites avant de tester l'url |
|
| 242 | - include_spip('inc/lien'); |
|
| 243 | - if ($url = calculer_url(_request('url_site')) and !tester_url_absolue($url)) { |
|
| 244 | - $erreurs['url_site'] = _T('info_url_site_pas_conforme'); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - $erreurs['message_erreur'] = ''; |
|
| 248 | - if (_request('login')) { |
|
| 249 | - // on n'est jamais cense poster le name 'login' |
|
| 250 | - $erreurs['login'] = _T('info_non_modifiable'); |
|
| 251 | - } |
|
| 252 | - elseif ( |
|
| 253 | - ($login = _request('new_login')) and |
|
| 254 | - $login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)) |
|
| 255 | - ) { |
|
| 256 | - // on verifie la meme chose que dans auteurs_edit_config() |
|
| 257 | - if ( |
|
| 258 | - ! auth_autoriser_modifier_login($auth_methode) |
|
| 259 | - or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['login' => true]) |
|
| 260 | - // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email |
|
| 261 | - or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['email' => true]) |
|
| 262 | - ) { |
|
| 263 | - $erreurs['login'] = _T('info_non_modifiable'); |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - if (empty($erreurs['login'])) { |
|
| 268 | - if ($err = auth_verifier_login($auth_methode, _request('new_login'), $id_auteur)) { |
|
| 269 | - $erreurs['login'] = $err; |
|
| 270 | - $erreurs['message_erreur'] .= $err; |
|
| 271 | - } else { |
|
| 272 | - // pass trop court ou confirmation non identique |
|
| 273 | - if ($p = _request('new_pass')) { |
|
| 274 | - if ($p != _request('new_pass2')) { |
|
| 275 | - $erreurs['new_pass'] = _T('info_passes_identiques'); |
|
| 276 | - $erreurs['message_erreur'] .= _T('info_passes_identiques'); |
|
| 277 | - } elseif ($err = auth_verifier_pass($auth_methode, _request('new_login'), $p, $id_auteur)) { |
|
| 278 | - $erreurs['new_pass'] = $err; |
|
| 279 | - $erreurs['message_erreur'] .= $err; |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - if (!$erreurs['message_erreur']) { |
|
| 286 | - unset($erreurs['message_erreur']); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - return $erreurs; |
|
| 160 | + // auto-renseigner le nom si il n'existe pas, sans couper |
|
| 161 | + titre_automatique('nom', ['email', 'login'], 255); |
|
| 162 | + |
|
| 163 | + $oblis = ['nom']; |
|
| 164 | + // si on veut renvoyer des identifiants il faut un email et un login |
|
| 165 | + if (_request('reset_password')) { |
|
| 166 | + $oblis[] = 'email'; |
|
| 167 | + $oblis[] = 'new_login'; |
|
| 168 | + } |
|
| 169 | + // mais il reste obligatoire si on a rien trouve |
|
| 170 | + $erreurs = formulaires_editer_objet_verifier('auteur', $id_auteur, $oblis); |
|
| 171 | + if (isset($erreurs['new_login'])) { |
|
| 172 | + $erreurs['login'] = $erreurs['new_login']; |
|
| 173 | + unset($erreurs['new_login']); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 177 | + $auth_methode = ($auth_methode ?: 'spip'); |
|
| 178 | + include_spip('inc/auth'); |
|
| 179 | + |
|
| 180 | + if (!nom_acceptable(_request('nom'))) { |
|
| 181 | + $erreurs['nom'] = _T('info_nom_pas_conforme'); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if ($email = _request('email')) { |
|
| 185 | + include_spip('inc/filtres'); |
|
| 186 | + include_spip('inc/autoriser'); |
|
| 187 | + // un redacteur qui modifie son email n'a pas le droit de le vider si il y en avait un |
|
| 188 | + if ( |
|
| 189 | + !autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?']) |
|
| 190 | + and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 191 | + and !strlen(trim($email)) |
|
| 192 | + and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 193 | + ) { |
|
| 194 | + $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email')); |
|
| 195 | + } else { |
|
| 196 | + if (!email_valide($email)) { |
|
| 197 | + $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email')); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + # Ne pas autoriser d'avoir deux auteurs avec le même email |
|
| 201 | + # cette fonctionalité nécessite que la base soit clean à l'activation : pas de |
|
| 202 | + # doublon sur la requête select email,count(*) from spip_auteurs group by email ; |
|
| 203 | + if (defined('_INTERDIRE_AUTEUR_MEME_EMAIL')) { |
|
| 204 | + #Nouvel auteur |
|
| 205 | + if (intval($id_auteur) == 0) { |
|
| 206 | + #Un auteur existe deja avec cette adresse ? |
|
| 207 | + if (sql_countsel('spip_auteurs', 'email=' . sql_quote($email)) > 0) { |
|
| 208 | + $erreurs['email'] = _T('erreur_email_deja_existant'); |
|
| 209 | + } |
|
| 210 | + } else { |
|
| 211 | + #Un auteur existe deja avec cette adresse ? et n'est pas le user courant. |
|
| 212 | + if ( |
|
| 213 | + (sql_countsel( |
|
| 214 | + 'spip_auteurs', |
|
| 215 | + 'email=' . sql_quote($email) |
|
| 216 | + ) > 0) and ($id_auteur != ($id_auteur_ancien = sql_getfetsel( |
|
| 217 | + 'id_auteur', |
|
| 218 | + 'spip_auteurs', |
|
| 219 | + 'email=' . sql_quote($email) |
|
| 220 | + ))) |
|
| 221 | + ) { |
|
| 222 | + $erreurs['email'] = _T('erreur_email_deja_existant'); |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // quand c'est un auteur existant on fait le reset password ici |
|
| 229 | + if (!(is_countable($erreurs) ? count($erreurs) : 0) and _request('reset_password') and intval($id_auteur)) { |
|
| 230 | + $erreurs = auteur_reset_password($id_auteur, $erreurs); |
|
| 231 | + return $erreurs; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + // corriger un cas si frequent : www.example.org sans le http:// qui precede |
|
| 235 | + if ($url = _request('url_site') and !tester_url_absolue($url)) { |
|
| 236 | + if (strpos($url, ':') === false and strncasecmp($url, 'www.', 4) === 0) { |
|
| 237 | + $url = 'http://' . $url; |
|
| 238 | + set_request('url_site', $url); |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | + // traiter les liens implicites avant de tester l'url |
|
| 242 | + include_spip('inc/lien'); |
|
| 243 | + if ($url = calculer_url(_request('url_site')) and !tester_url_absolue($url)) { |
|
| 244 | + $erreurs['url_site'] = _T('info_url_site_pas_conforme'); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + $erreurs['message_erreur'] = ''; |
|
| 248 | + if (_request('login')) { |
|
| 249 | + // on n'est jamais cense poster le name 'login' |
|
| 250 | + $erreurs['login'] = _T('info_non_modifiable'); |
|
| 251 | + } |
|
| 252 | + elseif ( |
|
| 253 | + ($login = _request('new_login')) and |
|
| 254 | + $login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)) |
|
| 255 | + ) { |
|
| 256 | + // on verifie la meme chose que dans auteurs_edit_config() |
|
| 257 | + if ( |
|
| 258 | + ! auth_autoriser_modifier_login($auth_methode) |
|
| 259 | + or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['login' => true]) |
|
| 260 | + // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email |
|
| 261 | + or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['email' => true]) |
|
| 262 | + ) { |
|
| 263 | + $erreurs['login'] = _T('info_non_modifiable'); |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + if (empty($erreurs['login'])) { |
|
| 268 | + if ($err = auth_verifier_login($auth_methode, _request('new_login'), $id_auteur)) { |
|
| 269 | + $erreurs['login'] = $err; |
|
| 270 | + $erreurs['message_erreur'] .= $err; |
|
| 271 | + } else { |
|
| 272 | + // pass trop court ou confirmation non identique |
|
| 273 | + if ($p = _request('new_pass')) { |
|
| 274 | + if ($p != _request('new_pass2')) { |
|
| 275 | + $erreurs['new_pass'] = _T('info_passes_identiques'); |
|
| 276 | + $erreurs['message_erreur'] .= _T('info_passes_identiques'); |
|
| 277 | + } elseif ($err = auth_verifier_pass($auth_methode, _request('new_login'), $p, $id_auteur)) { |
|
| 278 | + $erreurs['new_pass'] = $err; |
|
| 279 | + $erreurs['message_erreur'] .= $err; |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + if (!$erreurs['message_erreur']) { |
|
| 286 | + unset($erreurs['message_erreur']); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + return $erreurs; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | |
@@ -323,154 +323,154 @@ discard block |
||
| 323 | 323 | * Retour des traitements |
| 324 | 324 | **/ |
| 325 | 325 | function formulaires_editer_auteur_traiter_dist( |
| 326 | - $id_auteur = 'new', |
|
| 327 | - $retour = '', |
|
| 328 | - $associer_objet = '', |
|
| 329 | - $config_fonc = 'auteurs_edit_config', |
|
| 330 | - $row = [], |
|
| 331 | - $hidden = '' |
|
| 326 | + $id_auteur = 'new', |
|
| 327 | + $retour = '', |
|
| 328 | + $associer_objet = '', |
|
| 329 | + $config_fonc = 'auteurs_edit_config', |
|
| 330 | + $row = [], |
|
| 331 | + $hidden = '' |
|
| 332 | 332 | ) { |
| 333 | - if (_request('saisie_webmestre') or _request('webmestre')) { |
|
| 334 | - set_request('webmestre', _request('webmestre') ?: 'non'); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - // si il y a des modifs sensibles (statut, mot de passe), on refuse le traitement en ajax |
|
| 338 | - // le formulaire ne peut être traité depuis une XMLHttpRequest |
|
| 339 | - $prev = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 340 | - if ( |
|
| 341 | - _request('new_pass') // nouveau mot de passe |
|
| 342 | - or empty($prev['statut']) // creation auteur |
|
| 343 | - or (_request('email') and $prev['email'] !== _request('email')) // modification email |
|
| 344 | - or (_request('statut') === '0minirezo' and $prev['statut'] !== '0minirezo') // promotion 0minirezo |
|
| 345 | - or (_request('statut') and intval(_request('statut')) < intval($prev['statut'])) // promotion de statut |
|
| 346 | - or (_request('webmestre') and _request('webmestre') !== 'non' and $prev['webmestre'] !== 'oui') // promotion webmestre |
|
| 347 | - ) { |
|
| 348 | - refuser_traiter_formulaire_ajax(); |
|
| 349 | - // si on arrive là encore en ajax c'est pas OK, on genere une erreur |
|
| 350 | - if (_AJAX or !empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { |
|
| 351 | - return [ |
|
| 352 | - 'message_erreur' => _T('erreur_technique_ajaxform') |
|
| 353 | - ]; |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - $id_objet = null; |
|
| 358 | - $retour = parametre_url($retour, 'email_confirm', ''); |
|
| 359 | - |
|
| 360 | - if ($restreintes = _request('restreintes')) { |
|
| 361 | - foreach ($restreintes as $k => $v) { |
|
| 362 | - if (strpos($v, 'rubrique|') === 0) { |
|
| 363 | - $restreintes[$k] = substr($v, 9); |
|
| 364 | - } |
|
| 365 | - } |
|
| 366 | - set_request('restreintes', $restreintes); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - set_request( |
|
| 370 | - 'email', |
|
| 371 | - email_valide(_request('email')) |
|
| 372 | - ); // eviter d'enregistrer les cas qui sont acceptés par email_valide dans le verifier : |
|
| 373 | - // "[email protected] " ou encore "Marie Toto <[email protected]>" |
|
| 374 | - |
|
| 375 | - include_spip('inc/autoriser'); |
|
| 376 | - if (!autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?'])) { |
|
| 377 | - $email_nouveau = _request('email'); |
|
| 378 | - set_request('email'); // vider la saisie car l'auteur n'a pas le droit de modifier cet email |
|
| 379 | - // mais si c'est son propre profil on lui envoie un email à l'adresse qu'il a indique |
|
| 380 | - // pour qu'il confirme qu'il possede bien cette adresse |
|
| 381 | - // son clic sur l'url du message permettre de confirmer le changement |
|
| 382 | - // et de revenir sur son profil |
|
| 383 | - if ( |
|
| 384 | - $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 385 | - and $email_nouveau != |
|
| 386 | - ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 387 | - ) { |
|
| 388 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 389 | - $texte = _T( |
|
| 390 | - 'form_auteur_mail_confirmation', |
|
| 391 | - [ |
|
| 392 | - 'url' => generer_action_auteur( |
|
| 393 | - 'confirmer_email', |
|
| 394 | - $email_nouveau, |
|
| 395 | - parametre_url($retour, 'email_modif', 'ok') |
|
| 396 | - ) |
|
| 397 | - ] |
|
| 398 | - ); |
|
| 399 | - $envoyer_mail($email_nouveau, _T('form_auteur_confirmation'), $texte); |
|
| 400 | - set_request('email_confirm', $email_nouveau); |
|
| 401 | - if ($email_ancien) { |
|
| 402 | - $envoyer_mail( |
|
| 403 | - $email_ancien, |
|
| 404 | - _T('form_auteur_confirmation'), |
|
| 405 | - _T('form_auteur_envoi_mail_confirmation', ['email' => $email_nouveau]) |
|
| 406 | - ); |
|
| 407 | - } |
|
| 408 | - $retour = parametre_url($retour, 'email_confirm', $email_nouveau); |
|
| 409 | - } |
|
| 410 | - } |
|
| 333 | + if (_request('saisie_webmestre') or _request('webmestre')) { |
|
| 334 | + set_request('webmestre', _request('webmestre') ?: 'non'); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + // si il y a des modifs sensibles (statut, mot de passe), on refuse le traitement en ajax |
|
| 338 | + // le formulaire ne peut être traité depuis une XMLHttpRequest |
|
| 339 | + $prev = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 340 | + if ( |
|
| 341 | + _request('new_pass') // nouveau mot de passe |
|
| 342 | + or empty($prev['statut']) // creation auteur |
|
| 343 | + or (_request('email') and $prev['email'] !== _request('email')) // modification email |
|
| 344 | + or (_request('statut') === '0minirezo' and $prev['statut'] !== '0minirezo') // promotion 0minirezo |
|
| 345 | + or (_request('statut') and intval(_request('statut')) < intval($prev['statut'])) // promotion de statut |
|
| 346 | + or (_request('webmestre') and _request('webmestre') !== 'non' and $prev['webmestre'] !== 'oui') // promotion webmestre |
|
| 347 | + ) { |
|
| 348 | + refuser_traiter_formulaire_ajax(); |
|
| 349 | + // si on arrive là encore en ajax c'est pas OK, on genere une erreur |
|
| 350 | + if (_AJAX or !empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { |
|
| 351 | + return [ |
|
| 352 | + 'message_erreur' => _T('erreur_technique_ajaxform') |
|
| 353 | + ]; |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + $id_objet = null; |
|
| 358 | + $retour = parametre_url($retour, 'email_confirm', ''); |
|
| 359 | + |
|
| 360 | + if ($restreintes = _request('restreintes')) { |
|
| 361 | + foreach ($restreintes as $k => $v) { |
|
| 362 | + if (strpos($v, 'rubrique|') === 0) { |
|
| 363 | + $restreintes[$k] = substr($v, 9); |
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | + set_request('restreintes', $restreintes); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + set_request( |
|
| 370 | + 'email', |
|
| 371 | + email_valide(_request('email')) |
|
| 372 | + ); // eviter d'enregistrer les cas qui sont acceptés par email_valide dans le verifier : |
|
| 373 | + // "[email protected] " ou encore "Marie Toto <[email protected]>" |
|
| 374 | + |
|
| 375 | + include_spip('inc/autoriser'); |
|
| 376 | + if (!autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?'])) { |
|
| 377 | + $email_nouveau = _request('email'); |
|
| 378 | + set_request('email'); // vider la saisie car l'auteur n'a pas le droit de modifier cet email |
|
| 379 | + // mais si c'est son propre profil on lui envoie un email à l'adresse qu'il a indique |
|
| 380 | + // pour qu'il confirme qu'il possede bien cette adresse |
|
| 381 | + // son clic sur l'url du message permettre de confirmer le changement |
|
| 382 | + // et de revenir sur son profil |
|
| 383 | + if ( |
|
| 384 | + $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 385 | + and $email_nouveau != |
|
| 386 | + ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 387 | + ) { |
|
| 388 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 389 | + $texte = _T( |
|
| 390 | + 'form_auteur_mail_confirmation', |
|
| 391 | + [ |
|
| 392 | + 'url' => generer_action_auteur( |
|
| 393 | + 'confirmer_email', |
|
| 394 | + $email_nouveau, |
|
| 395 | + parametre_url($retour, 'email_modif', 'ok') |
|
| 396 | + ) |
|
| 397 | + ] |
|
| 398 | + ); |
|
| 399 | + $envoyer_mail($email_nouveau, _T('form_auteur_confirmation'), $texte); |
|
| 400 | + set_request('email_confirm', $email_nouveau); |
|
| 401 | + if ($email_ancien) { |
|
| 402 | + $envoyer_mail( |
|
| 403 | + $email_ancien, |
|
| 404 | + _T('form_auteur_confirmation'), |
|
| 405 | + _T('form_auteur_envoi_mail_confirmation', ['email' => $email_nouveau]) |
|
| 406 | + ); |
|
| 407 | + } |
|
| 408 | + $retour = parametre_url($retour, 'email_confirm', $email_nouveau); |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | - // Trafic de langue pour enregistrer la bonne |
|
| 413 | - if ($langue = _request('langue')) { |
|
| 414 | - set_request('lang', $langue); |
|
| 415 | - } |
|
| 412 | + // Trafic de langue pour enregistrer la bonne |
|
| 413 | + if ($langue = _request('langue')) { |
|
| 414 | + set_request('lang', $langue); |
|
| 415 | + } |
|
| 416 | 416 | |
| 417 | - $res = formulaires_editer_objet_traiter('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 418 | - |
|
| 419 | - if (_request('reset_password') and !intval($id_auteur) and intval($res['id_auteur'])) { |
|
| 420 | - $erreurs = []; |
|
| 421 | - $erreurs = auteur_reset_password($res['id_auteur'], $erreurs); |
|
| 422 | - if (isset($erreurs['message_ok'])) { |
|
| 423 | - if (!isset($res['message_ok'])) { $res['message_ok'] = ''; |
|
| 424 | - } |
|
| 425 | - $res['message_ok'] = trim($res['message_ok'] . ' ' . $erreurs['message_ok']); |
|
| 426 | - } |
|
| 427 | - if (isset($erreurs['message_erreur']) and $erreurs['message_erreur']) { |
|
| 428 | - if (!isset($res['message_erreur'])) { $res['message_erreur'] = ''; |
|
| 429 | - } |
|
| 430 | - $res['message_erreur'] = trim($res['message_erreur'] . ' ' . $erreurs['message_erreur']); |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - // Un lien auteur a prendre en compte ? |
|
| 435 | - if ($associer_objet and $id_auteur = $res['id_auteur']) { |
|
| 436 | - $objet = ''; |
|
| 437 | - if (intval($associer_objet)) { |
|
| 438 | - $objet = 'article'; |
|
| 439 | - $id_objet = intval($associer_objet); |
|
| 440 | - } elseif (preg_match(',^\w+\|[0-9]+$,', $associer_objet)) { |
|
| 441 | - [$objet, $id_objet] = explode('|', $associer_objet); |
|
| 442 | - } |
|
| 443 | - if ($objet and $id_objet and autoriser('modifier', $objet, $id_objet)) { |
|
| 444 | - include_spip('action/editer_auteur'); |
|
| 445 | - auteur_associer($id_auteur, [$objet => $id_objet]); |
|
| 446 | - if (isset($res['redirect'])) { |
|
| 447 | - $res['redirect'] = parametre_url($res['redirect'], 'id_lien_ajoute', $id_auteur, '&'); |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - return $res; |
|
| 417 | + $res = formulaires_editer_objet_traiter('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 418 | + |
|
| 419 | + if (_request('reset_password') and !intval($id_auteur) and intval($res['id_auteur'])) { |
|
| 420 | + $erreurs = []; |
|
| 421 | + $erreurs = auteur_reset_password($res['id_auteur'], $erreurs); |
|
| 422 | + if (isset($erreurs['message_ok'])) { |
|
| 423 | + if (!isset($res['message_ok'])) { $res['message_ok'] = ''; |
|
| 424 | + } |
|
| 425 | + $res['message_ok'] = trim($res['message_ok'] . ' ' . $erreurs['message_ok']); |
|
| 426 | + } |
|
| 427 | + if (isset($erreurs['message_erreur']) and $erreurs['message_erreur']) { |
|
| 428 | + if (!isset($res['message_erreur'])) { $res['message_erreur'] = ''; |
|
| 429 | + } |
|
| 430 | + $res['message_erreur'] = trim($res['message_erreur'] . ' ' . $erreurs['message_erreur']); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + // Un lien auteur a prendre en compte ? |
|
| 435 | + if ($associer_objet and $id_auteur = $res['id_auteur']) { |
|
| 436 | + $objet = ''; |
|
| 437 | + if (intval($associer_objet)) { |
|
| 438 | + $objet = 'article'; |
|
| 439 | + $id_objet = intval($associer_objet); |
|
| 440 | + } elseif (preg_match(',^\w+\|[0-9]+$,', $associer_objet)) { |
|
| 441 | + [$objet, $id_objet] = explode('|', $associer_objet); |
|
| 442 | + } |
|
| 443 | + if ($objet and $id_objet and autoriser('modifier', $objet, $id_objet)) { |
|
| 444 | + include_spip('action/editer_auteur'); |
|
| 445 | + auteur_associer($id_auteur, [$objet => $id_objet]); |
|
| 446 | + if (isset($res['redirect'])) { |
|
| 447 | + $res['redirect'] = parametre_url($res['redirect'], 'id_lien_ajoute', $id_auteur, '&'); |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + return $res; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | |
| 456 | 456 | function auteur_reset_password($id_auteur, $erreurs = []) { |
| 457 | - $auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 458 | - $config = auteurs_edit_config($auteur); |
|
| 459 | - |
|
| 460 | - if ($config['edit_pass']) { |
|
| 461 | - if ($email = auteur_regenerer_identifiants($id_auteur)) { |
|
| 462 | - $erreurs['message_ok'] = _T('message_nouveaux_identifiants_ok', ['email' => $email]); |
|
| 463 | - $erreurs['message_erreur'] = ''; |
|
| 464 | - } elseif ($email === false) { |
|
| 465 | - $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec_envoi'); |
|
| 466 | - } else { |
|
| 467 | - $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec'); |
|
| 468 | - } |
|
| 469 | - } else { |
|
| 470 | - $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec'); |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - return $erreurs; |
|
| 457 | + $auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 458 | + $config = auteurs_edit_config($auteur); |
|
| 459 | + |
|
| 460 | + if ($config['edit_pass']) { |
|
| 461 | + if ($email = auteur_regenerer_identifiants($id_auteur)) { |
|
| 462 | + $erreurs['message_ok'] = _T('message_nouveaux_identifiants_ok', ['email' => $email]); |
|
| 463 | + $erreurs['message_erreur'] = ''; |
|
| 464 | + } elseif ($email === false) { |
|
| 465 | + $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec_envoi'); |
|
| 466 | + } else { |
|
| 467 | + $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec'); |
|
| 468 | + } |
|
| 469 | + } else { |
|
| 470 | + $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec'); |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + return $erreurs; |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -481,53 +481,53 @@ discard block |
||
| 481 | 481 | * @return string |
| 482 | 482 | */ |
| 483 | 483 | function auteur_regenerer_identifiants($id_auteur, $notifier = true, $contexte = []) { |
| 484 | - if ($id_auteur) { |
|
| 485 | - $set = []; |
|
| 486 | - include_spip('inc/access'); |
|
| 487 | - $set['pass'] = creer_pass_aleatoire(max(_PASS_LONGUEUR_MINI, 16)); |
|
| 488 | - |
|
| 489 | - include_spip('action/editer_auteur'); |
|
| 490 | - auteur_modifier($id_auteur, $set); |
|
| 491 | - |
|
| 492 | - $row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 493 | - include_spip('inc/filtres'); |
|
| 494 | - if ( |
|
| 495 | - $notifier |
|
| 496 | - and $row['email'] |
|
| 497 | - and email_valide($row['email']) |
|
| 498 | - and trouver_fond($fond = 'modeles/mail_nouveaux_identifiants') |
|
| 499 | - ) { |
|
| 500 | - // envoyer l'email avec login/pass |
|
| 501 | - $c = [ |
|
| 502 | - 'id_auteur' => $id_auteur, |
|
| 503 | - 'nom' => $row['nom'], |
|
| 504 | - 'mode' => $row['statut'], |
|
| 505 | - 'email' => $row['email'], |
|
| 506 | - 'pass' => $set['pass'], |
|
| 507 | - ]; |
|
| 508 | - // on merge avec les champs fournit en appel, qui sont passes au modele de notification donc |
|
| 509 | - $contexte = array_merge($contexte, $c); |
|
| 510 | - // si pas de langue explicitement demandee, prendre celle de l'auteur si on la connait, ou a defaut celle du site |
|
| 511 | - // plutot que celle de l'admin qui vient de cliquer sur le bouton |
|
| 512 | - if (!isset($contexte['lang']) or !$contexte['lang']) { |
|
| 513 | - if (isset($row['lang']) and $row['lang']) { |
|
| 514 | - $contexte['lang'] = $row['lang']; |
|
| 515 | - } |
|
| 516 | - else { |
|
| 517 | - $contexte['lang'] = $GLOBALS['meta']['langue_site']; |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - lang_select($contexte['lang']); |
|
| 521 | - $message = recuperer_fond($fond, $contexte); |
|
| 522 | - include_spip('inc/notifications'); |
|
| 523 | - notifications_envoyer_mails($row['email'], $message); |
|
| 524 | - lang_select(); |
|
| 525 | - |
|
| 526 | - return $row['email']; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return false; |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - return ''; |
|
| 484 | + if ($id_auteur) { |
|
| 485 | + $set = []; |
|
| 486 | + include_spip('inc/access'); |
|
| 487 | + $set['pass'] = creer_pass_aleatoire(max(_PASS_LONGUEUR_MINI, 16)); |
|
| 488 | + |
|
| 489 | + include_spip('action/editer_auteur'); |
|
| 490 | + auteur_modifier($id_auteur, $set); |
|
| 491 | + |
|
| 492 | + $row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 493 | + include_spip('inc/filtres'); |
|
| 494 | + if ( |
|
| 495 | + $notifier |
|
| 496 | + and $row['email'] |
|
| 497 | + and email_valide($row['email']) |
|
| 498 | + and trouver_fond($fond = 'modeles/mail_nouveaux_identifiants') |
|
| 499 | + ) { |
|
| 500 | + // envoyer l'email avec login/pass |
|
| 501 | + $c = [ |
|
| 502 | + 'id_auteur' => $id_auteur, |
|
| 503 | + 'nom' => $row['nom'], |
|
| 504 | + 'mode' => $row['statut'], |
|
| 505 | + 'email' => $row['email'], |
|
| 506 | + 'pass' => $set['pass'], |
|
| 507 | + ]; |
|
| 508 | + // on merge avec les champs fournit en appel, qui sont passes au modele de notification donc |
|
| 509 | + $contexte = array_merge($contexte, $c); |
|
| 510 | + // si pas de langue explicitement demandee, prendre celle de l'auteur si on la connait, ou a defaut celle du site |
|
| 511 | + // plutot que celle de l'admin qui vient de cliquer sur le bouton |
|
| 512 | + if (!isset($contexte['lang']) or !$contexte['lang']) { |
|
| 513 | + if (isset($row['lang']) and $row['lang']) { |
|
| 514 | + $contexte['lang'] = $row['lang']; |
|
| 515 | + } |
|
| 516 | + else { |
|
| 517 | + $contexte['lang'] = $GLOBALS['meta']['langue_site']; |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + lang_select($contexte['lang']); |
|
| 521 | + $message = recuperer_fond($fond, $contexte); |
|
| 522 | + include_spip('inc/notifications'); |
|
| 523 | + notifications_envoyer_mails($row['email'], $message); |
|
| 524 | + lang_select(); |
|
| 525 | + |
|
| 526 | + return $row['email']; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return false; |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + return ''; |
|
| 533 | 533 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | if ($objet == 'rubrique') { |
| 115 | 115 | // si c'est une rubrique-secteur contenant des breves, demander la |
| 116 | 116 | // confirmation du deplacement |
| 117 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 117 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique='.intval($id_objet)); |
|
| 118 | 118 | |
| 119 | 119 | if ($contient_breves > 0) { |
| 120 | 120 | $scb = ($contient_breves > 1 ? 's' : ''); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | ); |
| 128 | 128 | $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
| 129 | 129 | . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
| 130 | - . $scb . |
|
| 130 | + . $scb. |
|
| 131 | 131 | "</label></div></div>\n"; |
| 132 | 132 | } else { |
| 133 | 133 | $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | $form .= $confirm; |
| 137 | 137 | if ($actionable) { |
| 138 | 138 | if (strpos($form, '<select') !== false) { |
| 139 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 139 | + $form .= "<div style='text-align: ".$GLOBALS['spip_lang_right'].";'>" |
|
| 140 | + . '<input class="fondo submit btn" type="submit" value="'._T('bouton_choisir').'"/>' |
|
| 141 | 141 | . '</div>'; |
| 142 | 142 | } |
| 143 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 143 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n".$form; |
|
| 144 | 144 | if ($action = charger_fonction("editer_$objet", 'action', true)) { |
| 145 | 145 | $form = generer_action_auteur( |
| 146 | 146 | "editer_$objet", |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | include_spip('inc/presentation'); |
| 168 | 168 | |
| 169 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 169 | + return debut_cadre_couleur($logo, true, '', $titre).$form.fin_cadre_couleur(); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | if ($statut == 'nouveau') { |
| 243 | 243 | if ($attente) { |
| 244 | 244 | $statut = $attente; |
| 245 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 245 | + $plus = ' ('._T('info_statut_auteur_a_confirmer').')'; |
|
| 246 | 246 | } else { |
| 247 | 247 | return _T('info_statut_auteur_a_confirmer'); |
| 248 | 248 | } |
@@ -255,16 +255,16 @@ discard block |
||
| 255 | 255 | '5poubelle' => _T('texte_statut_poubelle'), // bouh |
| 256 | 256 | ]; |
| 257 | 257 | if (isset($recom[$statut])) { |
| 258 | - return $recom[$statut] . $plus; |
|
| 258 | + return $recom[$statut].$plus; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | // retrouver directement par le statut sinon |
| 262 | 262 | if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
| 263 | 263 | if (isset($recom[$t])) { |
| 264 | - return $recom[$t] . $plus; |
|
| 264 | + return $recom[$t].$plus; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - return _T($t) . $plus; |
|
| 267 | + return _T($t).$plus; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // si on a pas reussi a le traduire, retournons la chaine telle quelle |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
| 389 | 389 | $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
| 390 | 390 | ? '' |
| 391 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 391 | + : (' AND '.sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 392 | 392 | |
| 393 | 393 | // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
| 394 | 394 | if ($objet == 'rubrique') { |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | return ''; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - return propre('[->' . $virtuel . ']'); |
|
| 425 | + return propre('[->'.$virtuel.']'); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
| 450 | 450 | |
| 451 | 451 | $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
| 452 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 452 | + return "<a style='float: ".$GLOBALS['spip_lang_right'].";' href='$url'>$clic</a>"; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | ); |
| 526 | 526 | |
| 527 | 527 | if ($alertes = array_filter($alertes)) { |
| 528 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 528 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>". |
|
| 529 | 529 | join(' | ', $alertes) |
| 530 | 530 | . '</div></div>'; |
| 531 | 531 | } |
@@ -559,13 +559,13 @@ discard block |
||
| 559 | 559 | */ |
| 560 | 560 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 561 | 561 | $titre = attribut_html($titre); |
| 562 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 563 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 562 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>". |
|
| 563 | + http_img_pack('information-16.png', $titre).'</a>'; |
|
| 564 | 564 | |
| 565 | 565 | if (!$titre_lien) { |
| 566 | 566 | return $icone; |
| 567 | 567 | } else { |
| 568 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | + return $icone."\n<a href='$lien'>$titre_lien</a>"; |
|
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | */ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/filtres_boites'); |
@@ -41,25 +41,25 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function parametres_css_prive() { |
| 43 | 43 | |
| 44 | - $args = []; |
|
| 45 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 44 | + $args = []; |
|
| 45 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 51 | 51 | |
| 52 | - $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 52 | + $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 53 | 53 | |
| 54 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | - parse_str($couleurs($c), $c); |
|
| 56 | - $args = array_merge($args, $c); |
|
| 54 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | + parse_str($couleurs($c), $c); |
|
| 56 | + $args = array_merge($args, $c); |
|
| 57 | 57 | |
| 58 | - if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | - $args['var_mode'] = 'recalcul'; |
|
| 60 | - } |
|
| 58 | + if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | + $args['var_mode'] = 'recalcul'; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return http_build_query($args); |
|
| 62 | + return http_build_query($args); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -82,91 +82,91 @@ discard block |
||
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | 84 | function chercher_rubrique( |
| 85 | - $titre, |
|
| 86 | - $id_objet, |
|
| 87 | - $id_parent, |
|
| 88 | - $objet, |
|
| 89 | - $id_secteur, |
|
| 90 | - $restreint, |
|
| 91 | - $actionable = false, |
|
| 92 | - $retour_sans_cadre = false |
|
| 85 | + $titre, |
|
| 86 | + $id_objet, |
|
| 87 | + $id_parent, |
|
| 88 | + $objet, |
|
| 89 | + $id_secteur, |
|
| 90 | + $restreint, |
|
| 91 | + $actionable = false, |
|
| 92 | + $retour_sans_cadre = false |
|
| 93 | 93 | ) { |
| 94 | 94 | |
| 95 | - include_spip('inc/autoriser'); |
|
| 96 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | - return ''; |
|
| 98 | - } |
|
| 99 | - if (!sql_countsel('spip_rubriques')) { |
|
| 100 | - return ''; |
|
| 101 | - } |
|
| 102 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | - |
|
| 105 | - if ($id_parent == 0) { |
|
| 106 | - $logo = 'racine-24.png'; |
|
| 107 | - } elseif ($id_secteur == $id_parent) { |
|
| 108 | - $logo = 'secteur-24.png'; |
|
| 109 | - } else { |
|
| 110 | - $logo = 'rubrique-24.png'; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $confirm = ''; |
|
| 114 | - if ($objet == 'rubrique') { |
|
| 115 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | - // confirmation du deplacement |
|
| 117 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | - |
|
| 119 | - if ($contient_breves > 0) { |
|
| 120 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | - $scb = _T( |
|
| 122 | - 'avis_deplacement_rubrique', |
|
| 123 | - [ |
|
| 124 | - 'contient_breves' => $contient_breves, |
|
| 125 | - 'scb' => $scb |
|
| 126 | - ] |
|
| 127 | - ); |
|
| 128 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | - . $scb . |
|
| 131 | - "</label></div></div>\n"; |
|
| 132 | - } else { |
|
| 133 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $form .= $confirm; |
|
| 137 | - if ($actionable) { |
|
| 138 | - if (strpos($form, '<select') !== false) { |
|
| 139 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | - . '</div>'; |
|
| 142 | - } |
|
| 143 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | - if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | - $form = generer_action_auteur( |
|
| 146 | - "editer_$objet", |
|
| 147 | - $id_objet, |
|
| 148 | - self(), |
|
| 149 | - $form, |
|
| 150 | - " method='post' class='submit_plongeur'" |
|
| 151 | - ); |
|
| 152 | - } else { |
|
| 153 | - $form = generer_action_auteur( |
|
| 154 | - 'editer_objet', |
|
| 155 | - "$objet/$id_objet", |
|
| 156 | - self(), |
|
| 157 | - $form, |
|
| 158 | - " method='post' class='submit_plongeur'" |
|
| 159 | - ); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if ($retour_sans_cadre) { |
|
| 164 | - return $form; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - include_spip('inc/presentation'); |
|
| 168 | - |
|
| 169 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 95 | + include_spip('inc/autoriser'); |
|
| 96 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | + return ''; |
|
| 98 | + } |
|
| 99 | + if (!sql_countsel('spip_rubriques')) { |
|
| 100 | + return ''; |
|
| 101 | + } |
|
| 102 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | + |
|
| 105 | + if ($id_parent == 0) { |
|
| 106 | + $logo = 'racine-24.png'; |
|
| 107 | + } elseif ($id_secteur == $id_parent) { |
|
| 108 | + $logo = 'secteur-24.png'; |
|
| 109 | + } else { |
|
| 110 | + $logo = 'rubrique-24.png'; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $confirm = ''; |
|
| 114 | + if ($objet == 'rubrique') { |
|
| 115 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | + // confirmation du deplacement |
|
| 117 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | + |
|
| 119 | + if ($contient_breves > 0) { |
|
| 120 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | + $scb = _T( |
|
| 122 | + 'avis_deplacement_rubrique', |
|
| 123 | + [ |
|
| 124 | + 'contient_breves' => $contient_breves, |
|
| 125 | + 'scb' => $scb |
|
| 126 | + ] |
|
| 127 | + ); |
|
| 128 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | + . $scb . |
|
| 131 | + "</label></div></div>\n"; |
|
| 132 | + } else { |
|
| 133 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $form .= $confirm; |
|
| 137 | + if ($actionable) { |
|
| 138 | + if (strpos($form, '<select') !== false) { |
|
| 139 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | + . '</div>'; |
|
| 142 | + } |
|
| 143 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | + if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | + $form = generer_action_auteur( |
|
| 146 | + "editer_$objet", |
|
| 147 | + $id_objet, |
|
| 148 | + self(), |
|
| 149 | + $form, |
|
| 150 | + " method='post' class='submit_plongeur'" |
|
| 151 | + ); |
|
| 152 | + } else { |
|
| 153 | + $form = generer_action_auteur( |
|
| 154 | + 'editer_objet', |
|
| 155 | + "$objet/$id_objet", |
|
| 156 | + self(), |
|
| 157 | + $form, |
|
| 158 | + " method='post' class='submit_plongeur'" |
|
| 159 | + ); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if ($retour_sans_cadre) { |
|
| 164 | + return $form; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + include_spip('inc/presentation'); |
|
| 168 | + |
|
| 169 | + return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | * @return bool |
| 181 | 181 | */ |
| 182 | 182 | function avoir_visiteurs($past = false, $accepter = true) { |
| 183 | - if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | - return true; |
|
| 185 | - } |
|
| 186 | - if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | - return true; |
|
| 188 | - } |
|
| 189 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | - return true; |
|
| 191 | - } |
|
| 192 | - if (!$past) { |
|
| 193 | - return false; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - return sql_countsel( |
|
| 197 | - 'spip_auteurs', |
|
| 198 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 183 | + if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | + return true; |
|
| 185 | + } |
|
| 186 | + if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | + return true; |
|
| 188 | + } |
|
| 189 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | + return true; |
|
| 191 | + } |
|
| 192 | + if (!$past) { |
|
| 193 | + return false; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + return sql_countsel( |
|
| 197 | + 'spip_auteurs', |
|
| 198 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 199 | 199 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))" |
| 200 | - ); |
|
| 200 | + ); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | 215 | function statuts_articles_visibles($statut_auteur) { |
| 216 | - static $auth = []; |
|
| 217 | - if (!isset($auth[$statut_auteur])) { |
|
| 218 | - $auth[$statut_auteur] = []; |
|
| 219 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | - foreach ($statuts as $s) { |
|
| 221 | - if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | - $auth[$statut_auteur][] = $s; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - return $auth[$statut_auteur]; |
|
| 216 | + static $auth = []; |
|
| 217 | + if (!isset($auth[$statut_auteur])) { |
|
| 218 | + $auth[$statut_auteur] = []; |
|
| 219 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | + foreach ($statuts as $s) { |
|
| 221 | + if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | + $auth[$statut_auteur][] = $s; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + return $auth[$statut_auteur]; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -238,38 +238,38 @@ discard block |
||
| 238 | 238 | * @return string |
| 239 | 239 | */ |
| 240 | 240 | function traduire_statut_auteur($statut, $attente = '') { |
| 241 | - $plus = ''; |
|
| 242 | - if ($statut == 'nouveau') { |
|
| 243 | - if ($attente) { |
|
| 244 | - $statut = $attente; |
|
| 245 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | - } else { |
|
| 247 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - $recom = [ |
|
| 252 | - 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | - 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | - 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | - ]; |
|
| 257 | - if (isset($recom[$statut])) { |
|
| 258 | - return $recom[$statut] . $plus; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - // retrouver directement par le statut sinon |
|
| 262 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | - if (isset($recom[$t])) { |
|
| 264 | - return $recom[$t] . $plus; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - return _T($t) . $plus; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | - // c'est toujours plus informatif que rien du tout |
|
| 272 | - return $statut; |
|
| 241 | + $plus = ''; |
|
| 242 | + if ($statut == 'nouveau') { |
|
| 243 | + if ($attente) { |
|
| 244 | + $statut = $attente; |
|
| 245 | + $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | + } else { |
|
| 247 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + $recom = [ |
|
| 252 | + 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | + 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | + 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | + ]; |
|
| 257 | + if (isset($recom[$statut])) { |
|
| 258 | + return $recom[$statut] . $plus; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + // retrouver directement par le statut sinon |
|
| 262 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | + if (isset($recom[$t])) { |
|
| 264 | + return $recom[$t] . $plus; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + return _T($t) . $plus; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | + // c'est toujours plus informatif que rien du tout |
|
| 272 | + return $statut; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -280,29 +280,29 @@ discard block |
||
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | 282 | function afficher_qui_edite($id_objet, $objet): string { |
| 283 | - static $qui = []; |
|
| 284 | - if (isset($qui[$objet][$id_objet])) { |
|
| 285 | - return $qui[$objet][$id_objet]; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - include_spip('inc/config'); |
|
| 289 | - if (lire_config('articles_modif', 'non') === 'non') { |
|
| 290 | - return $qui[$objet][$id_objet] = ''; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - include_spip('inc/drapeau_edition'); |
|
| 294 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 295 | - if (!$modif) { |
|
| 296 | - return $qui[$objet][$id_objet] = ''; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - include_spip('base/objets'); |
|
| 300 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 301 | - if (isset($infos['texte_signale_edition'])) { |
|
| 302 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 283 | + static $qui = []; |
|
| 284 | + if (isset($qui[$objet][$id_objet])) { |
|
| 285 | + return $qui[$objet][$id_objet]; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + include_spip('inc/config'); |
|
| 289 | + if (lire_config('articles_modif', 'non') === 'non') { |
|
| 290 | + return $qui[$objet][$id_objet] = ''; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + include_spip('inc/drapeau_edition'); |
|
| 294 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 295 | + if (!$modif) { |
|
| 296 | + return $qui[$objet][$id_objet] = ''; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + include_spip('base/objets'); |
|
| 300 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 301 | + if (isset($infos['texte_signale_edition'])) { |
|
| 302 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -320,53 +320,53 @@ discard block |
||
| 320 | 320 | * @return array |
| 321 | 321 | */ |
| 322 | 322 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array { |
| 323 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 324 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - switch ($quoi) { |
|
| 328 | - case 'redacteurs': |
|
| 329 | - $statut = AUTEURS_MIN_REDAC; |
|
| 330 | - $statut = explode(',', $statut); |
|
| 331 | - if ($en_base) { |
|
| 332 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 333 | - $retire = array_diff($statut, $check); |
|
| 334 | - $statut = array_diff($statut, $retire); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return array_unique($statut); |
|
| 338 | - |
|
| 339 | - case 'visiteurs': |
|
| 340 | - $statut = []; |
|
| 341 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 342 | - $exclus = explode(',', $exclus); |
|
| 343 | - if (!$en_base) { |
|
| 344 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 345 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 346 | - } |
|
| 347 | - $s_complement = array_column( |
|
| 348 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 349 | - 'statut' |
|
| 350 | - ); |
|
| 351 | - |
|
| 352 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 353 | - |
|
| 354 | - default: |
|
| 355 | - case 'tous': |
|
| 356 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 357 | - $s_complement = array_column( |
|
| 358 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 359 | - 'statut' |
|
| 360 | - ); |
|
| 361 | - $statut = array_merge($statut, $s_complement); |
|
| 362 | - if ($en_base) { |
|
| 363 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 364 | - $retire = array_diff($statut, $check); |
|
| 365 | - $statut = array_diff($statut, $retire); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - return array_unique($statut); |
|
| 369 | - } |
|
| 323 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 324 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + switch ($quoi) { |
|
| 328 | + case 'redacteurs': |
|
| 329 | + $statut = AUTEURS_MIN_REDAC; |
|
| 330 | + $statut = explode(',', $statut); |
|
| 331 | + if ($en_base) { |
|
| 332 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 333 | + $retire = array_diff($statut, $check); |
|
| 334 | + $statut = array_diff($statut, $retire); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return array_unique($statut); |
|
| 338 | + |
|
| 339 | + case 'visiteurs': |
|
| 340 | + $statut = []; |
|
| 341 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 342 | + $exclus = explode(',', $exclus); |
|
| 343 | + if (!$en_base) { |
|
| 344 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 345 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 346 | + } |
|
| 347 | + $s_complement = array_column( |
|
| 348 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 349 | + 'statut' |
|
| 350 | + ); |
|
| 351 | + |
|
| 352 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 353 | + |
|
| 354 | + default: |
|
| 355 | + case 'tous': |
|
| 356 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 357 | + $s_complement = array_column( |
|
| 358 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 359 | + 'statut' |
|
| 360 | + ); |
|
| 361 | + $statut = array_merge($statut, $s_complement); |
|
| 362 | + if ($en_base) { |
|
| 363 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 364 | + $retire = array_diff($statut, $check); |
|
| 365 | + $statut = array_diff($statut, $retire); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + return array_unique($statut); |
|
| 369 | + } |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -382,28 +382,28 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 384 | 384 | |
| 385 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 386 | - $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 387 | - ? '' |
|
| 388 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 389 | - |
|
| 390 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 391 | - if ($objet == 'rubrique') { |
|
| 392 | - $id_rubrique = 0; |
|
| 393 | - } else { |
|
| 394 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 398 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 399 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 400 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 401 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - return $id_rubrique; |
|
| 385 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 386 | + $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 387 | + ? '' |
|
| 388 | + : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 389 | + |
|
| 390 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 391 | + if ($objet == 'rubrique') { |
|
| 392 | + $id_rubrique = 0; |
|
| 393 | + } else { |
|
| 394 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 398 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 399 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 400 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 401 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + return $id_rubrique; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -414,12 +414,12 @@ discard block |
||
| 414 | 414 | * @return string |
| 415 | 415 | */ |
| 416 | 416 | function lien_article_virtuel($virtuel) { |
| 417 | - include_spip('inc/lien'); |
|
| 418 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 419 | - return ''; |
|
| 420 | - } |
|
| 417 | + include_spip('inc/lien'); |
|
| 418 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 419 | + return ''; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - return propre('[->' . $virtuel . ']'); |
|
| 422 | + return propre('[->' . $virtuel . ']'); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
@@ -442,11 +442,11 @@ discard block |
||
| 442 | 442 | * @filtre |
| 443 | 443 | */ |
| 444 | 444 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 445 | - include_spip('inc/acces'); |
|
| 446 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 445 | + include_spip('inc/acces'); |
|
| 446 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 447 | 447 | |
| 448 | - $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 449 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 448 | + $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 449 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | |
@@ -458,76 +458,76 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | function alertes_auteur($id_auteur): string { |
| 460 | 460 | |
| 461 | - $alertes = []; |
|
| 462 | - |
|
| 463 | - if ( |
|
| 464 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 465 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 466 | - ) { |
|
| 467 | - include_spip('genie/maintenance'); |
|
| 468 | - if ($msg = message_crash_tables()) { |
|
| 469 | - $alertes[] = $msg; |
|
| 470 | - } |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - if ( |
|
| 474 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 475 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 476 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 477 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 478 | - ) { |
|
| 479 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 480 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 484 | - if ( |
|
| 485 | - $a |
|
| 486 | - and is_array($a = unserialize($a)) |
|
| 487 | - and count($a) |
|
| 488 | - ) { |
|
| 489 | - $update = false; |
|
| 490 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 491 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 493 | - $update = true; |
|
| 494 | - } |
|
| 495 | - if (isset($a[''])) { |
|
| 496 | - $alertes = array_merge($alertes, $a['']); |
|
| 497 | - unset($a['']); |
|
| 498 | - $update = true; |
|
| 499 | - } |
|
| 500 | - if ($update) { |
|
| 501 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 502 | - } |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - if ( |
|
| 506 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 507 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 508 | - ) { |
|
| 509 | - include_spip('inc/plugin'); |
|
| 510 | - $alertes[] = plugin_donne_erreurs(); |
|
| 511 | - } |
|
| 512 | - |
|
| 513 | - $alertes = pipeline( |
|
| 514 | - 'alertes_auteur', |
|
| 515 | - [ |
|
| 516 | - 'args' => [ |
|
| 517 | - 'id_auteur' => $id_auteur, |
|
| 518 | - 'exec' => _request('exec'), |
|
| 519 | - ], |
|
| 520 | - 'data' => $alertes |
|
| 521 | - ] |
|
| 522 | - ); |
|
| 523 | - |
|
| 524 | - if ($alertes = array_filter($alertes)) { |
|
| 525 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 526 | - join(' | ', $alertes) |
|
| 527 | - . '</div></div>'; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - return ''; |
|
| 461 | + $alertes = []; |
|
| 462 | + |
|
| 463 | + if ( |
|
| 464 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 465 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 466 | + ) { |
|
| 467 | + include_spip('genie/maintenance'); |
|
| 468 | + if ($msg = message_crash_tables()) { |
|
| 469 | + $alertes[] = $msg; |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + if ( |
|
| 474 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 475 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 476 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 477 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 478 | + ) { |
|
| 479 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 480 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 484 | + if ( |
|
| 485 | + $a |
|
| 486 | + and is_array($a = unserialize($a)) |
|
| 487 | + and count($a) |
|
| 488 | + ) { |
|
| 489 | + $update = false; |
|
| 490 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 491 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 493 | + $update = true; |
|
| 494 | + } |
|
| 495 | + if (isset($a[''])) { |
|
| 496 | + $alertes = array_merge($alertes, $a['']); |
|
| 497 | + unset($a['']); |
|
| 498 | + $update = true; |
|
| 499 | + } |
|
| 500 | + if ($update) { |
|
| 501 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 502 | + } |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + if ( |
|
| 506 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 507 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 508 | + ) { |
|
| 509 | + include_spip('inc/plugin'); |
|
| 510 | + $alertes[] = plugin_donne_erreurs(); |
|
| 511 | + } |
|
| 512 | + |
|
| 513 | + $alertes = pipeline( |
|
| 514 | + 'alertes_auteur', |
|
| 515 | + [ |
|
| 516 | + 'args' => [ |
|
| 517 | + 'id_auteur' => $id_auteur, |
|
| 518 | + 'exec' => _request('exec'), |
|
| 519 | + ], |
|
| 520 | + 'data' => $alertes |
|
| 521 | + ] |
|
| 522 | + ); |
|
| 523 | + |
|
| 524 | + if ($alertes = array_filter($alertes)) { |
|
| 525 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 526 | + join(' | ', $alertes) |
|
| 527 | + . '</div></div>'; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + return ''; |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
@@ -537,9 +537,9 @@ discard block |
||
| 537 | 537 | * @return string |
| 538 | 538 | */ |
| 539 | 539 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 540 | - include_spip('inc/presenter_enfants'); |
|
| 540 | + include_spip('inc/presenter_enfants'); |
|
| 541 | 541 | |
| 542 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 542 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
@@ -557,15 +557,15 @@ discard block |
||
| 557 | 557 | * @return string |
| 558 | 558 | */ |
| 559 | 559 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 560 | - $titre = attribut_html($titre); |
|
| 561 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 562 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 563 | - |
|
| 564 | - if (!$titre_lien) { |
|
| 565 | - return $icone; |
|
| 566 | - } else { |
|
| 567 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | - } |
|
| 560 | + $titre = attribut_html($titre); |
|
| 561 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 562 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 563 | + |
|
| 564 | + if (!$titre_lien) { |
|
| 565 | + return $icone; |
|
| 566 | + } else { |
|
| 567 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | + } |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | |
@@ -584,22 +584,22 @@ discard block |
||
| 584 | 584 | * @return array |
| 585 | 585 | */ |
| 586 | 586 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 587 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 588 | - if (!(is_countable($res) ? count($res) : 0)) { |
|
| 589 | - return []; |
|
| 590 | - } |
|
| 591 | - $r = reset($res); |
|
| 592 | - if (isset($r['rang_lien'])) { |
|
| 593 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 594 | - asort($l); |
|
| 595 | - $l = array_keys($l); |
|
| 596 | - } else { |
|
| 597 | - // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 598 | - // Sinon c'est dans "id_objet" |
|
| 599 | - $l = array_column( |
|
| 600 | - $res, |
|
| 601 | - $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 602 | - ); |
|
| 603 | - } |
|
| 604 | - return $l; |
|
| 587 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 588 | + if (!(is_countable($res) ? count($res) : 0)) { |
|
| 589 | + return []; |
|
| 590 | + } |
|
| 591 | + $r = reset($res); |
|
| 592 | + if (isset($r['rang_lien'])) { |
|
| 593 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 594 | + asort($l); |
|
| 595 | + $l = array_keys($l); |
|
| 596 | + } else { |
|
| 597 | + // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 598 | + // Sinon c'est dans "id_objet" |
|
| 599 | + $l = array_column( |
|
| 600 | + $res, |
|
| 601 | + $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 602 | + ); |
|
| 603 | + } |
|
| 604 | + return $l; |
|
| 605 | 605 | } |
@@ -1,22 +1,22 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 4 | - return; |
|
| 4 | + return; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | function trier_rss($texte) { |
| 8 | - if (preg_match_all(',<item.*</item>\s*?,Uims', $texte, $matches, PREG_SET_ORDER)) { |
|
| 9 | - $placeholder = '<!--REINSERT-->'; |
|
| 10 | - $items = []; |
|
| 11 | - foreach ($matches as $match) { |
|
| 12 | - if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) { |
|
| 13 | - $items[strtotime($r[1])] = trim($match[0]); |
|
| 14 | - $texte = str_replace($match[0], unique($placeholder), $texte); |
|
| 15 | - } |
|
| 16 | - } |
|
| 17 | - krsort($items); |
|
| 18 | - $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte); |
|
| 19 | - } |
|
| 8 | + if (preg_match_all(',<item.*</item>\s*?,Uims', $texte, $matches, PREG_SET_ORDER)) { |
|
| 9 | + $placeholder = '<!--REINSERT-->'; |
|
| 10 | + $items = []; |
|
| 11 | + foreach ($matches as $match) { |
|
| 12 | + if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) { |
|
| 13 | + $items[strtotime($r[1])] = trim($match[0]); |
|
| 14 | + $texte = str_replace($match[0], unique($placeholder), $texte); |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | + krsort($items); |
|
| 18 | + $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - return $texte; |
|
| 21 | + return $texte; |
|
| 22 | 22 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | } |
| 16 | 16 | } |
| 17 | 17 | krsort($items); |
| 18 | - $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte); |
|
| 18 | + $texte = str_replace($placeholder, implode("\n\t", $items)."\n", $texte); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | return $texte; |
@@ -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,43 +31,43 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | 33 | function action_instituer_langue_objet_dist($objet, $id, $id_rubrique, $changer_lang, $serveur = '') { |
| 34 | - if ($changer_lang) { |
|
| 35 | - $table_objet_sql = table_objet_sql($objet); |
|
| 36 | - $id_table_objet = id_table_objet($objet); |
|
| 37 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 38 | - $desc = $trouver_table($table_objet_sql, $serveur); |
|
| 34 | + if ($changer_lang) { |
|
| 35 | + $table_objet_sql = table_objet_sql($objet); |
|
| 36 | + $id_table_objet = id_table_objet($objet); |
|
| 37 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 38 | + $desc = $trouver_table($table_objet_sql, $serveur); |
|
| 39 | 39 | |
| 40 | - $set = []; |
|
| 41 | - if (isset($desc['field']['langue_choisie'])) { |
|
| 42 | - $set['langue_choisie'] = 'oui'; |
|
| 43 | - } |
|
| 40 | + $set = []; |
|
| 41 | + if (isset($desc['field']['langue_choisie'])) { |
|
| 42 | + $set['langue_choisie'] = 'oui'; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - if ($changer_lang != 'herit') { |
|
| 46 | - $set['lang'] = $changer_lang; |
|
| 47 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 48 | - include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees |
|
| 49 | - if ($table_objet_sql == 'spip_rubriques') { |
|
| 50 | - calculer_langues_rubriques(); |
|
| 51 | - } |
|
| 52 | - $langues = calculer_langues_utilisees($serveur); |
|
| 53 | - ecrire_meta('langues_utilisees', $langues); |
|
| 54 | - } else { |
|
| 55 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 56 | - if (!$langue_parent) { |
|
| 57 | - $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 58 | - } |
|
| 59 | - $changer_lang = $langue_parent; |
|
| 60 | - $set['lang'] = $changer_lang; |
|
| 61 | - if (isset($set['langue_choisie'])) { |
|
| 62 | - $set['langue_choisie'] = 'non'; |
|
| 63 | - } |
|
| 64 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 65 | - if ($table_objet_sql == 'spip_rubriques') { |
|
| 66 | - include_spip('inc/rubriques'); |
|
| 67 | - calculer_langues_rubriques(); |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - } |
|
| 45 | + if ($changer_lang != 'herit') { |
|
| 46 | + $set['lang'] = $changer_lang; |
|
| 47 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 48 | + include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees |
|
| 49 | + if ($table_objet_sql == 'spip_rubriques') { |
|
| 50 | + calculer_langues_rubriques(); |
|
| 51 | + } |
|
| 52 | + $langues = calculer_langues_utilisees($serveur); |
|
| 53 | + ecrire_meta('langues_utilisees', $langues); |
|
| 54 | + } else { |
|
| 55 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 56 | + if (!$langue_parent) { |
|
| 57 | + $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 58 | + } |
|
| 59 | + $changer_lang = $langue_parent; |
|
| 60 | + $set['lang'] = $changer_lang; |
|
| 61 | + if (isset($set['langue_choisie'])) { |
|
| 62 | + $set['langue_choisie'] = 'non'; |
|
| 63 | + } |
|
| 64 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 65 | + if ($table_objet_sql == 'spip_rubriques') { |
|
| 66 | + include_spip('inc/rubriques'); |
|
| 67 | + calculer_langues_rubriques(); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - return $changer_lang; |
|
| 72 | + return $changer_lang; |
|
| 73 | 73 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | if ($changer_lang != 'herit') { |
| 46 | 46 | $set['lang'] = $changer_lang; |
| 47 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 47 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=".intval($id), [], $serveur); |
|
| 48 | 48 | include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees |
| 49 | 49 | if ($table_objet_sql == 'spip_rubriques') { |
| 50 | 50 | calculer_langues_rubriques(); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $langues = calculer_langues_utilisees($serveur); |
| 53 | 53 | ecrire_meta('langues_utilisees', $langues); |
| 54 | 54 | } else { |
| 55 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 55 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 56 | 56 | if (!$langue_parent) { |
| 57 | 57 | $langue_parent = $GLOBALS['meta']['langue_site']; |
| 58 | 58 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | if (isset($set['langue_choisie'])) { |
| 62 | 62 | $set['langue_choisie'] = 'non'; |
| 63 | 63 | } |
| 64 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 64 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=".intval($id), [], $serveur); |
|
| 65 | 65 | if ($table_objet_sql == 'spip_rubriques') { |
| 66 | 66 | include_spip('inc/rubriques'); |
| 67 | 67 | calculer_langues_rubriques(); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
| 57 | 57 | if (!is_numeric(_request('reinstall'))) { |
| 58 | 58 | include_spip('base/create'); |
| 59 | - spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 59 | + spip_log('recree les tables eventuellement disparues', 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 60 | 60 | creer_base(); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | exit; |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | - spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 72 | + spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 73 | 73 | |
| 74 | 74 | // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
| 75 | 75 | @spip_unlink(_CACHE_RUBRIQUES); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | @spip_unlink(_CACHE_PLUGINS_OPT); |
| 79 | 79 | @spip_unlink(_CACHE_PLUGINS_FCT); |
| 80 | 80 | @spip_unlink(_CACHE_CHEMIN); |
| 81 | - @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 81 | + @spip_unlink(_DIR_TMP.'plugin_xml_cache.gz'); |
|
| 82 | 82 | |
| 83 | 83 | include_spip('inc/auth'); |
| 84 | 84 | auth_synchroniser_distant(); |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
| 118 | 118 | |
| 119 | 119 | spip_log( |
| 120 | - "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 120 | + "Version anterieure: $version_installee. Courante: ".$GLOBALS['spip_version_base'], |
|
| 121 | + 'maj.'._LOG_INFO_IMPORTANTE |
|
| 122 | 122 | ); |
| 123 | 123 | if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
| 124 | 124 | sql_replace( |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
| 152 | 152 | if ($res) { |
| 153 | 153 | if (!is_array($res)) { |
| 154 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 154 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_ERREUR); |
|
| 155 | 155 | } else { |
| 156 | - echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 156 | + echo _T('avis_operation_echec').' '.join(' ', $res); |
|
| 157 | 157 | echo install_fin_html(); |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
| 242 | 242 | if ($res) { |
| 243 | 243 | if (!is_array($res)) { |
| 244 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 244 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_ERREUR); |
|
| 245 | 245 | } else { |
| 246 | - echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 246 | + echo '<p>'._T('avis_operation_echec').' '.join(' ', $res).'</p>'; |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | echo(install_debut_html($titre)); |
| 300 | 300 | // script de rechargement auto sur timeout |
| 301 | 301 | $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
| 302 | - echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 302 | + echo http_script("window.setTimeout('location.href=\"".$redirect."\";',".($timeout * 1000).')'); |
|
| 303 | 303 | echo "<div style='text-align: left'>\n"; |
| 304 | 304 | if (ob_get_level()) { |
| 305 | 305 | ob_flush(); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | return [$v, $etape]; |
| 389 | 389 | } |
| 390 | 390 | $n = time() - $time; |
| 391 | - spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 391 | + spip_log("$table $meta: $v en $n secondes", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 392 | 392 | if ($meta) { |
| 393 | 393 | ecrire_meta($meta, $installee = $v, 'oui', $table); |
| 394 | 394 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | if ($meta) { |
| 405 | 405 | ecrire_meta($meta, $cible, 'oui', $table); |
| 406 | 406 | } |
| 407 | - spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 407 | + spip_log("MAJ terminee. $meta: $installee", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 408 | 408 | |
| 409 | 409 | return []; |
| 410 | 410 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | * @return int |
| 430 | 430 | */ |
| 431 | 431 | function serie_alter($serie, $q = [], $meta = '', $table = 'meta', $redirect = '') { |
| 432 | - $meta2 = $meta . '_maj_' . $serie; |
|
| 432 | + $meta2 = $meta.'_maj_'.$serie; |
|
| 433 | 433 | $etape = 0; |
| 434 | 434 | if (isset($GLOBALS[$table][$meta2])) { |
| 435 | 435 | $etape = intval($GLOBALS[$table][$meta2]); |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | and function_exists($f = array_shift($r)) |
| 443 | 443 | ) { |
| 444 | 444 | // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
| 445 | - spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 445 | + spip_log("$msg: $f ".@join(',', $r), 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 446 | 446 | // pour les fonctions atomiques sql_xx |
| 447 | 447 | // on enregistre le meta avant de lancer la fonction, |
| 448 | 448 | // de maniere a eviter de boucler sur timeout |
@@ -460,12 +460,12 @@ discard block |
||
| 460 | 460 | relance_maj($meta, $table, $redirect); |
| 461 | 461 | } |
| 462 | 462 | ecrire_meta($meta2, $i + 1, 'non', $table); |
| 463 | - spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 463 | + spip_log("$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 464 | 464 | } else { |
| 465 | 465 | if (!is_array($r)) { |
| 466 | - spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 466 | + spip_log("maj $i format incorrect", 'maj.'._LOG_ERREUR); |
|
| 467 | 467 | } else { |
| 468 | - spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 468 | + spip_log("maj $i fonction $f non definie", 'maj.'._LOG_ERREUR); |
|
| 469 | 469 | } |
| 470 | 470 | // en cas d'erreur serieuse, on s'arrete |
| 471 | 471 | // mais on permet de passer par dessus en rechargeant la page. |
@@ -17,17 +17,17 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!defined('_UPGRADE_TIME_OUT')) { |
| 24 | - /** |
|
| 25 | - * Durée en secondes pour relancer les scripts de mises à jour, x secondes |
|
| 26 | - * avant que la durée d'exécution du script provoque un timeout |
|
| 27 | - * |
|
| 28 | - * @var int |
|
| 29 | - **/ |
|
| 30 | - define('_UPGRADE_TIME_OUT', 20); |
|
| 24 | + /** |
|
| 25 | + * Durée en secondes pour relancer les scripts de mises à jour, x secondes |
|
| 26 | + * avant que la durée d'exécution du script provoque un timeout |
|
| 27 | + * |
|
| 28 | + * @var int |
|
| 29 | + **/ |
|
| 30 | + define('_UPGRADE_TIME_OUT', 20); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -50,40 +50,40 @@ discard block |
||
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | 52 | function base_upgrade_dist($titre = '', $reprise = '') { |
| 53 | - if (!$titre) { |
|
| 54 | - return; |
|
| 55 | - } // anti-testeur automatique |
|
| 56 | - if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
|
| 57 | - if (!is_numeric(_request('reinstall'))) { |
|
| 58 | - include_spip('base/create'); |
|
| 59 | - spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 60 | - creer_base(); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // quand on rentre par ici, c'est toujours une mise a jour de SPIP |
|
| 64 | - // lancement de l'upgrade SPIP |
|
| 65 | - $res = maj_base(); |
|
| 66 | - |
|
| 67 | - if ($res) { |
|
| 68 | - // on arrete tout ici ! |
|
| 69 | - exit; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 73 | - |
|
| 74 | - // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
|
| 75 | - @spip_unlink(_CACHE_RUBRIQUES); |
|
| 76 | - @spip_unlink(_CACHE_PIPELINES); |
|
| 77 | - @spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 78 | - @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 79 | - @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 80 | - @spip_unlink(_CACHE_CHEMIN); |
|
| 81 | - @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 82 | - |
|
| 83 | - include_spip('inc/auth'); |
|
| 84 | - auth_synchroniser_distant(); |
|
| 85 | - $config = charger_fonction('config', 'inc'); |
|
| 86 | - $config(); |
|
| 53 | + if (!$titre) { |
|
| 54 | + return; |
|
| 55 | + } // anti-testeur automatique |
|
| 56 | + if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
|
| 57 | + if (!is_numeric(_request('reinstall'))) { |
|
| 58 | + include_spip('base/create'); |
|
| 59 | + spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 60 | + creer_base(); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // quand on rentre par ici, c'est toujours une mise a jour de SPIP |
|
| 64 | + // lancement de l'upgrade SPIP |
|
| 65 | + $res = maj_base(); |
|
| 66 | + |
|
| 67 | + if ($res) { |
|
| 68 | + // on arrete tout ici ! |
|
| 69 | + exit; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 73 | + |
|
| 74 | + // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
|
| 75 | + @spip_unlink(_CACHE_RUBRIQUES); |
|
| 76 | + @spip_unlink(_CACHE_PIPELINES); |
|
| 77 | + @spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 78 | + @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 79 | + @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 80 | + @spip_unlink(_CACHE_CHEMIN); |
|
| 81 | + @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 82 | + |
|
| 83 | + include_spip('inc/auth'); |
|
| 84 | + auth_synchroniser_distant(); |
|
| 85 | + $config = charger_fonction('config', 'inc'); |
|
| 86 | + $config(); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -114,51 +114,51 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | function maj_base($version_cible = 0, $redirect = '', $debut_page = true) { |
| 116 | 116 | |
| 117 | - $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
|
| 118 | - |
|
| 119 | - spip_log( |
|
| 120 | - "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 122 | - ); |
|
| 123 | - if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 124 | - sql_replace( |
|
| 125 | - 'spip_meta', |
|
| 126 | - [ |
|
| 127 | - 'nom' => 'version_installee', |
|
| 128 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 129 | - 'impt' => 'non' |
|
| 130 | - ] |
|
| 131 | - ); |
|
| 132 | - return false; |
|
| 133 | - } |
|
| 134 | - if (!upgrade_test()) { |
|
| 135 | - return true; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $cible = ($version_cible ?: $GLOBALS['spip_version_base']); |
|
| 139 | - |
|
| 140 | - if ($version_installee < 2021_01_01_00) { |
|
| 141 | - include_spip('maj/legacy/v21'); |
|
| 142 | - include_spip('maj/legacy/v30'); |
|
| 143 | - include_spip('maj/legacy/v31'); |
|
| 144 | - include_spip('maj/legacy/v32'); |
|
| 145 | - include_spip('maj/legacy/v40'); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - include_spip('maj/2021'); |
|
| 149 | - |
|
| 150 | - ksort($GLOBALS['maj']); |
|
| 151 | - $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
|
| 152 | - if ($res) { |
|
| 153 | - if (!is_array($res)) { |
|
| 154 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 155 | - } else { |
|
| 156 | - echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 157 | - echo install_fin_html(); |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - return $res; |
|
| 117 | + $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
|
| 118 | + |
|
| 119 | + spip_log( |
|
| 120 | + "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 122 | + ); |
|
| 123 | + if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 124 | + sql_replace( |
|
| 125 | + 'spip_meta', |
|
| 126 | + [ |
|
| 127 | + 'nom' => 'version_installee', |
|
| 128 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 129 | + 'impt' => 'non' |
|
| 130 | + ] |
|
| 131 | + ); |
|
| 132 | + return false; |
|
| 133 | + } |
|
| 134 | + if (!upgrade_test()) { |
|
| 135 | + return true; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $cible = ($version_cible ?: $GLOBALS['spip_version_base']); |
|
| 139 | + |
|
| 140 | + if ($version_installee < 2021_01_01_00) { |
|
| 141 | + include_spip('maj/legacy/v21'); |
|
| 142 | + include_spip('maj/legacy/v30'); |
|
| 143 | + include_spip('maj/legacy/v31'); |
|
| 144 | + include_spip('maj/legacy/v32'); |
|
| 145 | + include_spip('maj/legacy/v40'); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + include_spip('maj/2021'); |
|
| 149 | + |
|
| 150 | + ksort($GLOBALS['maj']); |
|
| 151 | + $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
|
| 152 | + if ($res) { |
|
| 153 | + if (!is_array($res)) { |
|
| 154 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 155 | + } else { |
|
| 156 | + echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 157 | + echo install_fin_html(); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + return $res; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -200,53 +200,53 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta = 'meta') { |
| 202 | 202 | |
| 203 | - if ($table_meta !== 'meta') { |
|
| 204 | - installer_table_meta($table_meta); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - $current_version = null; |
|
| 208 | - |
|
| 209 | - if ( |
|
| 210 | - (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) |
|
| 211 | - || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '=')) |
|
| 212 | - ) { |
|
| 213 | - // $maj['create'] contient les directives propres a la premiere creation de base |
|
| 214 | - // c'est une operation derogatoire qui fait aboutir directement dans la version_cible |
|
| 215 | - if (isset($maj['create'])) { |
|
| 216 | - if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) { |
|
| 217 | - // installation : on ne fait que l'operation create |
|
| 218 | - $maj = ['init' => $maj['create']]; |
|
| 219 | - // et on lui ajoute un appel a inc/config |
|
| 220 | - // pour creer les metas par defaut |
|
| 221 | - $config = charger_fonction('config', 'inc'); |
|
| 222 | - $maj[$version_cible] = [[$config]]; |
|
| 223 | - } |
|
| 224 | - // dans tous les cas enlever cet index du tableau |
|
| 225 | - unset($maj['create']); |
|
| 226 | - } |
|
| 227 | - // si init, deja dans le bon ordre |
|
| 228 | - if (!isset($maj['init'])) { |
|
| 229 | - include_spip('inc/plugin'); // pour spip_version_compare |
|
| 230 | - uksort($maj, 'spip_version_compare'); |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - // la redirection se fait par defaut sur la page d'administration des plugins |
|
| 234 | - // sauf lorsque nous sommes sur l'installation de SPIP |
|
| 235 | - // ou define _REDIRECT_MAJ_PLUGIN |
|
| 236 | - $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin')); |
|
| 237 | - if (defined('_ECRIRE_INSTALL')) { |
|
| 238 | - $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape')); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
|
| 242 | - if ($res) { |
|
| 243 | - if (!is_array($res)) { |
|
| 244 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 245 | - } else { |
|
| 246 | - echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - } |
|
| 203 | + if ($table_meta !== 'meta') { |
|
| 204 | + installer_table_meta($table_meta); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + $current_version = null; |
|
| 208 | + |
|
| 209 | + if ( |
|
| 210 | + (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) |
|
| 211 | + || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '=')) |
|
| 212 | + ) { |
|
| 213 | + // $maj['create'] contient les directives propres a la premiere creation de base |
|
| 214 | + // c'est une operation derogatoire qui fait aboutir directement dans la version_cible |
|
| 215 | + if (isset($maj['create'])) { |
|
| 216 | + if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) { |
|
| 217 | + // installation : on ne fait que l'operation create |
|
| 218 | + $maj = ['init' => $maj['create']]; |
|
| 219 | + // et on lui ajoute un appel a inc/config |
|
| 220 | + // pour creer les metas par defaut |
|
| 221 | + $config = charger_fonction('config', 'inc'); |
|
| 222 | + $maj[$version_cible] = [[$config]]; |
|
| 223 | + } |
|
| 224 | + // dans tous les cas enlever cet index du tableau |
|
| 225 | + unset($maj['create']); |
|
| 226 | + } |
|
| 227 | + // si init, deja dans le bon ordre |
|
| 228 | + if (!isset($maj['init'])) { |
|
| 229 | + include_spip('inc/plugin'); // pour spip_version_compare |
|
| 230 | + uksort($maj, 'spip_version_compare'); |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + // la redirection se fait par defaut sur la page d'administration des plugins |
|
| 234 | + // sauf lorsque nous sommes sur l'installation de SPIP |
|
| 235 | + // ou define _REDIRECT_MAJ_PLUGIN |
|
| 236 | + $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin')); |
|
| 237 | + if (defined('_ECRIRE_INSTALL')) { |
|
| 238 | + $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape')); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
|
| 242 | + if ($res) { |
|
| 243 | + if (!is_array($res)) { |
|
| 244 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 245 | + } else { |
|
| 246 | + echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -263,17 +263,17 @@ discard block |
||
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | 265 | function relance_maj($meta, $table, $redirect = '') { |
| 266 | - include_spip('inc/headers'); |
|
| 267 | - if (!$redirect) { |
|
| 268 | - // recuperer la valeur installee en cours |
|
| 269 | - // on la tronque numeriquement, elle ne sert pas reellement |
|
| 270 | - // sauf pour verifier que ce n'est pas oui ou non |
|
| 271 | - // sinon is_numeric va echouer sur un numero de version 1.2.3 |
|
| 272 | - $installee = intval($GLOBALS[$table][$meta]); |
|
| 273 | - $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 274 | - } |
|
| 275 | - echo redirige_formulaire($redirect); |
|
| 276 | - exit(); |
|
| 266 | + include_spip('inc/headers'); |
|
| 267 | + if (!$redirect) { |
|
| 268 | + // recuperer la valeur installee en cours |
|
| 269 | + // on la tronque numeriquement, elle ne sert pas reellement |
|
| 270 | + // sauf pour verifier que ce n'est pas oui ou non |
|
| 271 | + // sinon is_numeric va echouer sur un numero de version 1.2.3 |
|
| 272 | + $installee = intval($GLOBALS[$table][$meta]); |
|
| 273 | + $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 274 | + } |
|
| 275 | + echo redirige_formulaire($redirect); |
|
| 276 | + exit(); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -286,28 +286,28 @@ discard block |
||
| 286 | 286 | * @return void |
| 287 | 287 | */ |
| 288 | 288 | function maj_debut_page($installee, $meta, $table) { |
| 289 | - static $done = false; |
|
| 290 | - if ($done) { |
|
| 291 | - return; |
|
| 292 | - } |
|
| 293 | - include_spip('inc/minipres'); |
|
| 294 | - if (function_exists('ini_set')) { |
|
| 295 | - @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure |
|
| 296 | - } |
|
| 297 | - $timeout = _UPGRADE_TIME_OUT * 2; |
|
| 298 | - $titre = _T('titre_page_upgrade'); |
|
| 299 | - $balise_img = charger_filtre('balise_img'); |
|
| 300 | - $titre .= $balise_img(chemin_image('loader.svg'), '', 'loader'); |
|
| 301 | - echo(install_debut_html($titre)); |
|
| 302 | - // script de rechargement auto sur timeout |
|
| 303 | - $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 304 | - echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 305 | - echo "<div style='text-align: left'>\n"; |
|
| 306 | - if (ob_get_level()) { |
|
| 307 | - ob_flush(); |
|
| 308 | - } |
|
| 309 | - flush(); |
|
| 310 | - $done = true; |
|
| 289 | + static $done = false; |
|
| 290 | + if ($done) { |
|
| 291 | + return; |
|
| 292 | + } |
|
| 293 | + include_spip('inc/minipres'); |
|
| 294 | + if (function_exists('ini_set')) { |
|
| 295 | + @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure |
|
| 296 | + } |
|
| 297 | + $timeout = _UPGRADE_TIME_OUT * 2; |
|
| 298 | + $titre = _T('titre_page_upgrade'); |
|
| 299 | + $balise_img = charger_filtre('balise_img'); |
|
| 300 | + $titre .= $balise_img(chemin_image('loader.svg'), '', 'loader'); |
|
| 301 | + echo(install_debut_html($titre)); |
|
| 302 | + // script de rechargement auto sur timeout |
|
| 303 | + $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 304 | + echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 305 | + echo "<div style='text-align: left'>\n"; |
|
| 306 | + if (ob_get_level()) { |
|
| 307 | + ob_flush(); |
|
| 308 | + } |
|
| 309 | + flush(); |
|
| 310 | + $done = true; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | |
@@ -351,64 +351,64 @@ discard block |
||
| 351 | 351 | * - tableau vide sinon. |
| 352 | 352 | */ |
| 353 | 353 | function maj_while($installee, $cible, $maj, $meta = '', $table = 'meta', $redirect = '', $debut_page = false) { |
| 354 | - # inclusions pour que les procedures d'upgrade disposent des fonctions de base |
|
| 355 | - include_spip('base/create'); |
|
| 356 | - include_spip('base/abstract_sql'); |
|
| 357 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 358 | - include_spip('inc/plugin'); // pour spip_version_compare |
|
| 359 | - $n = 0; |
|
| 360 | - $time = time(); |
|
| 361 | - |
|
| 362 | - if (!defined('_TIME_OUT')) { |
|
| 363 | - /** |
|
| 364 | - * Définir le timeout qui peut-être utilisé dans les fonctions |
|
| 365 | - * de mises à jour qui durent trop longtemps |
|
| 366 | - * |
|
| 367 | - * À utiliser tel que : `if (time() >= _TIME_OUT)` |
|
| 368 | - * |
|
| 369 | - * @var int |
|
| 370 | - */ |
|
| 371 | - define('_TIME_OUT', $time + _UPGRADE_TIME_OUT); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - foreach ($maj as $v => $operations) { |
|
| 375 | - // si une maj pour cette version |
|
| 376 | - if ( |
|
| 377 | - $v == 'init' or |
|
| 378 | - (spip_version_compare($v, $installee, '>') |
|
| 379 | - and spip_version_compare($v, $cible, '<=')) |
|
| 380 | - ) { |
|
| 381 | - if ($debut_page) { |
|
| 382 | - maj_debut_page($v, $meta, $table); |
|
| 383 | - } |
|
| 384 | - echo "MAJ $v"; |
|
| 385 | - $etape = serie_alter($v, $operations, $meta, $table, $redirect); |
|
| 386 | - $trouver_table(''); // vider le cache des descriptions de table |
|
| 387 | - # echec sur une etape en cours ? |
|
| 388 | - # on sort |
|
| 389 | - if ($etape) { |
|
| 390 | - return [$v, $etape]; |
|
| 391 | - } |
|
| 392 | - $n = time() - $time; |
|
| 393 | - spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 394 | - if ($meta) { |
|
| 395 | - ecrire_meta($meta, $installee = $v, 'oui', $table); |
|
| 396 | - } |
|
| 397 | - echo (_IS_CLI ? "\n" : '<br />'); |
|
| 398 | - } |
|
| 399 | - if (time() >= _TIME_OUT) { |
|
| 400 | - relance_maj($meta, $table, $redirect); |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - $trouver_table(''); // vider le cache des descriptions de table |
|
| 404 | - // indispensable pour les chgt de versions qui n'ecrivent pas en base |
|
| 405 | - // tant pis pour la redondance eventuelle avec ci-dessus |
|
| 406 | - if ($meta) { |
|
| 407 | - ecrire_meta($meta, $cible, 'oui', $table); |
|
| 408 | - } |
|
| 409 | - spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 410 | - |
|
| 411 | - return []; |
|
| 354 | + # inclusions pour que les procedures d'upgrade disposent des fonctions de base |
|
| 355 | + include_spip('base/create'); |
|
| 356 | + include_spip('base/abstract_sql'); |
|
| 357 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 358 | + include_spip('inc/plugin'); // pour spip_version_compare |
|
| 359 | + $n = 0; |
|
| 360 | + $time = time(); |
|
| 361 | + |
|
| 362 | + if (!defined('_TIME_OUT')) { |
|
| 363 | + /** |
|
| 364 | + * Définir le timeout qui peut-être utilisé dans les fonctions |
|
| 365 | + * de mises à jour qui durent trop longtemps |
|
| 366 | + * |
|
| 367 | + * À utiliser tel que : `if (time() >= _TIME_OUT)` |
|
| 368 | + * |
|
| 369 | + * @var int |
|
| 370 | + */ |
|
| 371 | + define('_TIME_OUT', $time + _UPGRADE_TIME_OUT); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + foreach ($maj as $v => $operations) { |
|
| 375 | + // si une maj pour cette version |
|
| 376 | + if ( |
|
| 377 | + $v == 'init' or |
|
| 378 | + (spip_version_compare($v, $installee, '>') |
|
| 379 | + and spip_version_compare($v, $cible, '<=')) |
|
| 380 | + ) { |
|
| 381 | + if ($debut_page) { |
|
| 382 | + maj_debut_page($v, $meta, $table); |
|
| 383 | + } |
|
| 384 | + echo "MAJ $v"; |
|
| 385 | + $etape = serie_alter($v, $operations, $meta, $table, $redirect); |
|
| 386 | + $trouver_table(''); // vider le cache des descriptions de table |
|
| 387 | + # echec sur une etape en cours ? |
|
| 388 | + # on sort |
|
| 389 | + if ($etape) { |
|
| 390 | + return [$v, $etape]; |
|
| 391 | + } |
|
| 392 | + $n = time() - $time; |
|
| 393 | + spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 394 | + if ($meta) { |
|
| 395 | + ecrire_meta($meta, $installee = $v, 'oui', $table); |
|
| 396 | + } |
|
| 397 | + echo (_IS_CLI ? "\n" : '<br />'); |
|
| 398 | + } |
|
| 399 | + if (time() >= _TIME_OUT) { |
|
| 400 | + relance_maj($meta, $table, $redirect); |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + $trouver_table(''); // vider le cache des descriptions de table |
|
| 404 | + // indispensable pour les chgt de versions qui n'ecrivent pas en base |
|
| 405 | + // tant pis pour la redondance eventuelle avec ci-dessus |
|
| 406 | + if ($meta) { |
|
| 407 | + ecrire_meta($meta, $cible, 'oui', $table); |
|
| 408 | + } |
|
| 409 | + spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 410 | + |
|
| 411 | + return []; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -431,53 +431,53 @@ discard block |
||
| 431 | 431 | * @return int |
| 432 | 432 | */ |
| 433 | 433 | function serie_alter($serie, $q = [], $meta = '', $table = 'meta', $redirect = '') { |
| 434 | - $meta2 = $meta . '_maj_' . $serie; |
|
| 435 | - $etape = 0; |
|
| 436 | - if (isset($GLOBALS[$table][$meta2])) { |
|
| 437 | - $etape = intval($GLOBALS[$table][$meta2]); |
|
| 438 | - } |
|
| 439 | - foreach ($q as $i => $r) { |
|
| 440 | - if ($i >= $etape) { |
|
| 441 | - $msg = "maj $table $meta2 etape $i"; |
|
| 442 | - if ( |
|
| 443 | - is_array($r) |
|
| 444 | - and function_exists($f = array_shift($r)) |
|
| 445 | - ) { |
|
| 446 | - // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
|
| 447 | - spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 448 | - // pour les fonctions atomiques sql_xx |
|
| 449 | - // on enregistre le meta avant de lancer la fonction, |
|
| 450 | - // de maniere a eviter de boucler sur timeout |
|
| 451 | - // mais pour les fonctions complexes, |
|
| 452 | - // il faut les rejouer jusqu'a achevement. |
|
| 453 | - // C'est a elle d'assurer qu'elles progressent a chaque rappel |
|
| 454 | - if (strncmp($f, 'sql_', 4) == 0) { |
|
| 455 | - ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 456 | - } |
|
| 457 | - echo (_IS_CLI ? '.' : " <span title='$i'>.</span>"); |
|
| 458 | - $f(...$r); |
|
| 459 | - // si temps imparti depasse, on relance sans ecrire en meta |
|
| 460 | - // car on est peut etre sorti sur timeout si c'est une fonction longue |
|
| 461 | - if (time() >= _TIME_OUT) { |
|
| 462 | - relance_maj($meta, $table, $redirect); |
|
| 463 | - } |
|
| 464 | - ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 465 | - spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 466 | - } else { |
|
| 467 | - if (!is_array($r)) { |
|
| 468 | - spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 469 | - } else { |
|
| 470 | - spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 471 | - } |
|
| 472 | - // en cas d'erreur serieuse, on s'arrete |
|
| 473 | - // mais on permet de passer par dessus en rechargeant la page. |
|
| 474 | - return $i + 1; |
|
| 475 | - } |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - effacer_meta($meta2, $table); |
|
| 479 | - |
|
| 480 | - return 0; |
|
| 434 | + $meta2 = $meta . '_maj_' . $serie; |
|
| 435 | + $etape = 0; |
|
| 436 | + if (isset($GLOBALS[$table][$meta2])) { |
|
| 437 | + $etape = intval($GLOBALS[$table][$meta2]); |
|
| 438 | + } |
|
| 439 | + foreach ($q as $i => $r) { |
|
| 440 | + if ($i >= $etape) { |
|
| 441 | + $msg = "maj $table $meta2 etape $i"; |
|
| 442 | + if ( |
|
| 443 | + is_array($r) |
|
| 444 | + and function_exists($f = array_shift($r)) |
|
| 445 | + ) { |
|
| 446 | + // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
|
| 447 | + spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 448 | + // pour les fonctions atomiques sql_xx |
|
| 449 | + // on enregistre le meta avant de lancer la fonction, |
|
| 450 | + // de maniere a eviter de boucler sur timeout |
|
| 451 | + // mais pour les fonctions complexes, |
|
| 452 | + // il faut les rejouer jusqu'a achevement. |
|
| 453 | + // C'est a elle d'assurer qu'elles progressent a chaque rappel |
|
| 454 | + if (strncmp($f, 'sql_', 4) == 0) { |
|
| 455 | + ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 456 | + } |
|
| 457 | + echo (_IS_CLI ? '.' : " <span title='$i'>.</span>"); |
|
| 458 | + $f(...$r); |
|
| 459 | + // si temps imparti depasse, on relance sans ecrire en meta |
|
| 460 | + // car on est peut etre sorti sur timeout si c'est une fonction longue |
|
| 461 | + if (time() >= _TIME_OUT) { |
|
| 462 | + relance_maj($meta, $table, $redirect); |
|
| 463 | + } |
|
| 464 | + ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 465 | + spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 466 | + } else { |
|
| 467 | + if (!is_array($r)) { |
|
| 468 | + spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 469 | + } else { |
|
| 470 | + spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 471 | + } |
|
| 472 | + // en cas d'erreur serieuse, on s'arrete |
|
| 473 | + // mais on permet de passer par dessus en rechargeant la page. |
|
| 474 | + return $i + 1; |
|
| 475 | + } |
|
| 476 | + } |
|
| 477 | + } |
|
| 478 | + effacer_meta($meta2, $table); |
|
| 479 | + |
|
| 480 | + return 0; |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -486,16 +486,16 @@ discard block |
||
| 486 | 486 | * @return bool True si possible. |
| 487 | 487 | **/ |
| 488 | 488 | function upgrade_test() { |
| 489 | - sql_drop_table('spip_test', true); |
|
| 490 | - sql_create('spip_test', ['a' => 'int']); |
|
| 491 | - sql_alter('TABLE spip_test ADD b INT'); |
|
| 492 | - sql_insertq('spip_test', ['b' => 1], ['field' => ['b' => 'int']]); |
|
| 493 | - $result = sql_select('b', 'spip_test'); |
|
| 494 | - // ne pas garder le resultat de la requete sinon sqlite3 |
|
| 495 | - // ne peut pas supprimer la table spip_test lors du sql_alter qui suit |
|
| 496 | - // car cette table serait alors 'verouillee' |
|
| 497 | - $result = $result ? true : false; |
|
| 498 | - sql_alter('TABLE spip_test DROP b'); |
|
| 499 | - |
|
| 500 | - return $result; |
|
| 489 | + sql_drop_table('spip_test', true); |
|
| 490 | + sql_create('spip_test', ['a' => 'int']); |
|
| 491 | + sql_alter('TABLE spip_test ADD b INT'); |
|
| 492 | + sql_insertq('spip_test', ['b' => 1], ['field' => ['b' => 'int']]); |
|
| 493 | + $result = sql_select('b', 'spip_test'); |
|
| 494 | + // ne pas garder le resultat de la requete sinon sqlite3 |
|
| 495 | + // ne peut pas supprimer la table spip_test lors du sql_alter qui suit |
|
| 496 | + // car cette table serait alors 'verouillee' |
|
| 497 | + $result = $result ? true : false; |
|
| 498 | + sql_alter('TABLE spip_test DROP b'); |
|
| 499 | + |
|
| 500 | + return $result; |
|
| 501 | 501 | } |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | include_spip('inc/lang'); |
| 100 | 100 | |
| 101 | 101 | if ($GLOBALS['spip_lang'] <> $default) { |
| 102 | - $opt = lang_select($default); # et remplace |
|
| 102 | + $opt = lang_select($default); # et remplace |
|
| 103 | 103 | if ($GLOBALS['spip_lang'] <> $default) { |
| 104 | - $default = ''; # annule tout choix par defaut |
|
| 104 | + $default = ''; # annule tout choix par defaut |
|
| 105 | 105 | if ($opt) { |
| 106 | 106 | lang_select(); |
| 107 | 107 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | # lien a partir de / |
| 112 | 112 | $cible = parametre_url(self(), 'lang', '', '&'); |
| 113 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), true); |
|
| 113 | + $post = generer_url_action('converser', 'redirect='.rawurlencode($cible), true); |
|
| 114 | 114 | |
| 115 | 115 | return [ |
| 116 | 116 | 'formulaires/menu_lang', |
@@ -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 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * Pile complétée du code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function balise_MENU_LANG_ECRIRE($p) { |
| 40 | - return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 40 | + return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | * - string: Si pas de multilinguisme |
| 57 | 57 | */ |
| 58 | 58 | function balise_MENU_LANG_ECRIRE_stat($args, $context_compil) { |
| 59 | - include_spip('inc/lang'); |
|
| 60 | - if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 61 | - return ''; |
|
| 62 | - } |
|
| 59 | + include_spip('inc/lang'); |
|
| 60 | + if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 61 | + return ''; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return $args; |
|
| 64 | + return $args; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * Liste : Chemin du squelette, durée du cache, contexte |
| 78 | 78 | **/ |
| 79 | 79 | function balise_MENU_LANG_ECRIRE_dyn($opt) { |
| 80 | - return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 80 | + return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -97,30 +97,30 @@ discard block |
||
| 97 | 97 | * Liste : Chemin du squelette, durée du cache, contexte |
| 98 | 98 | **/ |
| 99 | 99 | function menu_lang_pour_tous($nom, $default) { |
| 100 | - include_spip('inc/lang'); |
|
| 100 | + include_spip('inc/lang'); |
|
| 101 | 101 | |
| 102 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 103 | - $opt = lang_select($default); # et remplace |
|
| 104 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 105 | - $default = ''; # annule tout choix par defaut |
|
| 106 | - if ($opt) { |
|
| 107 | - lang_select(); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - } |
|
| 102 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 103 | + $opt = lang_select($default); # et remplace |
|
| 104 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 105 | + $default = ''; # annule tout choix par defaut |
|
| 106 | + if ($opt) { |
|
| 107 | + lang_select(); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - # lien a partir de / |
|
| 113 | - $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 114 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), true); |
|
| 112 | + # lien a partir de / |
|
| 113 | + $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 114 | + $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), true); |
|
| 115 | 115 | |
| 116 | - return [ |
|
| 117 | - 'formulaires/menu_lang', |
|
| 118 | - 3600, |
|
| 119 | - [ |
|
| 120 | - 'nom' => $nom, |
|
| 121 | - 'url' => $post, |
|
| 122 | - 'name' => $nom, |
|
| 123 | - 'default' => $default, |
|
| 124 | - ] |
|
| 125 | - ]; |
|
| 116 | + return [ |
|
| 117 | + 'formulaires/menu_lang', |
|
| 118 | + 3600, |
|
| 119 | + [ |
|
| 120 | + 'nom' => $nom, |
|
| 121 | + 'url' => $post, |
|
| 122 | + 'name' => $nom, |
|
| 123 | + 'default' => $default, |
|
| 124 | + ] |
|
| 125 | + ]; |
|
| 126 | 126 | } |