[SPIP] +2.1.12
[velocampus/web/www.git] / www / ecrire / exec / dater.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2011 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined('_ECRIRE_INC_VERSION')) return;
14
15 // http://doc.spip.org/@exec_dater_dist
16 function exec_dater_dist()
17 {
18 exec_dater_args(intval(_request('id')), _request('type'), _request('script'));
19 }
20
21 // http://doc.spip.org/@exec_dater_args
22 function exec_dater_args($id, $type, $script)
23 {
24 if (!$id OR !autoriser('voir',$type,$id)) {
25 include_spip('inc/minipres');
26 echo minipres();
27 } else {
28 $table = table_objet_sql($type);
29 if (!id_table_objet($table)) {
30 spip_log("dater: $type table inconnue");
31 $type = 'article';
32 $table = table_objet_sql($type);
33 }
34 if (!preg_match('/^[_\w]+$/', $script)) $script = 'articles';
35 if (!function_exists($f = "dater_retour_$script")) $f = "dater_retour_articles";
36 include_spip('inc/actions');
37 ajax_retour($f($id, $type, $table));
38 }
39 }
40
41 function dater_retour_articles($id, $type, $table)
42 {
43 $r = sql_fetsel("date, date_redac,statut", $table, "id_$type=$id");
44 $date_redac = $r["date_redac"];
45 $dater = charger_fonction('dater', 'inc');
46 return $dater($id, 'ajax', $r['statut'], $type, 'articles', $r['date'], $date_redac);
47 }
48
49 function dater_retour_breves_voir($id, $type, $table)
50 {
51 $r = sql_fetsel("statut, date_heure", $table, "id_$type=$id");
52 $dater = charger_fonction('dater', 'inc');
53 return $dater($id, 'ajax', $r['statut'], $type, 'breves_voir', $r['date_heure']);
54 }
55
56 function dater_retour_sites($id, $type, $table)
57 {
58 $r = sql_fetsel("statut, date", $table, "id_$type=$id");
59 $dater = charger_fonction('dater', 'inc');
60 return $dater($id, 'ajax', $r['statut'], $type, 'sites', $r['date']);
61 }
62 ?>