Mise en route du suivi.
[aidenligne_francais_universite.git] / ecrire / inc / signatures.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2007 *
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
14 if (!defined("_ECRIRE_INC_VERSION")) return;
15
16 charger_generer_url();
17
18 // http://doc.spip.org/@message_de_signature
19 function message_de_signature($row)
20 {
21 return propre(echapper_tags($row['message']));
22 }
23
24 // http://doc.spip.org/@inc_signatures_dist
25 function inc_signatures_dist($script, $id, $debut, $where, $order, $limit='') {
26
27 # filtre de duree (a remplacer par une vraie pagination)
28 #$where .= ($where ? " AND " : "") . "date_time>DATE_SUB(NOW(),INTERVAL 180 DAY)";
29 if ($id) {
30 $args = "id_article=$id&";
31 $where .= " AND id_article=$id";
32 }
33 else $args = "";
34
35 $evt = (_SPIP_AJAX === 1);
36
37 $a = "editer_signature-$id";
38
39 $q = spip_query("SELECT date_time FROM spip_signatures " . ($where ? "WHERE $where" : '') . " ORDER BY date_time DESC");
40
41 while ($row = spip_fetch_array($q)) {
42 if($c++%$limit==0) {
43 if ($c > 1) $res .= " | ";
44 $date = (affdate_court($row['date_time']));
45 if ($c == ($debut+1))
46 $res .= "<span class='spip_medium'><b>$c</b></span>";
47 else {
48 $h = generer_url_ecrire($script, $args ."debut=".($c-1));
49 if ($evt)
50 $evt = "\nonclick="
51 . ajax_action_declencheur($h,$a);
52 $res .= http_href("$h$a", $c, $date, '', '', $evt);
53 }
54 }
55 }
56
57 $limit = (!$limit AND !$debut) ? '' : (($debut ? "$debut," : "") . $limit);
58 # ($limit . ($debut ? " OFFSET $debut" : "")); #PG
59 $request = spip_query("SELECT * FROM spip_signatures " . ($where ? " WHERE $where" : "") . ($order ? " ORDER BY $order" : "") . (!$limit ? '' : " LIMIT $limit"));
60
61 $res .= '<br />';
62
63 while($row=spip_fetch_array($request)){
64 $res .= '<br />' . signatures_edit($script, $id, $debut, $row);
65 }
66 return $res;
67 }
68
69 // http://doc.spip.org/@signatures_edit
70 function signatures_edit($script, $id, $debut, $row) {
71
72 global $couleur_foncee;
73
74 $id_signature = $row['id_signature'];
75 $id_article = $row['id_article'];
76 $date_time = $row['date_time'];
77 $nom_email= typo(echapper_tags($row['nom_email']));
78 $ad_email = echapper_tags($row['ad_email']);
79 $nom_site = typo(echapper_tags($row['nom_site']));
80 $url_site = echapper_tags($row['url_site']);
81 $statut = $row['statut'];
82
83 $arg = ($statut=="publie") ? "-$id_signature" : $id_signature;
84 $res = "";
85
86 if ($statut=="poubelle"){
87 $res .= "<table width='100%' cellpadding='2' cellspacing='0' border='0'><tr><td style='background-color: #ff0000'>";
88 }
89
90 $res .= "<table width='100%' cellpadding='3' cellspacing='0'><tr><td class='verdana2' style='background-color: $couleur_foncee; color: white;'><b>"
91 . ($nom_site ? "$nom_site / " : "")
92 . $nom_email
93 . "</b></td></tr>"
94 . "<tr><td style='background-color: #ffffff' class='serif'>";
95
96 if ($statut=="publie"){
97 $res .= icone (_T('icone_supprimer_signature'),
98 redirige_action_auteur('editer_signatures', $arg, $script, "id_article=$id&debut=$debut"),
99 "forum-interne-24.gif",
100 "supprimer.gif",
101 "right",
102 false);
103 } elseif ($statut=="poubelle"){
104 $res .= icone (_T('icone_valider_signature'),
105 redirige_action_auteur('editer_signatures', $arg, $script, "id_article=$id&debut=$debut"),
106 "forum-interne-24.gif",
107 "creer.gif",
108 "right",
109 false);
110 }
111
112 $res .= "<span class='spip_small'>".date_interface($date_time)."</span><br />";
113 if ($statut=="poubelle"){
114 $res .= "<span class='spip_x-small' style='color: red;'>"._T('info_message_efface')."</span><br />";
115 }
116 if (strlen($url_site)>6 AND strlen($nom_site)>0){
117 $res .= "<span class='spip_x-small'>"._T('info_site_web')."</span> <a href='$url_site'>$nom_site</a><br />";
118 }
119 if (strlen($ad_email)>0){
120 $res .= "<span class='spip_x-small'>"._T('info_adresse_email')."</span> <a href='mailto:$ad_email'>$ad_email</a><br />";
121 }
122
123 $res .= '<br />' . message_de_signature($row);
124
125 $titre = spip_fetch_array(spip_query("SELECT titre FROM spip_articles WHERE id_article=$id_article"));
126
127 if (!$id)
128 $res .= "<span class='arial1' style='float: $spip_lang_right; color: black; padding-$spip_lang_left: 4px;'><b>"
129 . _T('info_numero_abbreviation')
130 . $id_article
131 . " </b></span>";
132
133 $res .= "<a href='"
134 . (($statut == 'publie') ?
135 generer_url_action('redirect', "id_article=$id_article") :
136 generer_url_ecrire('articles', "id_article=$id_article"))
137 . "'>"
138 . typo($titre['titre'])
139 . "</a>"
140 . "</td></tr></table>";
141
142 if ($statut=="poubelle"){
143 $res .= "</td></tr></table>";
144 }
145
146 return $res;
147 }
148 ?>