[SPIP] +2.1.12
[velocampus/web/www.git] / www / ecrire / inc / signatures.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/@message_de_signature
16 function message_de_signature($row)
17 {
18 return propre(echapper_tags($row['message']));
19 }
20
21 // http://doc.spip.org/@inc_signatures_dist
22 function inc_signatures_dist($script, $id, $debut, $pas, $where, $order, $type='') {
23
24 if ($id) {
25 $args = "id_article=$id&";
26 }
27 else $args = "";
28
29 $t = sql_countsel("spip_signatures", $where);
30 if ($t > $pas) {
31 $res = navigation_pagination($t, $pas, generer_url_ecrire($script, $args), $debut, 'debut', false);
32 } else $res = '';
33
34 $limit = (!$pas AND !$debut) ? '' : (($debut ? "$debut," : "") . $pas);
35
36 $arg = "debut=$debut&type=$type";
37
38 $res .= "<br />\n";
39 include_spip('inc/urls');
40 $r = sql_allfetsel('*', 'spip_signatures', $where, '', $order, $limit);
41 foreach($r as $k => $row)
42 $r[$k] = signatures_edit($script, $id, $arg, $row);
43
44 return $res."<br />\n" . join("<br />\n", $r);
45 }
46
47 // http://doc.spip.org/@signatures_edit
48 function signatures_edit($script, $id, $arg, $row) {
49
50 global $spip_lang_right, $spip_lang_left;
51 $id_signature = $row['id_signature'];
52 $id_article = $row['id_article'];
53 $date_time = $row['date_time'];
54 $nom_email= typo(echapper_tags($row['nom_email']));
55 $ad_email = echapper_tags($row['ad_email']);
56 $nom_site = typo(echapper_tags($row['nom_site']));
57 $url_site = echapper_tags($row['url_site']);
58 $statut = $row['statut'];
59
60 $res = !autoriser('modererpetition', 'article', $id_article) ? '' : true;
61
62 if ($res) {
63 if ($id) $arg .= "&id_article=$id_article";
64 $arg .= "#signature$id_signature";
65 $retour_s = redirige_action_auteur('editer_signatures', $id_signature, $script, $arg);
66 $retour_a = redirige_action_auteur('editer_signatures', "-$id_signature", $script, $arg);
67
68 if ($statut=="poubelle"){
69 $res = icone_inline (_T('icone_valider_signature'),
70 $retour_s,
71 "forum-interne-24.gif",
72 "creer.gif",
73 "right",
74 false);
75 } else {
76 $res = icone_inline (_T('icone_supprimer_signature'),
77 $retour_a,
78 "forum-interne-24.gif",
79 "supprimer.gif",
80 "right",
81 false);
82 if ($statut<>"publie") {
83 $res .= icone_inline (_T('icone_relancer_signataire'),
84 $retour_s,
85 "forum-interne-24.gif",
86 "creer.gif",
87 "right",
88 false);
89 }
90 }
91 $res = "<div class='editer_auteurs'>$res</div>";
92 }
93
94 $res .= "<div class='spip_small date'>".date_interface($date_time)."</div>\n";
95 if ($statut=="poubelle"){
96 $res .= "<div class='spip_x-small info_statut'>"._T('info_message_efface')."</div>\n";
97 }
98 if (strlen($url_site)>6) {
99 if (!$nom_site) $nom_site = _T('info_site');
100 $res .= "<div class='site'><span class='spip_x-small'>"._T('info_site_web')."</span> <a href='$url_site'>$nom_site</a></div>\n";
101 }
102 if ($ad_email) {
103 $res .= "<div class='ad_email'><span class='spip_x-small'>"
104 ._T('info_adresse_email')
105 ."</span> "
106 . (!email_valide($ad_email)
107 ? $ad_email :
108 ("<a href='mailto:" . attribut_html($ad_email) . "'>$ad_email</a>"))
109 . "</div>\n";
110 }
111
112 $res .= "<div class='texte'>" . message_de_signature($row) . "</div>";
113
114 if (!$id) {
115 if ($r = sql_fetsel("titre, id_rubrique", "spip_articles", "id_article=$id_article")) {
116 $id_rubrique = $r['id_rubrique'];
117 $titre_a = $r['titre'];
118 $titre_r = supprimer_numero(sql_getfetsel("titre", "spip_rubriques", "id_rubrique=$id_rubrique"));
119 $href = generer_url_ecrire('naviguer', "id_rubrique=" . $id_rubrique);
120 $h2 = generer_url_ecrire_article($id_article);
121 $res .= "<div class='nettoyeur'></div><div class='reponse_a'><a title='$id_article' href='"
122 . $h2
123 . "'>"
124 . typo($titre_a)
125 . "</a><a ' class='reponse_a' style='float: $spip_lang_right; padding-$spip_lang_left: 4px;' href='$href' title='$id_rubrique'>"
126 . typo($titre_r)
127 . " </a></div>";
128 }
129 }
130
131 $res = "<table class='signature' id='signature$id_signature' width='100%' cellpadding='3' cellspacing='0'>\n<tr><td class='verdana2 cartouche'>"
132 . ($nom_site ? "$nom_site / " : "")
133 . $nom_email
134 . "</td></tr>"
135 . "\n<tr><td class='serif contenu'>"
136 . $res
137 . "</td></tr></table>\n";
138
139 if ($statut=="poubelle") {
140 $res = "<table class='signature' width='100%' cellpadding='2' cellspacing='0' border='0'><tr><td class='poubelle'>"
141 . $res
142 . "</td></tr></table>";
143 }
144
145 return $res;
146 }
147 ?>