@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | defined('URLS_PAGE_EXEMPLE') || define('URLS_PAGE_EXEMPLE', 'spip.php?article12'); |
@@ -29,23 +29,23 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | function urls_page_generer_url_objet_dist(int $id, string $objet, string $args = '', string $ancre = ''): string { |
| 31 | 31 | |
| 32 | - if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) { |
|
| 33 | - $url = $generer_url_externe($id, $args, $ancre); |
|
| 34 | - // une url === null indique "je ne traite pas cette url, appliquez le calcul standard" |
|
| 35 | - // une url vide est une url vide, ne rien faire de plus |
|
| 36 | - if (!is_null($url)) { |
|
| 37 | - return $url; |
|
| 38 | - } |
|
| 39 | - } |
|
| 32 | + if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) { |
|
| 33 | + $url = $generer_url_externe($id, $args, $ancre); |
|
| 34 | + // une url === null indique "je ne traite pas cette url, appliquez le calcul standard" |
|
| 35 | + // une url vide est une url vide, ne rien faire de plus |
|
| 36 | + if (!is_null($url)) { |
|
| 37 | + return $url; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $url = \_debut_urls_page . $objet . \_separateur_urls_page |
|
| 42 | - . $id . \_terminaison_urls_page; |
|
| 41 | + $url = \_debut_urls_page . $objet . \_separateur_urls_page |
|
| 42 | + . $id . \_terminaison_urls_page; |
|
| 43 | 43 | |
| 44 | - if ($args) { |
|
| 45 | - $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 46 | - } |
|
| 44 | + if ($args) { |
|
| 45 | + $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 48 | + return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -61,27 +61,27 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | function urls_page_decoder_url_dist(string $url, string $entite, array $contexte = []): array { |
| 63 | 63 | |
| 64 | - // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 65 | - if ($GLOBALS['profondeur_url'] > 0 && $entite == 'sommaire') { |
|
| 66 | - return [[], '404']; |
|
| 67 | - } |
|
| 64 | + // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 65 | + if ($GLOBALS['profondeur_url'] > 0 && $entite == 'sommaire') { |
|
| 66 | + return [[], '404']; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - include_spip('inc/urls'); |
|
| 70 | - $r = nettoyer_url_page($url, $contexte); |
|
| 71 | - if ($r) { |
|
| 72 | - array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 73 | - return $r; |
|
| 74 | - } |
|
| 69 | + include_spip('inc/urls'); |
|
| 70 | + $r = nettoyer_url_page($url, $contexte); |
|
| 71 | + if ($r) { |
|
| 72 | + array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 73 | + return $r; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /* |
|
| 76 | + /* |
|
| 77 | 77 | * Le bloc qui suit sert a faciliter les transitions depuis |
| 78 | 78 | * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html' |
| 79 | 79 | * Il est inutile de le recopier si vous personnalisez vos URLs |
| 80 | 80 | * et votre .htaccess |
| 81 | 81 | */ |
| 82 | - // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 83 | - // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 84 | - $url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? ''; |
|
| 85 | - return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte); |
|
| 86 | - /* Fin du bloc compatibilite url-propres */ |
|
| 82 | + // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 83 | + // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 84 | + $url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? ''; |
|
| 85 | + return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte); |
|
| 86 | + /* Fin du bloc compatibilite url-propres */ |
|
| 87 | 87 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * Pile complétée du code compilé |
| 41 | 41 | **/ |
| 42 | 42 | function balise_FORMULAIRE_ECRIRE_AUTEUR($p) { |
| 43 | - return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']); |
|
| 43 | + return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -58,44 +58,44 @@ discard block |
||
| 58 | 58 | * - chaîne vide sinon (erreur ou non affichage). |
| 59 | 59 | */ |
| 60 | 60 | function balise_FORMULAIRE_ECRIRE_AUTEUR_stat($args, $context_compil) { |
| 61 | - include_spip('inc/filtres'); |
|
| 62 | - // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 63 | - $id = (int) $args[1]; |
|
| 64 | - if (!$args[0] && !$id) { |
|
| 65 | - $msg = [ |
|
| 66 | - 'zbug_champ_hors_motif', |
|
| 67 | - [ |
|
| 68 | - 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 69 | - 'motif' => 'AUTEURS/ARTICLES' |
|
| 70 | - ] |
|
| 71 | - ]; |
|
| 61 | + include_spip('inc/filtres'); |
|
| 62 | + // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 63 | + $id = (int) $args[1]; |
|
| 64 | + if (!$args[0] && !$id) { |
|
| 65 | + $msg = [ |
|
| 66 | + 'zbug_champ_hors_motif', |
|
| 67 | + [ |
|
| 68 | + 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 69 | + 'motif' => 'AUTEURS/ARTICLES' |
|
| 70 | + ] |
|
| 71 | + ]; |
|
| 72 | 72 | |
| 73 | - erreur_squelette($msg, $context_compil); |
|
| 73 | + erreur_squelette($msg, $context_compil); |
|
| 74 | 74 | |
| 75 | - return ''; |
|
| 76 | - } |
|
| 77 | - // Si on est dans un contexte article, |
|
| 78 | - // sortir tous les mails des auteurs de l'article |
|
| 79 | - if (!$args[0] && $id) { |
|
| 80 | - $r = ''; |
|
| 81 | - $s = sql_allfetsel( |
|
| 82 | - 'email', |
|
| 83 | - 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 84 | - "A.email != '' AND L.id_objet=$id" |
|
| 85 | - ); |
|
| 86 | - foreach ($s as $row) { |
|
| 87 | - if (email_valide($row['email'])) { |
|
| 88 | - $r .= ', ' . $row['email']; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - $args[2] = substr($r, 2); |
|
| 92 | - } |
|
| 75 | + return ''; |
|
| 76 | + } |
|
| 77 | + // Si on est dans un contexte article, |
|
| 78 | + // sortir tous les mails des auteurs de l'article |
|
| 79 | + if (!$args[0] && $id) { |
|
| 80 | + $r = ''; |
|
| 81 | + $s = sql_allfetsel( |
|
| 82 | + 'email', |
|
| 83 | + 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 84 | + "A.email != '' AND L.id_objet=$id" |
|
| 85 | + ); |
|
| 86 | + foreach ($s as $row) { |
|
| 87 | + if (email_valide($row['email'])) { |
|
| 88 | + $r .= ', ' . $row['email']; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + $args[2] = substr($r, 2); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 95 | - if (!$args[2] || !email_valide($args[2])) { |
|
| 96 | - return ''; |
|
| 97 | - } |
|
| 94 | + // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 95 | + if (!$args[2] || !email_valide($args[2])) { |
|
| 96 | + return ''; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - // OK |
|
| 100 | - return $args; |
|
| 99 | + // OK |
|
| 100 | + return $args; |
|
| 101 | 101 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * Pile complétée du code compilé |
| 44 | 44 | **/ |
| 45 | 45 | function balise_FORMULAIRE_INSCRIPTION($p) { |
| 46 | - return calculer_balise_dynamique($p, 'FORMULAIRE_INSCRIPTION', []); |
|
| 46 | + return calculer_balise_dynamique($p, 'FORMULAIRE_INSCRIPTION', []); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -73,19 +73,19 @@ discard block |
||
| 73 | 73 | * - chaîne vide sinon. |
| 74 | 74 | */ |
| 75 | 75 | function balise_FORMULAIRE_INSCRIPTION_stat($args, $context_compil) { |
| 76 | - [$mode, $id_ou_options, $retour] = array_pad($args, 3, null); |
|
| 76 | + [$mode, $id_ou_options, $retour] = array_pad($args, 3, null); |
|
| 77 | 77 | |
| 78 | - // Compatibilité avec l'ancien param "id" dans les deux sens |
|
| 79 | - if (!is_array($id_ou_options)) { |
|
| 80 | - $options = ['id' => (int) $id_ou_options]; |
|
| 81 | - $id = $options['id']; |
|
| 82 | - }else { |
|
| 83 | - $options = $id_ou_options; |
|
| 84 | - $id = (int) ($id_ou_options['id'] ?? 0); |
|
| 85 | - } |
|
| 78 | + // Compatibilité avec l'ancien param "id" dans les deux sens |
|
| 79 | + if (!is_array($id_ou_options)) { |
|
| 80 | + $options = ['id' => (int) $id_ou_options]; |
|
| 81 | + $id = $options['id']; |
|
| 82 | + }else { |
|
| 83 | + $options = $id_ou_options; |
|
| 84 | + $id = (int) ($id_ou_options['id'] ?? 0); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - include_spip('action/inscrire_auteur'); |
|
| 88 | - $mode = tester_statut_inscription($mode, $id); |
|
| 87 | + include_spip('action/inscrire_auteur'); |
|
| 88 | + $mode = tester_statut_inscription($mode, $id); |
|
| 89 | 89 | |
| 90 | - return $mode ? [$mode, $options, $retour] : ''; |
|
| 90 | + return $mode ? [$mode, $options, $retour] : ''; |
|
| 91 | 91 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | 29 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 30 | - return; |
|
| 30 | + return; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -47,55 +47,55 @@ discard block |
||
| 47 | 47 | * array : description des roles applicables dans 3 index : colonne, titres, roles |
| 48 | 48 | **/ |
| 49 | 49 | function roles_presents($objet, $objet_destination = '') { |
| 50 | - $desc = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 51 | - |
|
| 52 | - // pas de liste de roles, on sort |
|
| 53 | - if (!isset($desc['roles_titres']) || !($titres = $desc['roles_titres'])) { |
|
| 54 | - return false; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - // on vérifie que la table de liaison existe |
|
| 58 | - include_spip('action/editer_liens'); |
|
| 59 | - if (!$lien = objet_associable($objet)) { |
|
| 60 | - return false; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role') |
|
| 64 | - $colonne = $desc['roles_colonne'] ?? 'role'; |
|
| 65 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 66 | - [, $table_lien] = $lien; |
|
| 67 | - $desc_lien = $trouver_table($table_lien); |
|
| 68 | - if (!isset($desc_lien['field'][$colonne])) { |
|
| 69 | - return false; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - // sur quoi peuvent s'appliquer nos rôles |
|
| 73 | - if (!$application = $desc['roles_objets']) { |
|
| 74 | - return false; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // destination presente, on restreint si possible |
|
| 78 | - if ($objet_destination) { |
|
| 79 | - $objet_destination = table_objet($objet_destination); |
|
| 80 | - |
|
| 81 | - // pour l'objet |
|
| 82 | - if (isset($application[$objet_destination])) { |
|
| 83 | - $application = $application[$objet_destination]; |
|
| 84 | - // sinon pour tous les objets |
|
| 85 | - } elseif (isset($application['*'])) { |
|
| 86 | - $application = $application['*']; |
|
| 87 | - } // sinon tant pis |
|
| 88 | - else { |
|
| 89 | - return false; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // tout est ok |
|
| 94 | - return [ |
|
| 95 | - 'titres' => $titres, |
|
| 96 | - 'roles' => $application, |
|
| 97 | - 'colonne' => $colonne |
|
| 98 | - ]; |
|
| 50 | + $desc = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 51 | + |
|
| 52 | + // pas de liste de roles, on sort |
|
| 53 | + if (!isset($desc['roles_titres']) || !($titres = $desc['roles_titres'])) { |
|
| 54 | + return false; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + // on vérifie que la table de liaison existe |
|
| 58 | + include_spip('action/editer_liens'); |
|
| 59 | + if (!$lien = objet_associable($objet)) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role') |
|
| 64 | + $colonne = $desc['roles_colonne'] ?? 'role'; |
|
| 65 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 66 | + [, $table_lien] = $lien; |
|
| 67 | + $desc_lien = $trouver_table($table_lien); |
|
| 68 | + if (!isset($desc_lien['field'][$colonne])) { |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + // sur quoi peuvent s'appliquer nos rôles |
|
| 73 | + if (!$application = $desc['roles_objets']) { |
|
| 74 | + return false; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // destination presente, on restreint si possible |
|
| 78 | + if ($objet_destination) { |
|
| 79 | + $objet_destination = table_objet($objet_destination); |
|
| 80 | + |
|
| 81 | + // pour l'objet |
|
| 82 | + if (isset($application[$objet_destination])) { |
|
| 83 | + $application = $application[$objet_destination]; |
|
| 84 | + // sinon pour tous les objets |
|
| 85 | + } elseif (isset($application['*'])) { |
|
| 86 | + $application = $application['*']; |
|
| 87 | + } // sinon tant pis |
|
| 88 | + else { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // tout est ok |
|
| 94 | + return [ |
|
| 95 | + 'titres' => $titres, |
|
| 96 | + 'roles' => $application, |
|
| 97 | + 'colonne' => $colonne |
|
| 98 | + ]; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | * Nom de la colonne, sinon vide |
| 110 | 110 | **/ |
| 111 | 111 | function roles_colonne($objet, $objet_destination) { |
| 112 | - if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 113 | - return $roles['colonne']; |
|
| 114 | - } |
|
| 112 | + if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 113 | + return $roles['colonne']; |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - return ''; |
|
| 116 | + return ''; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -135,21 +135,21 @@ discard block |
||
| 135 | 135 | * Liste ('', '', array()) sinon. |
| 136 | 136 | **/ |
| 137 | 137 | function roles_trouver_dans_qualif($objet, $objet_destination, $qualif = []) { |
| 138 | - // si des rôles sont possibles, on les utilise |
|
| 139 | - $role = $colonne_role = ''; # role défini |
|
| 140 | - // condition du where par defaut |
|
| 141 | - $cond = []; |
|
| 142 | - if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 143 | - $colonne_role = $roles['colonne']; |
|
| 144 | - // qu'il n'est pas défini |
|
| 145 | - if (!isset($qualif[$colonne_role]) || !($role = $qualif[$colonne_role])) { |
|
| 146 | - $role = $roles['roles']['defaut']; |
|
| 147 | - } |
|
| 148 | - // where |
|
| 149 | - $cond = ["$colonne_role=" . sql_quote($role)]; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return [$role, $colonne_role, $cond]; |
|
| 138 | + // si des rôles sont possibles, on les utilise |
|
| 139 | + $role = $colonne_role = ''; # role défini |
|
| 140 | + // condition du where par defaut |
|
| 141 | + $cond = []; |
|
| 142 | + if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 143 | + $colonne_role = $roles['colonne']; |
|
| 144 | + // qu'il n'est pas défini |
|
| 145 | + if (!isset($qualif[$colonne_role]) || !($role = $qualif[$colonne_role])) { |
|
| 146 | + $role = $roles['roles']['defaut']; |
|
| 147 | + } |
|
| 148 | + // where |
|
| 149 | + $cond = ["$colonne_role=" . sql_quote($role)]; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return [$role, $colonne_role, $cond]; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -171,18 +171,18 @@ discard block |
||
| 171 | 171 | * Liste (Tableau de conditions where complété du role, Colonne du role, role utilisé) |
| 172 | 172 | **/ |
| 173 | 173 | function roles_creer_condition_role($objet_source, $objet, $cond, $tous_si_absent = false) { |
| 174 | - // role par défaut, colonne |
|
| 175 | - [$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet); |
|
| 176 | - |
|
| 177 | - // chercher d'eventuels rôles transmis |
|
| 178 | - $role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut)); |
|
| 179 | - unset($cond['role']); // cette condition est particuliere... |
|
| 180 | - // on ajoute la condition du role aux autres conditions. |
|
| 181 | - if ($colonne_role && $role != '*') { |
|
| 182 | - $cond[] = "$colonne_role=" . sql_quote($role); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - return [$cond, $colonne_role, $role]; |
|
| 174 | + // role par défaut, colonne |
|
| 175 | + [$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet); |
|
| 176 | + |
|
| 177 | + // chercher d'eventuels rôles transmis |
|
| 178 | + $role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut)); |
|
| 179 | + unset($cond['role']); // cette condition est particuliere... |
|
| 180 | + // on ajoute la condition du role aux autres conditions. |
|
| 181 | + if ($colonne_role && $role != '*') { |
|
| 182 | + $cond[] = "$colonne_role=" . sql_quote($role); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + return [$cond, $colonne_role, $role]; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -204,28 +204,28 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | function roles_complets($objet_source, $objet, $id_objet, $objet_lien) { |
| 206 | 206 | |
| 207 | - $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 208 | - // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 209 | - if ($presents === false) { |
|
| 210 | - return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - // types de roles possibles |
|
| 214 | - $roles_possibles = $presents['roles']['roles']['choix']; |
|
| 215 | - // couples id / roles |
|
| 216 | - $ids = $presents['ids']; |
|
| 217 | - |
|
| 218 | - // pour chaque groupe, on fait le diff entre tous les roles possibles |
|
| 219 | - // et les roles attribués à l'élément : s'il en reste, c'est que l'élément |
|
| 220 | - // n'est pas complet |
|
| 221 | - $complets = []; |
|
| 222 | - foreach ($ids as $id => $roles_presents) { |
|
| 223 | - if (!array_diff($roles_possibles, $roles_presents)) { |
|
| 224 | - $complets[] = $id; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - return $complets; |
|
| 207 | + $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 208 | + // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 209 | + if ($presents === false) { |
|
| 210 | + return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + // types de roles possibles |
|
| 214 | + $roles_possibles = $presents['roles']['roles']['choix']; |
|
| 215 | + // couples id / roles |
|
| 216 | + $ids = $presents['ids']; |
|
| 217 | + |
|
| 218 | + // pour chaque groupe, on fait le diff entre tous les roles possibles |
|
| 219 | + // et les roles attribués à l'élément : s'il en reste, c'est que l'élément |
|
| 220 | + // n'est pas complet |
|
| 221 | + $complets = []; |
|
| 222 | + foreach ($ids as $id => $roles_presents) { |
|
| 223 | + if (!array_diff($roles_possibles, $roles_presents)) { |
|
| 224 | + $complets[] = $id; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + return $complets; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | |
@@ -242,17 +242,17 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | function roles_presents_sur_id($id_objet_source, $objet_source, $objet, $id_objet, $objet_lien) { |
| 244 | 244 | |
| 245 | - $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 246 | - // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 247 | - if ($presents === false) { |
|
| 248 | - return []; |
|
| 249 | - } |
|
| 245 | + $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 246 | + // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 247 | + if ($presents === false) { |
|
| 248 | + return []; |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - if (!isset($presents['ids'][$id_objet_source])) { |
|
| 252 | - return []; |
|
| 253 | - } |
|
| 251 | + if (!isset($presents['ids'][$id_objet_source])) { |
|
| 252 | + return []; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - return $presents['ids'][$id_objet_source]; |
|
| 255 | + return $presents['ids'][$id_objet_source]; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
@@ -280,47 +280,47 @@ discard block |
||
| 280 | 280 | * - False si pas de role déclarés |
| 281 | 281 | */ |
| 282 | 282 | function roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien) { |
| 283 | - static $done = []; |
|
| 284 | - |
|
| 285 | - // stocker le résultat |
|
| 286 | - $hash = "$objet_source-$objet-$id_objet-$objet_lien"; |
|
| 287 | - if (isset($done[$hash])) { |
|
| 288 | - return $done[$hash]; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - // pas de roles sur ces objets, on sort |
|
| 292 | - $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 293 | - if (!$roles) { |
|
| 294 | - return $done[$hash] = false; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - // inspiré de lister_objets_lies() |
|
| 298 | - if ($objet_lien == $objet) { |
|
| 299 | - $res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']); |
|
| 300 | - } else { |
|
| 301 | - $res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - // types de roles possibles |
|
| 305 | - $roles_possibles = $roles['roles']['choix']; |
|
| 306 | - // colonne du role |
|
| 307 | - $colonne = $roles['colonne']; |
|
| 308 | - |
|
| 309 | - // on recupere par id, et role existant |
|
| 310 | - $ids = []; |
|
| 311 | - while ($row = array_shift($res)) { |
|
| 312 | - $id = $row[$objet_source]; |
|
| 313 | - if (!isset($ids[$id])) { |
|
| 314 | - $ids[$id] = []; |
|
| 315 | - } |
|
| 316 | - // tableau des roles présents |
|
| 317 | - $ids[$id][] = $row[$colonne]; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - return $done[$hash] = [ |
|
| 321 | - 'roles' => $roles, |
|
| 322 | - 'ids' => $ids |
|
| 323 | - ]; |
|
| 283 | + static $done = []; |
|
| 284 | + |
|
| 285 | + // stocker le résultat |
|
| 286 | + $hash = "$objet_source-$objet-$id_objet-$objet_lien"; |
|
| 287 | + if (isset($done[$hash])) { |
|
| 288 | + return $done[$hash]; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + // pas de roles sur ces objets, on sort |
|
| 292 | + $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 293 | + if (!$roles) { |
|
| 294 | + return $done[$hash] = false; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + // inspiré de lister_objets_lies() |
|
| 298 | + if ($objet_lien == $objet) { |
|
| 299 | + $res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']); |
|
| 300 | + } else { |
|
| 301 | + $res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + // types de roles possibles |
|
| 305 | + $roles_possibles = $roles['roles']['choix']; |
|
| 306 | + // colonne du role |
|
| 307 | + $colonne = $roles['colonne']; |
|
| 308 | + |
|
| 309 | + // on recupere par id, et role existant |
|
| 310 | + $ids = []; |
|
| 311 | + while ($row = array_shift($res)) { |
|
| 312 | + $id = $row[$objet_source]; |
|
| 313 | + if (!isset($ids[$id])) { |
|
| 314 | + $ids[$id] = []; |
|
| 315 | + } |
|
| 316 | + // tableau des roles présents |
|
| 317 | + $ids[$id][] = $row[$colonne]; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + return $done[$hash] = [ |
|
| 321 | + 'roles' => $roles, |
|
| 322 | + 'ids' => $ids |
|
| 323 | + ]; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
@@ -338,33 +338,33 @@ discard block |
||
| 338 | 338 | * - false si pas de role déclarés |
| 339 | 339 | */ |
| 340 | 340 | function roles_connus_en_base($objet_source, $objet, $objet_lien) { |
| 341 | - static $done = []; |
|
| 342 | - |
|
| 343 | - // stocker le résultat |
|
| 344 | - $hash = "$objet_source-$objet-$objet_lien"; |
|
| 345 | - if (isset($done[$hash])) { |
|
| 346 | - return $done[$hash]; |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - if (!$lien = objet_associable($objet_lien)) { |
|
| 350 | - return $done[$hash] = false; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - // pas de roles sur ces objets, on sort |
|
| 354 | - $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 355 | - if (!$roles) { |
|
| 356 | - return $done[$hash] = false; |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - [$primary, $l] = $lien; |
|
| 360 | - $colone_role = $roles['colonne']; |
|
| 361 | - |
|
| 362 | - $all = sql_allfetsel( |
|
| 363 | - "DISTINCT $colone_role", |
|
| 364 | - $l, |
|
| 365 | - 'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 366 | - ); |
|
| 367 | - $done[$hash] = array_map('reset', $all); |
|
| 368 | - |
|
| 369 | - return $done[$hash]; |
|
| 341 | + static $done = []; |
|
| 342 | + |
|
| 343 | + // stocker le résultat |
|
| 344 | + $hash = "$objet_source-$objet-$objet_lien"; |
|
| 345 | + if (isset($done[$hash])) { |
|
| 346 | + return $done[$hash]; |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + if (!$lien = objet_associable($objet_lien)) { |
|
| 350 | + return $done[$hash] = false; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + // pas de roles sur ces objets, on sort |
|
| 354 | + $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 355 | + if (!$roles) { |
|
| 356 | + return $done[$hash] = false; |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + [$primary, $l] = $lien; |
|
| 360 | + $colone_role = $roles['colonne']; |
|
| 361 | + |
|
| 362 | + $all = sql_allfetsel( |
|
| 363 | + "DISTINCT $colone_role", |
|
| 364 | + $l, |
|
| 365 | + 'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 366 | + ); |
|
| 367 | + $done[$hash] = array_map('reset', $all); |
|
| 368 | + |
|
| 369 | + return $done[$hash]; |
|
| 370 | 370 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/charsets'); |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | * @return array |
| 42 | 42 | */ |
| 43 | 43 | function importer_csv_importcharset($texte, $definir_charset_source = false) { |
| 44 | - // le plus frequent, en particulier avec les trucs de ms@@@ |
|
| 45 | - static $charset_source = 'iso-8859-1'; |
|
| 46 | - if ($definir_charset_source) { |
|
| 47 | - $charset_source = $definir_charset_source === true ? 'iso-8859-1' : $definir_charset_source; |
|
| 48 | - } |
|
| 49 | - // mais open-office sait faire mieux, donc mefiance ! |
|
| 50 | - $charset = is_utf8($texte) ? 'utf-8' : $charset_source; |
|
| 51 | - return importer_charset($texte, $charset); |
|
| 44 | + // le plus frequent, en particulier avec les trucs de ms@@@ |
|
| 45 | + static $charset_source = 'iso-8859-1'; |
|
| 46 | + if ($definir_charset_source) { |
|
| 47 | + $charset_source = $definir_charset_source === true ? 'iso-8859-1' : $definir_charset_source; |
|
| 48 | + } |
|
| 49 | + // mais open-office sait faire mieux, donc mefiance ! |
|
| 50 | + $charset = is_utf8($texte) ? 'utf-8' : $charset_source; |
|
| 51 | + return importer_charset($texte, $charset); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | 61 | function importer_csv_nettoie_key($key) { |
| 62 | - return translitteration($key); |
|
| 62 | + return translitteration($key); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -78,70 +78,70 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | function inc_importer_csv_dist($file, $options = []) { |
| 80 | 80 | |
| 81 | - // support ancienne syntaxe |
|
| 82 | - // inc_importer_csv_dist($file, $head = false, $delim = ',', $enclos = '"', $len = 10000, $charset_source = '') |
|
| 83 | - if (!is_array($options)) { |
|
| 84 | - $args = func_get_args(); |
|
| 85 | - $options = []; |
|
| 86 | - foreach ([1 => 'head', 2 => 'delim', 3 => 'enclos', 4 => 'len', 5 => 'charset_source'] as $k => $option) { |
|
| 87 | - if (!empty($args[$k])) { |
|
| 88 | - $options[$option] = $args[$k]; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } |
|
| 81 | + // support ancienne syntaxe |
|
| 82 | + // inc_importer_csv_dist($file, $head = false, $delim = ',', $enclos = '"', $len = 10000, $charset_source = '') |
|
| 83 | + if (!is_array($options)) { |
|
| 84 | + $args = func_get_args(); |
|
| 85 | + $options = []; |
|
| 86 | + foreach ([1 => 'head', 2 => 'delim', 3 => 'enclos', 4 => 'len', 5 => 'charset_source'] as $k => $option) { |
|
| 87 | + if (!empty($args[$k])) { |
|
| 88 | + $options[$option] = $args[$k]; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - $default_options = [ |
|
| 94 | - 'head' => false, |
|
| 95 | - 'delim' => ',', |
|
| 96 | - 'enclos' => '"', |
|
| 97 | - 'len' => 10000, |
|
| 98 | - 'charset_source' => '', |
|
| 99 | - ]; |
|
| 100 | - $options = array_merge($default_options, $options); |
|
| 93 | + $default_options = [ |
|
| 94 | + 'head' => false, |
|
| 95 | + 'delim' => ',', |
|
| 96 | + 'enclos' => '"', |
|
| 97 | + 'len' => 10000, |
|
| 98 | + 'charset_source' => '', |
|
| 99 | + ]; |
|
| 100 | + $options = array_merge($default_options, $options); |
|
| 101 | 101 | |
| 102 | 102 | |
| 103 | - $return = []; |
|
| 104 | - if (@file_exists($file) && ($handle = fopen($file, 'r'))) { |
|
| 105 | - if ($options['charset_source']) { |
|
| 106 | - importer_csv_importcharset('', $options['charset_source']); |
|
| 107 | - } |
|
| 108 | - if ($options['head']) { |
|
| 109 | - $header = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos']); |
|
| 110 | - if ($header) { |
|
| 111 | - $header = array_map('importer_csv_importcharset', $header); |
|
| 112 | - $header = array_map('importer_csv_nettoie_key', $header); |
|
| 113 | - $header_type = []; |
|
| 114 | - foreach ($header as $heading) { |
|
| 115 | - $header_type[$heading] = isset($header_type[$heading]) ? 'array' : 'scalar'; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - } |
|
| 103 | + $return = []; |
|
| 104 | + if (@file_exists($file) && ($handle = fopen($file, 'r'))) { |
|
| 105 | + if ($options['charset_source']) { |
|
| 106 | + importer_csv_importcharset('', $options['charset_source']); |
|
| 107 | + } |
|
| 108 | + if ($options['head']) { |
|
| 109 | + $header = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos']); |
|
| 110 | + if ($header) { |
|
| 111 | + $header = array_map('importer_csv_importcharset', $header); |
|
| 112 | + $header = array_map('importer_csv_nettoie_key', $header); |
|
| 113 | + $header_type = []; |
|
| 114 | + foreach ($header as $heading) { |
|
| 115 | + $header_type[$heading] = isset($header_type[$heading]) ? 'array' : 'scalar'; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - while (($data = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos'])) !== false) { |
|
| 121 | - $data = array_map('importer_csv_importcharset', $data); |
|
| 122 | - if ($options['head'] && isset($header)) { |
|
| 123 | - $row = []; |
|
| 124 | - foreach ($header as $key => $heading) { |
|
| 125 | - if ($header_type[$heading] == 'array') { |
|
| 126 | - if (!isset($row[$heading])) { |
|
| 127 | - $row[$heading] = []; |
|
| 128 | - } |
|
| 129 | - if (isset($data[$key]) && strlen($data[$key])) { |
|
| 130 | - $row[$heading][] = $data[$key]; |
|
| 131 | - } |
|
| 132 | - } else { |
|
| 133 | - $row[$heading] = $data[$key] ?? ''; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $return[] = $row; |
|
| 137 | - } else { |
|
| 138 | - $return[] = $data; |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - if ($options['charset_source']) { |
|
| 142 | - importer_csv_importcharset('', true); |
|
| 143 | - } |
|
| 144 | - } |
|
| 120 | + while (($data = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos'])) !== false) { |
|
| 121 | + $data = array_map('importer_csv_importcharset', $data); |
|
| 122 | + if ($options['head'] && isset($header)) { |
|
| 123 | + $row = []; |
|
| 124 | + foreach ($header as $key => $heading) { |
|
| 125 | + if ($header_type[$heading] == 'array') { |
|
| 126 | + if (!isset($row[$heading])) { |
|
| 127 | + $row[$heading] = []; |
|
| 128 | + } |
|
| 129 | + if (isset($data[$key]) && strlen($data[$key])) { |
|
| 130 | + $row[$heading][] = $data[$key]; |
|
| 131 | + } |
|
| 132 | + } else { |
|
| 133 | + $row[$heading] = $data[$key] ?? ''; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $return[] = $row; |
|
| 137 | + } else { |
|
| 138 | + $return[] = $data; |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + if ($options['charset_source']) { |
|
| 142 | + importer_csv_importcharset('', true); |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - return $return ?: false; |
|
| 146 | + return $return ?: false; |
|
| 147 | 147 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/autoriser'); |
@@ -29,74 +29,74 @@ discard block |
||
| 29 | 29 | * Un tableau des sous rubriques |
| 30 | 30 | */ |
| 31 | 31 | function enfant_rub($collection, $debut = 0, $limite = 500) { |
| 32 | - $voir_logo = (isset($GLOBALS['meta']['image_process']) && $GLOBALS['meta']['image_process'] != 'non'); |
|
| 33 | - $logo = ''; |
|
| 34 | - |
|
| 35 | - if ($voir_logo) { |
|
| 36 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 37 | - include_spip('inc/filtres_images_mini'); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - $res = []; |
|
| 41 | - |
|
| 42 | - $result = sql_select( |
|
| 43 | - 'id_rubrique, id_parent, titre, descriptif, lang', |
|
| 44 | - 'spip_rubriques', |
|
| 45 | - 'id_parent=' . (int) $collection, |
|
| 46 | - '', |
|
| 47 | - '0+titre,titre', |
|
| 48 | - $debut == -1 ? '' : "$debut,$limite" |
|
| 49 | - ); |
|
| 50 | - while ($row = sql_fetch($result)) { |
|
| 51 | - $id_rubrique = $row['id_rubrique']; |
|
| 52 | - $id_parent = $row['id_parent']; |
|
| 53 | - // pour etre sur de passer par tous les traitements |
|
| 54 | - $titre = generer_objet_info($id_rubrique, 'rubrique', 'titre'); |
|
| 55 | - if ('' !== ($rang = recuperer_numero($row['titre']))) { |
|
| 56 | - $rang = "<span class='rang'>$rang.</span> "; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 60 | - $les_sous_enfants = sous_enfant_rub($id_rubrique); |
|
| 61 | - |
|
| 62 | - changer_typo($row['lang']); |
|
| 63 | - $lang_dir = lang_dir($row['lang']); |
|
| 64 | - $descriptif = propre($row['descriptif']); |
|
| 65 | - |
|
| 66 | - if ($voir_logo && ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on'))) { |
|
| 67 | - [$fid, $dir, $nom, $format] = $logo; |
|
| 68 | - $logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70); |
|
| 69 | - if ($logo) { |
|
| 70 | - $logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">'); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - $lib_bouton = (acces_restreint_rubrique($id_rubrique) |
|
| 75 | - ? http_img_pack('auteur-0minirezo-16.png', '', " width='16' height='16'", _T('image_administrer_rubrique')) |
|
| 76 | - : '') . |
|
| 77 | - " <a class='titremlien' dir='$lang_dir'" . |
|
| 78 | - ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
|
| 79 | - " href='" . |
|
| 80 | - generer_objet_url($id_rubrique, 'rubrique') . |
|
| 81 | - "'><span class='titre'>" . |
|
| 82 | - $rang . $titre |
|
| 83 | - . '</span>' |
|
| 84 | - . (is_string($logo) ? $logo : '') |
|
| 85 | - . '</a>'; |
|
| 86 | - |
|
| 87 | - $titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique") |
|
| 88 | - . ($descriptif ? "\n<div class='descriptif'>$descriptif</div>" : '') |
|
| 89 | - ; |
|
| 90 | - |
|
| 91 | - $res[] = |
|
| 92 | - debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) . |
|
| 93 | - $les_sous_enfants . |
|
| 94 | - fin_cadre_sous_rub(); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite |
|
| 99 | - return $res; |
|
| 32 | + $voir_logo = (isset($GLOBALS['meta']['image_process']) && $GLOBALS['meta']['image_process'] != 'non'); |
|
| 33 | + $logo = ''; |
|
| 34 | + |
|
| 35 | + if ($voir_logo) { |
|
| 36 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 37 | + include_spip('inc/filtres_images_mini'); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + $res = []; |
|
| 41 | + |
|
| 42 | + $result = sql_select( |
|
| 43 | + 'id_rubrique, id_parent, titre, descriptif, lang', |
|
| 44 | + 'spip_rubriques', |
|
| 45 | + 'id_parent=' . (int) $collection, |
|
| 46 | + '', |
|
| 47 | + '0+titre,titre', |
|
| 48 | + $debut == -1 ? '' : "$debut,$limite" |
|
| 49 | + ); |
|
| 50 | + while ($row = sql_fetch($result)) { |
|
| 51 | + $id_rubrique = $row['id_rubrique']; |
|
| 52 | + $id_parent = $row['id_parent']; |
|
| 53 | + // pour etre sur de passer par tous les traitements |
|
| 54 | + $titre = generer_objet_info($id_rubrique, 'rubrique', 'titre'); |
|
| 55 | + if ('' !== ($rang = recuperer_numero($row['titre']))) { |
|
| 56 | + $rang = "<span class='rang'>$rang.</span> "; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 60 | + $les_sous_enfants = sous_enfant_rub($id_rubrique); |
|
| 61 | + |
|
| 62 | + changer_typo($row['lang']); |
|
| 63 | + $lang_dir = lang_dir($row['lang']); |
|
| 64 | + $descriptif = propre($row['descriptif']); |
|
| 65 | + |
|
| 66 | + if ($voir_logo && ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on'))) { |
|
| 67 | + [$fid, $dir, $nom, $format] = $logo; |
|
| 68 | + $logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70); |
|
| 69 | + if ($logo) { |
|
| 70 | + $logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">'); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + $lib_bouton = (acces_restreint_rubrique($id_rubrique) |
|
| 75 | + ? http_img_pack('auteur-0minirezo-16.png', '', " width='16' height='16'", _T('image_administrer_rubrique')) |
|
| 76 | + : '') . |
|
| 77 | + " <a class='titremlien' dir='$lang_dir'" . |
|
| 78 | + ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
|
| 79 | + " href='" . |
|
| 80 | + generer_objet_url($id_rubrique, 'rubrique') . |
|
| 81 | + "'><span class='titre'>" . |
|
| 82 | + $rang . $titre |
|
| 83 | + . '</span>' |
|
| 84 | + . (is_string($logo) ? $logo : '') |
|
| 85 | + . '</a>'; |
|
| 86 | + |
|
| 87 | + $titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique") |
|
| 88 | + . ($descriptif ? "\n<div class='descriptif'>$descriptif</div>" : '') |
|
| 89 | + ; |
|
| 90 | + |
|
| 91 | + $res[] = |
|
| 92 | + debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) . |
|
| 93 | + $les_sous_enfants . |
|
| 94 | + fin_cadre_sous_rub(); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite |
|
| 99 | + return $res; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -109,71 +109,71 @@ discard block |
||
| 109 | 109 | * Le contenu du bloc dépliable |
| 110 | 110 | */ |
| 111 | 111 | function sous_enfant_rub($collection2) { |
| 112 | - $nb = sql_countsel('spip_rubriques', 'id_parent=' . (int) $collection2); |
|
| 113 | - |
|
| 114 | - $retour = ''; |
|
| 115 | - $pagination = ''; |
|
| 116 | - $debut = 0; |
|
| 117 | - $limite = 500; |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * On ne va afficher que 500 résultats max |
|
| 121 | - * Si > 500 on affiche une pagination |
|
| 122 | - */ |
|
| 123 | - if ($nb > $limite) { |
|
| 124 | - $debut = _request('debut_rubrique' . $collection2) ?: $debut; |
|
| 125 | - $pagination = chercher_filtre('pagination'); |
|
| 126 | - $pagination = '<nav class="pagination">' . $pagination( |
|
| 127 | - $nb, |
|
| 128 | - '_rubrique' . $collection2, |
|
| 129 | - $debut, |
|
| 130 | - $limite, |
|
| 131 | - true, |
|
| 132 | - 'prive' |
|
| 133 | - ) . '</nav>'; |
|
| 134 | - $limite = $debut + $limite; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - $result = sql_select( |
|
| 138 | - 'id_rubrique, id_parent, titre, lang', |
|
| 139 | - 'spip_rubriques', |
|
| 140 | - 'id_parent=' . (int) $collection2, |
|
| 141 | - '', |
|
| 142 | - '0+titre,titre', |
|
| 143 | - $debut == -1 ? '' : "$debut,$limite" |
|
| 144 | - ); |
|
| 145 | - |
|
| 146 | - while ($row = sql_fetch($result)) { |
|
| 147 | - $id_rubrique2 = $row['id_rubrique']; |
|
| 148 | - $titre2 = generer_objet_info( |
|
| 149 | - $id_rubrique2, |
|
| 150 | - 'rubrique', |
|
| 151 | - 'titre' |
|
| 152 | - ); // pour etre sur de passer par tous les traitements |
|
| 153 | - if ('' !== ($rang2 = recuperer_numero($row['titre']))) { |
|
| 154 | - $rang2 = "<span class='rang'>$rang2.</span> "; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - changer_typo($row['lang']); |
|
| 158 | - $lang_dir = lang_dir($row['lang']); |
|
| 159 | - if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
|
| 160 | - $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url( |
|
| 161 | - $id_rubrique2, |
|
| 162 | - 'rubrique' |
|
| 163 | - ) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - $retour = $pagination . $retour . $pagination; |
|
| 168 | - |
|
| 169 | - if (!$retour) { |
|
| 170 | - return ''; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - return debut_block_depliable($debut > 0, "enfants$collection2") |
|
| 174 | - . "\n<ul class='liste-items sous-sous-rub'>\n" |
|
| 175 | - . $retour |
|
| 176 | - . "</ul>\n" . fin_block() . "\n\n"; |
|
| 112 | + $nb = sql_countsel('spip_rubriques', 'id_parent=' . (int) $collection2); |
|
| 113 | + |
|
| 114 | + $retour = ''; |
|
| 115 | + $pagination = ''; |
|
| 116 | + $debut = 0; |
|
| 117 | + $limite = 500; |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * On ne va afficher que 500 résultats max |
|
| 121 | + * Si > 500 on affiche une pagination |
|
| 122 | + */ |
|
| 123 | + if ($nb > $limite) { |
|
| 124 | + $debut = _request('debut_rubrique' . $collection2) ?: $debut; |
|
| 125 | + $pagination = chercher_filtre('pagination'); |
|
| 126 | + $pagination = '<nav class="pagination">' . $pagination( |
|
| 127 | + $nb, |
|
| 128 | + '_rubrique' . $collection2, |
|
| 129 | + $debut, |
|
| 130 | + $limite, |
|
| 131 | + true, |
|
| 132 | + 'prive' |
|
| 133 | + ) . '</nav>'; |
|
| 134 | + $limite = $debut + $limite; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + $result = sql_select( |
|
| 138 | + 'id_rubrique, id_parent, titre, lang', |
|
| 139 | + 'spip_rubriques', |
|
| 140 | + 'id_parent=' . (int) $collection2, |
|
| 141 | + '', |
|
| 142 | + '0+titre,titre', |
|
| 143 | + $debut == -1 ? '' : "$debut,$limite" |
|
| 144 | + ); |
|
| 145 | + |
|
| 146 | + while ($row = sql_fetch($result)) { |
|
| 147 | + $id_rubrique2 = $row['id_rubrique']; |
|
| 148 | + $titre2 = generer_objet_info( |
|
| 149 | + $id_rubrique2, |
|
| 150 | + 'rubrique', |
|
| 151 | + 'titre' |
|
| 152 | + ); // pour etre sur de passer par tous les traitements |
|
| 153 | + if ('' !== ($rang2 = recuperer_numero($row['titre']))) { |
|
| 154 | + $rang2 = "<span class='rang'>$rang2.</span> "; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + changer_typo($row['lang']); |
|
| 158 | + $lang_dir = lang_dir($row['lang']); |
|
| 159 | + if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
|
| 160 | + $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url( |
|
| 161 | + $id_rubrique2, |
|
| 162 | + 'rubrique' |
|
| 163 | + ) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + $retour = $pagination . $retour . $pagination; |
|
| 168 | + |
|
| 169 | + if (!$retour) { |
|
| 170 | + return ''; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + return debut_block_depliable($debut > 0, "enfants$collection2") |
|
| 174 | + . "\n<ul class='liste-items sous-sous-rub'>\n" |
|
| 175 | + . $retour |
|
| 176 | + . "</ul>\n" . fin_block() . "\n\n"; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -188,41 +188,41 @@ discard block |
||
| 188 | 188 | * Le contenu textuel affiché, la liste des sous rubriques |
| 189 | 189 | */ |
| 190 | 190 | function afficher_enfant_rub($id_rubrique = 0) { |
| 191 | - $pagination = ''; |
|
| 192 | - $debut = 0; |
|
| 193 | - $limite = 500; |
|
| 194 | - |
|
| 195 | - $nb = sql_countsel('spip_rubriques', 'id_parent=' . (int) $id_rubrique); |
|
| 196 | - |
|
| 197 | - if ($nb > $limite) { |
|
| 198 | - $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut; |
|
| 199 | - $pagination = chercher_filtre('pagination'); |
|
| 200 | - $pagination = '<br class="nettoyeur"><nav class="pagination">' . |
|
| 201 | - $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
|
| 202 | - '</nav>'; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - $les_enfants = enfant_rub($id_rubrique, $debut, $limite); |
|
| 206 | - |
|
| 207 | - if (!$n = count($les_enfants)) { |
|
| 208 | - return ''; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - if ($n == 1) { |
|
| 212 | - $les_enfants = reset($les_enfants); |
|
| 213 | - $les_enfants2 = ''; |
|
| 214 | - } else { |
|
| 215 | - $n = ceil($n / 2); |
|
| 216 | - $les_enfants2 = implode('', array_slice($les_enfants, $n)); |
|
| 217 | - $les_enfants = implode('', array_slice($les_enfants, 0, $n)); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - return $pagination |
|
| 221 | - . "<div class='gauche'>" |
|
| 222 | - . $les_enfants |
|
| 223 | - . '</div>' |
|
| 224 | - . "<div class='droite'>" |
|
| 225 | - . $les_enfants2 |
|
| 226 | - . '</div>' |
|
| 227 | - . $pagination; |
|
| 191 | + $pagination = ''; |
|
| 192 | + $debut = 0; |
|
| 193 | + $limite = 500; |
|
| 194 | + |
|
| 195 | + $nb = sql_countsel('spip_rubriques', 'id_parent=' . (int) $id_rubrique); |
|
| 196 | + |
|
| 197 | + if ($nb > $limite) { |
|
| 198 | + $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut; |
|
| 199 | + $pagination = chercher_filtre('pagination'); |
|
| 200 | + $pagination = '<br class="nettoyeur"><nav class="pagination">' . |
|
| 201 | + $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
|
| 202 | + '</nav>'; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + $les_enfants = enfant_rub($id_rubrique, $debut, $limite); |
|
| 206 | + |
|
| 207 | + if (!$n = count($les_enfants)) { |
|
| 208 | + return ''; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + if ($n == 1) { |
|
| 212 | + $les_enfants = reset($les_enfants); |
|
| 213 | + $les_enfants2 = ''; |
|
| 214 | + } else { |
|
| 215 | + $n = ceil($n / 2); |
|
| 216 | + $les_enfants2 = implode('', array_slice($les_enfants, $n)); |
|
| 217 | + $les_enfants = implode('', array_slice($les_enfants, 0, $n)); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + return $pagination |
|
| 221 | + . "<div class='gauche'>" |
|
| 222 | + . $les_enfants |
|
| 223 | + . '</div>' |
|
| 224 | + . "<div class='droite'>" |
|
| 225 | + . $les_enfants2 |
|
| 226 | + . '</div>' |
|
| 227 | + . $pagination; |
|
| 228 | 228 | } |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/rechercher'); |
| 23 | 23 | if (!defined('_DELAI_CACHE_resultats')) { |
| 24 | - define('_DELAI_CACHE_resultats', 600); |
|
| 24 | + define('_DELAI_CACHE_resultats', 600); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -48,126 +48,126 @@ discard block |
||
| 48 | 48 | * @return array |
| 49 | 49 | */ |
| 50 | 50 | function inc_prepare_recherche_dist( |
| 51 | - $recherche, |
|
| 52 | - $table = 'articles', |
|
| 53 | - $cond = false, |
|
| 54 | - $serveur = '', |
|
| 55 | - $modificateurs = [], |
|
| 56 | - $primary = '' |
|
| 51 | + $recherche, |
|
| 52 | + $table = 'articles', |
|
| 53 | + $cond = false, |
|
| 54 | + $serveur = '', |
|
| 55 | + $modificateurs = [], |
|
| 56 | + $primary = '' |
|
| 57 | 57 | ) { |
| 58 | - $where = null; |
|
| 59 | - $rows = null; |
|
| 60 | - static $cache = []; |
|
| 61 | - $delai_fraicheur = min( |
|
| 62 | - \_DELAI_CACHE_resultats, |
|
| 63 | - time() - ($GLOBALS['meta']['derniere_modif'] ?? 0) |
|
| 64 | - ); |
|
| 65 | - |
|
| 66 | - // si recherche n'est pas dans le contexte, on va prendre en globals |
|
| 67 | - // ca permet de faire des inclure simple. |
|
| 68 | - if (!isset($recherche) && isset($GLOBALS['recherche'])) { |
|
| 69 | - $recherche = $GLOBALS['recherche']; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - // traiter le cas {recherche?} |
|
| 73 | - if ($cond && !strlen($recherche)) { |
|
| 74 | - return [ |
|
| 75 | - '0 as points' /* as points */, /* where */ |
|
| 76 | - '' |
|
| 77 | - ]; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - $rechercher = false; |
|
| 82 | - |
|
| 83 | - $where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND'); |
|
| 84 | - if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 85 | - $hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : ''); |
|
| 86 | - $hash = substr(md5($recherche . $table), 0, 16); |
|
| 87 | - $where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')"; |
|
| 88 | - $row = sql_fetsel( |
|
| 89 | - 'recherche', |
|
| 90 | - 'spip_resultats AS resultats', |
|
| 91 | - $where . " AND $where_resultat_recent", |
|
| 92 | - '', |
|
| 93 | - '', |
|
| 94 | - '0,1' |
|
| 95 | - ); |
|
| 96 | - if (!$row || (defined('_VAR_MODE') && _VAR_MODE == 'recalcul')) { |
|
| 97 | - $rechercher = true; |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - // si on n'a pas encore traite les donnees dans une boucle precedente |
|
| 102 | - if ($rechercher) { |
|
| 103 | - //$tables = liste_des_champs(); |
|
| 104 | - $x = objet_type($table); |
|
| 105 | - $points = recherche_en_base( |
|
| 106 | - $recherche, |
|
| 107 | - $x, |
|
| 108 | - [ |
|
| 109 | - 'score' => true, |
|
| 110 | - 'toutvoir' => true, |
|
| 111 | - 'jointures' => true |
|
| 112 | - ], |
|
| 113 | - $serveur |
|
| 114 | - ); |
|
| 115 | - // pas de résultat, pas de point |
|
| 116 | - $points = $points[$x] ?? []; |
|
| 117 | - |
|
| 118 | - // permettre aux plugins de modifier le resultat |
|
| 119 | - $points = pipeline('prepare_recherche', [ |
|
| 120 | - 'args' => [ |
|
| 121 | - 'type' => $x, |
|
| 122 | - 'recherche' => $recherche, |
|
| 123 | - 'serveur' => $serveur, |
|
| 124 | - 'modificateurs' => $modificateurs |
|
| 125 | - ], |
|
| 126 | - 'data' => $points |
|
| 127 | - ]); |
|
| 128 | - |
|
| 129 | - // supprimer les anciens resultats de cette recherche |
|
| 130 | - // et les resultats trop vieux avec une marge |
|
| 131 | - // pas de AS resultats dans un delete (mysql) |
|
| 132 | - $whered = str_replace( |
|
| 133 | - ['resultats.recherche', 'resultats.table_objet', 'resultats.serveur'], |
|
| 134 | - ['recherche', 'table_objet', 'serveur'], |
|
| 135 | - $where |
|
| 136 | - ); |
|
| 137 | - |
|
| 138 | - sql_delete( |
|
| 139 | - 'spip_resultats', |
|
| 140 | - "NOT($where_resultat_recent) OR ($whered)" |
|
| 141 | - ); |
|
| 142 | - |
|
| 143 | - // inserer les resultats dans la table de cache des resultats |
|
| 144 | - if (is_countable($points) ? count($points) : 0) { |
|
| 145 | - $tab_couples = []; |
|
| 146 | - foreach ($points as $id => $p) { |
|
| 147 | - $tab_couples[] = [ |
|
| 148 | - 'recherche' => $hash, |
|
| 149 | - 'id' => $id, |
|
| 150 | - 'points' => $p['score'], |
|
| 151 | - 'table_objet' => $table, |
|
| 152 | - 'serveur' => $hash_serv, |
|
| 153 | - ]; |
|
| 154 | - } |
|
| 155 | - sql_insertq_multi('spip_resultats', $tab_couples, []); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 160 | - if (!$serveur) { |
|
| 161 | - $cache[$serveur][$table][$recherche] = ['resultats.points AS points', $where]; |
|
| 162 | - } else { |
|
| 163 | - if (sql_countsel('spip_resultats as resultats', $where)) { |
|
| 164 | - $rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where); |
|
| 165 | - } |
|
| 166 | - $cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - return $cache[$serveur][$table][$recherche]; |
|
| 58 | + $where = null; |
|
| 59 | + $rows = null; |
|
| 60 | + static $cache = []; |
|
| 61 | + $delai_fraicheur = min( |
|
| 62 | + \_DELAI_CACHE_resultats, |
|
| 63 | + time() - ($GLOBALS['meta']['derniere_modif'] ?? 0) |
|
| 64 | + ); |
|
| 65 | + |
|
| 66 | + // si recherche n'est pas dans le contexte, on va prendre en globals |
|
| 67 | + // ca permet de faire des inclure simple. |
|
| 68 | + if (!isset($recherche) && isset($GLOBALS['recherche'])) { |
|
| 69 | + $recherche = $GLOBALS['recherche']; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + // traiter le cas {recherche?} |
|
| 73 | + if ($cond && !strlen($recherche)) { |
|
| 74 | + return [ |
|
| 75 | + '0 as points' /* as points */, /* where */ |
|
| 76 | + '' |
|
| 77 | + ]; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + $rechercher = false; |
|
| 82 | + |
|
| 83 | + $where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND'); |
|
| 84 | + if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 85 | + $hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : ''); |
|
| 86 | + $hash = substr(md5($recherche . $table), 0, 16); |
|
| 87 | + $where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')"; |
|
| 88 | + $row = sql_fetsel( |
|
| 89 | + 'recherche', |
|
| 90 | + 'spip_resultats AS resultats', |
|
| 91 | + $where . " AND $where_resultat_recent", |
|
| 92 | + '', |
|
| 93 | + '', |
|
| 94 | + '0,1' |
|
| 95 | + ); |
|
| 96 | + if (!$row || (defined('_VAR_MODE') && _VAR_MODE == 'recalcul')) { |
|
| 97 | + $rechercher = true; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + // si on n'a pas encore traite les donnees dans une boucle precedente |
|
| 102 | + if ($rechercher) { |
|
| 103 | + //$tables = liste_des_champs(); |
|
| 104 | + $x = objet_type($table); |
|
| 105 | + $points = recherche_en_base( |
|
| 106 | + $recherche, |
|
| 107 | + $x, |
|
| 108 | + [ |
|
| 109 | + 'score' => true, |
|
| 110 | + 'toutvoir' => true, |
|
| 111 | + 'jointures' => true |
|
| 112 | + ], |
|
| 113 | + $serveur |
|
| 114 | + ); |
|
| 115 | + // pas de résultat, pas de point |
|
| 116 | + $points = $points[$x] ?? []; |
|
| 117 | + |
|
| 118 | + // permettre aux plugins de modifier le resultat |
|
| 119 | + $points = pipeline('prepare_recherche', [ |
|
| 120 | + 'args' => [ |
|
| 121 | + 'type' => $x, |
|
| 122 | + 'recherche' => $recherche, |
|
| 123 | + 'serveur' => $serveur, |
|
| 124 | + 'modificateurs' => $modificateurs |
|
| 125 | + ], |
|
| 126 | + 'data' => $points |
|
| 127 | + ]); |
|
| 128 | + |
|
| 129 | + // supprimer les anciens resultats de cette recherche |
|
| 130 | + // et les resultats trop vieux avec une marge |
|
| 131 | + // pas de AS resultats dans un delete (mysql) |
|
| 132 | + $whered = str_replace( |
|
| 133 | + ['resultats.recherche', 'resultats.table_objet', 'resultats.serveur'], |
|
| 134 | + ['recherche', 'table_objet', 'serveur'], |
|
| 135 | + $where |
|
| 136 | + ); |
|
| 137 | + |
|
| 138 | + sql_delete( |
|
| 139 | + 'spip_resultats', |
|
| 140 | + "NOT($where_resultat_recent) OR ($whered)" |
|
| 141 | + ); |
|
| 142 | + |
|
| 143 | + // inserer les resultats dans la table de cache des resultats |
|
| 144 | + if (is_countable($points) ? count($points) : 0) { |
|
| 145 | + $tab_couples = []; |
|
| 146 | + foreach ($points as $id => $p) { |
|
| 147 | + $tab_couples[] = [ |
|
| 148 | + 'recherche' => $hash, |
|
| 149 | + 'id' => $id, |
|
| 150 | + 'points' => $p['score'], |
|
| 151 | + 'table_objet' => $table, |
|
| 152 | + 'serveur' => $hash_serv, |
|
| 153 | + ]; |
|
| 154 | + } |
|
| 155 | + sql_insertq_multi('spip_resultats', $tab_couples, []); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 160 | + if (!$serveur) { |
|
| 161 | + $cache[$serveur][$table][$recherche] = ['resultats.points AS points', $where]; |
|
| 162 | + } else { |
|
| 163 | + if (sql_countsel('spip_resultats as resultats', $where)) { |
|
| 164 | + $rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where); |
|
| 165 | + } |
|
| 166 | + $cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + return $cache[$serveur][$table][$recherche]; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | |
@@ -183,22 +183,22 @@ discard block |
||
| 183 | 183 | * @return array |
| 184 | 184 | */ |
| 185 | 185 | function generer_select_where_explicites($table, $primary, $rows, $serveur) { |
| 186 | - # calculer le {id_article IN()} et le {... as points} |
|
| 187 | - if ($rows === []) { |
|
| 188 | - return ["''", '0=1']; |
|
| 189 | - } else { |
|
| 190 | - $listes_ids = []; |
|
| 191 | - $select = '0'; |
|
| 192 | - foreach ($rows as $r) { |
|
| 193 | - $listes_ids[$r['points']][] = $r['id']; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - foreach ($listes_ids as $p => $ids) { |
|
| 197 | - $select .= "+$p*(" . |
|
| 198 | - sql_in("$table.$primary", $ids, '', $serveur) |
|
| 199 | - . ') '; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - return ["$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur)]; |
|
| 203 | - } |
|
| 186 | + # calculer le {id_article IN()} et le {... as points} |
|
| 187 | + if ($rows === []) { |
|
| 188 | + return ["''", '0=1']; |
|
| 189 | + } else { |
|
| 190 | + $listes_ids = []; |
|
| 191 | + $select = '0'; |
|
| 192 | + foreach ($rows as $r) { |
|
| 193 | + $listes_ids[$r['points']][] = $r['id']; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + foreach ($listes_ids as $p => $ids) { |
|
| 197 | + $select .= "+$p*(" . |
|
| 198 | + sql_in("$table.$primary", $ids, '', $serveur) |
|
| 199 | + . ') '; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + return ["$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur)]; |
|
| 203 | + } |
|
| 204 | 204 | } |
@@ -10,10 +10,10 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | if (!defined('_AUTO_SELECTION_RUBRIQUE')) { |
| 16 | - define('_AUTO_SELECTION_RUBRIQUE', false); |
|
| 16 | + define('_AUTO_SELECTION_RUBRIQUE', false); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
@@ -27,39 +27,39 @@ discard block |
||
| 27 | 27 | * @return string |
| 28 | 28 | */ |
| 29 | 29 | function inc_preselectionner_parent_nouvel_objet_dist($objet, $row) { |
| 30 | - if (!_AUTO_SELECTION_RUBRIQUE) { |
|
| 31 | - return ''; |
|
| 32 | - } |
|
| 30 | + if (!_AUTO_SELECTION_RUBRIQUE) { |
|
| 31 | + return ''; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - if (!isset($row['id_rubrique'])) { |
|
| 35 | - return ''; |
|
| 36 | - } |
|
| 34 | + if (!isset($row['id_rubrique'])) { |
|
| 35 | + return ''; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - $id_rubrique = ''; |
|
| 39 | - if ($GLOBALS['connect_id_rubrique']) { |
|
| 40 | - // si admin restreint : sa rubrique |
|
| 41 | - $id_rubrique = $GLOBALS['connect_id_rubrique'][0]; |
|
| 42 | - } elseif ( |
|
| 43 | - is_int(_AUTO_SELECTION_RUBRIQUE) |
|
| 44 | - && sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique=' . (int) _AUTO_SELECTION_RUBRIQUE) |
|
| 45 | - ) { |
|
| 46 | - $id_rubrique = _AUTO_SELECTION_RUBRIQUE; |
|
| 47 | - } else { |
|
| 48 | - // sinon la derniere rubrique cree |
|
| 49 | - $row_rub = sql_fetsel('id_rubrique', 'spip_rubriques', '', '', 'id_rubrique DESC', '0,1'); |
|
| 50 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 51 | - } |
|
| 52 | - // si le choix ne convient pas, on cherche dans un secteur |
|
| 53 | - if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) { |
|
| 54 | - $id_rubrique = ''; |
|
| 55 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 56 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 57 | - while (!$id_rubrique && ($row_rub = sql_fetch($res))) { |
|
| 58 | - if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) { |
|
| 59 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - } |
|
| 38 | + $id_rubrique = ''; |
|
| 39 | + if ($GLOBALS['connect_id_rubrique']) { |
|
| 40 | + // si admin restreint : sa rubrique |
|
| 41 | + $id_rubrique = $GLOBALS['connect_id_rubrique'][0]; |
|
| 42 | + } elseif ( |
|
| 43 | + is_int(_AUTO_SELECTION_RUBRIQUE) |
|
| 44 | + && sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique=' . (int) _AUTO_SELECTION_RUBRIQUE) |
|
| 45 | + ) { |
|
| 46 | + $id_rubrique = _AUTO_SELECTION_RUBRIQUE; |
|
| 47 | + } else { |
|
| 48 | + // sinon la derniere rubrique cree |
|
| 49 | + $row_rub = sql_fetsel('id_rubrique', 'spip_rubriques', '', '', 'id_rubrique DESC', '0,1'); |
|
| 50 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 51 | + } |
|
| 52 | + // si le choix ne convient pas, on cherche dans un secteur |
|
| 53 | + if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) { |
|
| 54 | + $id_rubrique = ''; |
|
| 55 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 56 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 57 | + while (!$id_rubrique && ($row_rub = sql_fetch($res))) { |
|
| 58 | + if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) { |
|
| 59 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return $id_rubrique; |
|
| 64 | + return $id_rubrique; |
|
| 65 | 65 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | **/ |
| 8 | 8 | |
| 9 | 9 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 10 | - return; |
|
| 10 | + return; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | include_spip('inc/acces'); |
@@ -101,93 +101,93 @@ discard block |
||
| 101 | 101 | * @return int|bool Timestamp du verrou, false si erreur |
| 102 | 102 | */ |
| 103 | 103 | function spip_nfslock($fichier, $max_age = 0) { |
| 104 | - $tries = 0; |
|
| 104 | + $tries = 0; |
|
| 105 | 105 | |
| 106 | - if (!$max_age) { |
|
| 107 | - $max_age = _DEFAULT_LOCKTIME; |
|
| 108 | - } |
|
| 109 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 106 | + if (!$max_age) { |
|
| 107 | + $max_age = _DEFAULT_LOCKTIME; |
|
| 108 | + } |
|
| 109 | + $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | - /* |
|
| 112 | + /* |
|
| 113 | 113 | * 1. create a tmp file with a psuedo random file name. we also make |
| 114 | 114 | * tpath which is a buffer to store the full pathname of the tmp file. |
| 115 | 115 | */ |
| 116 | 116 | |
| 117 | - $id = creer_uniqid(); |
|
| 118 | - $tpath = _DIR_TMP . "slock.$id"; |
|
| 119 | - $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
|
| 120 | - if (!$tmpfd) { /* open failed */ |
|
| 121 | - @fclose($tmpfd); |
|
| 122 | - spip_unlink($tpath); |
|
| 117 | + $id = creer_uniqid(); |
|
| 118 | + $tpath = _DIR_TMP . "slock.$id"; |
|
| 119 | + $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
|
| 120 | + if (!$tmpfd) { /* open failed */ |
|
| 121 | + @fclose($tmpfd); |
|
| 122 | + spip_unlink($tpath); |
|
| 123 | 123 | |
| 124 | - return false; //NFSL_SYSF |
|
| 125 | - } |
|
| 124 | + return false; //NFSL_SYSF |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /* |
|
| 127 | + /* |
|
| 128 | 128 | * 2. make fullpath, a buffer for the full pathname of the lock file. |
| 129 | 129 | * then start looping trying to lock it |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | - while ($tries < 10) { |
|
| 133 | - /* |
|
| 132 | + while ($tries < 10) { |
|
| 133 | + /* |
|
| 134 | 134 | * 3. link tmp file to lock file. if it goes, we win and we clean |
| 135 | 135 | * up and return the st_ctime of the lock file. |
| 136 | 136 | */ |
| 137 | 137 | |
| 138 | - if (link($tpath, $lock_file) == 1) { |
|
| 139 | - spip_unlink($tpath); /* got it! */ |
|
| 140 | - @fclose($tmpfd); |
|
| 141 | - if (($our_tmp = lstat($lock_file)) == false) { /* stat failed... shouldn't happen */ |
|
| 142 | - spip_unlink($lock_file); |
|
| 138 | + if (link($tpath, $lock_file) == 1) { |
|
| 139 | + spip_unlink($tpath); /* got it! */ |
|
| 140 | + @fclose($tmpfd); |
|
| 141 | + if (($our_tmp = lstat($lock_file)) == false) { /* stat failed... shouldn't happen */ |
|
| 142 | + spip_unlink($lock_file); |
|
| 143 | 143 | |
| 144 | - return false; // (NFSL_SYSF); |
|
| 145 | - } |
|
| 144 | + return false; // (NFSL_SYSF); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - return ($our_tmp['ctime']); |
|
| 148 | - } |
|
| 147 | + return ($our_tmp['ctime']); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /* |
|
| 150 | + /* |
|
| 151 | 151 | * 4. the lock failed. check for a stale lock file, being mindful |
| 152 | 152 | * of NFS and the fact the time is set from the NFS server. we |
| 153 | 153 | * do a write on the tmp file to update its time to the server's |
| 154 | 154 | * idea of "now." |
| 155 | 155 | */ |
| 156 | 156 | |
| 157 | - $old_stat = lstat($lock_file); |
|
| 158 | - if (@fwrite($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) { |
|
| 159 | - break; |
|
| 160 | - } /* something bogus is going on */ |
|
| 157 | + $old_stat = lstat($lock_file); |
|
| 158 | + if (@fwrite($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) { |
|
| 159 | + break; |
|
| 160 | + } /* something bogus is going on */ |
|
| 161 | 161 | |
| 162 | 162 | |
| 163 | - if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 164 | - spip_unlink($lock_file); /* break the stale lock */ |
|
| 165 | - $tries++; |
|
| 166 | - /* It is CRITICAL that we sleep after breaking |
|
| 163 | + if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 164 | + spip_unlink($lock_file); /* break the stale lock */ |
|
| 165 | + $tries++; |
|
| 166 | + /* It is CRITICAL that we sleep after breaking |
|
| 167 | 167 | * the lock. Otherwise, we could race with |
| 168 | 168 | * another process and unlink it's newly- |
| 169 | 169 | * created file. |
| 170 | 170 | */ |
| 171 | - sleep(1 + random_int(0, 4)); |
|
| 172 | - continue; |
|
| 173 | - } |
|
| 171 | + sleep(1 + random_int(0, 4)); |
|
| 172 | + continue; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - /* |
|
| 175 | + /* |
|
| 176 | 176 | * 5. try again |
| 177 | 177 | */ |
| 178 | 178 | |
| 179 | - $tries++; |
|
| 180 | - sleep(1 + random_int(0, 4)); |
|
| 181 | - } |
|
| 179 | + $tries++; |
|
| 180 | + sleep(1 + random_int(0, 4)); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /* |
|
| 183 | + /* |
|
| 184 | 184 | * 6. give up, failure. |
| 185 | 185 | */ |
| 186 | 186 | |
| 187 | - spip_unlink($tpath); |
|
| 188 | - @fclose($tmpfd); |
|
| 187 | + spip_unlink($tpath); |
|
| 188 | + @fclose($tmpfd); |
|
| 189 | 189 | |
| 190 | - return false; //(NFSL_LOCKED); |
|
| 190 | + return false; //(NFSL_LOCKED); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -231,71 +231,71 @@ discard block |
||
| 231 | 231 | * return bool true si déverrouillé, false sinon |
| 232 | 232 | */ |
| 233 | 233 | function spip_nfsunlock($fichier, $birth, $max_age = 0, $test = false) { |
| 234 | - $id = creer_uniqid(); |
|
| 235 | - if (!$max_age) { |
|
| 236 | - $max_age = _DEFAULT_LOCKTIME; |
|
| 237 | - } |
|
| 234 | + $id = creer_uniqid(); |
|
| 235 | + if (!$max_age) { |
|
| 236 | + $max_age = _DEFAULT_LOCKTIME; |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - /* |
|
| 239 | + /* |
|
| 240 | 240 | * 1. Build a temp file and stat that to get an idea of what the server |
| 241 | 241 | * thinks the current time is (our_tmp.st_ctime).. |
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | - $tpath = _DIR_TMP . "stime.$id"; |
|
| 245 | - $tmpfd = @fopen($tpath, 'w'); |
|
| 246 | - if (!$tmpfd || @fwrite($tmpfd, 'zz', 2) != 2 || !($our_tmp = fstat($tmpfd))) { |
|
| 247 | - /* The open failed, or we can't write the file, or we can't stat it */ |
|
| 248 | - @fclose($tmpfd); |
|
| 249 | - spip_unlink($tpath); |
|
| 244 | + $tpath = _DIR_TMP . "stime.$id"; |
|
| 245 | + $tmpfd = @fopen($tpath, 'w'); |
|
| 246 | + if (!$tmpfd || @fwrite($tmpfd, 'zz', 2) != 2 || !($our_tmp = fstat($tmpfd))) { |
|
| 247 | + /* The open failed, or we can't write the file, or we can't stat it */ |
|
| 248 | + @fclose($tmpfd); |
|
| 249 | + spip_unlink($tpath); |
|
| 250 | 250 | |
| 251 | - return false; //(NFSL_SYSF); |
|
| 252 | - } |
|
| 251 | + return false; //(NFSL_SYSF); |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 255 | - spip_unlink($tpath); |
|
| 254 | + @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 255 | + spip_unlink($tpath); |
|
| 256 | 256 | |
| 257 | - /* |
|
| 257 | + /* |
|
| 258 | 258 | * 2. make fullpath, a buffer for the full pathname of the lock file |
| 259 | 259 | */ |
| 260 | 260 | |
| 261 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 261 | + $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 262 | 262 | |
| 263 | - /* |
|
| 263 | + /* |
|
| 264 | 264 | * 3. If the ctime hasn't been modified, unlink the file and return. If the |
| 265 | 265 | * lock has expired, sleep the usual random interval before returning. |
| 266 | 266 | * If we didn't sleep, there could be a race if the caller immediately |
| 267 | 267 | * tries to relock the file. |
| 268 | 268 | */ |
| 269 | 269 | |
| 270 | - if ( |
|
| 271 | - ($old_stat = @lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 272 | - && ($old_stat['ctime'] == $birth) |
|
| 273 | - ) { /* hasn't been modified since birth */ |
|
| 274 | - if (!$test) { |
|
| 275 | - spip_unlink($lock_file); |
|
| 276 | - } /* so the lock is ours to remove */ |
|
| 277 | - if ($our_tmp['ctime'] >= $birth + $max_age) { /* the lock has expired */ |
|
| 278 | - if (!$test) { |
|
| 279 | - return false; |
|
| 280 | - } //(NFSL_LOST); |
|
| 281 | - sleep(1 + (random_int(0, 4))); /* so sleep a bit */ |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - return true;//(NFSL_OK); /* success */ |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - /* |
|
| 270 | + if ( |
|
| 271 | + ($old_stat = @lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 272 | + && ($old_stat['ctime'] == $birth) |
|
| 273 | + ) { /* hasn't been modified since birth */ |
|
| 274 | + if (!$test) { |
|
| 275 | + spip_unlink($lock_file); |
|
| 276 | + } /* so the lock is ours to remove */ |
|
| 277 | + if ($our_tmp['ctime'] >= $birth + $max_age) { /* the lock has expired */ |
|
| 278 | + if (!$test) { |
|
| 279 | + return false; |
|
| 280 | + } //(NFSL_LOST); |
|
| 281 | + sleep(1 + (random_int(0, 4))); /* so sleep a bit */ |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + return true;//(NFSL_OK); /* success */ |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + /* |
|
| 288 | 288 | * 4. Either ctime has been modified, or the entire lock file is missing. |
| 289 | 289 | * If the lock should still be ours, based on the ctime of the temp |
| 290 | 290 | * file, return with NFSL_STOLEN. If not, then our lock is expired and |
| 291 | 291 | * someone else has grabbed the file, so return NFSL_LOST. |
| 292 | 292 | */ |
| 293 | 293 | |
| 294 | - if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */ |
|
| 295 | - return false; |
|
| 296 | - } //(NFSL_STOLEN); |
|
| 294 | + if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */ |
|
| 295 | + return false; |
|
| 296 | + } //(NFSL_STOLEN); |
|
| 297 | 297 | |
| 298 | - return false; //(NFSL_LOST); /* The lock must have expired first. */ |
|
| 298 | + return false; //(NFSL_LOST); /* The lock must have expired first. */ |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | |
@@ -319,5 +319,5 @@ discard block |
||
| 319 | 319 | * return bool true si déverrouillé, false sinon |
| 320 | 320 | */ |
| 321 | 321 | function spip_nfslock_test($fichier, $birth, $max_age = 0) { |
| 322 | - return spip_nfsunlock($fichier, $birth, $max_age, true); |
|
| 322 | + return spip_nfsunlock($fichier, $birth, $max_age, true); |
|
| 323 | 323 | } |