[SPIP] ~2.1.12 -->2.1.25
[velocampus/web/www.git] / www / ecrire / exec / message_edit.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/date');
17
18
19 // http://doc.spip.org/@exec_message_edit_dist
20 function exec_message_edit_dist()
21 {
22 exec_message_edit_args(intval(_request('id_message')),
23 _request('new'),
24 intval(_request('dest')));
25 }
26 // http://doc.spip.org/@exec_message_edit_args
27 function exec_message_edit_args($id_message, $new, $dest)
28 {
29 global $connect_id_auteur, $connect_statut;
30
31 if ($new == 'oui') {
32 $onfocus = "\nonfocus=\"if(!antifocus){this.value='';antifocus=true;}\"";
33 } else $onfocus = '';
34
35 $row = sql_fetsel("*", "spip_messages", "id_message=$id_message");
36
37 $id_message = $row['id_message'];
38 $date_heure = $row["date_heure"];
39 $date_fin = $row["date_fin"];
40 $titre = entites_html($row["titre"]);
41 $texte = entites_html($row["texte"]);
42 $type = $row["type"];
43 $statut = $row["statut"];
44 $rv = $row["rv"];
45 $expediteur = $row["id_auteur"];
46
47 if (!($expediteur == $connect_id_auteur OR ($type == 'affich' AND $connect_statut == '0minirezo'))) {
48 include_spip('inc/minipres');
49 echo minipres();
50 } else {
51
52 $commencer_page = charger_fonction('commencer_page', 'inc');
53 echo $commencer_page(_T('titre_page_message_edit'), "accueil", "messagerie");
54
55 if ($type == 'normal') {
56 $le_type = _T('bouton_envoi_message_02');
57 $logo = "message";
58 }
59 if ($type == 'pb') {
60 $le_type = _T('bouton_pense_bete');
61 $logo = "pense-bete";
62 }
63 if ($type == 'affich') {
64 $le_type = _T('bouton_annonce');
65 $logo = "annonce";
66 }
67
68
69 echo debut_gauche('', true);
70
71 if($type == 'normal' AND $dest) {
72 $email = sql_getfetsel("email", "spip_auteurs", "id_auteur=$dest");
73 if (strlen($email) > 3) {
74 echo icone(_T('info_envoyer_message_prive'), "mailto:".$email, "envoi-message-24.gif");
75 }
76 }
77
78 echo debut_droite('', true);
79
80 $res = "<div class='arial2'>"
81 . "<span style='color:green' class='verdana1 spip_small'><b>$le_type</b></span>";
82 if ($type == "affich")
83 $res .="<p style='color:red;' class='verdana1 spip_x-small'>" . _T('texte_message_edit')."</p>";
84
85 $res .= '<br /><br />'."<label for='titre'>" . _T('texte_titre_obligatoire')."</label><br />\n";
86 $res .="<input type='text' class='formo' name='titre' id='titre' value=\"$titre\" size='40' $onfocus />";
87
88 if (!$dest) {
89 if ($type == 'normal') {
90 $res .="<br /><label for='cherche_auteur'><b>"._T('info_nom_destinataire')."</b></label><br />\n";
91 $res .="<input type='text' class='formo' name='cherche_auteur' id='cherche_auteur' value='' size='40'/>";
92 }
93 } else {
94 $nom = sql_getfetsel("nom", "spip_auteurs", "id_auteur=$dest");
95 $res .= "<br /><b>" .
96 _T('info_nom_destinataire') .
97 "</b>&nbsp;:&nbsp;&nbsp; " .
98 $nom .
99 "<br /><br />\n";
100 }
101 $res .= '<br />';
102
103 //////////////////////////////////////////////////////
104 // Fixer rendez-vous?
105 //
106 if ($rv == "oui") $fonction = "rv.gif"; else $fonction = "";
107
108 $res .= debut_cadre_trait_couleur($logo.".gif", true, $fonction, _T('titre_rendez_vous'))
109 . afficher_si_rdv($date_heure, $date_fin, ($rv == "oui"))
110 . fin_cadre_trait_couleur(true)
111 . "\n<p><label for='texte'><b>"
112 . _T('info_texte_message_02')
113 . "</b></label><br />"
114 . "<textarea name='texte' id='texte' rows='20' class='formo' cols='40'>"
115 . $texte
116 . "</textarea></p><br />\n"
117 . "\n<div style='text-align: right'><input type='submit' value='"
118 . _T('bouton_valider')
119 . "' /></div>"
120 . "\n</div>";
121
122 echo redirige_action_post('editer_message', $id_message, 'message',"id_message=$id_message", $res);
123
124 echo fin_gauche(), fin_page();
125 }
126 }
127
128 // http://doc.spip.org/@afficher_si_rdv
129 function afficher_si_rdv($date_heure, $date_fin, $choix)
130 {
131 $heures_debut = heures($date_heure);
132 $minutes_debut = minutes($date_heure);
133 $heures_fin = heures($date_fin);
134 $minutes_fin = minutes($date_fin);
135
136 if ($date_fin == "0000-00-00 00:00:00") {
137 $date_fin = $date_heure;
138 $heures_fin = $heures_debut + 1;
139 }
140
141 if ($heures_fin >=24){
142 $heures_fin = 23;
143 $minutes_fin = 59;
144 }
145
146 $lib = _T('item_non_afficher_calendrier');
147 if (!$choix) $lib = "<b>$lib</b>";
148
149 $res = "\n<div><input type='radio' name='rv' value='non' id='rv_off'" .
150 (!$choix ? " checked='checked' " : '')
151 . "\nonclick=\"changeVisible(this.checked, 'heure-rv', 'none', 'block');\"/>"
152 . "<label for='rv_off'>"
153 . $lib
154 . "</label>"
155 . "</div>";
156
157 $lib = _T('item_afficher_calendrier');
158 if ($choix) $lib = "<b>$lib</b>";
159
160 $res .= "\n<div><input type='radio' name='rv' value='oui' id='rv_on' " .
161 ($choix ? " checked='checked' " : '') .
162 "\nonclick=\"changeVisible(this.checked, 'heure-rv', 'block', 'none');\"/>" .
163 "<label for='rv_on'>"
164 . $lib
165 . "</label>"
166 . '</div>';
167
168 $display = ($choix ? "block" : "none");
169
170 return $res .
171 "\n<div id='heure-rv' style='display: $display; padding-top: 4px; padding-left: 24px;'>" .
172 afficher_jour_mois_annee_h_m($date_heure, $heures_debut, $minutes_debut) .
173 "<br />".
174 afficher_jour_mois_annee_h_m($date_fin, $heures_fin, $minutes_fin, '_fin') .
175 "</div>";
176 }
177
178 ?>