diff --git a/.gitattributes b/.gitattributes index 202d04bbea0266ace828a0403a67bdfa9be322b5..11bb4733854e457411788eb948f10d93240c11ad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -244,6 +244,7 @@ ecrire/inc/instituer_auteur.php -text ecrire/inc/instituer_breve.php -text ecrire/inc/instituer_site.php -text ecrire/inc/joindre.php -text +ecrire/inc/journal.php -text ecrire/inc/json.php -text ecrire/inc/lang_liste.php -text ecrire/inc/legender.php -text diff --git a/ecrire/inc/journal.php b/ecrire/inc/journal.php new file mode 100644 index 0000000000000000000000000000000000000000..5545ff7c49997b93712fd955752dfb7255044339 --- /dev/null +++ b/ecrire/inc/journal.php @@ -0,0 +1,51 @@ +<?php + +/***************************************************************************\ + * SPIP, Systeme de publication pour l'internet * + * * + * Copyright (c) 2001-2009 * + * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * + * * + * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * + * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * +\***************************************************************************/ + +if (!defined("_ECRIRE_INC_VERSION")) return; + + +/* + * Consigner une phrase dans le journal de bord du site + * Cette API travaille a minima, mais un plugin pourra stocker + * ces journaux en base et fournir des outils d'affichage, de selection etc + * + * @param string $journal + * @param array $opt + */ +function journal($phrase, $opt = array()) { + if (!strlen($phrase)) + return; + if ($opt) + $phrase .= " :: ".str_replace("\n", ' ', join(', ',$opt)); + spip_log($phrase, 'journal'); +} + +/* Lire le journal de bord en appliquant les criteres de choix + * et le renvoyer sous forme de tableau horodate ; attention a + * limiter a un nombre raisonnable d'items : l'API ne definit + * pas de limite + * + * @param array $criteres + */ +function lire_journal($criteres = null) { + $journal = array(); + foreach (array(_DIR_TMP.'prive_journal.log', _DIR_TMP.'journal.log') as $f) + if (@is_readable($f)) + foreach(file($f) as $l) { + if ($time = strtotime(join(' ', array_slice(explode(' ',$l),0,3)))) + $journal[$time] = join(' ', array_slice(explode(' ',$l),6)); + } + krsort($journal); + return $journal; +} + +?> diff --git a/ecrire/inc/modifier.php b/ecrire/inc/modifier.php index 1f1da0bceae6295275fa90f2f3afac385e9316b7..19638ea9298e68d7c5b660628446e3c73bb8bc04 100644 --- a/ecrire/inc/modifier.php +++ b/ecrire/inc/modifier.php @@ -157,6 +157,17 @@ function modifier_contenu($type, $id, $options, $c=false, $serveur='') { exit; } + // journaliser l'affaire + // message a affiner :-) + include_spip('inc/journal'); + include_spip('inc/filtres_mini'); + $qui = sinon($GLOBALS['visiteur_session']['nom'], $GLOBALS['ip']); + journal(_L($qui.' a édité l’'.$type.' '.$id.' ('.join('+',array_diff(array_keys($champs), array('date_modif'))).')'), array( + 'faire' => 'modifier', + 'quoi' => $type, + 'id' => $id + )); + return true; }