@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | **/ |
| 22 | 22 | |
| 23 | 23 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 24 | - return; |
|
| 24 | + return; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -31,27 +31,27 @@ discard block |
||
| 31 | 31 | * Environnement du formulaire |
| 32 | 32 | **/ |
| 33 | 33 | function formulaires_configurer_preferences_charger_dist() { |
| 34 | - // travailler sur des meta fraiches |
|
| 35 | - include_spip('inc/meta'); |
|
| 36 | - lire_metas(); |
|
| 34 | + // travailler sur des meta fraiches |
|
| 35 | + include_spip('inc/meta'); |
|
| 36 | + lire_metas(); |
|
| 37 | 37 | |
| 38 | - $valeurs = []; |
|
| 39 | - $valeurs['display_navigation'] = $GLOBALS['visiteur_session']['prefs']['display_navigation'] ?? 'navigation_avec_icones'; |
|
| 40 | - $valeurs['display'] = (isset($GLOBALS['visiteur_session']['prefs']['display']) and $GLOBALS['visiteur_session']['prefs']['display'] > 0) ? $GLOBALS['visiteur_session']['prefs']['display'] : 2; |
|
| 41 | - $valeurs['couleur'] = (isset($GLOBALS['visiteur_session']['prefs']['couleur']) and $GLOBALS['visiteur_session']['prefs']['couleur'] > 0) ? $GLOBALS['visiteur_session']['prefs']['couleur'] : 1; |
|
| 38 | + $valeurs = []; |
|
| 39 | + $valeurs['display_navigation'] = $GLOBALS['visiteur_session']['prefs']['display_navigation'] ?? 'navigation_avec_icones'; |
|
| 40 | + $valeurs['display'] = (isset($GLOBALS['visiteur_session']['prefs']['display']) and $GLOBALS['visiteur_session']['prefs']['display'] > 0) ? $GLOBALS['visiteur_session']['prefs']['display'] : 2; |
|
| 41 | + $valeurs['couleur'] = (isset($GLOBALS['visiteur_session']['prefs']['couleur']) and $GLOBALS['visiteur_session']['prefs']['couleur'] > 0) ? $GLOBALS['visiteur_session']['prefs']['couleur'] : 1; |
|
| 42 | 42 | |
| 43 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 44 | - $les_couleurs = $couleurs(); |
|
| 45 | - foreach ($les_couleurs as $k => $c) { |
|
| 46 | - $valeurs['_couleurs_url'][$k] = generer_url_public('style_prive.css', 'ltr=' |
|
| 47 | - . $GLOBALS['spip_lang_left'] . '&' |
|
| 48 | - . $couleurs($k)); |
|
| 49 | - $valeurs['couleurs'][$k] = $c; |
|
| 50 | - } |
|
| 43 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 44 | + $les_couleurs = $couleurs(); |
|
| 45 | + foreach ($les_couleurs as $k => $c) { |
|
| 46 | + $valeurs['_couleurs_url'][$k] = generer_url_public('style_prive.css', 'ltr=' |
|
| 47 | + . $GLOBALS['spip_lang_left'] . '&' |
|
| 48 | + . $couleurs($k)); |
|
| 49 | + $valeurs['couleurs'][$k] = $c; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $valeurs['imessage'] = $GLOBALS['visiteur_session']['imessage']; |
|
| 52 | + $valeurs['imessage'] = $GLOBALS['visiteur_session']['imessage']; |
|
| 53 | 53 | |
| 54 | - return $valeurs; |
|
| 54 | + return $valeurs; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -62,33 +62,33 @@ discard block |
||
| 62 | 62 | **/ |
| 63 | 63 | function formulaires_configurer_preferences_traiter_dist() { |
| 64 | 64 | |
| 65 | - if ($couleur = _request('couleur')) { |
|
| 66 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 67 | - $les_couleurs = $couleurs([], true); |
|
| 68 | - if (isset($les_couleurs[$couleur])) { |
|
| 69 | - $GLOBALS['visiteur_session']['prefs']['couleur'] = $couleur; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - if ($display = intval(_request('display'))) { |
|
| 73 | - $GLOBALS['visiteur_session']['prefs']['display'] = $display; |
|
| 74 | - } |
|
| 75 | - if ( |
|
| 76 | - $display_navigation = _request('display_navigation') |
|
| 77 | - and in_array($display_navigation, ['navigation_sans_icone', 'navigation_avec_icones']) |
|
| 78 | - ) { |
|
| 79 | - $GLOBALS['visiteur_session']['prefs']['display_navigation'] = $display_navigation; |
|
| 80 | - } |
|
| 65 | + if ($couleur = _request('couleur')) { |
|
| 66 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 67 | + $les_couleurs = $couleurs([], true); |
|
| 68 | + if (isset($les_couleurs[$couleur])) { |
|
| 69 | + $GLOBALS['visiteur_session']['prefs']['couleur'] = $couleur; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + if ($display = intval(_request('display'))) { |
|
| 73 | + $GLOBALS['visiteur_session']['prefs']['display'] = $display; |
|
| 74 | + } |
|
| 75 | + if ( |
|
| 76 | + $display_navigation = _request('display_navigation') |
|
| 77 | + and in_array($display_navigation, ['navigation_sans_icone', 'navigation_avec_icones']) |
|
| 78 | + ) { |
|
| 79 | + $GLOBALS['visiteur_session']['prefs']['display_navigation'] = $display_navigation; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - if (intval($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 83 | - include_spip('action/editer_auteur'); |
|
| 84 | - $c = ['prefs' => serialize($GLOBALS['visiteur_session']['prefs'])]; |
|
| 82 | + if (intval($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 83 | + include_spip('action/editer_auteur'); |
|
| 84 | + $c = ['prefs' => serialize($GLOBALS['visiteur_session']['prefs'])]; |
|
| 85 | 85 | |
| 86 | - if ($imessage = _request('imessage') and in_array($imessage, ['oui', 'non'])) { |
|
| 87 | - $c['imessage'] = $imessage; |
|
| 88 | - } |
|
| 86 | + if ($imessage = _request('imessage') and in_array($imessage, ['oui', 'non'])) { |
|
| 87 | + $c['imessage'] = $imessage; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], $c); |
|
| 91 | - } |
|
| 90 | + auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], $c); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - return ['message_ok' => _T('config_info_enregistree'), 'editable' => true]; |
|
| 93 | + return ['message_ok' => _T('config_info_enregistree'), 'editable' => true]; |
|
| 94 | 94 | } |
@@ -11,77 +11,77 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | # Les information d'une rubrique selectionnee dans le mini navigateur |
| 18 | 18 | |
| 19 | 19 | function inc_informer_dist($id, $col, $exclus, $rac, $type, $do = 'aff') { |
| 20 | - include_spip('inc/texte'); |
|
| 21 | - $titre = $descriptif = ''; |
|
| 22 | - if ($type === 'rubrique') { |
|
| 23 | - $row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . intval($id)); |
|
| 24 | - if ($row) { |
|
| 25 | - $titre = typo($row['titre']); |
|
| 26 | - $descriptif = propre($row['descriptif']); |
|
| 27 | - } else { |
|
| 28 | - $titre = _T('info_racine_site'); |
|
| 29 | - } |
|
| 30 | - } |
|
| 20 | + include_spip('inc/texte'); |
|
| 21 | + $titre = $descriptif = ''; |
|
| 22 | + if ($type === 'rubrique') { |
|
| 23 | + $row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . intval($id)); |
|
| 24 | + if ($row) { |
|
| 25 | + $titre = typo($row['titre']); |
|
| 26 | + $descriptif = propre($row['descriptif']); |
|
| 27 | + } else { |
|
| 28 | + $titre = _T('info_racine_site'); |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - $res = ''; |
|
| 33 | - if ( |
|
| 34 | - $type === 'rubrique' |
|
| 35 | - and intval($GLOBALS['visiteur_session']['prefs']['display'] ?? 0) !== 1 |
|
| 36 | - and isset($GLOBALS['meta']['image_process']) |
|
| 37 | - ) { |
|
| 38 | - if ($GLOBALS['meta']['image_process'] !== 'non') { |
|
| 39 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 40 | - if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 41 | - [$fid, $dir, $nom, $format] = $res; |
|
| 42 | - include_spip('inc/filtres_images_mini'); |
|
| 43 | - $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
|
| 44 | - if ($res) { |
|
| 45 | - $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>"; |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - } |
|
| 32 | + $res = ''; |
|
| 33 | + if ( |
|
| 34 | + $type === 'rubrique' |
|
| 35 | + and intval($GLOBALS['visiteur_session']['prefs']['display'] ?? 0) !== 1 |
|
| 36 | + and isset($GLOBALS['meta']['image_process']) |
|
| 37 | + ) { |
|
| 38 | + if ($GLOBALS['meta']['image_process'] !== 'non') { |
|
| 39 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 40 | + if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 41 | + [$fid, $dir, $nom, $format] = $res; |
|
| 42 | + include_spip('inc/filtres_images_mini'); |
|
| 43 | + $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
|
| 44 | + if ($res) { |
|
| 45 | + $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>"; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - $rac = spip_htmlentities($rac, ENT_QUOTES); |
|
| 52 | - $do = spip_htmlentities($do, ENT_QUOTES); |
|
| 53 | - $id = intval($id); |
|
| 51 | + $rac = spip_htmlentities($rac, ENT_QUOTES); |
|
| 52 | + $do = spip_htmlentities($do, ENT_QUOTES); |
|
| 53 | + $id = intval($id); |
|
| 54 | 54 | |
| 55 | 55 | # ce lien provoque la selection (directe) de la rubrique cliquee |
| 56 | 56 | # et l'affichage de son titre dans le bandeau |
| 57 | - $titre = strtr( |
|
| 58 | - str_replace( |
|
| 59 | - "'", |
|
| 60 | - '’', |
|
| 61 | - str_replace('"', '"', textebrut($titre)) |
|
| 62 | - ), |
|
| 63 | - "\n\r", |
|
| 64 | - ' ' |
|
| 65 | - ); |
|
| 57 | + $titre = strtr( |
|
| 58 | + str_replace( |
|
| 59 | + "'", |
|
| 60 | + '’', |
|
| 61 | + str_replace('"', '"', textebrut($titre)) |
|
| 62 | + ), |
|
| 63 | + "\n\r", |
|
| 64 | + ' ' |
|
| 65 | + ); |
|
| 66 | 66 | |
| 67 | - $js_func = $do . '_selection_titre'; |
|
| 67 | + $js_func = $do . '_selection_titre'; |
|
| 68 | 68 | |
| 69 | - return "<div style='display: none;'>" |
|
| 70 | - . "<input type='text' id='" . $rac . "_sel' value='$id' />" |
|
| 71 | - . "<input type='text' id='" . $rac . "_sel2' value=\"" |
|
| 72 | - . entites_html($titre) |
|
| 73 | - . '" />' |
|
| 74 | - . '</div>' |
|
| 75 | - . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
|
| 76 | - . '<div class="informer__item">' |
|
| 77 | - . (!$res ? '' : $res) |
|
| 78 | - . "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>' |
|
| 79 | - . (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>') |
|
| 80 | - . '</div>' |
|
| 81 | - . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 82 | - . "<input type='submit' class='fondo btn submit' value='" |
|
| 83 | - . _T('bouton_choisir') |
|
| 84 | - . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
|
| 85 | - . '</div>' |
|
| 86 | - . '</div>'; |
|
| 69 | + return "<div style='display: none;'>" |
|
| 70 | + . "<input type='text' id='" . $rac . "_sel' value='$id' />" |
|
| 71 | + . "<input type='text' id='" . $rac . "_sel2' value=\"" |
|
| 72 | + . entites_html($titre) |
|
| 73 | + . '" />' |
|
| 74 | + . '</div>' |
|
| 75 | + . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
|
| 76 | + . '<div class="informer__item">' |
|
| 77 | + . (!$res ? '' : $res) |
|
| 78 | + . "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>' |
|
| 79 | + . (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>') |
|
| 80 | + . '</div>' |
|
| 81 | + . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 82 | + . "<input type='submit' class='fondo btn submit' value='" |
|
| 83 | + . _T('bouton_choisir') |
|
| 84 | + . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
|
| 85 | + . '</div>' |
|
| 86 | + . '</div>'; |
|
| 87 | 87 | } |
@@ -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 | /** |
@@ -43,25 +43,25 @@ discard block |
||
| 43 | 43 | * @return string Code HTML |
| 44 | 44 | **/ |
| 45 | 45 | function inc_commencer_page_dist( |
| 46 | - $titre = '', |
|
| 47 | - $rubrique = 'accueil', |
|
| 48 | - $sous_rubrique = 'accueil', |
|
| 49 | - $id_rubrique = '', |
|
| 50 | - $menu = true, |
|
| 51 | - $minipres = false, |
|
| 52 | - $alertes = true |
|
| 46 | + $titre = '', |
|
| 47 | + $rubrique = 'accueil', |
|
| 48 | + $sous_rubrique = 'accueil', |
|
| 49 | + $id_rubrique = '', |
|
| 50 | + $menu = true, |
|
| 51 | + $minipres = false, |
|
| 52 | + $alertes = true |
|
| 53 | 53 | ) { |
| 54 | 54 | |
| 55 | - include_spip('inc/headers'); |
|
| 55 | + include_spip('inc/headers'); |
|
| 56 | 56 | |
| 57 | - http_no_cache(); |
|
| 57 | + http_no_cache(); |
|
| 58 | 58 | |
| 59 | - return init_entete($titre, $id_rubrique, $minipres) |
|
| 60 | - . init_body($rubrique, $sous_rubrique, $id_rubrique, $menu) |
|
| 61 | - . "<div id='page'>" |
|
| 62 | - . auteurs_recemment_connectes($GLOBALS['connect_id_auteur']) |
|
| 63 | - . ($alertes ? alertes_auteur($GLOBALS['connect_id_auteur']) : '') |
|
| 64 | - . '<div class="largeur">'; |
|
| 59 | + return init_entete($titre, $id_rubrique, $minipres) |
|
| 60 | + . init_body($rubrique, $sous_rubrique, $id_rubrique, $menu) |
|
| 61 | + . "<div id='page'>" |
|
| 62 | + . auteurs_recemment_connectes($GLOBALS['connect_id_auteur']) |
|
| 63 | + . ($alertes ? alertes_auteur($GLOBALS['connect_id_auteur']) : '') |
|
| 64 | + . '<div class="largeur">'; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -82,21 +82,21 @@ discard block |
||
| 82 | 82 | * Entête du fichier HTML avec le DOCTYPE |
| 83 | 83 | */ |
| 84 | 84 | function init_entete($titre = '', $dummy = 0, $minipres = false) { |
| 85 | - include_spip('inc/texte'); |
|
| 86 | - if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 87 | - $nom_site_spip = _T('info_mon_site_spip'); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - $titre = '[' |
|
| 91 | - . $nom_site_spip |
|
| 92 | - . ']' |
|
| 93 | - . ($titre ? ' ' . textebrut(typo($titre)) : ''); |
|
| 94 | - |
|
| 95 | - return _DOCTYPE_ECRIRE |
|
| 96 | - . html_lang_attributes() |
|
| 97 | - . "<head>\n" |
|
| 98 | - . init_head($titre, $dummy, $minipres) |
|
| 99 | - . "</head>\n"; |
|
| 85 | + include_spip('inc/texte'); |
|
| 86 | + if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 87 | + $nom_site_spip = _T('info_mon_site_spip'); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + $titre = '[' |
|
| 91 | + . $nom_site_spip |
|
| 92 | + . ']' |
|
| 93 | + . ($titre ? ' ' . textebrut(typo($titre)) : ''); |
|
| 94 | + |
|
| 95 | + return _DOCTYPE_ECRIRE |
|
| 96 | + . html_lang_attributes() |
|
| 97 | + . "<head>\n" |
|
| 98 | + . init_head($titre, $dummy, $minipres) |
|
| 99 | + . "</head>\n"; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @return string |
| 111 | 111 | */ |
| 112 | 112 | function init_head($titre = '', $dummy = 0, $minipres = false) { |
| 113 | - return recuperer_fond('prive/squelettes/head/dist', ['titre' => $titre, 'minipres' => $minipres ? ' ' : '']); |
|
| 113 | + return recuperer_fond('prive/squelettes/head/dist', ['titre' => $titre, 'minipres' => $minipres ? ' ' : '']); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -132,20 +132,20 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | function init_body($rubrique = 'accueil', $sous_rubrique = 'accueil', $id_rubrique = '', $menu = true) { |
| 134 | 134 | |
| 135 | - $res = pipeline('body_prive', "<body class='" |
|
| 136 | - . init_body_class() . ' ' . _request('exec') . "'" |
|
| 137 | - . ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : '') |
|
| 138 | - . '>'); |
|
| 135 | + $res = pipeline('body_prive', "<body class='" |
|
| 136 | + . init_body_class() . ' ' . _request('exec') . "'" |
|
| 137 | + . ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : '') |
|
| 138 | + . '>'); |
|
| 139 | 139 | |
| 140 | - if (!$menu) { |
|
| 141 | - return $res; |
|
| 142 | - } |
|
| 140 | + if (!$menu) { |
|
| 141 | + return $res; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | |
| 145 | - $bandeau = charger_fonction('bandeau', 'inc'); |
|
| 145 | + $bandeau = charger_fonction('bandeau', 'inc'); |
|
| 146 | 146 | |
| 147 | - return $res |
|
| 148 | - . $bandeau(); |
|
| 147 | + return $res |
|
| 148 | + . $bandeau(); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -157,23 +157,23 @@ discard block |
||
| 157 | 157 | * @return string Classes CSS (séparées par des espaces) |
| 158 | 158 | */ |
| 159 | 159 | function init_body_class() { |
| 160 | - $display_modes = [ |
|
| 161 | - 0 => 'icones_img_texte' // défaut. |
|
| 162 | - /*init*/, |
|
| 163 | - 1 => 'icones_texte', |
|
| 164 | - 2 => 'icones_img_texte', |
|
| 165 | - 3 => 'icones_img' |
|
| 166 | - ]; |
|
| 160 | + $display_modes = [ |
|
| 161 | + 0 => 'icones_img_texte' // défaut. |
|
| 162 | + /*init*/, |
|
| 163 | + 1 => 'icones_texte', |
|
| 164 | + 2 => 'icones_img_texte', |
|
| 165 | + 3 => 'icones_img' |
|
| 166 | + ]; |
|
| 167 | 167 | |
| 168 | - $prefs = $GLOBALS['visiteur_session']['prefs'] ?? []; |
|
| 168 | + $prefs = $GLOBALS['visiteur_session']['prefs'] ?? []; |
|
| 169 | 169 | |
| 170 | - $display_mode = $display_modes[intval($prefs['display'] ?? 0)] ?? $display_modes[0]; |
|
| 171 | - $spip_display_navigation = isset($prefs['display_navigation']) ? spip_sanitize_classname($prefs['display_navigation']) : 'navigation_avec_icones'; |
|
| 170 | + $display_mode = $display_modes[intval($prefs['display'] ?? 0)] ?? $display_modes[0]; |
|
| 171 | + $spip_display_navigation = isset($prefs['display_navigation']) ? spip_sanitize_classname($prefs['display_navigation']) : 'navigation_avec_icones'; |
|
| 172 | 172 | |
| 173 | - $couleur = intval($prefs['couleur'] ?? 2); |
|
| 173 | + $couleur = intval($prefs['couleur'] ?? 2); |
|
| 174 | 174 | |
| 175 | - $classes = "spip-theme-colors-$couleur $spip_display_navigation $display_mode"; |
|
| 176 | - return spip_sanitize_classname($classes); |
|
| 175 | + $classes = "spip-theme-colors-$couleur $spip_display_navigation $display_mode"; |
|
| 176 | + return spip_sanitize_classname($classes); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
@@ -184,5 +184,5 @@ discard block |
||
| 184 | 184 | * @return string |
| 185 | 185 | */ |
| 186 | 186 | function auteurs_recemment_connectes($id_auteur) { |
| 187 | - return recuperer_fond('prive/objets/liste/auteurs_enligne'); |
|
| 187 | + return recuperer_fond('prive/objets/liste/auteurs_enligne'); |
|
| 188 | 188 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** Drapeau indiquant que l'on est dans l'espace privé */ |
| 20 | 20 | define('_ESPACE_PRIVE', true); |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - include 'inc_version.php'; |
|
| 22 | + include 'inc_version.php'; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | include_spip('inc/cookie'); |
@@ -35,18 +35,18 @@ discard block |
||
| 35 | 35 | // alors il faut blinder les variables d'URL |
| 36 | 36 | // |
| 37 | 37 | if (autoriser_sans_cookie($exec, false)) { |
| 38 | - if (!isset($reinstall)) { |
|
| 39 | - $reinstall = 'non'; |
|
| 40 | - } |
|
| 41 | - $var_auth = true; |
|
| 38 | + if (!isset($reinstall)) { |
|
| 39 | + $reinstall = 'non'; |
|
| 40 | + } |
|
| 41 | + $var_auth = true; |
|
| 42 | 42 | } else { |
| 43 | - // Authentification, redefinissable |
|
| 44 | - $auth = charger_fonction('auth', 'inc'); |
|
| 45 | - $var_auth = $auth(); |
|
| 46 | - if ($var_auth) { |
|
| 47 | - echo auth_echec($var_auth); |
|
| 48 | - exit; |
|
| 49 | - } |
|
| 43 | + // Authentification, redefinissable |
|
| 44 | + $auth = charger_fonction('auth', 'inc'); |
|
| 45 | + $var_auth = $auth(); |
|
| 46 | + if ($var_auth) { |
|
| 47 | + echo auth_echec($var_auth); |
|
| 48 | + exit; |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // initialiser a la langue par defaut |
@@ -57,29 +57,29 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | if (_request('action') or _request('var_ajax') or _request('formulaire_action')) { |
| 60 | - if (!autoriser_sans_cookie($exec)) { |
|
| 61 | - // Charger l'aiguilleur qui va mettre sur la bonne voie les traitements derogatoires |
|
| 62 | - include_spip('public/aiguiller'); |
|
| 63 | - if ( |
|
| 64 | - // cas des appels actions ?action=xxx |
|
| 65 | - traiter_appels_actions() |
|
| 66 | - or |
|
| 67 | - // cas des hits ajax sur les inclusions ajax |
|
| 68 | - traiter_appels_inclusions_ajax() |
|
| 69 | - or |
|
| 70 | - // cas des formulaires charger/verifier/traiter |
|
| 71 | - traiter_formulaires_dynamiques() |
|
| 72 | - ) { |
|
| 73 | - exit; |
|
| 74 | - } // le hit est fini ! |
|
| 75 | - } |
|
| 60 | + if (!autoriser_sans_cookie($exec)) { |
|
| 61 | + // Charger l'aiguilleur qui va mettre sur la bonne voie les traitements derogatoires |
|
| 62 | + include_spip('public/aiguiller'); |
|
| 63 | + if ( |
|
| 64 | + // cas des appels actions ?action=xxx |
|
| 65 | + traiter_appels_actions() |
|
| 66 | + or |
|
| 67 | + // cas des hits ajax sur les inclusions ajax |
|
| 68 | + traiter_appels_inclusions_ajax() |
|
| 69 | + or |
|
| 70 | + // cas des formulaires charger/verifier/traiter |
|
| 71 | + traiter_formulaires_dynamiques() |
|
| 72 | + ) { |
|
| 73 | + exit; |
|
| 74 | + } // le hit est fini ! |
|
| 75 | + } |
|
| 76 | 76 | } |
| 77 | 77 | // securiser les redirect du back-office |
| 78 | 78 | if (_request('redirect')) { |
| 79 | - if (!function_exists('securiser_redirect_action')) { |
|
| 80 | - include_spip('public/aiguiller'); |
|
| 81 | - } |
|
| 82 | - set_request('redirect', securiser_redirect_action(_request('redirect'))); |
|
| 79 | + if (!function_exists('securiser_redirect_action')) { |
|
| 80 | + include_spip('public/aiguiller'); |
|
| 81 | + } |
|
| 82 | + set_request('redirect', securiser_redirect_action(_request('redirect'))); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | // Controle de la version, sauf si on est deja en train de s'en occuper |
| 91 | 91 | if ( |
| 92 | - !$reinstall == 'oui' |
|
| 93 | - and !_AJAX |
|
| 94 | - and isset($GLOBALS['meta']['version_installee']) |
|
| 95 | - and ($GLOBALS['spip_version_base'] != (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 92 | + !$reinstall == 'oui' |
|
| 93 | + and !_AJAX |
|
| 94 | + and isset($GLOBALS['meta']['version_installee']) |
|
| 95 | + and ($GLOBALS['spip_version_base'] != (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 96 | 96 | ) { |
| 97 | - $exec = 'demande_mise_a_jour'; |
|
| 97 | + $exec = 'demande_mise_a_jour'; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Quand une action d'administration est en cours (meta "admin"), |
@@ -104,39 +104,39 @@ discard block |
||
| 104 | 104 | // sinon c'est qu'elle a ete interrompue et il faut la reprendre |
| 105 | 105 | |
| 106 | 106 | elseif (isset($GLOBALS['meta']['admin'])) { |
| 107 | - if (preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)) { |
|
| 108 | - [, $var_f, $n] = $l; |
|
| 109 | - } |
|
| 110 | - if ( |
|
| 111 | - _AJAX |
|
| 112 | - or !( |
|
| 113 | - isset($_COOKIE['spip_admin']) |
|
| 114 | - or (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']['statut'] == '0minirezo') |
|
| 115 | - ) |
|
| 116 | - ) { |
|
| 117 | - spip_log('Quand la meta admin vaut ' . |
|
| 118 | - $GLOBALS['meta']['admin'] . |
|
| 119 | - ' seul un admin peut se connecter et sans AJAX.' . |
|
| 120 | - ' En cas de probleme, detruire cette meta.'); |
|
| 121 | - die(_T('info_travaux_texte')); |
|
| 122 | - } |
|
| 123 | - if ($n) { |
|
| 124 | - [, $var_f, $n] = $l; |
|
| 125 | - if (tester_url_ecrire("base_$var_f")) { |
|
| 126 | - $var_f = "base_$var_f"; |
|
| 127 | - } |
|
| 128 | - if ($var_f != $exec) { |
|
| 129 | - spip_log("Le script $var_f lance par auteur$n se substitue a l'exec $exec"); |
|
| 130 | - $exec = $var_f; |
|
| 131 | - set_request('exec', $exec); |
|
| 132 | - } |
|
| 133 | - } |
|
| 107 | + if (preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)) { |
|
| 108 | + [, $var_f, $n] = $l; |
|
| 109 | + } |
|
| 110 | + if ( |
|
| 111 | + _AJAX |
|
| 112 | + or !( |
|
| 113 | + isset($_COOKIE['spip_admin']) |
|
| 114 | + or (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']['statut'] == '0minirezo') |
|
| 115 | + ) |
|
| 116 | + ) { |
|
| 117 | + spip_log('Quand la meta admin vaut ' . |
|
| 118 | + $GLOBALS['meta']['admin'] . |
|
| 119 | + ' seul un admin peut se connecter et sans AJAX.' . |
|
| 120 | + ' En cas de probleme, detruire cette meta.'); |
|
| 121 | + die(_T('info_travaux_texte')); |
|
| 122 | + } |
|
| 123 | + if ($n) { |
|
| 124 | + [, $var_f, $n] = $l; |
|
| 125 | + if (tester_url_ecrire("base_$var_f")) { |
|
| 126 | + $var_f = "base_$var_f"; |
|
| 127 | + } |
|
| 128 | + if ($var_f != $exec) { |
|
| 129 | + spip_log("Le script $var_f lance par auteur$n se substitue a l'exec $exec"); |
|
| 130 | + $exec = $var_f; |
|
| 131 | + set_request('exec', $exec); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | } |
| 135 | 135 | // si nom pas plausible, prendre le script par defaut |
| 136 | 136 | // attention aux deux cas 404/403 qui commencent par un 4 ! |
| 137 | 137 | elseif (!preg_match(',^[a-z4_][0-9a-z_-]*$,i', $exec)) { |
| 138 | - $exec = 'accueil'; |
|
| 139 | - set_request('exec', $exec); |
|
| 138 | + $exec = 'accueil'; |
|
| 139 | + set_request('exec', $exec); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | // si la langue est specifiee par cookie et ne correspond pas |
@@ -144,19 +144,19 @@ discard block |
||
| 144 | 144 | // on appelle directement la fonction, car un appel d'action peut conduire a une boucle infinie |
| 145 | 145 | // si le cookie n'est pas pose correctement dans l'action |
| 146 | 146 | if ( |
| 147 | - !$var_auth and isset($_COOKIE['spip_lang_ecrire']) |
|
| 148 | - and $_COOKIE['spip_lang_ecrire'] <> $GLOBALS['visiteur_session']['lang'] |
|
| 147 | + !$var_auth and isset($_COOKIE['spip_lang_ecrire']) |
|
| 148 | + and $_COOKIE['spip_lang_ecrire'] <> $GLOBALS['visiteur_session']['lang'] |
|
| 149 | 149 | ) { |
| 150 | - include_spip('action/converser'); |
|
| 151 | - action_converser_post($GLOBALS['visiteur_session']['lang'], true); |
|
| 150 | + include_spip('action/converser'); |
|
| 151 | + action_converser_post($GLOBALS['visiteur_session']['lang'], true); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | if ($var_f = tester_url_ecrire($exec)) { |
| 155 | - $var_f = charger_fonction($var_f); |
|
| 156 | - $var_f(); // at last |
|
| 155 | + $var_f = charger_fonction($var_f); |
|
| 156 | + $var_f(); // at last |
|
| 157 | 157 | } else { |
| 158 | - // Rien de connu: rerouter vers exec=404 au lieu d'echouer |
|
| 159 | - // ce qui permet de laisser la main a un plugin |
|
| 160 | - $var_f = charger_fonction('404'); |
|
| 161 | - $var_f($exec); |
|
| 158 | + // Rien de connu: rerouter vers exec=404 au lieu d'echouer |
|
| 159 | + // ce qui permet de laisser la main a un plugin |
|
| 160 | + $var_f = charger_fonction('404'); |
|
| 161 | + $var_f($exec); |
|
| 162 | 162 | } |
@@ -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 | /** |
@@ -43,22 +43,22 @@ discard block |
||
| 43 | 43 | * Pile complétée par le code à générer |
| 44 | 44 | */ |
| 45 | 45 | function balise_ALERTE_MESSAGE_dist($p) { |
| 46 | - $_texte = interprete_argument_balise(1, $p); |
|
| 47 | - $_titre = interprete_argument_balise(2, $p); |
|
| 48 | - $_class = interprete_argument_balise(3, $p); |
|
| 49 | - $_role = interprete_argument_balise(4, $p); |
|
| 50 | - $_id = interprete_argument_balise(5, $p); |
|
| 51 | - $_texte = ($_texte ?: "''"); |
|
| 52 | - $_titre = ($_titre ? ", $_titre" : ', null'); |
|
| 53 | - $_class = ($_class ? ", $_class" : ', null'); |
|
| 54 | - $_role = ($_role ? ", $_role" : ', null'); |
|
| 55 | - $_id = ($_id ? ", $_id" : ', null'); |
|
| 46 | + $_texte = interprete_argument_balise(1, $p); |
|
| 47 | + $_titre = interprete_argument_balise(2, $p); |
|
| 48 | + $_class = interprete_argument_balise(3, $p); |
|
| 49 | + $_role = interprete_argument_balise(4, $p); |
|
| 50 | + $_id = interprete_argument_balise(5, $p); |
|
| 51 | + $_texte = ($_texte ?: "''"); |
|
| 52 | + $_titre = ($_titre ? ", $_titre" : ', null'); |
|
| 53 | + $_class = ($_class ? ", $_class" : ', null'); |
|
| 54 | + $_role = ($_role ? ", $_role" : ', null'); |
|
| 55 | + $_id = ($_id ? ", $_id" : ', null'); |
|
| 56 | 56 | |
| 57 | - $f = chercher_filtre('message_alerte'); |
|
| 58 | - $p->code = "$f($_texte$_titre$_class$_role$_id)"; |
|
| 59 | - $p->interdire_scripts = false; |
|
| 57 | + $f = chercher_filtre('message_alerte'); |
|
| 58 | + $p->code = "$f($_texte$_titre$_class$_role$_id)"; |
|
| 59 | + $p->interdire_scripts = false; |
|
| 60 | 60 | |
| 61 | - return $p; |
|
| 61 | + return $p; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -86,20 +86,20 @@ discard block |
||
| 86 | 86 | * Pile complétée par le code à générer |
| 87 | 87 | */ |
| 88 | 88 | function balise_ALERTE_OUVRIR_dist($p) { |
| 89 | - $_titre = interprete_argument_balise(1, $p); |
|
| 90 | - $_class = interprete_argument_balise(2, $p); |
|
| 91 | - $_role = interprete_argument_balise(3, $p); |
|
| 92 | - $_id = interprete_argument_balise(4, $p); |
|
| 93 | - $_titre = ($_titre ? "$_titre" : 'null'); |
|
| 94 | - $_class = ($_class ? ", $_class" : ', null'); |
|
| 95 | - $_role = ($_role ? ", $_role" : ', null'); |
|
| 96 | - $_id = ($_id ? ", $_id" : ', null'); |
|
| 89 | + $_titre = interprete_argument_balise(1, $p); |
|
| 90 | + $_class = interprete_argument_balise(2, $p); |
|
| 91 | + $_role = interprete_argument_balise(3, $p); |
|
| 92 | + $_id = interprete_argument_balise(4, $p); |
|
| 93 | + $_titre = ($_titre ? "$_titre" : 'null'); |
|
| 94 | + $_class = ($_class ? ", $_class" : ', null'); |
|
| 95 | + $_role = ($_role ? ", $_role" : ', null'); |
|
| 96 | + $_id = ($_id ? ", $_id" : ', null'); |
|
| 97 | 97 | |
| 98 | - $f = chercher_filtre('message_alerte_ouvrir'); |
|
| 99 | - $p->code = "$f($_titre$_class$_role$_id)"; |
|
| 100 | - $p->interdire_scripts = false; |
|
| 98 | + $f = chercher_filtre('message_alerte_ouvrir'); |
|
| 99 | + $p->code = "$f($_titre$_class$_role$_id)"; |
|
| 100 | + $p->interdire_scripts = false; |
|
| 101 | 101 | |
| 102 | - return $p; |
|
| 102 | + return $p; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -121,11 +121,11 @@ discard block |
||
| 121 | 121 | * Pile complétée par le code à générer |
| 122 | 122 | */ |
| 123 | 123 | function balise_ALERTE_FERMER_dist($p) { |
| 124 | - $f = chercher_filtre('message_alerte_fermer'); |
|
| 125 | - $p->code = "$f()"; |
|
| 126 | - $p->interdire_scripts = false; |
|
| 124 | + $f = chercher_filtre('message_alerte_fermer'); |
|
| 125 | + $p->code = "$f()"; |
|
| 126 | + $p->interdire_scripts = false; |
|
| 127 | 127 | |
| 128 | - return $p; |
|
| 128 | + return $p; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -160,14 +160,14 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | function message_alerte(string $texte, ?string $titre = null, ?string $class = null, ?string $role = null, ?string $id = null): string { |
| 162 | 162 | |
| 163 | - $message_alerte_ouvrir = chercher_filtre('message_alerte_ouvrir'); |
|
| 164 | - $message_alerte_fermer = chercher_filtre('message_alerte_fermer'); |
|
| 165 | - $message = |
|
| 166 | - $message_alerte_ouvrir($titre, $class, $role, $id) . |
|
| 167 | - $texte . |
|
| 168 | - $message_alerte_fermer(); |
|
| 163 | + $message_alerte_ouvrir = chercher_filtre('message_alerte_ouvrir'); |
|
| 164 | + $message_alerte_fermer = chercher_filtre('message_alerte_fermer'); |
|
| 165 | + $message = |
|
| 166 | + $message_alerte_ouvrir($titre, $class, $role, $id) . |
|
| 167 | + $texte . |
|
| 168 | + $message_alerte_fermer(); |
|
| 169 | 169 | |
| 170 | - return $message; |
|
| 170 | + return $message; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -198,56 +198,56 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | function message_alerte_ouvrir(?string $titre = null, ?string $class = null, ?string $role = null, ?string $id = null): string { |
| 200 | 200 | |
| 201 | - $prive = test_espace_prive(); |
|
| 201 | + $prive = test_espace_prive(); |
|
| 202 | 202 | |
| 203 | - // Valeurs par défaut |
|
| 204 | - $titre = trim($titre ?? ''); |
|
| 205 | - $role ??= 'alert'; // fallback uniquement si null |
|
| 206 | - $class ??= 'notice'; // fallback uniquement si null |
|
| 203 | + // Valeurs par défaut |
|
| 204 | + $titre = trim($titre ?? ''); |
|
| 205 | + $role ??= 'alert'; // fallback uniquement si null |
|
| 206 | + $class ??= 'notice'; // fallback uniquement si null |
|
| 207 | 207 | |
| 208 | - // Type d'alerte : le chercher dans les classes, nettoyer celles-ci, puis le réinjecter |
|
| 209 | - $types = [ |
|
| 210 | - 'notice', |
|
| 211 | - 'error', |
|
| 212 | - 'success', |
|
| 213 | - 'info', |
|
| 214 | - ]; |
|
| 215 | - $type = array_intersect(explode(' ', $class), $types); |
|
| 216 | - $type = reset($type); |
|
| 217 | - $class = trim(str_replace($types, '', $class) . " $type"); |
|
| 208 | + // Type d'alerte : le chercher dans les classes, nettoyer celles-ci, puis le réinjecter |
|
| 209 | + $types = [ |
|
| 210 | + 'notice', |
|
| 211 | + 'error', |
|
| 212 | + 'success', |
|
| 213 | + 'info', |
|
| 214 | + ]; |
|
| 215 | + $type = array_intersect(explode(' ', $class), $types); |
|
| 216 | + $type = reset($type); |
|
| 217 | + $class = trim(str_replace($types, '', $class) . " $type"); |
|
| 218 | 218 | |
| 219 | - // Classes |
|
| 220 | - $class_racine = 'msg-alert'; |
|
| 221 | - $clearfix = ($prive ? 'clearfix' : ''); |
|
| 222 | - $class_alerte = "$class_racine $class"; |
|
| 223 | - $class_texte = "{$class_racine}__text $clearfix"; |
|
| 224 | - $class_titre = "{$class_racine}__heading"; |
|
| 219 | + // Classes |
|
| 220 | + $class_racine = 'msg-alert'; |
|
| 221 | + $clearfix = ($prive ? 'clearfix' : ''); |
|
| 222 | + $class_alerte = "$class_racine $class"; |
|
| 223 | + $class_texte = "{$class_racine}__text $clearfix"; |
|
| 224 | + $class_titre = "{$class_racine}__heading"; |
|
| 225 | 225 | |
| 226 | - // Titre : markup |
|
| 227 | - $titre = trim($titre); |
|
| 228 | - if (strlen($titre)) { |
|
| 229 | - include_spip('inc/filtres'); |
|
| 230 | - // Si besoin on encapsule le titre : un h3 dans le privé, un simple div sinon. |
|
| 231 | - $cherche_tag = ($prive ? '<h' : '<'); |
|
| 232 | - $wrap_tag = ($prive ? '<h3>' : '<div>'); |
|
| 233 | - if (strpos($titre, $cherche_tag) !== 0) { |
|
| 234 | - $titre = wrap($titre, $wrap_tag); |
|
| 235 | - } |
|
| 236 | - // puis on ajoute la classe |
|
| 237 | - $titre = ajouter_class($titre, $class_titre); |
|
| 238 | - } |
|
| 226 | + // Titre : markup |
|
| 227 | + $titre = trim($titre); |
|
| 228 | + if (strlen($titre)) { |
|
| 229 | + include_spip('inc/filtres'); |
|
| 230 | + // Si besoin on encapsule le titre : un h3 dans le privé, un simple div sinon. |
|
| 231 | + $cherche_tag = ($prive ? '<h' : '<'); |
|
| 232 | + $wrap_tag = ($prive ? '<h3>' : '<div>'); |
|
| 233 | + if (strpos($titre, $cherche_tag) !== 0) { |
|
| 234 | + $titre = wrap($titre, $wrap_tag); |
|
| 235 | + } |
|
| 236 | + // puis on ajoute la classe |
|
| 237 | + $titre = ajouter_class($titre, $class_titre); |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - // Attributs |
|
| 241 | - $attr_role = ($role ? "role=\"$role\"" : ''); |
|
| 242 | - $attr_id = ($id ? "id=\"$id\"" : ''); |
|
| 243 | - $attr_data = ($type ? "data-alert=\"$type\"" : ''); |
|
| 240 | + // Attributs |
|
| 241 | + $attr_role = ($role ? "role=\"$role\"" : ''); |
|
| 242 | + $attr_id = ($id ? "id=\"$id\"" : ''); |
|
| 243 | + $attr_data = ($type ? "data-alert=\"$type\"" : ''); |
|
| 244 | 244 | |
| 245 | - $message = |
|
| 246 | - "<div class=\"$class_alerte\" $attr_role $attr_id $attr_data>" |
|
| 247 | - . $titre |
|
| 248 | - . "<div class=\"$class_texte\">"; |
|
| 245 | + $message = |
|
| 246 | + "<div class=\"$class_alerte\" $attr_role $attr_id $attr_data>" |
|
| 247 | + . $titre |
|
| 248 | + . "<div class=\"$class_texte\">"; |
|
| 249 | 249 | |
| 250 | - return $message; |
|
| 250 | + return $message; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -261,5 +261,5 @@ discard block |
||
| 261 | 261 | * HTML de fin de l'alerte |
| 262 | 262 | */ |
| 263 | 263 | function message_alerte_fermer(): string { |
| 264 | - return '</div></div>'; |
|
| 264 | + return '</div></div>'; |
|
| 265 | 265 | } |
@@ -11,298 +11,298 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | // methodes sql |
| 19 | 19 | function inc_recherche_to_array_dist($recherche, $options = []) { |
| 20 | 20 | |
| 21 | - // options par defaut |
|
| 22 | - $options = array_merge( |
|
| 23 | - [ |
|
| 24 | - 'score' => true, |
|
| 25 | - 'champs' => false, |
|
| 26 | - 'toutvoir' => false, |
|
| 27 | - 'matches' => false, |
|
| 28 | - 'jointures' => false |
|
| 29 | - ], |
|
| 30 | - $options |
|
| 31 | - ); |
|
| 21 | + // options par defaut |
|
| 22 | + $options = array_merge( |
|
| 23 | + [ |
|
| 24 | + 'score' => true, |
|
| 25 | + 'champs' => false, |
|
| 26 | + 'toutvoir' => false, |
|
| 27 | + 'matches' => false, |
|
| 28 | + 'jointures' => false |
|
| 29 | + ], |
|
| 30 | + $options |
|
| 31 | + ); |
|
| 32 | 32 | |
| 33 | - include_spip('inc/rechercher'); |
|
| 34 | - include_spip('inc/autoriser'); |
|
| 33 | + include_spip('inc/rechercher'); |
|
| 34 | + include_spip('inc/autoriser'); |
|
| 35 | 35 | |
| 36 | - $requete = [ |
|
| 37 | - 'SELECT' => [], |
|
| 38 | - 'FROM' => [], |
|
| 39 | - 'WHERE' => [], |
|
| 40 | - 'GROUPBY' => [], |
|
| 41 | - 'ORDERBY' => [], |
|
| 42 | - 'LIMIT' => '', |
|
| 43 | - 'HAVING' => [] |
|
| 44 | - ]; |
|
| 36 | + $requete = [ |
|
| 37 | + 'SELECT' => [], |
|
| 38 | + 'FROM' => [], |
|
| 39 | + 'WHERE' => [], |
|
| 40 | + 'GROUPBY' => [], |
|
| 41 | + 'ORDERBY' => [], |
|
| 42 | + 'LIMIT' => '', |
|
| 43 | + 'HAVING' => [] |
|
| 44 | + ]; |
|
| 45 | 45 | |
| 46 | - $table = sinon($options['table'], 'article'); |
|
| 47 | - if ($options['champs']) { |
|
| 48 | - $champs = $options['champs']; |
|
| 49 | - } else { |
|
| 50 | - $l = liste_des_champs(); |
|
| 51 | - $champs = $l['article']; |
|
| 52 | - } |
|
| 53 | - $serveur = $options['serveur']; |
|
| 46 | + $table = sinon($options['table'], 'article'); |
|
| 47 | + if ($options['champs']) { |
|
| 48 | + $champs = $options['champs']; |
|
| 49 | + } else { |
|
| 50 | + $l = liste_des_champs(); |
|
| 51 | + $champs = $l['article']; |
|
| 52 | + } |
|
| 53 | + $serveur = $options['serveur']; |
|
| 54 | 54 | |
| 55 | - [$methode, $q, $preg] = expression_recherche($recherche, $options); |
|
| 55 | + [$methode, $q, $preg] = expression_recherche($recherche, $options); |
|
| 56 | 56 | |
| 57 | - $jointures = $options['jointures'] |
|
| 58 | - ? liste_des_jointures() |
|
| 59 | - : []; |
|
| 57 | + $jointures = $options['jointures'] |
|
| 58 | + ? liste_des_jointures() |
|
| 59 | + : []; |
|
| 60 | 60 | |
| 61 | - $_id_table = id_table_objet($table); |
|
| 61 | + $_id_table = id_table_objet($table); |
|
| 62 | 62 | |
| 63 | - // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ',' |
|
| 64 | - // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs) |
|
| 65 | - if (strpos($_id_table, ',') !== false) { |
|
| 66 | - $_id_table = explode(',', $_id_table); |
|
| 67 | - $_id_table = reset($_id_table); |
|
| 68 | - } |
|
| 63 | + // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ',' |
|
| 64 | + // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs) |
|
| 65 | + if (strpos($_id_table, ',') !== false) { |
|
| 66 | + $_id_table = explode(',', $_id_table); |
|
| 67 | + $_id_table = reset($_id_table); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - $requete['SELECT'][] = 't.' . $_id_table; |
|
| 71 | - $a = []; |
|
| 72 | - // Recherche fulltext |
|
| 73 | - foreach ($champs as $champ => $poids) { |
|
| 74 | - if (is_array($champ)) { |
|
| 75 | - spip_log('requetes imbriquees interdites'); |
|
| 76 | - } else { |
|
| 77 | - if (strpos($champ, '.') === false) { |
|
| 78 | - $champ = "t.$champ"; |
|
| 79 | - } |
|
| 80 | - $requete['SELECT'][] = $champ; |
|
| 81 | - $a[] = $champ . ' ' . $methode . ' ' . $q; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - if ($a) { |
|
| 85 | - $requete['WHERE'][] = join(' OR ', $a); |
|
| 86 | - } |
|
| 87 | - $requete['FROM'][] = table_objet_sql($table) . ' AS t'; |
|
| 70 | + $requete['SELECT'][] = 't.' . $_id_table; |
|
| 71 | + $a = []; |
|
| 72 | + // Recherche fulltext |
|
| 73 | + foreach ($champs as $champ => $poids) { |
|
| 74 | + if (is_array($champ)) { |
|
| 75 | + spip_log('requetes imbriquees interdites'); |
|
| 76 | + } else { |
|
| 77 | + if (strpos($champ, '.') === false) { |
|
| 78 | + $champ = "t.$champ"; |
|
| 79 | + } |
|
| 80 | + $requete['SELECT'][] = $champ; |
|
| 81 | + $a[] = $champ . ' ' . $methode . ' ' . $q; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + if ($a) { |
|
| 85 | + $requete['WHERE'][] = join(' OR ', $a); |
|
| 86 | + } |
|
| 87 | + $requete['FROM'][] = table_objet_sql($table) . ' AS t'; |
|
| 88 | 88 | |
| 89 | - $results = []; |
|
| 89 | + $results = []; |
|
| 90 | 90 | |
| 91 | - $s = sql_select( |
|
| 92 | - $requete['SELECT'], |
|
| 93 | - $requete['FROM'], |
|
| 94 | - $requete['WHERE'], |
|
| 95 | - implode(' ', $requete['GROUPBY']), |
|
| 96 | - $requete['ORDERBY'], |
|
| 97 | - $requete['LIMIT'], |
|
| 98 | - $requete['HAVING'], |
|
| 99 | - $serveur |
|
| 100 | - ); |
|
| 91 | + $s = sql_select( |
|
| 92 | + $requete['SELECT'], |
|
| 93 | + $requete['FROM'], |
|
| 94 | + $requete['WHERE'], |
|
| 95 | + implode(' ', $requete['GROUPBY']), |
|
| 96 | + $requete['ORDERBY'], |
|
| 97 | + $requete['LIMIT'], |
|
| 98 | + $requete['HAVING'], |
|
| 99 | + $serveur |
|
| 100 | + ); |
|
| 101 | 101 | |
| 102 | - while ( |
|
| 103 | - $t = sql_fetch($s, $serveur) |
|
| 104 | - and (!isset($t['score']) or $t['score'] > 0) |
|
| 105 | - ) { |
|
| 106 | - $id = intval($t[$_id_table]); |
|
| 102 | + while ( |
|
| 103 | + $t = sql_fetch($s, $serveur) |
|
| 104 | + and (!isset($t['score']) or $t['score'] > 0) |
|
| 105 | + ) { |
|
| 106 | + $id = intval($t[$_id_table]); |
|
| 107 | 107 | |
| 108 | - if ( |
|
| 109 | - $options['toutvoir'] |
|
| 110 | - or autoriser('voir', $table, $id) |
|
| 111 | - ) { |
|
| 112 | - // indiquer les champs concernes |
|
| 113 | - $champs_vus = []; |
|
| 114 | - $score = 0; |
|
| 115 | - $matches = []; |
|
| 108 | + if ( |
|
| 109 | + $options['toutvoir'] |
|
| 110 | + or autoriser('voir', $table, $id) |
|
| 111 | + ) { |
|
| 112 | + // indiquer les champs concernes |
|
| 113 | + $champs_vus = []; |
|
| 114 | + $score = 0; |
|
| 115 | + $matches = []; |
|
| 116 | 116 | |
| 117 | - $vu = false; |
|
| 118 | - foreach ($champs as $champ => $poids) { |
|
| 119 | - $champ = explode('.', $champ); |
|
| 120 | - $champ = end($champ); |
|
| 121 | - // translitteration_rapide uniquement si on est deja en utf-8 |
|
| 122 | - $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ])); |
|
| 123 | - if ( |
|
| 124 | - $n = |
|
| 125 | - ($options['score'] || $options['matches']) |
|
| 126 | - ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER) |
|
| 127 | - : preg_match($preg, $value) |
|
| 128 | - ) { |
|
| 129 | - $vu = true; |
|
| 117 | + $vu = false; |
|
| 118 | + foreach ($champs as $champ => $poids) { |
|
| 119 | + $champ = explode('.', $champ); |
|
| 120 | + $champ = end($champ); |
|
| 121 | + // translitteration_rapide uniquement si on est deja en utf-8 |
|
| 122 | + $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ])); |
|
| 123 | + if ( |
|
| 124 | + $n = |
|
| 125 | + ($options['score'] || $options['matches']) |
|
| 126 | + ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER) |
|
| 127 | + : preg_match($preg, $value) |
|
| 128 | + ) { |
|
| 129 | + $vu = true; |
|
| 130 | 130 | |
| 131 | - if ($options['champs']) { |
|
| 132 | - $champs_vus[$champ] = $t[$champ]; |
|
| 133 | - } |
|
| 134 | - if ($options['score']) { |
|
| 135 | - // compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars |
|
| 136 | - $score += $poids * strlen(implode('', array_column($regs, 0))); |
|
| 137 | - } |
|
| 131 | + if ($options['champs']) { |
|
| 132 | + $champs_vus[$champ] = $t[$champ]; |
|
| 133 | + } |
|
| 134 | + if ($options['score']) { |
|
| 135 | + // compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars |
|
| 136 | + $score += $poids * strlen(implode('', array_column($regs, 0))); |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - if ($options['matches']) { |
|
| 140 | - $matches[$champ] = $regs; |
|
| 141 | - } |
|
| 139 | + if ($options['matches']) { |
|
| 140 | + $matches[$champ] = $regs; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - if ( |
|
| 144 | - !$options['champs'] |
|
| 145 | - and !$options['score'] |
|
| 146 | - and !$options['matches'] |
|
| 147 | - ) { |
|
| 148 | - break; |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - } |
|
| 143 | + if ( |
|
| 144 | + !$options['champs'] |
|
| 145 | + and !$options['score'] |
|
| 146 | + and !$options['matches'] |
|
| 147 | + ) { |
|
| 148 | + break; |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - if ($vu) { |
|
| 154 | - if (!isset($results)) { |
|
| 155 | - $results = []; |
|
| 156 | - } |
|
| 157 | - $results[$id] = []; |
|
| 158 | - if ($champs_vus) { |
|
| 159 | - $results[$id]['champs'] = $champs_vus; |
|
| 160 | - } |
|
| 161 | - if ($score) { |
|
| 162 | - $results[$id]['score'] = $score; |
|
| 163 | - } |
|
| 164 | - if ($matches) { |
|
| 165 | - $results[$id]['matches'] = $matches; |
|
| 166 | - } |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - } |
|
| 153 | + if ($vu) { |
|
| 154 | + if (!isset($results)) { |
|
| 155 | + $results = []; |
|
| 156 | + } |
|
| 157 | + $results[$id] = []; |
|
| 158 | + if ($champs_vus) { |
|
| 159 | + $results[$id]['champs'] = $champs_vus; |
|
| 160 | + } |
|
| 161 | + if ($score) { |
|
| 162 | + $results[$id]['score'] = $score; |
|
| 163 | + } |
|
| 164 | + if ($matches) { |
|
| 165 | + $results[$id]['matches'] = $matches; |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | 171 | |
| 172 | - // Gerer les donnees associees |
|
| 173 | - // ici on est un peu naze : pas capables de reconstruire une jointure complexe |
|
| 174 | - // on ne sait passer que par table de laison en 1 coup |
|
| 175 | - if ( |
|
| 176 | - isset($jointures[$table]) |
|
| 177 | - and $joints = recherche_en_base( |
|
| 178 | - $recherche, |
|
| 179 | - $jointures[$table], |
|
| 180 | - array_merge($options, ['jointures' => false]) |
|
| 181 | - ) |
|
| 182 | - ) { |
|
| 183 | - include_spip('action/editer_liens'); |
|
| 184 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 185 | - $cle_depart = id_table_objet($table); |
|
| 186 | - $table_depart = table_objet($table, $serveur); |
|
| 187 | - $desc_depart = $trouver_table($table_depart, $serveur); |
|
| 188 | - $depart_associable = objet_associable($table); |
|
| 189 | - foreach ($joints as $table_liee => $ids_trouves) { |
|
| 190 | - // on peut definir une fonction de recherche jointe pour regler les cas particuliers |
|
| 191 | - if ( |
|
| 192 | - !( |
|
| 193 | - $rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true) |
|
| 194 | - or $rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true) |
|
| 195 | - or $rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true) |
|
| 196 | - ) |
|
| 197 | - ) { |
|
| 198 | - $cle_arrivee = id_table_objet($table_liee); |
|
| 199 | - $table_arrivee = table_objet($table_liee, $serveur); |
|
| 200 | - $desc_arrivee = $trouver_table($table_arrivee, $serveur); |
|
| 201 | - // cas simple : $cle_depart dans la table_liee |
|
| 202 | - if (isset($desc_arrivee['field'][$cle_depart])) { |
|
| 203 | - $s = sql_select( |
|
| 204 | - "$cle_depart, $cle_arrivee", |
|
| 205 | - $desc_arrivee['table_sql'], |
|
| 206 | - sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 207 | - '', |
|
| 208 | - '', |
|
| 209 | - '', |
|
| 210 | - '', |
|
| 211 | - $serveur |
|
| 212 | - ); |
|
| 213 | - } // cas simple : $cle_arrivee dans la table |
|
| 214 | - elseif (isset($desc_depart['field'][$cle_arrivee])) { |
|
| 215 | - $s = sql_select( |
|
| 216 | - "$cle_depart, $cle_arrivee", |
|
| 217 | - $desc_depart['table_sql'], |
|
| 218 | - sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 219 | - '', |
|
| 220 | - '', |
|
| 221 | - '', |
|
| 222 | - '', |
|
| 223 | - $serveur |
|
| 224 | - ); |
|
| 225 | - } |
|
| 226 | - // sinon cherchons une table de liaison |
|
| 227 | - // cas recherche principale article, objet lie document : passer par spip_documents_liens |
|
| 228 | - elseif ($l = objet_associable($table_liee)) { |
|
| 229 | - [$primary, $table_liens] = $l; |
|
| 230 | - $s = sql_select( |
|
| 231 | - "id_objet as $cle_depart, $primary as $cle_arrivee", |
|
| 232 | - $table_liens, |
|
| 233 | - ["objet='$table'", sql_in($primary, array_keys($ids_trouves))], |
|
| 234 | - '', |
|
| 235 | - '', |
|
| 236 | - '', |
|
| 237 | - '', |
|
| 238 | - $serveur |
|
| 239 | - ); |
|
| 240 | - } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens |
|
| 241 | - elseif ($l = $depart_associable) { |
|
| 242 | - [$primary, $table_liens] = $l; |
|
| 243 | - $s = sql_select( |
|
| 244 | - "$primary as $cle_depart, id_objet as $cle_arrivee", |
|
| 245 | - $table_liens, |
|
| 246 | - ["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))], |
|
| 247 | - '', |
|
| 248 | - '', |
|
| 249 | - '', |
|
| 250 | - '', |
|
| 251 | - $serveur |
|
| 252 | - ); |
|
| 253 | - } // cas table de liaison generique spip_xxx_yyy |
|
| 254 | - elseif ( |
|
| 255 | - $t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur) |
|
| 256 | - or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur) |
|
| 257 | - ) { |
|
| 258 | - $s = sql_select( |
|
| 259 | - "$cle_depart,$cle_arrivee", |
|
| 260 | - $t['table_sql'], |
|
| 261 | - sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 262 | - '', |
|
| 263 | - '', |
|
| 264 | - '', |
|
| 265 | - '', |
|
| 266 | - $serveur |
|
| 267 | - ); |
|
| 268 | - } |
|
| 269 | - } else { |
|
| 270 | - [$cle_depart, $cle_arrivee, $s] = $rechercher_joints( |
|
| 271 | - $table, |
|
| 272 | - $table_liee, |
|
| 273 | - array_keys($ids_trouves), |
|
| 274 | - $serveur |
|
| 275 | - ); |
|
| 276 | - } |
|
| 172 | + // Gerer les donnees associees |
|
| 173 | + // ici on est un peu naze : pas capables de reconstruire une jointure complexe |
|
| 174 | + // on ne sait passer que par table de laison en 1 coup |
|
| 175 | + if ( |
|
| 176 | + isset($jointures[$table]) |
|
| 177 | + and $joints = recherche_en_base( |
|
| 178 | + $recherche, |
|
| 179 | + $jointures[$table], |
|
| 180 | + array_merge($options, ['jointures' => false]) |
|
| 181 | + ) |
|
| 182 | + ) { |
|
| 183 | + include_spip('action/editer_liens'); |
|
| 184 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 185 | + $cle_depart = id_table_objet($table); |
|
| 186 | + $table_depart = table_objet($table, $serveur); |
|
| 187 | + $desc_depart = $trouver_table($table_depart, $serveur); |
|
| 188 | + $depart_associable = objet_associable($table); |
|
| 189 | + foreach ($joints as $table_liee => $ids_trouves) { |
|
| 190 | + // on peut definir une fonction de recherche jointe pour regler les cas particuliers |
|
| 191 | + if ( |
|
| 192 | + !( |
|
| 193 | + $rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true) |
|
| 194 | + or $rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true) |
|
| 195 | + or $rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true) |
|
| 196 | + ) |
|
| 197 | + ) { |
|
| 198 | + $cle_arrivee = id_table_objet($table_liee); |
|
| 199 | + $table_arrivee = table_objet($table_liee, $serveur); |
|
| 200 | + $desc_arrivee = $trouver_table($table_arrivee, $serveur); |
|
| 201 | + // cas simple : $cle_depart dans la table_liee |
|
| 202 | + if (isset($desc_arrivee['field'][$cle_depart])) { |
|
| 203 | + $s = sql_select( |
|
| 204 | + "$cle_depart, $cle_arrivee", |
|
| 205 | + $desc_arrivee['table_sql'], |
|
| 206 | + sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 207 | + '', |
|
| 208 | + '', |
|
| 209 | + '', |
|
| 210 | + '', |
|
| 211 | + $serveur |
|
| 212 | + ); |
|
| 213 | + } // cas simple : $cle_arrivee dans la table |
|
| 214 | + elseif (isset($desc_depart['field'][$cle_arrivee])) { |
|
| 215 | + $s = sql_select( |
|
| 216 | + "$cle_depart, $cle_arrivee", |
|
| 217 | + $desc_depart['table_sql'], |
|
| 218 | + sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 219 | + '', |
|
| 220 | + '', |
|
| 221 | + '', |
|
| 222 | + '', |
|
| 223 | + $serveur |
|
| 224 | + ); |
|
| 225 | + } |
|
| 226 | + // sinon cherchons une table de liaison |
|
| 227 | + // cas recherche principale article, objet lie document : passer par spip_documents_liens |
|
| 228 | + elseif ($l = objet_associable($table_liee)) { |
|
| 229 | + [$primary, $table_liens] = $l; |
|
| 230 | + $s = sql_select( |
|
| 231 | + "id_objet as $cle_depart, $primary as $cle_arrivee", |
|
| 232 | + $table_liens, |
|
| 233 | + ["objet='$table'", sql_in($primary, array_keys($ids_trouves))], |
|
| 234 | + '', |
|
| 235 | + '', |
|
| 236 | + '', |
|
| 237 | + '', |
|
| 238 | + $serveur |
|
| 239 | + ); |
|
| 240 | + } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens |
|
| 241 | + elseif ($l = $depart_associable) { |
|
| 242 | + [$primary, $table_liens] = $l; |
|
| 243 | + $s = sql_select( |
|
| 244 | + "$primary as $cle_depart, id_objet as $cle_arrivee", |
|
| 245 | + $table_liens, |
|
| 246 | + ["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))], |
|
| 247 | + '', |
|
| 248 | + '', |
|
| 249 | + '', |
|
| 250 | + '', |
|
| 251 | + $serveur |
|
| 252 | + ); |
|
| 253 | + } // cas table de liaison generique spip_xxx_yyy |
|
| 254 | + elseif ( |
|
| 255 | + $t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur) |
|
| 256 | + or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur) |
|
| 257 | + ) { |
|
| 258 | + $s = sql_select( |
|
| 259 | + "$cle_depart,$cle_arrivee", |
|
| 260 | + $t['table_sql'], |
|
| 261 | + sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 262 | + '', |
|
| 263 | + '', |
|
| 264 | + '', |
|
| 265 | + '', |
|
| 266 | + $serveur |
|
| 267 | + ); |
|
| 268 | + } |
|
| 269 | + } else { |
|
| 270 | + [$cle_depart, $cle_arrivee, $s] = $rechercher_joints( |
|
| 271 | + $table, |
|
| 272 | + $table_liee, |
|
| 273 | + array_keys($ids_trouves), |
|
| 274 | + $serveur |
|
| 275 | + ); |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) { |
|
| 279 | - $id = $t[$cle_depart]; |
|
| 280 | - $joint = $ids_trouves[$t[$cle_arrivee]]; |
|
| 281 | - if (!isset($results)) { |
|
| 282 | - $results = []; |
|
| 283 | - } |
|
| 284 | - if (!isset($results[$id])) { |
|
| 285 | - $results[$id] = []; |
|
| 286 | - } |
|
| 287 | - if (isset($joint['score']) and $joint['score']) { |
|
| 288 | - if (!isset($results[$id]['score'])) { |
|
| 289 | - $results[$id]['score'] = 0; |
|
| 290 | - } |
|
| 291 | - $results[$id]['score'] += $joint['score']; |
|
| 292 | - } |
|
| 293 | - if (isset($joint['champs']) and $joint['champs']) { |
|
| 294 | - foreach ($joint['champs'] as $c => $val) { |
|
| 295 | - $results[$id]['champs'][$table_liee . '.' . $c] = $val; |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - if (isset($joint['matches']) and $joint['matches']) { |
|
| 299 | - foreach ($joint['matches'] as $c => $val) { |
|
| 300 | - $results[$id]['matches'][$table_liee . '.' . $c] = $val; |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - } |
|
| 278 | + while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) { |
|
| 279 | + $id = $t[$cle_depart]; |
|
| 280 | + $joint = $ids_trouves[$t[$cle_arrivee]]; |
|
| 281 | + if (!isset($results)) { |
|
| 282 | + $results = []; |
|
| 283 | + } |
|
| 284 | + if (!isset($results[$id])) { |
|
| 285 | + $results[$id] = []; |
|
| 286 | + } |
|
| 287 | + if (isset($joint['score']) and $joint['score']) { |
|
| 288 | + if (!isset($results[$id]['score'])) { |
|
| 289 | + $results[$id]['score'] = 0; |
|
| 290 | + } |
|
| 291 | + $results[$id]['score'] += $joint['score']; |
|
| 292 | + } |
|
| 293 | + if (isset($joint['champs']) and $joint['champs']) { |
|
| 294 | + foreach ($joint['champs'] as $c => $val) { |
|
| 295 | + $results[$id]['champs'][$table_liee . '.' . $c] = $val; |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + if (isset($joint['matches']) and $joint['matches']) { |
|
| 299 | + foreach ($joint['matches'] as $c => $val) { |
|
| 300 | + $results[$id]['matches'][$table_liee . '.' . $c] = $val; |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - return $results; |
|
| 307 | + return $results; |
|
| 308 | 308 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Formulaires |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/filtres'); |
@@ -35,22 +35,22 @@ discard block |
||
| 35 | 35 | * Saisie protégée |
| 36 | 36 | **/ |
| 37 | 37 | function protege_champ($texte) { |
| 38 | - if (is_array($texte)) { |
|
| 39 | - return array_map('protege_champ', $texte); |
|
| 40 | - } elseif ($texte === null) { |
|
| 41 | - return $texte; |
|
| 42 | - } elseif (is_bool($texte)) { |
|
| 43 | - return $texte ? '1' : ''; |
|
| 44 | - } elseif (is_string($texte) and $texte) { |
|
| 45 | - if (preg_match(',^[abis]:\d+[:;],', $texte) and @unserialize($texte) !== false) { |
|
| 46 | - // ne pas corrompre une valeur serialize |
|
| 47 | - return $texte; |
|
| 48 | - } elseif (strpbrk($texte, "&\"'<>") !== false) { |
|
| 49 | - return spip_htmlspecialchars($texte, ENT_QUOTES); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - return $texte; |
|
| 38 | + if (is_array($texte)) { |
|
| 39 | + return array_map('protege_champ', $texte); |
|
| 40 | + } elseif ($texte === null) { |
|
| 41 | + return $texte; |
|
| 42 | + } elseif (is_bool($texte)) { |
|
| 43 | + return $texte ? '1' : ''; |
|
| 44 | + } elseif (is_string($texte) and $texte) { |
|
| 45 | + if (preg_match(',^[abis]:\d+[:;],', $texte) and @unserialize($texte) !== false) { |
|
| 46 | + // ne pas corrompre une valeur serialize |
|
| 47 | + return $texte; |
|
| 48 | + } elseif (strpbrk($texte, "&\"'<>") !== false) { |
|
| 49 | + return spip_htmlspecialchars($texte, ENT_QUOTES); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + return $texte; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -64,17 +64,17 @@ discard block |
||
| 64 | 64 | * - false : pas de squelette trouvé |
| 65 | 65 | **/ |
| 66 | 66 | function existe_formulaire($form) { |
| 67 | - if (substr($form, 0, 11) == 'FORMULAIRE_') { |
|
| 68 | - $form = strtolower(substr($form, 11)); |
|
| 69 | - } else { |
|
| 70 | - $form = strtolower($form); |
|
| 71 | - } |
|
| 67 | + if (substr($form, 0, 11) == 'FORMULAIRE_') { |
|
| 68 | + $form = strtolower(substr($form, 11)); |
|
| 69 | + } else { |
|
| 70 | + $form = strtolower($form); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - if (!$form) { |
|
| 74 | - return ''; |
|
| 75 | - } // on ne sait pas, le nom du formulaire n'est pas fourni ici |
|
| 73 | + if (!$form) { |
|
| 74 | + return ''; |
|
| 75 | + } // on ne sait pas, le nom du formulaire n'est pas fourni ici |
|
| 76 | 76 | |
| 77 | - return trouver_fond($form, 'formulaires/') ? $form : false; |
|
| 77 | + return trouver_fond($form, 'formulaires/') ? $form : false; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -83,31 +83,31 @@ discard block |
||
| 83 | 83 | * @return false|array |
| 84 | 84 | */ |
| 85 | 85 | function test_formulaire_inclus_par_modele() { |
| 86 | - $trace = debug_backtrace(0, 20); |
|
| 87 | - $trace_fonctions = array_column($trace, 'function'); |
|
| 88 | - $trace_fonctions = array_map('strtolower', $trace_fonctions); |
|
| 89 | - |
|
| 90 | - // regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn |
|
| 91 | - if ( |
|
| 92 | - function_exists('arguments_balise_dyn_depuis_modele') |
|
| 93 | - and $form = arguments_balise_dyn_depuis_modele(null, 'read') |
|
| 94 | - ) { |
|
| 95 | - if (in_array('balise_formulaire__dyn', $trace_fonctions)) { |
|
| 96 | - $k = array_search('balise_formulaire__dyn', $trace_fonctions); |
|
| 97 | - if ($trace[$k]['args'][0] === $form) { |
|
| 98 | - return $trace[$k]['args']; |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil, |
|
| 104 | - // mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette |
|
| 105 | - if (in_array('eval', $trace_fonctions) and in_array('inclure_modele', $trace_fonctions)) { |
|
| 106 | - $k = array_search('inclure_modele', $trace_fonctions); |
|
| 107 | - // les arguments de recuperer_fond() passes par inclure_modele() |
|
| 108 | - return $trace[$k - 1]['args'][1]['args']; |
|
| 109 | - } |
|
| 110 | - return false; |
|
| 86 | + $trace = debug_backtrace(0, 20); |
|
| 87 | + $trace_fonctions = array_column($trace, 'function'); |
|
| 88 | + $trace_fonctions = array_map('strtolower', $trace_fonctions); |
|
| 89 | + |
|
| 90 | + // regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn |
|
| 91 | + if ( |
|
| 92 | + function_exists('arguments_balise_dyn_depuis_modele') |
|
| 93 | + and $form = arguments_balise_dyn_depuis_modele(null, 'read') |
|
| 94 | + ) { |
|
| 95 | + if (in_array('balise_formulaire__dyn', $trace_fonctions)) { |
|
| 96 | + $k = array_search('balise_formulaire__dyn', $trace_fonctions); |
|
| 97 | + if ($trace[$k]['args'][0] === $form) { |
|
| 98 | + return $trace[$k]['args']; |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil, |
|
| 104 | + // mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette |
|
| 105 | + if (in_array('eval', $trace_fonctions) and in_array('inclure_modele', $trace_fonctions)) { |
|
| 106 | + $k = array_search('inclure_modele', $trace_fonctions); |
|
| 107 | + // les arguments de recuperer_fond() passes par inclure_modele() |
|
| 108 | + return $trace[$k - 1]['args'][1]['args']; |
|
| 109 | + } |
|
| 110 | + return false; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -122,19 +122,19 @@ discard block |
||
| 122 | 122 | **/ |
| 123 | 123 | function balise_FORMULAIRE__dist($p) { |
| 124 | 124 | |
| 125 | - // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide. |
|
| 126 | - // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer |
|
| 127 | - if (existe_formulaire($p->nom_champ) === false) { |
|
| 128 | - $p->code = "''"; |
|
| 129 | - $p->interdire_scripts = false; |
|
| 125 | + // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide. |
|
| 126 | + // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer |
|
| 127 | + if (existe_formulaire($p->nom_champ) === false) { |
|
| 128 | + $p->code = "''"; |
|
| 129 | + $p->interdire_scripts = false; |
|
| 130 | 130 | |
| 131 | - return $p; |
|
| 132 | - } |
|
| 131 | + return $p; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - // sinon renvoyer un code php dynamique |
|
| 135 | - $p = calculer_balise_dynamique($p, $p->nom_champ, []); |
|
| 134 | + // sinon renvoyer un code php dynamique |
|
| 135 | + $p = calculer_balise_dynamique($p, $p->nom_champ, []); |
|
| 136 | 136 | |
| 137 | - return $p; |
|
| 137 | + return $p; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | * - string : texte à afficher directement |
| 155 | 155 | */ |
| 156 | 156 | function balise_FORMULAIRE__dyn($form, ...$args) { |
| 157 | - $form = existe_formulaire($form); |
|
| 158 | - if (!$form) { |
|
| 159 | - return ''; |
|
| 160 | - } |
|
| 157 | + $form = existe_formulaire($form); |
|
| 158 | + if (!$form) { |
|
| 159 | + return ''; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - $contexte = balise_FORMULAIRE__contexte($form, $args); |
|
| 163 | - if (!is_array($contexte)) { |
|
| 164 | - return $contexte; |
|
| 165 | - } |
|
| 162 | + $contexte = balise_FORMULAIRE__contexte($form, $args); |
|
| 163 | + if (!is_array($contexte)) { |
|
| 164 | + return $contexte; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - return ["formulaires/$form", 3600, $contexte]; |
|
| 167 | + return ["formulaires/$form", 3600, $contexte]; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -179,85 +179,85 @@ discard block |
||
| 179 | 179 | * string: Formulaire non applicable (message d’explication) |
| 180 | 180 | **/ |
| 181 | 181 | function balise_FORMULAIRE__contexte($form, $args) { |
| 182 | - // tester si ce formulaire vient d'etre poste (memes arguments) |
|
| 183 | - // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page |
|
| 184 | - // si poste, on recupere les erreurs |
|
| 185 | - |
|
| 186 | - $je_suis_poste = false; |
|
| 187 | - if ( |
|
| 188 | - $post_form = _request('formulaire_action') |
|
| 189 | - and $post_form == $form |
|
| 190 | - and $p = _request('formulaire_action_args') |
|
| 191 | - and is_array($p = decoder_contexte_ajax($p, $post_form)) |
|
| 192 | - ) { |
|
| 193 | - // enlever le faux attribut de langue masque |
|
| 194 | - array_shift($p); |
|
| 195 | - if (formulaire__identifier($form, $args, $p)) { |
|
| 196 | - $je_suis_poste = true; |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - $editable = true; |
|
| 201 | - $erreurs = $post = []; |
|
| 202 | - if ($je_suis_poste) { |
|
| 203 | - $post = traiter_formulaires_dynamiques(true); |
|
| 204 | - $e = "erreurs_$form"; |
|
| 205 | - $erreurs = $post[$e] ?? []; |
|
| 206 | - $editable = "editable_$form"; |
|
| 207 | - $editable = (!isset($post[$e])) |
|
| 208 | - || (is_countable($erreurs) ? count($erreurs) : 0) |
|
| 209 | - || (isset($post[$editable]) && $post[$editable]); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - $valeurs = formulaire__charger($form, $args, $je_suis_poste); |
|
| 213 | - |
|
| 214 | - // si $valeurs n'est pas un tableau, le formulaire n'est pas applicable |
|
| 215 | - // C'est plus fort qu'editable qui est gere par le squelette |
|
| 216 | - // Idealement $valeur doit etre alors un message explicatif. |
|
| 217 | - if (!is_array($valeurs)) { |
|
| 218 | - return is_string($valeurs) ? $valeurs : ''; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // charger peut passer une action si le formulaire ne tourne pas sur self() |
|
| 222 | - // ou une action vide si elle ne sert pas |
|
| 223 | - $action = $valeurs['action'] ?? self('&', true); |
|
| 224 | - // bug IEx : si action finit par / |
|
| 225 | - // IE croit que le <form ... action=../ > est autoferme |
|
| 226 | - if (substr($action, -1) == '/') { |
|
| 227 | - // on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un / |
|
| 228 | - $action .= '#'; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - // recuperer la saisie en cours si erreurs |
|
| 232 | - // seulement si c'est ce formulaire qui est poste |
|
| 233 | - // ou si on le demande explicitement par le parametre _forcer_request = true |
|
| 234 | - $dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])); |
|
| 235 | - foreach (array_keys($valeurs) as $champ) { |
|
| 236 | - if ($champ[0] !== '_' and !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) { |
|
| 237 | - if ($dispo and (($v = _request($champ)) !== null)) { |
|
| 238 | - $valeurs[$champ] = $v; |
|
| 239 | - } |
|
| 240 | - // nettoyer l'url des champs qui vont etre saisis |
|
| 241 | - if ($action) { |
|
| 242 | - $action = parametre_url($action, $champ, ''); |
|
| 243 | - } |
|
| 244 | - // proteger les ' et les " dans les champs que l'on va injecter |
|
| 245 | - $valeurs[$champ] = protege_champ($valeurs[$champ]); |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - if ($action) { |
|
| 250 | - // nettoyer l'url |
|
| 251 | - $action = parametre_url($action, 'formulaire_action', ''); |
|
| 252 | - $action = parametre_url($action, 'formulaire_action_args', ''); |
|
| 253 | - $action = parametre_url($action, 'formulaire_action_sign', ''); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * @deprecated 4.0 |
|
| 258 | - * servait pour poster sur les actions de type editer_xxx() qui ne prenaient pas d'argument autrement que par _request('arg') et pour lesquelles il fallait donc passer un hash valide |
|
| 259 | - */ |
|
| 260 | - /* |
|
| 182 | + // tester si ce formulaire vient d'etre poste (memes arguments) |
|
| 183 | + // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page |
|
| 184 | + // si poste, on recupere les erreurs |
|
| 185 | + |
|
| 186 | + $je_suis_poste = false; |
|
| 187 | + if ( |
|
| 188 | + $post_form = _request('formulaire_action') |
|
| 189 | + and $post_form == $form |
|
| 190 | + and $p = _request('formulaire_action_args') |
|
| 191 | + and is_array($p = decoder_contexte_ajax($p, $post_form)) |
|
| 192 | + ) { |
|
| 193 | + // enlever le faux attribut de langue masque |
|
| 194 | + array_shift($p); |
|
| 195 | + if (formulaire__identifier($form, $args, $p)) { |
|
| 196 | + $je_suis_poste = true; |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + $editable = true; |
|
| 201 | + $erreurs = $post = []; |
|
| 202 | + if ($je_suis_poste) { |
|
| 203 | + $post = traiter_formulaires_dynamiques(true); |
|
| 204 | + $e = "erreurs_$form"; |
|
| 205 | + $erreurs = $post[$e] ?? []; |
|
| 206 | + $editable = "editable_$form"; |
|
| 207 | + $editable = (!isset($post[$e])) |
|
| 208 | + || (is_countable($erreurs) ? count($erreurs) : 0) |
|
| 209 | + || (isset($post[$editable]) && $post[$editable]); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + $valeurs = formulaire__charger($form, $args, $je_suis_poste); |
|
| 213 | + |
|
| 214 | + // si $valeurs n'est pas un tableau, le formulaire n'est pas applicable |
|
| 215 | + // C'est plus fort qu'editable qui est gere par le squelette |
|
| 216 | + // Idealement $valeur doit etre alors un message explicatif. |
|
| 217 | + if (!is_array($valeurs)) { |
|
| 218 | + return is_string($valeurs) ? $valeurs : ''; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // charger peut passer une action si le formulaire ne tourne pas sur self() |
|
| 222 | + // ou une action vide si elle ne sert pas |
|
| 223 | + $action = $valeurs['action'] ?? self('&', true); |
|
| 224 | + // bug IEx : si action finit par / |
|
| 225 | + // IE croit que le <form ... action=../ > est autoferme |
|
| 226 | + if (substr($action, -1) == '/') { |
|
| 227 | + // on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un / |
|
| 228 | + $action .= '#'; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + // recuperer la saisie en cours si erreurs |
|
| 232 | + // seulement si c'est ce formulaire qui est poste |
|
| 233 | + // ou si on le demande explicitement par le parametre _forcer_request = true |
|
| 234 | + $dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])); |
|
| 235 | + foreach (array_keys($valeurs) as $champ) { |
|
| 236 | + if ($champ[0] !== '_' and !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) { |
|
| 237 | + if ($dispo and (($v = _request($champ)) !== null)) { |
|
| 238 | + $valeurs[$champ] = $v; |
|
| 239 | + } |
|
| 240 | + // nettoyer l'url des champs qui vont etre saisis |
|
| 241 | + if ($action) { |
|
| 242 | + $action = parametre_url($action, $champ, ''); |
|
| 243 | + } |
|
| 244 | + // proteger les ' et les " dans les champs que l'on va injecter |
|
| 245 | + $valeurs[$champ] = protege_champ($valeurs[$champ]); |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + if ($action) { |
|
| 250 | + // nettoyer l'url |
|
| 251 | + $action = parametre_url($action, 'formulaire_action', ''); |
|
| 252 | + $action = parametre_url($action, 'formulaire_action_args', ''); |
|
| 253 | + $action = parametre_url($action, 'formulaire_action_sign', ''); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * @deprecated 4.0 |
|
| 258 | + * servait pour poster sur les actions de type editer_xxx() qui ne prenaient pas d'argument autrement que par _request('arg') et pour lesquelles il fallait donc passer un hash valide |
|
| 259 | + */ |
|
| 260 | + /* |
|
| 261 | 261 | if (isset($valeurs['_action'])) { |
| 262 | 262 | $securiser_action = charger_fonction('securiser_action', 'inc'); |
| 263 | 263 | $secu = $securiser_action(reset($valeurs['_action']), end($valeurs['_action']), '', -1); |
@@ -267,59 +267,59 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | */ |
| 269 | 269 | |
| 270 | - // empiler la lang en tant que premier argument implicite du CVT |
|
| 271 | - // pour permettre de la restaurer au moment du Verifier et du Traiter |
|
| 272 | - array_unshift($args, $GLOBALS['spip_lang']); |
|
| 273 | - |
|
| 274 | - $valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form); |
|
| 275 | - $valeurs['erreurs'] = $erreurs; |
|
| 276 | - $valeurs['action'] = $action; |
|
| 277 | - $valeurs['form'] = $form; |
|
| 278 | - |
|
| 279 | - $valeurs['formulaire_sign'] = ''; |
|
| 280 | - if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 281 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 282 | - $secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1); |
|
| 283 | - $valeurs['formulaire_sign'] = $secu['hash']; |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - if (!isset($valeurs['id'])) { |
|
| 287 | - $valeurs['id'] = 'new'; |
|
| 288 | - } |
|
| 289 | - // editable peut venir de charger() ou de traiter() sinon |
|
| 290 | - if (!isset($valeurs['editable'])) { |
|
| 291 | - $valeurs['editable'] = $editable; |
|
| 292 | - } |
|
| 293 | - // dans tous les cas, renvoyer un espace ou vide (et pas un booleen) |
|
| 294 | - $valeurs['editable'] = ($valeurs['editable'] ? ' ' : ''); |
|
| 295 | - |
|
| 296 | - if ($je_suis_poste) { |
|
| 297 | - $valeurs['message_erreur'] = ''; |
|
| 298 | - if (isset($erreurs['message_erreur'])) { |
|
| 299 | - $valeurs['message_erreur'] = $erreurs['message_erreur']; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - $valeurs['message_ok'] = ''; |
|
| 303 | - if (isset($post["message_ok_$form"])) { |
|
| 304 | - $valeurs['message_ok'] = $post["message_ok_$form"]; |
|
| 305 | - } elseif (isset($erreurs['message_ok'])) { |
|
| 306 | - $valeurs['message_ok'] = $erreurs['message_ok']; |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - // accessibilite : encapsuler toutes les erreurs dans un role='alert' |
|
| 310 | - // uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux) |
|
| 311 | - // et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ) |
|
| 312 | - if (html5_permis()) { |
|
| 313 | - foreach ($erreurs as $k => $v) { |
|
| 314 | - if (is_string($v) and strlen(trim($v)) and strpos($k, '_') !== 0) { |
|
| 315 | - // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
|
| 316 | - $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 317 | - } |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - return $valeurs; |
|
| 270 | + // empiler la lang en tant que premier argument implicite du CVT |
|
| 271 | + // pour permettre de la restaurer au moment du Verifier et du Traiter |
|
| 272 | + array_unshift($args, $GLOBALS['spip_lang']); |
|
| 273 | + |
|
| 274 | + $valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form); |
|
| 275 | + $valeurs['erreurs'] = $erreurs; |
|
| 276 | + $valeurs['action'] = $action; |
|
| 277 | + $valeurs['form'] = $form; |
|
| 278 | + |
|
| 279 | + $valeurs['formulaire_sign'] = ''; |
|
| 280 | + if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 281 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 282 | + $secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1); |
|
| 283 | + $valeurs['formulaire_sign'] = $secu['hash']; |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + if (!isset($valeurs['id'])) { |
|
| 287 | + $valeurs['id'] = 'new'; |
|
| 288 | + } |
|
| 289 | + // editable peut venir de charger() ou de traiter() sinon |
|
| 290 | + if (!isset($valeurs['editable'])) { |
|
| 291 | + $valeurs['editable'] = $editable; |
|
| 292 | + } |
|
| 293 | + // dans tous les cas, renvoyer un espace ou vide (et pas un booleen) |
|
| 294 | + $valeurs['editable'] = ($valeurs['editable'] ? ' ' : ''); |
|
| 295 | + |
|
| 296 | + if ($je_suis_poste) { |
|
| 297 | + $valeurs['message_erreur'] = ''; |
|
| 298 | + if (isset($erreurs['message_erreur'])) { |
|
| 299 | + $valeurs['message_erreur'] = $erreurs['message_erreur']; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + $valeurs['message_ok'] = ''; |
|
| 303 | + if (isset($post["message_ok_$form"])) { |
|
| 304 | + $valeurs['message_ok'] = $post["message_ok_$form"]; |
|
| 305 | + } elseif (isset($erreurs['message_ok'])) { |
|
| 306 | + $valeurs['message_ok'] = $erreurs['message_ok']; |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + // accessibilite : encapsuler toutes les erreurs dans un role='alert' |
|
| 310 | + // uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux) |
|
| 311 | + // et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ) |
|
| 312 | + if (html5_permis()) { |
|
| 313 | + foreach ($erreurs as $k => $v) { |
|
| 314 | + if (is_string($v) and strlen(trim($v)) and strpos($k, '_') !== 0) { |
|
| 315 | + // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
|
| 316 | + $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 317 | + } |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + return $valeurs; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -331,51 +331,51 @@ discard block |
||
| 331 | 331 | * @return array |
| 332 | 332 | */ |
| 333 | 333 | function formulaire__charger($form, $args, $poste) { |
| 334 | - if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) { |
|
| 335 | - $valeurs = $charger_valeurs(...$args); |
|
| 336 | - } else { |
|
| 337 | - $valeurs = []; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - $valeurs = pipeline( |
|
| 341 | - 'formulaire_charger', |
|
| 342 | - [ |
|
| 343 | - 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 344 | - 'data' => $valeurs |
|
| 345 | - ] |
|
| 346 | - ); |
|
| 347 | - |
|
| 348 | - // prise en charge CVT multi etape |
|
| 349 | - if (is_array($valeurs) and isset($valeurs['_etapes'])) { |
|
| 350 | - include_spip('inc/cvt_multietapes'); |
|
| 351 | - $valeurs = cvtmulti_formulaire_charger_etapes( |
|
| 352 | - ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 353 | - $valeurs |
|
| 354 | - ); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - // si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline ! |
|
| 358 | - if (is_array($valeurs)) { |
|
| 359 | - if (!isset($valeurs['_pipelines'])) { |
|
| 360 | - $valeurs['_pipelines'] = []; |
|
| 361 | - } |
|
| 362 | - // l'ancien argument _pipeline devient maintenant _pipelines |
|
| 363 | - // reinjectons le vieux _pipeline au debut de _pipelines |
|
| 364 | - if (isset($valeurs['_pipeline'])) { |
|
| 365 | - $pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline']; |
|
| 366 | - $args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : []; |
|
| 367 | - |
|
| 368 | - $pipelines = [$pipe => $args]; |
|
| 369 | - $valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - // et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire |
|
| 373 | - // qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond |
|
| 374 | - // (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes) |
|
| 375 | - $valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste]; |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - return $valeurs; |
|
| 334 | + if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) { |
|
| 335 | + $valeurs = $charger_valeurs(...$args); |
|
| 336 | + } else { |
|
| 337 | + $valeurs = []; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + $valeurs = pipeline( |
|
| 341 | + 'formulaire_charger', |
|
| 342 | + [ |
|
| 343 | + 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 344 | + 'data' => $valeurs |
|
| 345 | + ] |
|
| 346 | + ); |
|
| 347 | + |
|
| 348 | + // prise en charge CVT multi etape |
|
| 349 | + if (is_array($valeurs) and isset($valeurs['_etapes'])) { |
|
| 350 | + include_spip('inc/cvt_multietapes'); |
|
| 351 | + $valeurs = cvtmulti_formulaire_charger_etapes( |
|
| 352 | + ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 353 | + $valeurs |
|
| 354 | + ); |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + // si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline ! |
|
| 358 | + if (is_array($valeurs)) { |
|
| 359 | + if (!isset($valeurs['_pipelines'])) { |
|
| 360 | + $valeurs['_pipelines'] = []; |
|
| 361 | + } |
|
| 362 | + // l'ancien argument _pipeline devient maintenant _pipelines |
|
| 363 | + // reinjectons le vieux _pipeline au debut de _pipelines |
|
| 364 | + if (isset($valeurs['_pipeline'])) { |
|
| 365 | + $pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline']; |
|
| 366 | + $args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : []; |
|
| 367 | + |
|
| 368 | + $pipelines = [$pipe => $args]; |
|
| 369 | + $valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + // et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire |
|
| 373 | + // qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond |
|
| 374 | + // (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes) |
|
| 375 | + $valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste]; |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + return $valeurs; |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -394,9 +394,9 @@ discard block |
||
| 394 | 394 | * @return bool |
| 395 | 395 | */ |
| 396 | 396 | function formulaire__identifier($form, $args, $p) { |
| 397 | - if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) { |
|
| 398 | - return $identifier_args(...$args) === $identifier_args(...$p); |
|
| 399 | - } |
|
| 397 | + if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) { |
|
| 398 | + return $identifier_args(...$args) === $identifier_args(...$p); |
|
| 399 | + } |
|
| 400 | 400 | |
| 401 | - return $args === $p; |
|
| 401 | + return $args === $p; |
|
| 402 | 402 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -30,36 +30,36 @@ discard block |
||
| 30 | 30 | * `on` ou `off` |
| 31 | 31 | */ |
| 32 | 32 | function logo_supprimer($objet, $id_objet, $etat) { |
| 33 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 34 | - $objet = objet_type($objet); |
|
| 35 | - $primary = id_table_objet($objet); |
|
| 36 | - include_spip('inc/chercher_logo'); |
|
| 37 | - |
|
| 38 | - // existe-t-il deja un logo ? |
|
| 39 | - $logo = $chercher_logo($id_objet, $primary, $etat); |
|
| 40 | - if ($logo) { |
|
| 41 | - # TODO : deprecated, a supprimer -> anciens logos IMG/artonxx.png pas en base |
|
| 42 | - if ((is_countable($logo) ? count($logo) : 0) < 6) { |
|
| 43 | - spip_log('Supprimer ancien logo ' . json_encode($logo, JSON_THROW_ON_ERROR), 'logo'); |
|
| 44 | - spip_unlink($logo[0]); |
|
| 45 | - } |
|
| 46 | - elseif ( |
|
| 47 | - $doc = $logo[5] |
|
| 48 | - and isset($doc['id_document']) |
|
| 49 | - and $id_document = $doc['id_document'] |
|
| 50 | - ) { |
|
| 51 | - include_spip('action/editer_liens'); |
|
| 52 | - // supprimer le lien dans la base |
|
| 53 | - objet_dissocier(['document' => $id_document], [$objet => $id_objet], ['role' => '*']); |
|
| 54 | - |
|
| 55 | - // verifier si il reste des liens avec d'autres objets et sinon supprimer |
|
| 56 | - $liens = objet_trouver_liens(['document' => $id_document], '*'); |
|
| 57 | - if (!count($liens)) { |
|
| 58 | - $supprimer_document = charger_fonction('supprimer_document', 'action'); |
|
| 59 | - $supprimer_document($doc['id_document']); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - } |
|
| 33 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 34 | + $objet = objet_type($objet); |
|
| 35 | + $primary = id_table_objet($objet); |
|
| 36 | + include_spip('inc/chercher_logo'); |
|
| 37 | + |
|
| 38 | + // existe-t-il deja un logo ? |
|
| 39 | + $logo = $chercher_logo($id_objet, $primary, $etat); |
|
| 40 | + if ($logo) { |
|
| 41 | + # TODO : deprecated, a supprimer -> anciens logos IMG/artonxx.png pas en base |
|
| 42 | + if ((is_countable($logo) ? count($logo) : 0) < 6) { |
|
| 43 | + spip_log('Supprimer ancien logo ' . json_encode($logo, JSON_THROW_ON_ERROR), 'logo'); |
|
| 44 | + spip_unlink($logo[0]); |
|
| 45 | + } |
|
| 46 | + elseif ( |
|
| 47 | + $doc = $logo[5] |
|
| 48 | + and isset($doc['id_document']) |
|
| 49 | + and $id_document = $doc['id_document'] |
|
| 50 | + ) { |
|
| 51 | + include_spip('action/editer_liens'); |
|
| 52 | + // supprimer le lien dans la base |
|
| 53 | + objet_dissocier(['document' => $id_document], [$objet => $id_objet], ['role' => '*']); |
|
| 54 | + |
|
| 55 | + // verifier si il reste des liens avec d'autres objets et sinon supprimer |
|
| 56 | + $liens = objet_trouver_liens(['document' => $id_document], '*'); |
|
| 57 | + if (!count($liens)) { |
|
| 58 | + $supprimer_document = charger_fonction('supprimer_document', 'action'); |
|
| 59 | + $supprimer_document($doc['id_document']); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -76,200 +76,200 @@ discard block |
||
| 76 | 76 | * Erreur, sinon '' |
| 77 | 77 | */ |
| 78 | 78 | function logo_modifier($objet, $id_objet, $etat, $source) { |
| 79 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 80 | - $objet = objet_type($objet); |
|
| 81 | - $primary = id_table_objet($objet); |
|
| 82 | - include_spip('inc/chercher_logo'); |
|
| 83 | - |
|
| 84 | - $mode = preg_replace(',\W,', '', $etat); |
|
| 85 | - if (!$mode) { |
|
| 86 | - spip_log("logo_modifier : etat $etat invalide", 'logo'); |
|
| 87 | - $erreur = 'etat invalide'; |
|
| 88 | - |
|
| 89 | - return $erreur; |
|
| 90 | - } |
|
| 91 | - // chercher dans la base |
|
| 92 | - $mode_document = 'logo' . $mode; |
|
| 93 | - |
|
| 94 | - include_spip('inc/documents'); |
|
| 95 | - $erreur = ''; |
|
| 96 | - |
|
| 97 | - if (!$source) { |
|
| 98 | - spip_log('spip_image_ajouter : source inconnue', 'logo'); |
|
| 99 | - $erreur = 'source inconnue'; |
|
| 100 | - |
|
| 101 | - return $erreur; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - // fichier dans upload/ |
|
| 105 | - if (is_string($source)) { |
|
| 106 | - $tmp_name = false; |
|
| 107 | - if (file_exists($source)) { |
|
| 108 | - $tmp_name = $source; |
|
| 109 | - } elseif (file_exists($f = determine_upload() . $source)) { |
|
| 110 | - $tmp_name = $f; |
|
| 111 | - } |
|
| 112 | - if (!$tmp_name) { |
|
| 113 | - spip_log('spip_image_ajouter : source inconnue', 'logo'); |
|
| 114 | - $erreur = 'source inconnue'; |
|
| 115 | - |
|
| 116 | - return $erreur; |
|
| 117 | - } |
|
| 118 | - $source = [ |
|
| 119 | - 'tmp_name' => $tmp_name, |
|
| 120 | - 'name' => basename($tmp_name), |
|
| 121 | - ]; |
|
| 122 | - } elseif ($erreur = check_upload_error($source['error'], '', true)) { |
|
| 123 | - return $erreur; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // supprimer le logo eventueel existant |
|
| 127 | - // TODO : si un logo existe, le modifier plutot que supprimer + reinserer (mais il faut gerer le cas ou il est utilise par plusieurs objets, donc pas si simple) |
|
| 128 | - // mais de toute facon l'interface actuelle oblige a supprimer + reinserer |
|
| 129 | - if (empty($GLOBALS['logo_migrer_en_base'])) { |
|
| 130 | - logo_supprimer($objet, $id_objet, $etat); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - include_spip('inc/autoriser'); |
|
| 135 | - $source['mode'] = $mode_document; |
|
| 136 | - $ajouter_documents = charger_fonction('ajouter_documents', 'action'); |
|
| 137 | - autoriser_exception('associerdocuments', $objet, $id_objet); |
|
| 138 | - $ajoutes = $ajouter_documents('new', [$source], $objet, $id_objet, $mode_document); |
|
| 139 | - autoriser_exception('associerdocuments', $objet, $id_objet, false); |
|
| 140 | - |
|
| 141 | - $id_document = reset($ajoutes); |
|
| 142 | - |
|
| 143 | - if (!is_numeric($id_document)) { |
|
| 144 | - $erreur = ($id_document ?: 'Erreur inconnue'); |
|
| 145 | - spip_log("Erreur ajout logo : $erreur pour source=" . json_encode($source, JSON_THROW_ON_ERROR), 'logo'); |
|
| 146 | - return $erreur; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - return ''; // tout est bon, pas d'erreur |
|
| 79 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 80 | + $objet = objet_type($objet); |
|
| 81 | + $primary = id_table_objet($objet); |
|
| 82 | + include_spip('inc/chercher_logo'); |
|
| 83 | + |
|
| 84 | + $mode = preg_replace(',\W,', '', $etat); |
|
| 85 | + if (!$mode) { |
|
| 86 | + spip_log("logo_modifier : etat $etat invalide", 'logo'); |
|
| 87 | + $erreur = 'etat invalide'; |
|
| 88 | + |
|
| 89 | + return $erreur; |
|
| 90 | + } |
|
| 91 | + // chercher dans la base |
|
| 92 | + $mode_document = 'logo' . $mode; |
|
| 93 | + |
|
| 94 | + include_spip('inc/documents'); |
|
| 95 | + $erreur = ''; |
|
| 96 | + |
|
| 97 | + if (!$source) { |
|
| 98 | + spip_log('spip_image_ajouter : source inconnue', 'logo'); |
|
| 99 | + $erreur = 'source inconnue'; |
|
| 100 | + |
|
| 101 | + return $erreur; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + // fichier dans upload/ |
|
| 105 | + if (is_string($source)) { |
|
| 106 | + $tmp_name = false; |
|
| 107 | + if (file_exists($source)) { |
|
| 108 | + $tmp_name = $source; |
|
| 109 | + } elseif (file_exists($f = determine_upload() . $source)) { |
|
| 110 | + $tmp_name = $f; |
|
| 111 | + } |
|
| 112 | + if (!$tmp_name) { |
|
| 113 | + spip_log('spip_image_ajouter : source inconnue', 'logo'); |
|
| 114 | + $erreur = 'source inconnue'; |
|
| 115 | + |
|
| 116 | + return $erreur; |
|
| 117 | + } |
|
| 118 | + $source = [ |
|
| 119 | + 'tmp_name' => $tmp_name, |
|
| 120 | + 'name' => basename($tmp_name), |
|
| 121 | + ]; |
|
| 122 | + } elseif ($erreur = check_upload_error($source['error'], '', true)) { |
|
| 123 | + return $erreur; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // supprimer le logo eventueel existant |
|
| 127 | + // TODO : si un logo existe, le modifier plutot que supprimer + reinserer (mais il faut gerer le cas ou il est utilise par plusieurs objets, donc pas si simple) |
|
| 128 | + // mais de toute facon l'interface actuelle oblige a supprimer + reinserer |
|
| 129 | + if (empty($GLOBALS['logo_migrer_en_base'])) { |
|
| 130 | + logo_supprimer($objet, $id_objet, $etat); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + include_spip('inc/autoriser'); |
|
| 135 | + $source['mode'] = $mode_document; |
|
| 136 | + $ajouter_documents = charger_fonction('ajouter_documents', 'action'); |
|
| 137 | + autoriser_exception('associerdocuments', $objet, $id_objet); |
|
| 138 | + $ajoutes = $ajouter_documents('new', [$source], $objet, $id_objet, $mode_document); |
|
| 139 | + autoriser_exception('associerdocuments', $objet, $id_objet, false); |
|
| 140 | + |
|
| 141 | + $id_document = reset($ajoutes); |
|
| 142 | + |
|
| 143 | + if (!is_numeric($id_document)) { |
|
| 144 | + $erreur = ($id_document ?: 'Erreur inconnue'); |
|
| 145 | + spip_log("Erreur ajout logo : $erreur pour source=" . json_encode($source, JSON_THROW_ON_ERROR), 'logo'); |
|
| 146 | + return $erreur; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + return ''; // tout est bon, pas d'erreur |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | function logo_migrer_en_base($objet, $time_limit) { |
| 153 | 153 | |
| 154 | - $dir_logos_erreurs = sous_repertoire(_DIR_IMG, 'logo_erreurs'); |
|
| 155 | - $dir_logos = sous_repertoire(_DIR_IMG, 'logo'); |
|
| 156 | - $formats_logos = ['jpg', 'png', 'svg', 'gif']; |
|
| 157 | - if (isset($GLOBALS['formats_logos'])) { |
|
| 158 | - $formats_logos = $GLOBALS['formats_logos']; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - |
|
| 162 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 163 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 164 | - include_spip('inc/chercher_logo'); |
|
| 165 | - $_id_objet = id_table_objet($objet); |
|
| 166 | - $table = table_objet_sql($objet); |
|
| 167 | - $type = type_du_logo($_id_objet); |
|
| 168 | - $desc = $trouver_table($table); |
|
| 169 | - |
|
| 170 | - // on desactive les revisions |
|
| 171 | - $liste_objets_versionnes = $GLOBALS['meta']['objets_versions'] ?? ''; |
|
| 172 | - unset($GLOBALS['meta']['objets_versions']); |
|
| 173 | - // et le signalement des editions |
|
| 174 | - $articles_modif = $GLOBALS['meta']['articles_modif'] ?? ''; |
|
| 175 | - $GLOBALS['meta']['articles_modif'] = 'non'; |
|
| 176 | - |
|
| 177 | - foreach (['on', 'off'] as $mode) { |
|
| 178 | - $nom_base = $type . $mode; |
|
| 179 | - $dir = (defined('_DIR_LOGOS') ? _DIR_LOGOS : _DIR_IMG); |
|
| 180 | - |
|
| 181 | - $files = glob($dir . $nom_base . '*'); |
|
| 182 | - // est-ce que c'est une nouvelle tentative de migration ? |
|
| 183 | - // dans ce cas les logos sont deja dans IMG/logo/ |
|
| 184 | - if (!(is_countable($files) ? count($files) : 0)) { |
|
| 185 | - $files = glob($dir_logos . $nom_base . '*'); |
|
| 186 | - if (is_countable($files) ? count($files) : 0) { |
|
| 187 | - // mais il faut verifier si ils ont pas deja ete migres pour tout ou partie |
|
| 188 | - $filescheck = []; |
|
| 189 | - foreach ($files as $file) { |
|
| 190 | - $short = basename(dirname($file)) . DIRECTORY_SEPARATOR . basename($file); |
|
| 191 | - $filescheck[$short] = $file; |
|
| 192 | - } |
|
| 193 | - // trouver ceux deja migres |
|
| 194 | - $deja = sql_allfetsel('fichier', 'spip_documents', sql_in('fichier', array_keys($filescheck)) . " AND mode LIKE 'logo%'"); |
|
| 195 | - if (is_countable($deja) ? count($deja) : 0) { |
|
| 196 | - $deja = array_column($deja, 'fichier'); |
|
| 197 | - $restant = array_diff(array_keys($filescheck), $deja); |
|
| 198 | - $files = []; |
|
| 199 | - if (count($restant)) { |
|
| 200 | - foreach ($restant as $r) { |
|
| 201 | - $files[] = $filescheck[$r]; |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - // et si il en reste on peut y aller... |
|
| 206 | - // mais il faut modifier $dir qui sert de base dans la suite |
|
| 207 | - if (is_countable($files) ? count($files) : 0) { |
|
| 208 | - $dir = $dir_logos; |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - $count = (is_countable($files) ? count($files) : 0); |
|
| 214 | - spip_log("logo_migrer_en_base $objet $mode : " . $count . ' logos restant', 'maj' . _LOG_INFO_IMPORTANTE); |
|
| 215 | - |
|
| 216 | - $deja = []; |
|
| 217 | - foreach ($files as $file) { |
|
| 218 | - $logo = substr($file, strlen($dir . $nom_base)); |
|
| 219 | - $logo = explode('.', $logo); |
|
| 220 | - if ( |
|
| 221 | - is_numeric($logo[0]) |
|
| 222 | - and ($id_objet = intval($logo[0]) or in_array($objet, ['site', 'rubrique'])) |
|
| 223 | - ) { |
|
| 224 | - if (!isset($deja[$id_objet])) { |
|
| 225 | - $logo = $chercher_logo($id_objet, $_id_objet, $mode); |
|
| 226 | - // if no logo in base |
|
| 227 | - if (!$logo or (is_countable($logo) ? count($logo) : 0) < 6) { |
|
| 228 | - foreach ($formats_logos as $format) { |
|
| 229 | - if (@file_exists($d = ($dir . ($nom = $nom_base . intval($id_objet) . '.' . $format)))) { |
|
| 230 | - if (isset($desc['field']['date_modif'])) { |
|
| 231 | - $date_modif = sql_getfetsel('date_modif', $table, "$_id_objet=$id_objet"); |
|
| 232 | - } else { |
|
| 233 | - $date_modif = null; |
|
| 234 | - } |
|
| 235 | - // s'assurer que le logo a les bon droits au passage (evite un echec en cas de sanitization d'un svg) |
|
| 236 | - @chmod($d, _SPIP_CHMOD & 0666); |
|
| 237 | - // logo_modifier commence par supprimer le logo existant, donc on le deplace pour pas le perdre |
|
| 238 | - @rename($d, $dir_logos . $nom); |
|
| 239 | - // et on le declare comme nouveau logo |
|
| 240 | - logo_modifier($objet, $id_objet, $mode, $dir_logos . $nom); |
|
| 241 | - if ($date_modif) { |
|
| 242 | - sql_updateq($table, ['date_modif' => $date_modif], "$_id_objet=$id_objet"); |
|
| 243 | - } |
|
| 244 | - break; |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - $deja[$id_objet] = true; |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - // si le fichier est encore la on le move : rien a faire ici |
|
| 252 | - // (sauf si c'est une re-migration : il est deja dans logo/ donc il bouge pas) |
|
| 253 | - if ($dir !== $dir_logos and file_exists($file)) { |
|
| 254 | - @rename($file, $dir_logos_erreurs . basename($file)); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - $count--; |
|
| 258 | - if ($count % 250 === 0) { |
|
| 259 | - spip_log("logo_migrer_en_base $objet $mode : " . $count . ' logos restant', 'maj' . _LOG_INFO_IMPORTANTE); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - if ($time_limit and time() > $time_limit) { |
|
| 263 | - effacer_meta('drapeau_edition'); |
|
| 264 | - return; |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - if ($liste_objets_versionnes) { |
|
| 270 | - $GLOBALS['meta']['objets_versions'] = $liste_objets_versionnes; |
|
| 271 | - } |
|
| 272 | - $GLOBALS['meta']['articles_modif'] = $articles_modif; |
|
| 273 | - |
|
| 274 | - effacer_meta('drapeau_edition'); |
|
| 154 | + $dir_logos_erreurs = sous_repertoire(_DIR_IMG, 'logo_erreurs'); |
|
| 155 | + $dir_logos = sous_repertoire(_DIR_IMG, 'logo'); |
|
| 156 | + $formats_logos = ['jpg', 'png', 'svg', 'gif']; |
|
| 157 | + if (isset($GLOBALS['formats_logos'])) { |
|
| 158 | + $formats_logos = $GLOBALS['formats_logos']; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + |
|
| 162 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 163 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 164 | + include_spip('inc/chercher_logo'); |
|
| 165 | + $_id_objet = id_table_objet($objet); |
|
| 166 | + $table = table_objet_sql($objet); |
|
| 167 | + $type = type_du_logo($_id_objet); |
|
| 168 | + $desc = $trouver_table($table); |
|
| 169 | + |
|
| 170 | + // on desactive les revisions |
|
| 171 | + $liste_objets_versionnes = $GLOBALS['meta']['objets_versions'] ?? ''; |
|
| 172 | + unset($GLOBALS['meta']['objets_versions']); |
|
| 173 | + // et le signalement des editions |
|
| 174 | + $articles_modif = $GLOBALS['meta']['articles_modif'] ?? ''; |
|
| 175 | + $GLOBALS['meta']['articles_modif'] = 'non'; |
|
| 176 | + |
|
| 177 | + foreach (['on', 'off'] as $mode) { |
|
| 178 | + $nom_base = $type . $mode; |
|
| 179 | + $dir = (defined('_DIR_LOGOS') ? _DIR_LOGOS : _DIR_IMG); |
|
| 180 | + |
|
| 181 | + $files = glob($dir . $nom_base . '*'); |
|
| 182 | + // est-ce que c'est une nouvelle tentative de migration ? |
|
| 183 | + // dans ce cas les logos sont deja dans IMG/logo/ |
|
| 184 | + if (!(is_countable($files) ? count($files) : 0)) { |
|
| 185 | + $files = glob($dir_logos . $nom_base . '*'); |
|
| 186 | + if (is_countable($files) ? count($files) : 0) { |
|
| 187 | + // mais il faut verifier si ils ont pas deja ete migres pour tout ou partie |
|
| 188 | + $filescheck = []; |
|
| 189 | + foreach ($files as $file) { |
|
| 190 | + $short = basename(dirname($file)) . DIRECTORY_SEPARATOR . basename($file); |
|
| 191 | + $filescheck[$short] = $file; |
|
| 192 | + } |
|
| 193 | + // trouver ceux deja migres |
|
| 194 | + $deja = sql_allfetsel('fichier', 'spip_documents', sql_in('fichier', array_keys($filescheck)) . " AND mode LIKE 'logo%'"); |
|
| 195 | + if (is_countable($deja) ? count($deja) : 0) { |
|
| 196 | + $deja = array_column($deja, 'fichier'); |
|
| 197 | + $restant = array_diff(array_keys($filescheck), $deja); |
|
| 198 | + $files = []; |
|
| 199 | + if (count($restant)) { |
|
| 200 | + foreach ($restant as $r) { |
|
| 201 | + $files[] = $filescheck[$r]; |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + // et si il en reste on peut y aller... |
|
| 206 | + // mais il faut modifier $dir qui sert de base dans la suite |
|
| 207 | + if (is_countable($files) ? count($files) : 0) { |
|
| 208 | + $dir = $dir_logos; |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + $count = (is_countable($files) ? count($files) : 0); |
|
| 214 | + spip_log("logo_migrer_en_base $objet $mode : " . $count . ' logos restant', 'maj' . _LOG_INFO_IMPORTANTE); |
|
| 215 | + |
|
| 216 | + $deja = []; |
|
| 217 | + foreach ($files as $file) { |
|
| 218 | + $logo = substr($file, strlen($dir . $nom_base)); |
|
| 219 | + $logo = explode('.', $logo); |
|
| 220 | + if ( |
|
| 221 | + is_numeric($logo[0]) |
|
| 222 | + and ($id_objet = intval($logo[0]) or in_array($objet, ['site', 'rubrique'])) |
|
| 223 | + ) { |
|
| 224 | + if (!isset($deja[$id_objet])) { |
|
| 225 | + $logo = $chercher_logo($id_objet, $_id_objet, $mode); |
|
| 226 | + // if no logo in base |
|
| 227 | + if (!$logo or (is_countable($logo) ? count($logo) : 0) < 6) { |
|
| 228 | + foreach ($formats_logos as $format) { |
|
| 229 | + if (@file_exists($d = ($dir . ($nom = $nom_base . intval($id_objet) . '.' . $format)))) { |
|
| 230 | + if (isset($desc['field']['date_modif'])) { |
|
| 231 | + $date_modif = sql_getfetsel('date_modif', $table, "$_id_objet=$id_objet"); |
|
| 232 | + } else { |
|
| 233 | + $date_modif = null; |
|
| 234 | + } |
|
| 235 | + // s'assurer que le logo a les bon droits au passage (evite un echec en cas de sanitization d'un svg) |
|
| 236 | + @chmod($d, _SPIP_CHMOD & 0666); |
|
| 237 | + // logo_modifier commence par supprimer le logo existant, donc on le deplace pour pas le perdre |
|
| 238 | + @rename($d, $dir_logos . $nom); |
|
| 239 | + // et on le declare comme nouveau logo |
|
| 240 | + logo_modifier($objet, $id_objet, $mode, $dir_logos . $nom); |
|
| 241 | + if ($date_modif) { |
|
| 242 | + sql_updateq($table, ['date_modif' => $date_modif], "$_id_objet=$id_objet"); |
|
| 243 | + } |
|
| 244 | + break; |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + $deja[$id_objet] = true; |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + // si le fichier est encore la on le move : rien a faire ici |
|
| 252 | + // (sauf si c'est une re-migration : il est deja dans logo/ donc il bouge pas) |
|
| 253 | + if ($dir !== $dir_logos and file_exists($file)) { |
|
| 254 | + @rename($file, $dir_logos_erreurs . basename($file)); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + $count--; |
|
| 258 | + if ($count % 250 === 0) { |
|
| 259 | + spip_log("logo_migrer_en_base $objet $mode : " . $count . ' logos restant', 'maj' . _LOG_INFO_IMPORTANTE); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + if ($time_limit and time() > $time_limit) { |
|
| 263 | + effacer_meta('drapeau_edition'); |
|
| 264 | + return; |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + if ($liste_objets_versionnes) { |
|
| 270 | + $GLOBALS['meta']['objets_versions'] = $liste_objets_versionnes; |
|
| 271 | + } |
|
| 272 | + $GLOBALS['meta']['articles_modif'] = $articles_modif; |
|
| 273 | + |
|
| 274 | + effacer_meta('drapeau_edition'); |
|
| 275 | 275 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Autorisations |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -38,89 +38,89 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | if (!function_exists('autoriser')) { |
| 41 | - /** |
|
| 42 | - * Autoriser une action |
|
| 43 | - * |
|
| 44 | - * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 45 | - * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 46 | - * les autorisations. |
|
| 47 | - * |
|
| 48 | - * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 49 | - * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 50 | - * dans cet ordre : |
|
| 51 | - * |
|
| 52 | - * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 53 | - * - autoriser_{type}, sinon avec _dist |
|
| 54 | - * - autoriser_{faire}, sinon avec _dist |
|
| 55 | - * - autoriser_{defaut}, sinon avec _dist |
|
| 56 | - * |
|
| 57 | - * Seul le premier argument est obligatoire. |
|
| 58 | - * |
|
| 59 | - * @note |
|
| 60 | - * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 61 | - * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 62 | - * cette valeur. |
|
| 63 | - * |
|
| 64 | - * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 65 | - * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 66 | - * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 67 | - * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 68 | - * |
|
| 69 | - * @note |
|
| 70 | - * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 71 | - * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 72 | - * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 73 | - * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 74 | - * quel serait le type, quel serait l'action ? |
|
| 75 | - * |
|
| 76 | - * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 77 | - * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 78 | - * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 79 | - * |
|
| 80 | - * @api |
|
| 81 | - * @see autoriser_dist() |
|
| 82 | - * @see objet_type() |
|
| 83 | - * |
|
| 84 | - * @param string $faire |
|
| 85 | - * une action ('modifier', 'publier'...) |
|
| 86 | - * @param string|null $type |
|
| 87 | - * Type d’objet ou élément sur lequel appliquer l’action. |
|
| 88 | - * - null: indifférent à tout type d’élément ou objet éditorial |
|
| 89 | - * - string: objet éditorial (objet_type() est appliqué pour homogénéiser l’entrée) |
|
| 90 | - * - _string: autre élément (avec un souligné en premier caractère, désactive objet_type()). |
|
| 91 | - * Les soulignés seront retirés (cf. la note). |
|
| 92 | - * @param string|int|null $id |
|
| 93 | - * id de l'objet ou élément sur lequel on veut agir, si pertinent. |
|
| 94 | - * - null: non utile pour l’autorisation |
|
| 95 | - * - int: identifiant numérique (cas de tous les objets éditoriaux de SPIP) |
|
| 96 | - * - string: identifiant textuel |
|
| 97 | - * @param null|int|array $qui |
|
| 98 | - * - si null on prend alors visiteur_session |
|
| 99 | - * - un id_auteur (on regarde dans la base) |
|
| 100 | - * - un tableau auteur complet, y compris [restreint] |
|
| 101 | - * @param array $opt |
|
| 102 | - * options sous forme de tableau associatif |
|
| 103 | - * @return bool |
|
| 104 | - * true si la personne peut effectuer l'action |
|
| 105 | - */ |
|
| 106 | - function autoriser(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
|
| 107 | - // Charger les fonctions d'autorisation supplementaires |
|
| 108 | - static $pipe; |
|
| 109 | - if (!isset($pipe)) { |
|
| 110 | - $pipe = 1; |
|
| 111 | - pipeline('autoriser'); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return autoriser_dist($faire, $type, $id, $qui, $opt); |
|
| 115 | - } |
|
| 41 | + /** |
|
| 42 | + * Autoriser une action |
|
| 43 | + * |
|
| 44 | + * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 45 | + * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 46 | + * les autorisations. |
|
| 47 | + * |
|
| 48 | + * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 49 | + * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 50 | + * dans cet ordre : |
|
| 51 | + * |
|
| 52 | + * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 53 | + * - autoriser_{type}, sinon avec _dist |
|
| 54 | + * - autoriser_{faire}, sinon avec _dist |
|
| 55 | + * - autoriser_{defaut}, sinon avec _dist |
|
| 56 | + * |
|
| 57 | + * Seul le premier argument est obligatoire. |
|
| 58 | + * |
|
| 59 | + * @note |
|
| 60 | + * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 61 | + * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 62 | + * cette valeur. |
|
| 63 | + * |
|
| 64 | + * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 65 | + * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 66 | + * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 67 | + * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 68 | + * |
|
| 69 | + * @note |
|
| 70 | + * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 71 | + * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 72 | + * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 73 | + * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 74 | + * quel serait le type, quel serait l'action ? |
|
| 75 | + * |
|
| 76 | + * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 77 | + * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 78 | + * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 79 | + * |
|
| 80 | + * @api |
|
| 81 | + * @see autoriser_dist() |
|
| 82 | + * @see objet_type() |
|
| 83 | + * |
|
| 84 | + * @param string $faire |
|
| 85 | + * une action ('modifier', 'publier'...) |
|
| 86 | + * @param string|null $type |
|
| 87 | + * Type d’objet ou élément sur lequel appliquer l’action. |
|
| 88 | + * - null: indifférent à tout type d’élément ou objet éditorial |
|
| 89 | + * - string: objet éditorial (objet_type() est appliqué pour homogénéiser l’entrée) |
|
| 90 | + * - _string: autre élément (avec un souligné en premier caractère, désactive objet_type()). |
|
| 91 | + * Les soulignés seront retirés (cf. la note). |
|
| 92 | + * @param string|int|null $id |
|
| 93 | + * id de l'objet ou élément sur lequel on veut agir, si pertinent. |
|
| 94 | + * - null: non utile pour l’autorisation |
|
| 95 | + * - int: identifiant numérique (cas de tous les objets éditoriaux de SPIP) |
|
| 96 | + * - string: identifiant textuel |
|
| 97 | + * @param null|int|array $qui |
|
| 98 | + * - si null on prend alors visiteur_session |
|
| 99 | + * - un id_auteur (on regarde dans la base) |
|
| 100 | + * - un tableau auteur complet, y compris [restreint] |
|
| 101 | + * @param array $opt |
|
| 102 | + * options sous forme de tableau associatif |
|
| 103 | + * @return bool |
|
| 104 | + * true si la personne peut effectuer l'action |
|
| 105 | + */ |
|
| 106 | + function autoriser(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
|
| 107 | + // Charger les fonctions d'autorisation supplementaires |
|
| 108 | + static $pipe; |
|
| 109 | + if (!isset($pipe)) { |
|
| 110 | + $pipe = 1; |
|
| 111 | + pipeline('autoriser'); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return autoriser_dist($faire, $type, $id, $qui, $opt); |
|
| 115 | + } |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | // mes_fonctions peut aussi declarer des autorisations, il faut donc le charger |
| 120 | 120 | // mais apres la fonction autoriser() |
| 121 | 121 | if ($f = find_in_path('mes_fonctions.php')) { |
| 122 | - global $dossier_squelettes; |
|
| 123 | - include_once(_ROOT_CWD . $f); |
|
| 122 | + global $dossier_squelettes; |
|
| 123 | + include_once(_ROOT_CWD . $f); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -151,85 +151,85 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | function autoriser_dist(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
| 153 | 153 | |
| 154 | - if ($type === null) { |
|
| 155 | - $type = ''; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - // Qui ? visiteur_session ? |
|
| 159 | - // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 160 | - if ($qui === null or $qui === '') { |
|
| 161 | - $qui = $GLOBALS['visiteur_session'] ?: []; |
|
| 162 | - $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 163 | - } elseif (is_numeric($qui)) { |
|
| 164 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 165 | - if (!$qui) { |
|
| 166 | - return false; |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - // Admins restreints, on construit ici (pas generique mais...) |
|
| 171 | - // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 172 | - if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 173 | - $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : []; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - spip_log( |
|
| 177 | - "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?', |
|
| 178 | - 'autoriser' . _LOG_DEBUG |
|
| 179 | - ); |
|
| 180 | - |
|
| 181 | - // passer par objet_type pour avoir les alias |
|
| 182 | - // sauf si _ est le premier caractère. |
|
| 183 | - if ($type and $type[0] !== '_') { |
|
| 184 | - $type = objet_type($type, false); |
|
| 185 | - } |
|
| 186 | - // et supprimer les _ |
|
| 187 | - $type = str_replace('_', '', (string) $type); |
|
| 188 | - |
|
| 189 | - // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 190 | - if ( |
|
| 191 | - (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 192 | - or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 193 | - ) { |
|
| 194 | - spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 195 | - return true; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - // Chercher une fonction d'autorisation |
|
| 199 | - // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 200 | - // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 201 | - $fonctions = $type |
|
| 202 | - ? [ |
|
| 203 | - 'autoriser_' . $type . '_' . $faire, |
|
| 204 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 205 | - 'autoriser_' . $type, |
|
| 206 | - 'autoriser_' . $type . '_dist', |
|
| 207 | - 'autoriser_' . $faire, |
|
| 208 | - 'autoriser_' . $faire . '_dist', |
|
| 209 | - 'autoriser_defaut', |
|
| 210 | - 'autoriser_defaut_dist' |
|
| 211 | - ] |
|
| 212 | - : [ |
|
| 213 | - 'autoriser_' . $faire, |
|
| 214 | - 'autoriser_' . $faire . '_dist', |
|
| 215 | - 'autoriser_defaut', |
|
| 216 | - 'autoriser_defaut_dist' |
|
| 217 | - ]; |
|
| 218 | - |
|
| 219 | - $a = false; |
|
| 220 | - foreach ($fonctions as $f) { |
|
| 221 | - if (function_exists($f)) { |
|
| 222 | - $a = $f($faire, $type, $id, $qui, $opt); |
|
| 223 | - break; |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - spip_log( |
|
| 228 | - "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 229 | - 'autoriser' . _LOG_DEBUG |
|
| 230 | - ); |
|
| 231 | - |
|
| 232 | - return $a; |
|
| 154 | + if ($type === null) { |
|
| 155 | + $type = ''; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + // Qui ? visiteur_session ? |
|
| 159 | + // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 160 | + if ($qui === null or $qui === '') { |
|
| 161 | + $qui = $GLOBALS['visiteur_session'] ?: []; |
|
| 162 | + $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 163 | + } elseif (is_numeric($qui)) { |
|
| 164 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 165 | + if (!$qui) { |
|
| 166 | + return false; |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + // Admins restreints, on construit ici (pas generique mais...) |
|
| 171 | + // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 172 | + if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 173 | + $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : []; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + spip_log( |
|
| 177 | + "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?', |
|
| 178 | + 'autoriser' . _LOG_DEBUG |
|
| 179 | + ); |
|
| 180 | + |
|
| 181 | + // passer par objet_type pour avoir les alias |
|
| 182 | + // sauf si _ est le premier caractère. |
|
| 183 | + if ($type and $type[0] !== '_') { |
|
| 184 | + $type = objet_type($type, false); |
|
| 185 | + } |
|
| 186 | + // et supprimer les _ |
|
| 187 | + $type = str_replace('_', '', (string) $type); |
|
| 188 | + |
|
| 189 | + // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 190 | + if ( |
|
| 191 | + (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 192 | + or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 193 | + ) { |
|
| 194 | + spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 195 | + return true; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + // Chercher une fonction d'autorisation |
|
| 199 | + // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 200 | + // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 201 | + $fonctions = $type |
|
| 202 | + ? [ |
|
| 203 | + 'autoriser_' . $type . '_' . $faire, |
|
| 204 | + 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 205 | + 'autoriser_' . $type, |
|
| 206 | + 'autoriser_' . $type . '_dist', |
|
| 207 | + 'autoriser_' . $faire, |
|
| 208 | + 'autoriser_' . $faire . '_dist', |
|
| 209 | + 'autoriser_defaut', |
|
| 210 | + 'autoriser_defaut_dist' |
|
| 211 | + ] |
|
| 212 | + : [ |
|
| 213 | + 'autoriser_' . $faire, |
|
| 214 | + 'autoriser_' . $faire . '_dist', |
|
| 215 | + 'autoriser_defaut', |
|
| 216 | + 'autoriser_defaut_dist' |
|
| 217 | + ]; |
|
| 218 | + |
|
| 219 | + $a = false; |
|
| 220 | + foreach ($fonctions as $f) { |
|
| 221 | + if (function_exists($f)) { |
|
| 222 | + $a = $f($faire, $type, $id, $qui, $opt); |
|
| 223 | + break; |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + spip_log( |
|
| 228 | + "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 229 | + 'autoriser' . _LOG_DEBUG |
|
| 230 | + ); |
|
| 231 | + |
|
| 232 | + return $a; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | // une globale pour aller au plus vite dans la fonction generique ci dessus |
@@ -249,33 +249,33 @@ discard block |
||
| 249 | 249 | * @return bool |
| 250 | 250 | */ |
| 251 | 251 | function autoriser_exception(string $faire, ?string $type = '', $id = null, $autoriser = true): bool { |
| 252 | - // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 253 | - static $autorisation; |
|
| 254 | - // Tolérance avec certains appels |
|
| 255 | - if ($type === null) { |
|
| 256 | - $type = ''; |
|
| 257 | - } |
|
| 258 | - if ($id === null) { |
|
| 259 | - $id = 0; |
|
| 260 | - } |
|
| 261 | - if ($autoriser === 'verifier') { |
|
| 262 | - return isset($autorisation[$faire][$type][$id]); |
|
| 263 | - } |
|
| 264 | - if ($autoriser === true) { |
|
| 265 | - $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 266 | - } |
|
| 267 | - if ($autoriser === false) { |
|
| 268 | - if ($id === '*') { |
|
| 269 | - unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 270 | - unset($autorisation[$faire][$type]); |
|
| 271 | - } |
|
| 272 | - else { |
|
| 273 | - unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 274 | - unset($autorisation[$faire][$type][$id]); |
|
| 275 | - } |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - return false; |
|
| 252 | + // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 253 | + static $autorisation; |
|
| 254 | + // Tolérance avec certains appels |
|
| 255 | + if ($type === null) { |
|
| 256 | + $type = ''; |
|
| 257 | + } |
|
| 258 | + if ($id === null) { |
|
| 259 | + $id = 0; |
|
| 260 | + } |
|
| 261 | + if ($autoriser === 'verifier') { |
|
| 262 | + return isset($autorisation[$faire][$type][$id]); |
|
| 263 | + } |
|
| 264 | + if ($autoriser === true) { |
|
| 265 | + $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 266 | + } |
|
| 267 | + if ($autoriser === false) { |
|
| 268 | + if ($id === '*') { |
|
| 269 | + unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 270 | + unset($autorisation[$faire][$type]); |
|
| 271 | + } |
|
| 272 | + else { |
|
| 273 | + unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 274 | + unset($autorisation[$faire][$type][$id]); |
|
| 275 | + } |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + return false; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -294,9 +294,9 @@ discard block |
||
| 294 | 294 | * @return bool true s'il a le droit, false sinon |
| 295 | 295 | **/ |
| 296 | 296 | function autoriser_defaut_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 297 | - return |
|
| 298 | - $qui['statut'] === '0minirezo' |
|
| 299 | - and !$qui['restreint']; |
|
| 297 | + return |
|
| 298 | + $qui['statut'] === '0minirezo' |
|
| 299 | + and !$qui['restreint']; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | * @return bool true s'il a le droit, false sinon |
| 317 | 317 | */ |
| 318 | 318 | function autoriser_loger_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 319 | - if ($qui['statut'] === '5poubelle') { |
|
| 320 | - return false; |
|
| 321 | - } |
|
| 322 | - return true; |
|
| 319 | + if ($qui['statut'] === '5poubelle') { |
|
| 320 | + return false; |
|
| 321 | + } |
|
| 322 | + return true; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @return bool true s'il a le droit, false sinon |
| 336 | 336 | **/ |
| 337 | 337 | function autoriser_ecrire_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 338 | - return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 338 | + return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @return bool true s'il a le droit, false sinon |
| 355 | 355 | **/ |
| 356 | 356 | function autoriser_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 357 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 357 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -374,18 +374,18 @@ discard block |
||
| 374 | 374 | **/ |
| 375 | 375 | function autoriser_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 376 | 376 | |
| 377 | - // Le visiteur a-t-il un statut prevu par la config ? |
|
| 378 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 379 | - return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 380 | - } |
|
| 377 | + // Le visiteur a-t-il un statut prevu par la config ? |
|
| 378 | + if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 379 | + return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | - // A-t-on un token de prévisualisation valable ? |
|
| 383 | - include_spip('inc/securiser_action'); |
|
| 384 | - if (decrire_token_previsu()) { |
|
| 385 | - return true; |
|
| 386 | - } |
|
| 382 | + // A-t-on un token de prévisualisation valable ? |
|
| 383 | + include_spip('inc/securiser_action'); |
|
| 384 | + if (decrire_token_previsu()) { |
|
| 385 | + return true; |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - return false; |
|
| 388 | + return false; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
@@ -414,58 +414,58 @@ discard block |
||
| 414 | 414 | */ |
| 415 | 415 | function test_previsualiser_objet_champ(string $type = '', $id = null, array $qui = [], array $opt = []): bool { |
| 416 | 416 | |
| 417 | - // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 418 | - if (!$type) { |
|
| 419 | - return true; |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - include_spip('base/objets'); |
|
| 423 | - $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 424 | - if (isset($infos['statut'])) { |
|
| 425 | - foreach ($infos['statut'] as $c) { |
|
| 426 | - if (isset($c['publie'])) { |
|
| 427 | - if (!isset($c['previsu'])) { |
|
| 428 | - return false; |
|
| 429 | - } // pas de previsu definie => NIET |
|
| 430 | - $champ = $c['champ']; |
|
| 431 | - if (!isset($opt[$champ])) { |
|
| 432 | - return false; |
|
| 433 | - } // pas de champ passe a la demande => NIET |
|
| 434 | - $previsu = explode(',', $c['previsu']); |
|
| 435 | - // regarder si ce statut est autorise pour l'auteur |
|
| 436 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 437 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 438 | - // sinon l’auteur en session |
|
| 439 | - include_spip('inc/securiser_action'); |
|
| 440 | - if ($desc = decrire_token_previsu()) { |
|
| 441 | - $id_auteur = $desc['id_auteur']; |
|
| 442 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 443 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 444 | - } else { |
|
| 445 | - $id_auteur = null; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - if (!$id_auteur) { |
|
| 449 | - return false; |
|
| 450 | - } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 451 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 452 | - } elseif ( |
|
| 453 | - !sql_countsel( |
|
| 454 | - 'spip_auteurs_liens', |
|
| 455 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 456 | - ) |
|
| 457 | - ) { |
|
| 458 | - return false; |
|
| 459 | - } // pas auteur de cet objet => NIET |
|
| 460 | - } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 461 | - // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 462 | - return false; |
|
| 463 | - } |
|
| 464 | - } |
|
| 465 | - } |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - return true; |
|
| 417 | + // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 418 | + if (!$type) { |
|
| 419 | + return true; |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + include_spip('base/objets'); |
|
| 423 | + $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 424 | + if (isset($infos['statut'])) { |
|
| 425 | + foreach ($infos['statut'] as $c) { |
|
| 426 | + if (isset($c['publie'])) { |
|
| 427 | + if (!isset($c['previsu'])) { |
|
| 428 | + return false; |
|
| 429 | + } // pas de previsu definie => NIET |
|
| 430 | + $champ = $c['champ']; |
|
| 431 | + if (!isset($opt[$champ])) { |
|
| 432 | + return false; |
|
| 433 | + } // pas de champ passe a la demande => NIET |
|
| 434 | + $previsu = explode(',', $c['previsu']); |
|
| 435 | + // regarder si ce statut est autorise pour l'auteur |
|
| 436 | + if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 437 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 438 | + // sinon l’auteur en session |
|
| 439 | + include_spip('inc/securiser_action'); |
|
| 440 | + if ($desc = decrire_token_previsu()) { |
|
| 441 | + $id_auteur = $desc['id_auteur']; |
|
| 442 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 443 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 444 | + } else { |
|
| 445 | + $id_auteur = null; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + if (!$id_auteur) { |
|
| 449 | + return false; |
|
| 450 | + } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 451 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 452 | + } elseif ( |
|
| 453 | + !sql_countsel( |
|
| 454 | + 'spip_auteurs_liens', |
|
| 455 | + 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 456 | + ) |
|
| 457 | + ) { |
|
| 458 | + return false; |
|
| 459 | + } // pas auteur de cet objet => NIET |
|
| 460 | + } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 461 | + // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 462 | + return false; |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + return true; |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -481,51 +481,51 @@ discard block |
||
| 481 | 481 | * @return bool true s'il a le droit, false sinon |
| 482 | 482 | **/ |
| 483 | 483 | function autoriser_changerlangue_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 484 | - $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 485 | - $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 486 | - $table = table_objet_sql($type); |
|
| 487 | - if ( |
|
| 488 | - in_array($table, $multi_objets) |
|
| 489 | - or in_array($table, $gerer_trad_objets) |
|
| 490 | - ) { // affichage du formulaire si la configuration l'accepte |
|
| 491 | - $multi_secteurs = lire_config('multi_secteurs'); |
|
| 492 | - $champs = objet_info($type, 'field'); |
|
| 493 | - if ( |
|
| 494 | - $multi_secteurs === 'oui' |
|
| 495 | - and array_key_exists('id_rubrique', $champs) |
|
| 496 | - ) { |
|
| 497 | - // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 498 | - $primary = id_table_objet($type); |
|
| 499 | - if ($table != 'spip_rubriques') { |
|
| 500 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 501 | - } else { |
|
| 502 | - $id_rubrique = $id; |
|
| 503 | - } |
|
| 504 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 505 | - if (!$id_secteur > 0) { |
|
| 506 | - $id_secteur = $id_rubrique; |
|
| 507 | - } |
|
| 508 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 509 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 510 | - if ($langue_secteur != $langue_objet) { |
|
| 511 | - // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 512 | - return true; |
|
| 513 | - } |
|
| 514 | - if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 515 | - return false; |
|
| 516 | - } else { |
|
| 517 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 518 | - if ($id_parent != 0) { |
|
| 519 | - // sous-rubriques : pas de choix de langue |
|
| 520 | - return false; |
|
| 521 | - } |
|
| 522 | - } |
|
| 523 | - } |
|
| 524 | - } else { |
|
| 525 | - return false; |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 484 | + $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 485 | + $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 486 | + $table = table_objet_sql($type); |
|
| 487 | + if ( |
|
| 488 | + in_array($table, $multi_objets) |
|
| 489 | + or in_array($table, $gerer_trad_objets) |
|
| 490 | + ) { // affichage du formulaire si la configuration l'accepte |
|
| 491 | + $multi_secteurs = lire_config('multi_secteurs'); |
|
| 492 | + $champs = objet_info($type, 'field'); |
|
| 493 | + if ( |
|
| 494 | + $multi_secteurs === 'oui' |
|
| 495 | + and array_key_exists('id_rubrique', $champs) |
|
| 496 | + ) { |
|
| 497 | + // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 498 | + $primary = id_table_objet($type); |
|
| 499 | + if ($table != 'spip_rubriques') { |
|
| 500 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 501 | + } else { |
|
| 502 | + $id_rubrique = $id; |
|
| 503 | + } |
|
| 504 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 505 | + if (!$id_secteur > 0) { |
|
| 506 | + $id_secteur = $id_rubrique; |
|
| 507 | + } |
|
| 508 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 509 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 510 | + if ($langue_secteur != $langue_objet) { |
|
| 511 | + // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 512 | + return true; |
|
| 513 | + } |
|
| 514 | + if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 515 | + return false; |
|
| 516 | + } else { |
|
| 517 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 518 | + if ($id_parent != 0) { |
|
| 519 | + // sous-rubriques : pas de choix de langue |
|
| 520 | + return false; |
|
| 521 | + } |
|
| 522 | + } |
|
| 523 | + } |
|
| 524 | + } else { |
|
| 525 | + return false; |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | * @return bool true s'il a le droit, false sinon |
| 542 | 542 | **/ |
| 543 | 543 | function autoriser_changertraduction_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 544 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 544 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -557,41 +557,41 @@ discard block |
||
| 557 | 557 | * @return bool true s'il a le droit, false sinon |
| 558 | 558 | **/ |
| 559 | 559 | function autoriser_dater_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 560 | - $table = table_objet($type); |
|
| 561 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 562 | - $desc = $trouver_table($table); |
|
| 563 | - if (!$desc) { |
|
| 564 | - return false; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - if (!isset($opt['statut'])) { |
|
| 568 | - if (isset($desc['field']['statut'])) { |
|
| 569 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 570 | - } else { |
|
| 571 | - $statut = 'publie'; |
|
| 572 | - } // pas de statut => publie |
|
| 573 | - } else { |
|
| 574 | - $statut = $opt['statut']; |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - // Liste des statuts publiés pour cet objet |
|
| 578 | - if (isset($desc['statut'][0]['publie'])) { |
|
| 579 | - $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 580 | - } |
|
| 581 | - // Sinon en dur le statut "publie" |
|
| 582 | - else { |
|
| 583 | - $statuts_publies = ['publie']; |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - if ( |
|
| 587 | - in_array($statut, $statuts_publies) |
|
| 588 | - // Ou cas particulier géré en dur ici pour les articles |
|
| 589 | - or ($statut === 'prop' and $type === 'article' and $GLOBALS['meta']['post_dates'] === 'non') |
|
| 590 | - ) { |
|
| 591 | - return autoriser('modifier', $type, $id); |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - return false; |
|
| 560 | + $table = table_objet($type); |
|
| 561 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 562 | + $desc = $trouver_table($table); |
|
| 563 | + if (!$desc) { |
|
| 564 | + return false; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + if (!isset($opt['statut'])) { |
|
| 568 | + if (isset($desc['field']['statut'])) { |
|
| 569 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 570 | + } else { |
|
| 571 | + $statut = 'publie'; |
|
| 572 | + } // pas de statut => publie |
|
| 573 | + } else { |
|
| 574 | + $statut = $opt['statut']; |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + // Liste des statuts publiés pour cet objet |
|
| 578 | + if (isset($desc['statut'][0]['publie'])) { |
|
| 579 | + $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 580 | + } |
|
| 581 | + // Sinon en dur le statut "publie" |
|
| 582 | + else { |
|
| 583 | + $statuts_publies = ['publie']; |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + if ( |
|
| 587 | + in_array($statut, $statuts_publies) |
|
| 588 | + // Ou cas particulier géré en dur ici pour les articles |
|
| 589 | + or ($statut === 'prop' and $type === 'article' and $GLOBALS['meta']['post_dates'] === 'non') |
|
| 590 | + ) { |
|
| 591 | + return autoriser('modifier', $type, $id); |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + return false; |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | /** |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * @return bool true s'il a le droit, false sinon |
| 611 | 611 | **/ |
| 612 | 612 | function autoriser_instituer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 613 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 613 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | /** |
@@ -628,12 +628,12 @@ discard block |
||
| 628 | 628 | * @return bool true s'il a le droit, false sinon |
| 629 | 629 | **/ |
| 630 | 630 | function autoriser_rubrique_publierdans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 631 | - return |
|
| 632 | - ($qui['statut'] === '0minirezo') |
|
| 633 | - and ( |
|
| 634 | - !$qui['restreint'] or !$id |
|
| 635 | - or in_array($id, $qui['restreint']) |
|
| 636 | - ); |
|
| 631 | + return |
|
| 632 | + ($qui['statut'] === '0minirezo') |
|
| 633 | + and ( |
|
| 634 | + !$qui['restreint'] or !$id |
|
| 635 | + or in_array($id, $qui['restreint']) |
|
| 636 | + ); |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | /** |
@@ -651,12 +651,12 @@ discard block |
||
| 651 | 651 | * @return bool true s'il a le droit, false sinon |
| 652 | 652 | **/ |
| 653 | 653 | function autoriser_rubrique_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 654 | - if (!empty($opt['id_parent'])) { |
|
| 655 | - return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 656 | - } |
|
| 657 | - else { |
|
| 658 | - return autoriser('defaut', null, 0, $qui, $opt); |
|
| 659 | - } |
|
| 654 | + if (!empty($opt['id_parent'])) { |
|
| 655 | + return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 656 | + } |
|
| 657 | + else { |
|
| 658 | + return autoriser('defaut', null, 0, $qui, $opt); |
|
| 659 | + } |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | /** |
@@ -674,10 +674,10 @@ discard block |
||
| 674 | 674 | * @return bool true s'il a le droit, false sinon |
| 675 | 675 | **/ |
| 676 | 676 | function autoriser_rubrique_creerrubriquedans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 677 | - return |
|
| 678 | - ($id or ($qui['statut'] === '0minirezo' and !$qui['restreint'])) |
|
| 679 | - and autoriser('voir', 'rubrique', $id) |
|
| 680 | - and autoriser('publierdans', 'rubrique', $id); |
|
| 677 | + return |
|
| 678 | + ($id or ($qui['statut'] === '0minirezo' and !$qui['restreint'])) |
|
| 679 | + and autoriser('voir', 'rubrique', $id) |
|
| 680 | + and autoriser('publierdans', 'rubrique', $id); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -695,10 +695,10 @@ discard block |
||
| 695 | 695 | * @return bool true s'il a le droit, false sinon |
| 696 | 696 | **/ |
| 697 | 697 | function autoriser_rubrique_creerarticledans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 698 | - return |
|
| 699 | - $id |
|
| 700 | - and autoriser('voir', 'rubrique', $id) |
|
| 701 | - and autoriser('creer', 'article'); |
|
| 698 | + return |
|
| 699 | + $id |
|
| 700 | + and autoriser('voir', 'rubrique', $id) |
|
| 701 | + and autoriser('creer', 'article'); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | |
@@ -717,8 +717,8 @@ discard block |
||
| 717 | 717 | * @return bool true s'il a le droit, false sinon |
| 718 | 718 | **/ |
| 719 | 719 | function autoriser_rubrique_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 720 | - return |
|
| 721 | - autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 720 | + return |
|
| 721 | + autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | /** |
@@ -736,29 +736,29 @@ discard block |
||
| 736 | 736 | * @return bool true s'il a le droit, false sinon |
| 737 | 737 | **/ |
| 738 | 738 | function autoriser_rubrique_supprimer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 739 | - if (!$id = intval($id)) { |
|
| 740 | - return false; |
|
| 741 | - } |
|
| 739 | + if (!$id = intval($id)) { |
|
| 740 | + return false; |
|
| 741 | + } |
|
| 742 | 742 | |
| 743 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 744 | - return false; |
|
| 745 | - } |
|
| 743 | + if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 744 | + return false; |
|
| 745 | + } |
|
| 746 | 746 | |
| 747 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 748 | - return false; |
|
| 749 | - } |
|
| 747 | + if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 748 | + return false; |
|
| 749 | + } |
|
| 750 | 750 | |
| 751 | - $compte = pipeline( |
|
| 752 | - 'objet_compte_enfants', |
|
| 753 | - ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 754 | - ); |
|
| 755 | - foreach ($compte as $objet => $n) { |
|
| 756 | - if ($n) { |
|
| 757 | - return false; |
|
| 758 | - } |
|
| 759 | - } |
|
| 751 | + $compte = pipeline( |
|
| 752 | + 'objet_compte_enfants', |
|
| 753 | + ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 754 | + ); |
|
| 755 | + foreach ($compte as $objet => $n) { |
|
| 756 | + if ($n) { |
|
| 757 | + return false; |
|
| 758 | + } |
|
| 759 | + } |
|
| 760 | 760 | |
| 761 | - return autoriser('modifier', 'rubrique', $id); |
|
| 761 | + return autoriser('modifier', 'rubrique', $id); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | |
@@ -778,23 +778,23 @@ discard block |
||
| 778 | 778 | * @return bool true s'il a le droit, false sinon |
| 779 | 779 | **/ |
| 780 | 780 | function autoriser_article_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 781 | - if (!$id) { |
|
| 782 | - return false; |
|
| 783 | - } |
|
| 784 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 785 | - |
|
| 786 | - return |
|
| 787 | - $r |
|
| 788 | - and |
|
| 789 | - ( |
|
| 790 | - autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 791 | - or ( |
|
| 792 | - (!isset($opt['statut']) or !in_array($opt['statut'], ['publie', 'refuse'], true)) |
|
| 793 | - and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 794 | - and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 795 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 796 | - ) |
|
| 797 | - ); |
|
| 781 | + if (!$id) { |
|
| 782 | + return false; |
|
| 783 | + } |
|
| 784 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 785 | + |
|
| 786 | + return |
|
| 787 | + $r |
|
| 788 | + and |
|
| 789 | + ( |
|
| 790 | + autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 791 | + or ( |
|
| 792 | + (!isset($opt['statut']) or !in_array($opt['statut'], ['publie', 'refuse'], true)) |
|
| 793 | + and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 794 | + and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 795 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 796 | + ) |
|
| 797 | + ); |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | /** |
@@ -812,13 +812,13 @@ discard block |
||
| 812 | 812 | * @return bool true s'il a le droit, false sinon |
| 813 | 813 | **/ |
| 814 | 814 | function autoriser_article_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 815 | - if (!empty($opt['id_parent'])) { |
|
| 816 | - // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 817 | - return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 818 | - } |
|
| 819 | - else { |
|
| 820 | - return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 821 | - } |
|
| 815 | + if (!empty($opt['id_parent'])) { |
|
| 816 | + // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 817 | + return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 818 | + } |
|
| 819 | + else { |
|
| 820 | + return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 821 | + } |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
@@ -840,28 +840,28 @@ discard block |
||
| 840 | 840 | * @return bool true s'il a le droit, false sinon |
| 841 | 841 | */ |
| 842 | 842 | function autoriser_article_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 843 | - if ($qui['statut'] === '0minirezo') { |
|
| 844 | - return true; |
|
| 845 | - } |
|
| 846 | - // cas des articles : depend du statut de l'article et de l'auteur |
|
| 847 | - if (isset($opt['statut'])) { |
|
| 848 | - $statut = $opt['statut']; |
|
| 849 | - } else { |
|
| 850 | - if (!$id) { |
|
| 851 | - return false; |
|
| 852 | - } |
|
| 853 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 854 | - } |
|
| 855 | - |
|
| 856 | - return |
|
| 857 | - // si on est pas auteur de l'article, |
|
| 858 | - // seuls les propose et publies sont visibles |
|
| 859 | - in_array($statut, ['prop', 'publie']) |
|
| 860 | - // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 861 | - or |
|
| 862 | - ($id |
|
| 863 | - and $qui['id_auteur'] |
|
| 864 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 843 | + if ($qui['statut'] === '0minirezo') { |
|
| 844 | + return true; |
|
| 845 | + } |
|
| 846 | + // cas des articles : depend du statut de l'article et de l'auteur |
|
| 847 | + if (isset($opt['statut'])) { |
|
| 848 | + $statut = $opt['statut']; |
|
| 849 | + } else { |
|
| 850 | + if (!$id) { |
|
| 851 | + return false; |
|
| 852 | + } |
|
| 853 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + return |
|
| 857 | + // si on est pas auteur de l'article, |
|
| 858 | + // seuls les propose et publies sont visibles |
|
| 859 | + in_array($statut, ['prop', 'publie']) |
|
| 860 | + // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 861 | + or |
|
| 862 | + ($id |
|
| 863 | + and $qui['id_auteur'] |
|
| 864 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | |
@@ -880,24 +880,24 @@ discard block |
||
| 880 | 880 | * @return bool true s'il a le droit, false sinon |
| 881 | 881 | **/ |
| 882 | 882 | function autoriser_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 883 | - # securite, mais on aurait pas du arriver ici ! |
|
| 884 | - if ( |
|
| 885 | - function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 886 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 887 | - ) { |
|
| 888 | - return $f($faire, $type, $id, $qui, $opt); |
|
| 889 | - } |
|
| 883 | + # securite, mais on aurait pas du arriver ici ! |
|
| 884 | + if ( |
|
| 885 | + function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 886 | + or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 887 | + ) { |
|
| 888 | + return $f($faire, $type, $id, $qui, $opt); |
|
| 889 | + } |
|
| 890 | 890 | |
| 891 | - if ($qui['statut'] === '0minirezo') { |
|
| 892 | - return true; |
|
| 893 | - } |
|
| 894 | - // admins et redacteurs peuvent voir un auteur |
|
| 895 | - if ($type === 'auteur') { |
|
| 896 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 897 | - } |
|
| 898 | - // sinon par defaut tout est visible |
|
| 899 | - // sauf cas particuliers traites separemment (ie article) |
|
| 900 | - return true; |
|
| 891 | + if ($qui['statut'] === '0minirezo') { |
|
| 892 | + return true; |
|
| 893 | + } |
|
| 894 | + // admins et redacteurs peuvent voir un auteur |
|
| 895 | + if ($type === 'auteur') { |
|
| 896 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 897 | + } |
|
| 898 | + // sinon par defaut tout est visible |
|
| 899 | + // sauf cas particuliers traites separemment (ie article) |
|
| 900 | + return true; |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | |
@@ -920,12 +920,12 @@ discard block |
||
| 920 | 920 | * @return bool true s'il a le droit, false sinon |
| 921 | 921 | **/ |
| 922 | 922 | function autoriser_webmestre_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 923 | - return |
|
| 924 | - (defined('_ID_WEBMESTRES') ? |
|
| 925 | - in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 926 | - : $qui['webmestre'] === 'oui') |
|
| 927 | - and $qui['statut'] === '0minirezo' |
|
| 928 | - and !$qui['restreint']; |
|
| 923 | + return |
|
| 924 | + (defined('_ID_WEBMESTRES') ? |
|
| 925 | + in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 926 | + : $qui['webmestre'] === 'oui') |
|
| 927 | + and $qui['statut'] === '0minirezo' |
|
| 928 | + and !$qui['restreint']; |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | /** |
@@ -943,9 +943,9 @@ discard block |
||
| 943 | 943 | * @return bool true s'il a le droit, false sinon |
| 944 | 944 | **/ |
| 945 | 945 | function autoriser_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 946 | - return |
|
| 947 | - $qui['statut'] === '0minirezo' |
|
| 948 | - and !$qui['restreint']; |
|
| 946 | + return |
|
| 947 | + $qui['statut'] === '0minirezo' |
|
| 948 | + and !$qui['restreint']; |
|
| 949 | 949 | } |
| 950 | 950 | |
| 951 | 951 | /** |
@@ -963,8 +963,8 @@ discard block |
||
| 963 | 963 | * @return bool true s'il a le droit, false sinon |
| 964 | 964 | **/ |
| 965 | 965 | function autoriser_sauvegarder_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 966 | - return |
|
| 967 | - $qui['statut'] === '0minirezo'; |
|
| 966 | + return |
|
| 967 | + $qui['statut'] === '0minirezo'; |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | /** |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | * @return bool true s'il a le droit, false sinon |
| 983 | 983 | **/ |
| 984 | 984 | function autoriser_detruire_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 985 | - return autoriser('webmestre', null, 0, $qui, $opt); |
|
| 985 | + return autoriser('webmestre', null, 0, $qui, $opt); |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | /** |
@@ -1001,23 +1001,23 @@ discard block |
||
| 1001 | 1001 | * @return bool true s'il a le droit, false sinon |
| 1002 | 1002 | **/ |
| 1003 | 1003 | function autoriser_auteur_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1004 | - // les admins peuvent "previsualiser" une page auteur |
|
| 1005 | - if ( |
|
| 1006 | - $qui['statut'] === '0minirezo' |
|
| 1007 | - and !$qui['restreint'] |
|
| 1008 | - ) { |
|
| 1009 | - return true; |
|
| 1010 | - } elseif ($id === 0) { |
|
| 1011 | - return false; |
|
| 1012 | - } |
|
| 1013 | - // "Voir en ligne" si l'auteur a un article publie |
|
| 1014 | - $n = sql_fetsel( |
|
| 1015 | - 'A.id_article', |
|
| 1016 | - 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 1017 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1018 | - ); |
|
| 1004 | + // les admins peuvent "previsualiser" une page auteur |
|
| 1005 | + if ( |
|
| 1006 | + $qui['statut'] === '0minirezo' |
|
| 1007 | + and !$qui['restreint'] |
|
| 1008 | + ) { |
|
| 1009 | + return true; |
|
| 1010 | + } elseif ($id === 0) { |
|
| 1011 | + return false; |
|
| 1012 | + } |
|
| 1013 | + // "Voir en ligne" si l'auteur a un article publie |
|
| 1014 | + $n = sql_fetsel( |
|
| 1015 | + 'A.id_article', |
|
| 1016 | + 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 1017 | + "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1018 | + ); |
|
| 1019 | 1019 | |
| 1020 | - return $n ? true : false; |
|
| 1020 | + return $n ? true : false; |
|
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | * @return bool true s'il a le droit, false sinon |
| 1047 | 1047 | **/ |
| 1048 | 1048 | function autoriser_auteur_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1049 | - return ($qui['statut'] === '0minirezo'); |
|
| 1049 | + return ($qui['statut'] === '0minirezo'); |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | |
@@ -1067,75 +1067,75 @@ discard block |
||
| 1067 | 1067 | * @return bool true s'il a le droit, false sinon |
| 1068 | 1068 | **/ |
| 1069 | 1069 | function autoriser_auteur_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1070 | - $id = intval($id); |
|
| 1071 | - |
|
| 1072 | - // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 1073 | - // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 1074 | - if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 1075 | - if ( |
|
| 1076 | - $id == $qui['id_auteur'] |
|
| 1077 | - && empty($opt['statut']) |
|
| 1078 | - && empty($opt['webmestre']) |
|
| 1079 | - && empty($opt['restreintes']) |
|
| 1080 | - && empty($opt['login']) |
|
| 1081 | - ) { |
|
| 1082 | - return true; |
|
| 1083 | - } |
|
| 1084 | - return false; |
|
| 1085 | - } |
|
| 1086 | - |
|
| 1087 | - // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 1088 | - // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1089 | - if ($qui['restreint']) { |
|
| 1090 | - if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1091 | - return false; |
|
| 1092 | - } elseif ( |
|
| 1093 | - (isset($opt['statut']) and ($opt['statut'] === '0minirezo')) |
|
| 1094 | - or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1095 | - ) { |
|
| 1096 | - return false; |
|
| 1097 | - } else { |
|
| 1098 | - if ($id == $qui['id_auteur']) { |
|
| 1099 | - if (isset($opt['statut']) and $opt['statut']) { |
|
| 1100 | - return false; |
|
| 1101 | - } else { |
|
| 1102 | - return true; |
|
| 1103 | - } |
|
| 1104 | - } else { |
|
| 1105 | - if ($id_auteur = intval($id)) { |
|
| 1106 | - $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1107 | - if ($t and $t['statut'] != '0minirezo') { |
|
| 1108 | - return true; |
|
| 1109 | - } else { |
|
| 1110 | - return false; |
|
| 1111 | - } |
|
| 1112 | - } // id = 0 => creation |
|
| 1113 | - else { |
|
| 1114 | - return true; |
|
| 1115 | - } |
|
| 1116 | - } |
|
| 1117 | - } |
|
| 1118 | - } |
|
| 1119 | - |
|
| 1120 | - // Un admin complet fait ce qu'il veut |
|
| 1121 | - // sauf se degrader |
|
| 1122 | - if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1123 | - return false; |
|
| 1124 | - } elseif ( |
|
| 1125 | - isset($opt['webmestre']) |
|
| 1126 | - and $opt['webmestre'] |
|
| 1127 | - and (defined('_ID_WEBMESTRES') |
|
| 1128 | - or !autoriser('webmestre')) |
|
| 1129 | - ) { |
|
| 1130 | - // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1131 | - // ou si les webmestres sont fixes par constante (securite) |
|
| 1132 | - return false; |
|
| 1133 | - } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1134 | - elseif (intval($id) and !autoriser('webmestre') and autoriser('webmestre', '', 0, $id)) { |
|
| 1135 | - return false; |
|
| 1136 | - } else { |
|
| 1137 | - return true; |
|
| 1138 | - } |
|
| 1070 | + $id = intval($id); |
|
| 1071 | + |
|
| 1072 | + // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 1073 | + // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 1074 | + if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 1075 | + if ( |
|
| 1076 | + $id == $qui['id_auteur'] |
|
| 1077 | + && empty($opt['statut']) |
|
| 1078 | + && empty($opt['webmestre']) |
|
| 1079 | + && empty($opt['restreintes']) |
|
| 1080 | + && empty($opt['login']) |
|
| 1081 | + ) { |
|
| 1082 | + return true; |
|
| 1083 | + } |
|
| 1084 | + return false; |
|
| 1085 | + } |
|
| 1086 | + |
|
| 1087 | + // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 1088 | + // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1089 | + if ($qui['restreint']) { |
|
| 1090 | + if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1091 | + return false; |
|
| 1092 | + } elseif ( |
|
| 1093 | + (isset($opt['statut']) and ($opt['statut'] === '0minirezo')) |
|
| 1094 | + or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1095 | + ) { |
|
| 1096 | + return false; |
|
| 1097 | + } else { |
|
| 1098 | + if ($id == $qui['id_auteur']) { |
|
| 1099 | + if (isset($opt['statut']) and $opt['statut']) { |
|
| 1100 | + return false; |
|
| 1101 | + } else { |
|
| 1102 | + return true; |
|
| 1103 | + } |
|
| 1104 | + } else { |
|
| 1105 | + if ($id_auteur = intval($id)) { |
|
| 1106 | + $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1107 | + if ($t and $t['statut'] != '0minirezo') { |
|
| 1108 | + return true; |
|
| 1109 | + } else { |
|
| 1110 | + return false; |
|
| 1111 | + } |
|
| 1112 | + } // id = 0 => creation |
|
| 1113 | + else { |
|
| 1114 | + return true; |
|
| 1115 | + } |
|
| 1116 | + } |
|
| 1117 | + } |
|
| 1118 | + } |
|
| 1119 | + |
|
| 1120 | + // Un admin complet fait ce qu'il veut |
|
| 1121 | + // sauf se degrader |
|
| 1122 | + if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1123 | + return false; |
|
| 1124 | + } elseif ( |
|
| 1125 | + isset($opt['webmestre']) |
|
| 1126 | + and $opt['webmestre'] |
|
| 1127 | + and (defined('_ID_WEBMESTRES') |
|
| 1128 | + or !autoriser('webmestre')) |
|
| 1129 | + ) { |
|
| 1130 | + // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1131 | + // ou si les webmestres sont fixes par constante (securite) |
|
| 1132 | + return false; |
|
| 1133 | + } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1134 | + elseif (intval($id) and !autoriser('webmestre') and autoriser('webmestre', '', 0, $id)) { |
|
| 1135 | + return false; |
|
| 1136 | + } else { |
|
| 1137 | + return true; |
|
| 1138 | + } |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | |
@@ -1154,7 +1154,7 @@ discard block |
||
| 1154 | 1154 | * @return bool true s'il a le droit, false sinon |
| 1155 | 1155 | **/ |
| 1156 | 1156 | function autoriser_associerauteurs_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1157 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1157 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | |
@@ -1173,7 +1173,7 @@ discard block |
||
| 1173 | 1173 | * @return bool true s'il a le droit, false sinon |
| 1174 | 1174 | **/ |
| 1175 | 1175 | function autoriser_chargerftp_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1176 | - return $qui['statut'] === '0minirezo'; |
|
| 1176 | + return $qui['statut'] === '0minirezo'; |
|
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | /** |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | * @return bool true s'il a le droit, false sinon |
| 1192 | 1192 | **/ |
| 1193 | 1193 | function autoriser_debug_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1194 | - return $qui['statut'] === '0minirezo'; |
|
| 1194 | + return $qui['statut'] === '0minirezo'; |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | /** |
@@ -1208,54 +1208,54 @@ discard block |
||
| 1208 | 1208 | * @return array Liste des rubriques |
| 1209 | 1209 | **/ |
| 1210 | 1210 | function liste_rubriques_auteur($id_auteur, $raz = false) { |
| 1211 | - static $restreint = []; |
|
| 1212 | - |
|
| 1213 | - if (!$id_auteur = intval($id_auteur)) { |
|
| 1214 | - return []; |
|
| 1215 | - } |
|
| 1216 | - if ($raz) { |
|
| 1217 | - unset($restreint[$id_auteur]); |
|
| 1218 | - } elseif (isset($restreint[$id_auteur])) { |
|
| 1219 | - return $restreint[$id_auteur]; |
|
| 1220 | - } |
|
| 1221 | - |
|
| 1222 | - $rubriques = []; |
|
| 1223 | - if ( |
|
| 1224 | - (!isset($GLOBALS['meta']['version_installee']) |
|
| 1225 | - or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1226 | - and $r = sql_allfetsel( |
|
| 1227 | - 'id_objet', |
|
| 1228 | - 'spip_auteurs_liens', |
|
| 1229 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1230 | - ) |
|
| 1231 | - and is_countable($r) ? count($r) : 0 |
|
| 1232 | - ) { |
|
| 1233 | - $r = array_column($r, 'id_objet'); |
|
| 1234 | - |
|
| 1235 | - // recuperer toute la branche, au format chaine enumeration |
|
| 1236 | - include_spip('inc/rubriques'); |
|
| 1237 | - $r = calcul_branche_in($r); |
|
| 1238 | - $r = explode(',', $r); |
|
| 1239 | - |
|
| 1240 | - // passer les rubriques en index, elimine les doublons |
|
| 1241 | - $r = array_flip($r); |
|
| 1242 | - // recuperer les index seuls |
|
| 1243 | - $r = array_keys($r); |
|
| 1244 | - // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1245 | - // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1246 | - $rubriques = array_combine($r, $r); |
|
| 1247 | - } |
|
| 1248 | - |
|
| 1249 | - // Affecter l'auteur session le cas echeant |
|
| 1250 | - if ( |
|
| 1251 | - isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1252 | - and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1253 | - ) { |
|
| 1254 | - $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - |
|
| 1258 | - return $restreint[$id_auteur] = $rubriques; |
|
| 1211 | + static $restreint = []; |
|
| 1212 | + |
|
| 1213 | + if (!$id_auteur = intval($id_auteur)) { |
|
| 1214 | + return []; |
|
| 1215 | + } |
|
| 1216 | + if ($raz) { |
|
| 1217 | + unset($restreint[$id_auteur]); |
|
| 1218 | + } elseif (isset($restreint[$id_auteur])) { |
|
| 1219 | + return $restreint[$id_auteur]; |
|
| 1220 | + } |
|
| 1221 | + |
|
| 1222 | + $rubriques = []; |
|
| 1223 | + if ( |
|
| 1224 | + (!isset($GLOBALS['meta']['version_installee']) |
|
| 1225 | + or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1226 | + and $r = sql_allfetsel( |
|
| 1227 | + 'id_objet', |
|
| 1228 | + 'spip_auteurs_liens', |
|
| 1229 | + 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1230 | + ) |
|
| 1231 | + and is_countable($r) ? count($r) : 0 |
|
| 1232 | + ) { |
|
| 1233 | + $r = array_column($r, 'id_objet'); |
|
| 1234 | + |
|
| 1235 | + // recuperer toute la branche, au format chaine enumeration |
|
| 1236 | + include_spip('inc/rubriques'); |
|
| 1237 | + $r = calcul_branche_in($r); |
|
| 1238 | + $r = explode(',', $r); |
|
| 1239 | + |
|
| 1240 | + // passer les rubriques en index, elimine les doublons |
|
| 1241 | + $r = array_flip($r); |
|
| 1242 | + // recuperer les index seuls |
|
| 1243 | + $r = array_keys($r); |
|
| 1244 | + // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1245 | + // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1246 | + $rubriques = array_combine($r, $r); |
|
| 1247 | + } |
|
| 1248 | + |
|
| 1249 | + // Affecter l'auteur session le cas echeant |
|
| 1250 | + if ( |
|
| 1251 | + isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1252 | + and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1253 | + ) { |
|
| 1254 | + $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + |
|
| 1258 | + return $restreint[$id_auteur] = $rubriques; |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | /** |
@@ -1273,7 +1273,7 @@ discard block |
||
| 1273 | 1273 | * @return bool true s'il a le droit, false sinon |
| 1274 | 1274 | **/ |
| 1275 | 1275 | function autoriser_rubrique_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1276 | - return autoriser('previsualiser'); |
|
| 1276 | + return autoriser('previsualiser'); |
|
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | 1279 | /** |
@@ -1291,7 +1291,7 @@ discard block |
||
| 1291 | 1291 | * @return bool true s'il a le droit, false sinon |
| 1292 | 1292 | **/ |
| 1293 | 1293 | function autoriser_rubrique_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1294 | - return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1294 | + return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | /** |
@@ -1309,9 +1309,9 @@ discard block |
||
| 1309 | 1309 | * @return bool true s'il a le droit, false sinon |
| 1310 | 1310 | **/ |
| 1311 | 1311 | function autoriser_auteur_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1312 | - $id = intval($id); |
|
| 1313 | - return (($id == $qui['id_auteur']) or |
|
| 1314 | - (($qui['statut'] === '0minirezo') and !$qui['restreint'])); |
|
| 1312 | + $id = intval($id); |
|
| 1313 | + return (($id == $qui['id_auteur']) or |
|
| 1314 | + (($qui['statut'] === '0minirezo') and !$qui['restreint'])); |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | /** |
@@ -1329,8 +1329,8 @@ discard block |
||
| 1329 | 1329 | * @return bool true s'il a le droit, false sinon |
| 1330 | 1330 | **/ |
| 1331 | 1331 | function autoriser_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1332 | - // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1333 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1332 | + // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1333 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | |
@@ -1350,7 +1350,7 @@ discard block |
||
| 1350 | 1350 | * @return true |
| 1351 | 1351 | **/ |
| 1352 | 1352 | function autoriser_ok_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1353 | - return true; |
|
| 1353 | + return true; |
|
| 1354 | 1354 | } |
| 1355 | 1355 | |
| 1356 | 1356 | /** |
@@ -1369,7 +1369,7 @@ discard block |
||
| 1369 | 1369 | * @return false |
| 1370 | 1370 | **/ |
| 1371 | 1371 | function autoriser_niet_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1372 | - return false; |
|
| 1372 | + return false; |
|
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | /** |
@@ -1387,11 +1387,11 @@ discard block |
||
| 1387 | 1387 | * @return bool true s'il a le droit, false sinon |
| 1388 | 1388 | **/ |
| 1389 | 1389 | function autoriser_base_reparer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1390 | - if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1391 | - return false; |
|
| 1392 | - } |
|
| 1390 | + if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1391 | + return false; |
|
| 1392 | + } |
|
| 1393 | 1393 | |
| 1394 | - return true; |
|
| 1394 | + return true; |
|
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | /** |
@@ -1409,7 +1409,7 @@ discard block |
||
| 1409 | 1409 | * @return true |
| 1410 | 1410 | **/ |
| 1411 | 1411 | function autoriser_infosperso_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1412 | - return true; |
|
| 1412 | + return true; |
|
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | 1415 | /** |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | * @return true |
| 1428 | 1428 | **/ |
| 1429 | 1429 | function autoriser_langage_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1430 | - return true; |
|
| 1430 | + return true; |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | /** |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | * @return bool true s'il a le droit, false sinon |
| 1446 | 1446 | **/ |
| 1447 | 1447 | function autoriser_configurerlangage_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1448 | - return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1448 | + return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | 1451 | /** |
@@ -1463,7 +1463,7 @@ discard block |
||
| 1463 | 1463 | * @return true |
| 1464 | 1464 | **/ |
| 1465 | 1465 | function autoriser_preferences_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1466 | - return true; |
|
| 1466 | + return true; |
|
| 1467 | 1467 | } |
| 1468 | 1468 | |
| 1469 | 1469 | /** |
@@ -1481,7 +1481,7 @@ discard block |
||
| 1481 | 1481 | * @return bool true s'il a le droit, false sinon |
| 1482 | 1482 | **/ |
| 1483 | 1483 | function autoriser_configurerpreferences_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1484 | - return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1484 | + return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | /** |
@@ -1499,8 +1499,8 @@ discard block |
||
| 1499 | 1499 | * @return bool true s'il a le droit, false sinon |
| 1500 | 1500 | **/ |
| 1501 | 1501 | function autoriser_menudeveloppement_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1502 | - return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1503 | - and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui'); |
|
| 1502 | + return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1503 | + and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui'); |
|
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | 1506 | /** |
@@ -1519,7 +1519,7 @@ discard block |
||
| 1519 | 1519 | * @return true |
| 1520 | 1520 | **/ |
| 1521 | 1521 | function autoriser_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1522 | - return true; |
|
| 1522 | + return true; |
|
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | /** |
@@ -1537,7 +1537,7 @@ discard block |
||
| 1537 | 1537 | * @return true |
| 1538 | 1538 | **/ |
| 1539 | 1539 | function autoriser_auteurs_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1540 | - return true; |
|
| 1540 | + return true; |
|
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | 1543 | /** |
@@ -1555,7 +1555,7 @@ discard block |
||
| 1555 | 1555 | * @return bool true s'il a le droit, false sinon |
| 1556 | 1556 | **/ |
| 1557 | 1557 | function autoriser_auteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1558 | - return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1558 | + return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | 1561 | /** |
@@ -1573,7 +1573,7 @@ discard block |
||
| 1573 | 1573 | * @return true |
| 1574 | 1574 | **/ |
| 1575 | 1575 | function autoriser_articles_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1576 | - return true; |
|
| 1576 | + return true; |
|
| 1577 | 1577 | } |
| 1578 | 1578 | |
| 1579 | 1579 | /** |
@@ -1591,7 +1591,7 @@ discard block |
||
| 1591 | 1591 | * @return bool true s'il a le droit, false sinon |
| 1592 | 1592 | **/ |
| 1593 | 1593 | function autoriser_articles_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1594 | - return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1594 | + return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | /** |
@@ -1609,7 +1609,7 @@ discard block |
||
| 1609 | 1609 | * @return true |
| 1610 | 1610 | **/ |
| 1611 | 1611 | function autoriser_rubriques_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1612 | - return true; |
|
| 1612 | + return true; |
|
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | 1615 | /** |
@@ -1627,7 +1627,7 @@ discard block |
||
| 1627 | 1627 | * @return bool true s'il a le droit, false sinon |
| 1628 | 1628 | **/ |
| 1629 | 1629 | function autoriser_rubriques_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1630 | - return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1630 | + return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | 1633 | /** |
@@ -1645,7 +1645,7 @@ discard block |
||
| 1645 | 1645 | * @return bool true s'il a le droit, false sinon |
| 1646 | 1646 | **/ |
| 1647 | 1647 | function autoriser_articlecreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1648 | - return verifier_table_non_vide(); |
|
| 1648 | + return verifier_table_non_vide(); |
|
| 1649 | 1649 | } |
| 1650 | 1650 | |
| 1651 | 1651 | |
@@ -1666,7 +1666,7 @@ discard block |
||
| 1666 | 1666 | * @return bool true s'il a le droit, false sinon |
| 1667 | 1667 | **/ |
| 1668 | 1668 | function autoriser_auteurcreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1669 | - return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1669 | + return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1670 | 1670 | } |
| 1671 | 1671 | |
| 1672 | 1672 | /** |
@@ -1684,13 +1684,13 @@ discard block |
||
| 1684 | 1684 | * @return bool true s'il a le droit, false sinon |
| 1685 | 1685 | **/ |
| 1686 | 1686 | function autoriser_visiteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1687 | - include_spip('base/abstract_sql'); |
|
| 1688 | - return |
|
| 1689 | - $qui['statut'] === '0minirezo' and !$qui['restreint'] |
|
| 1690 | - and ( |
|
| 1691 | - $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1692 | - or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1693 | - ); |
|
| 1687 | + include_spip('base/abstract_sql'); |
|
| 1688 | + return |
|
| 1689 | + $qui['statut'] === '0minirezo' and !$qui['restreint'] |
|
| 1690 | + and ( |
|
| 1691 | + $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1692 | + or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1693 | + ); |
|
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | 1696 | /** |
@@ -1708,7 +1708,7 @@ discard block |
||
| 1708 | 1708 | * @return bool true s'il a le droit, false sinon |
| 1709 | 1709 | **/ |
| 1710 | 1710 | function autoriser_suiviedito_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1711 | - return $qui['statut'] === '0minirezo'; |
|
| 1711 | + return $qui['statut'] === '0minirezo'; |
|
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | 1714 | /** |
@@ -1726,7 +1726,7 @@ discard block |
||
| 1726 | 1726 | * @return bool true s'il a le droit, false sinon |
| 1727 | 1727 | **/ |
| 1728 | 1728 | function autoriser_synchro_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1729 | - return $qui['statut'] === '0minirezo'; |
|
| 1729 | + return $qui['statut'] === '0minirezo'; |
|
| 1730 | 1730 | } |
| 1731 | 1731 | |
| 1732 | 1732 | /** |
@@ -1744,7 +1744,7 @@ discard block |
||
| 1744 | 1744 | * @return bool true s'il a le droit, false sinon |
| 1745 | 1745 | **/ |
| 1746 | 1746 | function autoriser_configurerinteractions_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1747 | - return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1747 | + return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | 1750 | /** |
@@ -1762,7 +1762,7 @@ discard block |
||
| 1762 | 1762 | * @return bool true s'il a le droit, false sinon |
| 1763 | 1763 | **/ |
| 1764 | 1764 | function autoriser_configurerlangue_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1765 | - return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1765 | + return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | 1768 | /** |
@@ -1780,7 +1780,7 @@ discard block |
||
| 1780 | 1780 | * @return bool true s'il a le droit, false sinon |
| 1781 | 1781 | **/ |
| 1782 | 1782 | function autoriser_configurermultilinguisme_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1783 | - return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1783 | + return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1784 | 1784 | } |
| 1785 | 1785 | |
| 1786 | 1786 | /** |
@@ -1798,7 +1798,7 @@ discard block |
||
| 1798 | 1798 | * @return bool true s'il a le droit, false sinon |
| 1799 | 1799 | **/ |
| 1800 | 1800 | function autoriser_configurercontenu_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1801 | - return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1801 | + return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | 1804 | /** |
@@ -1816,7 +1816,7 @@ discard block |
||
| 1816 | 1816 | * @return bool true s'il a le droit, false sinon |
| 1817 | 1817 | **/ |
| 1818 | 1818 | function autoriser_configureravancees_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1819 | - return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1819 | + return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1820 | 1820 | } |
| 1821 | 1821 | |
| 1822 | 1822 | /** |
@@ -1834,7 +1834,7 @@ discard block |
||
| 1834 | 1834 | * @return bool true s'il a le droit, false sinon |
| 1835 | 1835 | **/ |
| 1836 | 1836 | function autoriser_adminplugin_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1837 | - return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1837 | + return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1838 | 1838 | } |
| 1839 | 1839 | |
| 1840 | 1840 | /** |
@@ -1852,7 +1852,7 @@ discard block |
||
| 1852 | 1852 | * @return bool true s'il a le droit, false sinon |
| 1853 | 1853 | **/ |
| 1854 | 1854 | function autoriser_admintech_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1855 | - return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1855 | + return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | 1858 | /** |
@@ -1870,7 +1870,7 @@ discard block |
||
| 1870 | 1870 | * @return bool true s'il a le droit, false sinon |
| 1871 | 1871 | **/ |
| 1872 | 1872 | function autoriser_queue_purger_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1873 | - return autoriser('webmestre'); |
|
| 1873 | + return autoriser('webmestre'); |
|
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | 1876 | |
@@ -1890,11 +1890,11 @@ discard block |
||
| 1890 | 1890 | * @return bool true s'il a le droit, false sinon |
| 1891 | 1891 | **/ |
| 1892 | 1892 | function autoriser_echafauder_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1893 | - if (test_espace_prive()) { |
|
| 1894 | - return intval($qui['id_auteur']) ? true : false; |
|
| 1895 | - } else { |
|
| 1896 | - return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1897 | - } |
|
| 1893 | + if (test_espace_prive()) { |
|
| 1894 | + return intval($qui['id_auteur']) ? true : false; |
|
| 1895 | + } else { |
|
| 1896 | + return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1897 | + } |
|
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | 1900 | |
@@ -1909,27 +1909,27 @@ discard block |
||
| 1909 | 1909 | * Identifiants d'auteurs |
| 1910 | 1910 | */ |
| 1911 | 1911 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1912 | - $objet = objet_type($objet); |
|
| 1913 | - $where = [ |
|
| 1914 | - 'objet=' . sql_quote($objet), |
|
| 1915 | - 'id_objet=' . intval($id_objet) |
|
| 1916 | - ]; |
|
| 1917 | - if (!empty($cond)) { |
|
| 1918 | - if (is_array($cond)) { |
|
| 1919 | - $where = array_merge($where, $cond); |
|
| 1920 | - } else { |
|
| 1921 | - $where[] = $cond; |
|
| 1922 | - } |
|
| 1923 | - } |
|
| 1924 | - $auteurs = sql_allfetsel( |
|
| 1925 | - 'id_auteur', |
|
| 1926 | - 'spip_auteurs_liens', |
|
| 1927 | - $where |
|
| 1928 | - ); |
|
| 1929 | - if (is_array($auteurs)) { |
|
| 1930 | - return array_column($auteurs, 'id_auteur'); |
|
| 1931 | - } |
|
| 1932 | - return []; |
|
| 1912 | + $objet = objet_type($objet); |
|
| 1913 | + $where = [ |
|
| 1914 | + 'objet=' . sql_quote($objet), |
|
| 1915 | + 'id_objet=' . intval($id_objet) |
|
| 1916 | + ]; |
|
| 1917 | + if (!empty($cond)) { |
|
| 1918 | + if (is_array($cond)) { |
|
| 1919 | + $where = array_merge($where, $cond); |
|
| 1920 | + } else { |
|
| 1921 | + $where[] = $cond; |
|
| 1922 | + } |
|
| 1923 | + } |
|
| 1924 | + $auteurs = sql_allfetsel( |
|
| 1925 | + 'id_auteur', |
|
| 1926 | + 'spip_auteurs_liens', |
|
| 1927 | + $where |
|
| 1928 | + ); |
|
| 1929 | + if (is_array($auteurs)) { |
|
| 1930 | + return array_column($auteurs, 'id_auteur'); |
|
| 1931 | + } |
|
| 1932 | + return []; |
|
| 1933 | 1933 | } |
| 1934 | 1934 | |
| 1935 | 1935 | /** |
@@ -1944,11 +1944,11 @@ discard block |
||
| 1944 | 1944 | * - false : serveur SQL indisponible |
| 1945 | 1945 | */ |
| 1946 | 1946 | function auteurs_article($id_article, $cond = '') { |
| 1947 | - return sql_allfetsel( |
|
| 1948 | - 'id_auteur', |
|
| 1949 | - 'spip_auteurs_liens', |
|
| 1950 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1951 | - ); |
|
| 1947 | + return sql_allfetsel( |
|
| 1948 | + 'id_auteur', |
|
| 1949 | + 'spip_auteurs_liens', |
|
| 1950 | + "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1951 | + ); |
|
| 1952 | 1952 | } |
| 1953 | 1953 | |
| 1954 | 1954 | |
@@ -1962,7 +1962,7 @@ discard block |
||
| 1962 | 1962 | */ |
| 1963 | 1963 | function acces_restreint_rubrique($id_rubrique) { |
| 1964 | 1964 | |
| 1965 | - return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1965 | + return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1966 | 1966 | } |
| 1967 | 1967 | |
| 1968 | 1968 | |
@@ -1975,12 +1975,12 @@ discard block |
||
| 1975 | 1975 | * @return bool true si un parent existe |
| 1976 | 1976 | */ |
| 1977 | 1977 | function verifier_table_non_vide($table = 'spip_rubriques') { |
| 1978 | - static $done = []; |
|
| 1979 | - if (!isset($done[$table])) { |
|
| 1980 | - $done[$table] = sql_countsel($table) > 0; |
|
| 1981 | - } |
|
| 1978 | + static $done = []; |
|
| 1979 | + if (!isset($done[$table])) { |
|
| 1980 | + $done[$table] = sql_countsel($table) > 0; |
|
| 1981 | + } |
|
| 1982 | 1982 | |
| 1983 | - return $done[$table]; |
|
| 1983 | + return $done[$table]; |
|
| 1984 | 1984 | } |
| 1985 | 1985 | |
| 1986 | 1986 | /** |
@@ -2007,15 +2007,15 @@ discard block |
||
| 2007 | 2007 | */ |
| 2008 | 2008 | function autoriser_inscrireauteur_dist($faire, $quoi, $id, $qui, $opt) { |
| 2009 | 2009 | |
| 2010 | - $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 2011 | - switch ($s) { |
|
| 2012 | - case 'info_redacteurs': |
|
| 2013 | - return ($GLOBALS['meta']['accepter_inscriptions'] === 'oui'); |
|
| 2014 | - case 'info_visiteurs': |
|
| 2015 | - return ($GLOBALS['meta']['accepter_visiteurs'] === 'oui' or $GLOBALS['meta']['forums_publics'] === 'abo'); |
|
| 2016 | - } |
|
| 2010 | + $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 2011 | + switch ($s) { |
|
| 2012 | + case 'info_redacteurs': |
|
| 2013 | + return ($GLOBALS['meta']['accepter_inscriptions'] === 'oui'); |
|
| 2014 | + case 'info_visiteurs': |
|
| 2015 | + return ($GLOBALS['meta']['accepter_visiteurs'] === 'oui' or $GLOBALS['meta']['forums_publics'] === 'abo'); |
|
| 2016 | + } |
|
| 2017 | 2017 | |
| 2018 | - return false; |
|
| 2018 | + return false; |
|
| 2019 | 2019 | } |
| 2020 | 2020 | |
| 2021 | 2021 | /** |
@@ -2033,7 +2033,7 @@ discard block |
||
| 2033 | 2033 | * @return bool true s'il a le droit, false sinon |
| 2034 | 2034 | **/ |
| 2035 | 2035 | function autoriser_inscription_relancer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 2036 | - return $qui['statut'] === '0minirezo' and !$qui['restreint']; |
|
| 2036 | + return $qui['statut'] === '0minirezo' and !$qui['restreint']; |
|
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | 2039 | /** |
@@ -2051,5 +2051,5 @@ discard block |
||
| 2051 | 2051 | * @return bool true s'il a le droit, false sinon |
| 2052 | 2052 | **/ |
| 2053 | 2053 | function autoriser_phpinfos_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 2054 | - return autoriser('webmestre'); |
|
| 2054 | + return autoriser('webmestre'); |
|
| 2055 | 2055 | } |