From 2ef6c85cbb062290e8a6a12d195baa0b35e6fd4c Mon Sep 17 00:00:00 2001 From: tofulm Date: Tue, 18 Apr 2023 18:28:32 +0200 Subject: [PATCH] feat ajout la fonction forcer_hit() --- gamutable_fonctions.php | 27 +++++++++++++++++++++++++++ paquet.xml | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gamutable_fonctions.php b/gamutable_fonctions.php index 30b21d4..f9f460c 100644 --- a/gamutable_fonctions.php +++ b/gamutable_fonctions.php @@ -14,6 +14,33 @@ if (!defined("_ECRIRE_INC_VERSION")) { } include_spip("inc/vite"); +/** + * fonction pour forcer un hit pour un objet + * un hit => maj de champ maj + * + * @param string $objet + * @param int $id_objet + * @param string $table (optional) pour forcer sur une table spécifique ou le test se fait sur la cle primaire de $objet + * si $table est renseigné : ex : + * $objet = rubrique + * $id_objet = 4 + * $table = 'spip_articles' + * => le hit sur l'id_rubrique 4 de spip_articles + * + * @return void [TODO:description] + */ +function forcer_hit(string $objet, int $id_objet, string $table = null):void { + include_spip('inc/invalideur'); + $id = id_table_objet($objet); + if (!$table) { + $table = table_objet_sql($objet); + } else { + $id_c = id_table_objet($table); + suivre_invalideur("id='$id_c/1'"); + } + sql_updateq($table, ['maj' => date("Y-m-d H:i:s")], "$id=".$id_objet); + suivre_invalideur("id='$id/1'"); +} if (!function_exists('tsEnDate')) { /** diff --git a/paquet.xml b/paquet.xml index 4d18fc7..b91015c 100644 --- a/paquet.xml +++ b/paquet.xml @@ -1,7 +1,7 @@