[SPIP] ~2.1.12 -->2.1.25
[velocampus/web/www.git] / www / ecrire / inc / petitionner.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2014 *
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 include_spip('inc/actions');
17 include_spip('inc/texte');
18
19 // http://doc.spip.org/@inc_petitionner_dist
20 function inc_petitionner_dist($id_article, $script, $args, $ajax=false)
21 {
22 global $spip_lang_right;
23
24 $petition = sql_fetsel("*", "spip_petitions", "id_article=$id_article");
25
26 if (!autoriser('modererpetition', 'article', $id_article))
27 return petitionner_decompte($id_article, $petition);
28
29 $choix = petitionner_choisir($petition);
30
31 if ($petition) {
32 $res = $choix
33 . petitionner_decompte($id_article, $petition)
34 . petitionner_params($petition)
35 . petitionner_message($petition);
36 $class = '';
37 } else {
38 $res = $choix;
39 $class = $ajax ? '' : ' visible_au_chargement';
40 }
41
42 $atts = " class='$class' style='float: $spip_lang_right;' id='valider_petition'";
43
44 $res = ajax_action_post('petitionner', $id_article, $script, $args, $res,_T('bouton_changer'), $atts);
45
46 return ajax_action_greffe("petitionner", $id_article, $res);
47 }
48
49 // http://doc.spip.org/@petitionner_choisir
50 function petitionner_choisir($petition)
51 {
52 if ($petition) {
53 $menu = array(
54 'on' => _T('bouton_radio_petition_activee'),
55 'off'=> _T('bouton_radio_supprimer_petition')
56 );
57 $val_menu = 'on';
58 } else {
59 $menu = array(
60 'off'=> _T('bouton_radio_pas_petition'),
61 'on' => _T('bouton_radio_activer_petition')
62 );
63 $val_menu = 'off';
64 }
65
66 $res = "";
67 foreach ($menu as $val => $desc) {
68 $res .= "<option" . (($val_menu == $val) ? " selected='selected'" : '') . " value='$val'>".$desc."</option>\n";
69 }
70
71 return "<select name='change_petition' id='change_petition'
72 class='spip_xx-small'
73 onchange=\"\$('#valider_petition').css('visibility','visible');\"
74 >\n$res</select><br />\n";
75 }
76
77 // http://doc.spip.org/@petitionner_decompte
78 function petitionner_decompte($id_article, $petition)
79 {
80 $signatures = sql_countsel("spip_signatures", "id_article=$id_article");
81
82 if (!$signatures) return '';
83
84 return '<!-- visible -->' // message pour l'appelant
85 . icone_horizontale(
86 $signatures.'&nbsp;'. _T('info_signatures'),
87 generer_url_ecrire("controle_petition", "id_article=$id_article",'', false),
88 "suivi-petition-24.gif",
89 "",
90 false
91 );
92 }
93
94 // http://doc.spip.org/@petitionner_message
95 function petitionner_message($petition)
96 {
97 return "<br /><label for='texte_petition'>"._T('texte_descriptif_petition')."</label>&nbsp;:<br />"
98 . "<textarea name='texte_petition' id='texte_petition' class='forml' rows='4' cols='10'>"
99 . entites_html($petition["texte"])
100 . "</textarea>\n";
101 }
102
103 // http://doc.spip.org/@petitionner_params
104 function petitionner_params($petition)
105 {
106 $email_unique=$petition["email_unique"];
107 $site_obli=$petition["site_obli"];
108 $site_unique=$petition["site_unique"];
109 $message=$petition["message"];
110
111 $res = "<input type='checkbox' name='email_unique' id='emailunique' "
112 . (($email_unique=="oui")?"checked='checked' ":"")
113 . "/>"
114 . " <label for='emailunique'>"._T('bouton_checkbox_signature_unique_email')."</label><br />";
115
116 $res .= "<input type='checkbox' name='site_obli' id='siteobli' "
117 . ($site_obli=="oui"?"checked='checked'":"")
118 . " />";
119
120 return $res
121 . " <label for='siteobli'>"._T('bouton_checkbox_indiquer_site')."</label><br />"
122 . "<input type='checkbox' name='site_unique' id='siteunique' "
123 . ($site_unique=="oui"?"checked='checked'":"")
124 . " />"
125 . " <label for='siteunique'>"._T('bouton_checkbox_signature_unique_site')."</label><br />"
126 . "<input type='checkbox' name='message' id='message' "
127 . ($message=="oui"?"checked='checked'":"")
128 . " />"
129 . " <label for='message'>"._T('bouton_checkbox_envoi_message')."</label>";
130
131 }
132 ?>