[SPIP] +2.1.12
[velocampus/web/www.git] / www / ecrire / exec / controle_petition.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 include_spip('inc/presentation');
16
17 // http://doc.spip.org/@exec_controle_petition_dist
18 function exec_controle_petition_dist()
19 {
20 exec_controle_petition_args(intval(_request('id_article')),
21 _request('type'),
22 _request('date'),
23 intval(_request('debut')),
24 intval(_request('id_signature')),
25 intval(_request('pas'))); // a proposer grapiquement
26 }
27
28 // http://doc.spip.org/@exec_controle_petition_args
29 function exec_controle_petition_args($id_article, $type, $date, $debut, $id_signature, $pas=NULL)
30 {
31 if ($id_signature) {
32 $id_article = sql_getfetsel("id_article", "spip_signatures", "id_signature=$id_signature");
33 $where = '(id_signature=' . sql_quote($id_signature) . ') AND ';
34 } else $where = '';
35 if ($id_article AND !($titre = sql_getfetsel("titre", "spip_articles", "id_article=$id_article"))) {
36 include_spip('inc/minipres');
37 echo minipres(_T('public:aucun_article'));
38 } else controle_petition_args($id_article, $type, $date, $debut, $titre, $where, $pas);
39 }
40
41 function controle_petition_args($id_article, $type, $date, $debut, $titre, $where, $pas)
42 {
43 if (!preg_match('/^\w+$/',$type)) $type = 'public';
44 if ($id_article) $where .= "id_article=$id_article AND ";
45 $extrait = "(statut='publie' OR statut='poubelle')";
46 if ($type == 'interne') $extrait = "NOT($extrait)";
47 $where .= $extrait;
48 $order = "date_time DESC";
49 if (!$pas) $pas = 10;
50 if ($date) {
51 include_spip('inc/forum');
52 $query = array('SELECT' => 'UNIX_TIMESTAMP(date_time) AS d',
53 'FROM' => 'spip_signatures',
54 'WHERE' => $where,
55 'ORDER BY' => $order);
56 $debut = navigation_trouve_date($date, 'd', $pas, $query);
57 }
58 $signatures = charger_fonction('signatures', 'inc');
59
60 $res = $signatures('controle_petition', $id_article, $debut, $pas, $where, $order, $type);
61
62 if (_AJAX) {
63 ajax_retour($res);
64 } else {
65
66 if (autoriser('modererpetition')
67 OR (
68 $id_article > 0
69 AND autoriser('modererpetition', 'article', $id_article)
70 ))
71 $ong = controle_petition_onglet($id_article, $debut, $type);
72 else {
73 $type = 'public';
74 $ong = '';
75 }
76 controle_petition_page($id_article, $titre, $ong, $res);
77 }
78 }
79
80 // http://doc.spip.org/@controle_petition_page
81 function controle_petition_page($id_article, $titre, $ong, $corps)
82 {
83 if ($id_article) {
84 $a = generer_url_ecrire("statistiques_visites","id_article=$id_article");
85 $rac = "<br /><br /><br /><br /><br />" .
86 bloc_des_raccourcis(icone_horizontale(_T('icone_statistiques_visites'),$a, "statistiques-24.gif","rien.gif", false));
87
88 $titre = "<a href='" .
89 generer_url_entite($id_article,'article') .
90 "'>" .
91 typo($titre) .
92 "</a>" .
93 " <span class='arial1'>(" .
94 _T('info_numero_abbreviation') .
95 $id_article .
96 ")</span>";
97
98 if (!sql_countsel('spip_petitions', "id_article=$id_article"))
99 $titre .= '<br >' . _T('info_petition_close');
100
101 $args = array('id_article' => $id_article);
102 } else {
103 $args = array();
104 $rac = $titre = '';
105 }
106
107 $head = _T('titre_page_controle_petition');
108 $idom = "editer_signature-" . $id_article;
109 $commencer_page = charger_fonction('commencer_page', 'inc');
110
111 echo $commencer_page($head, "forum", "suivi-petition");
112 echo debut_gauche('', true);
113 echo $rac;
114 echo debut_droite('', true);
115 echo gros_titre(_T('titre_suivi_petition'),'', false);
116 echo $ong;
117 echo bouton_spip_rss('signatures', $args);
118 echo $titre;
119 echo "<br /><br />";
120 echo "<div id='", $idom, "' class='serif2'>", $corps, "</div>";
121 echo fin_gauche(), fin_page();
122 }
123
124 // http://doc.spip.org/@controle_petition_onglet
125 function controle_petition_onglet($id_article, $debut, $type, $arg='')
126 {
127 $arg .= ($id_article ? "id_article=$id_article&" :'');
128 $arg2 = ($debut ? "debut=$debut&" : '');
129 if ($type=='public') {
130 $argp = $arg2;
131 $argi = '';
132 } else {
133 $argi = $arg2;
134 $argp = '';
135 }
136
137 return debut_onglet()
138 . onglet(_T('titre_signatures_confirmees'), generer_url_ecrire('controle_petition', $argp . $arg . "type=public"), "public", $type=='public', "forum-public-24.gif")
139 . onglet(_T('titre_signatures_attente'), generer_url_ecrire('controle_petition', $argi . $arg . "type=interne"), "interne", $type=='interne', "forum-interne-24.gif")
140 . fin_onglet()
141 . '<br />';
142 }
143 ?>