[76] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * Abomailmans |
---|
| 5 | * MaZiaR - NetAktiv |
---|
| 6 | * tech@netaktiv.com |
---|
| 7 | * Printemps 2007 |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | include_spip('inc/abomailmans'); |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | function abomailmans_update(){ |
---|
| 15 | include_spip('base/abstract_sql'); |
---|
| 16 | $id_abomailman = intval(_request('id_abomailman')); |
---|
| 17 | $new = _request('new'); |
---|
| 18 | $supp_abomailman = intval(_request('supp_abomailman')); |
---|
| 19 | $retour = _request('retour'); |
---|
| 20 | $titre = _request('titre'); |
---|
| 21 | $descriptif = _request('descriptif'); |
---|
| 22 | $email = _request('email'); |
---|
| 23 | $supp_confirme = _request('supp_confirme'); |
---|
| 24 | $supp_rejet = _request('supp_rejet'); |
---|
| 25 | |
---|
| 26 | // |
---|
| 27 | // Modifications des donnees de base du formulaire |
---|
| 28 | // |
---|
| 29 | if (abomailmans_abomailman_administrable($id_abomailman)) { |
---|
| 30 | if ($supp_abomailman = intval($supp_abomailman) AND $supp_confirme AND !$supp_rejet) { |
---|
| 31 | $query = "DELETE FROM spip_abomailmans WHERE id_abomailman=$supp_abomailman"; |
---|
| 32 | $result = spip_query($query); |
---|
| 33 | if ($retour) { |
---|
| 34 | $retour = urldecode($retour); |
---|
| 35 | Header("Location: $retour"); |
---|
| 36 | exit; |
---|
| 37 | } |
---|
| 38 | } |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | if (abomailmans_abomailman_editable($id_abomailman)) { |
---|
| 42 | // creation |
---|
| 43 | if ($new == 'oui' && $titre) { |
---|
| 44 | $id_abomailman = spip_abstract_insert( |
---|
| 45 | "spip_abomailmans","(titre,descriptif,email)", |
---|
| 46 | "(". |
---|
| 47 | spip_abstract_quote($titre).", ". |
---|
| 48 | spip_abstract_quote($descriptif).", ". |
---|
| 49 | spip_abstract_quote($email).")"); |
---|
| 50 | } |
---|
| 51 | // maj |
---|
| 52 | else if ($id_abomailman && $titre) { |
---|
| 53 | spip_query("UPDATE spip_abomailmans SET ". |
---|
| 54 | "titre=".spip_abstract_quote($titre).", ". |
---|
| 55 | "descriptif=".spip_abstract_quote($descriptif).", ". |
---|
| 56 | "email=".spip_abstract_quote($email). |
---|
| 57 | "WHERE id_abomailman=$id_abomailman"); |
---|
| 58 | } |
---|
| 59 | // lecture |
---|
| 60 | $result = spip_query("SELECT * FROM spip_abomailmans WHERE id_abomailman=".spip_abstract_quote($id_abomailman)); |
---|
| 61 | if ($row = spip_fetch_array($result)) { |
---|
| 62 | $id_abomailman = $row['id_abomailman']; |
---|
| 63 | $titre = $row['titre']; |
---|
| 64 | $descriptif = $row['descriptif']; |
---|
| 65 | $email = $row['email']; |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | return $id_abomailman; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | function exec_abomailmans_edit(){ |
---|
| 73 | global $spip_lang_right; |
---|
| 74 | $id_abomailman = intval(_request('id_abomailman')); |
---|
| 75 | $new = _request('new'); |
---|
| 76 | $supp_abomailman = intval(_request('supp_abomailman')); |
---|
| 77 | $retour = _request('retour'); |
---|
| 78 | $titre = _request('titre'); |
---|
| 79 | $descriptif = _request('descriptif'); |
---|
| 80 | $email = _request('email'); |
---|
| 81 | $supp_confirme = _request('supp_confirme'); |
---|
| 82 | $supp_rejet = _request('supp_rejet'); |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | _abomailmans_install(); |
---|
| 86 | |
---|
| 87 | if ($retour) |
---|
| 88 | $retour = urldecode($retour); |
---|
| 89 | include_spip("inc/presentation"); |
---|
| 90 | include_spip("inc/config"); |
---|
| 91 | |
---|
| 92 | $clean_link = parametre_url(self(),'new',''); |
---|
| 93 | $abomailman_link = generer_url_ecrire('abomailmans_edit'); |
---|
| 94 | if ($new == 'oui' && !$titre) |
---|
| 95 | $abomailman_link = parametre_url($abomailman_link,"new",$new); |
---|
| 96 | if ($retour) |
---|
| 97 | $abomailman_link = parametre_url($abomailman_link,"retour",urlencode($retour)); |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | // |
---|
| 101 | // Recupere les donnees |
---|
| 102 | // |
---|
| 103 | if ($new == 'oui' && !$titre) { |
---|
| 104 | $titre = _T("abomailmans:nouvelle_liste"); |
---|
| 105 | $descriptif = ""; |
---|
| 106 | $email = ""; |
---|
| 107 | $js_titre = " onfocus=\"if(!antifocus){this.value='';antifocus=true;}\""; |
---|
| 108 | } |
---|
| 109 | else { |
---|
| 110 | // |
---|
| 111 | // Modifications au structure du formulaire |
---|
| 112 | // |
---|
| 113 | $id_abomailman = abomailmans_update(); |
---|
| 114 | |
---|
| 115 | $result = spip_query("SELECT * FROM spip_abomailmans WHERE id_abomailman=".spip_abstract_quote($id_abomailman)); |
---|
| 116 | if ($row = spip_fetch_array($result)) { |
---|
| 117 | $id_abomailman = $row['id_abomailman']; |
---|
| 118 | $titre = $row['titre']; |
---|
| 119 | $descriptif = $row['descriptif']; |
---|
| 120 | $email = $row['email']; |
---|
| 121 | |
---|
| 122 | } |
---|
| 123 | $js_titre = ""; |
---|
| 124 | } |
---|
| 125 | $abomailman_link = parametre_url($abomailman_link,"id_abomailman",$id_abomailman); |
---|
| 126 | $clean_link = parametre_url($clean_link,"id_abomailman",$id_abomailman); |
---|
| 127 | |
---|
| 128 | // |
---|
| 129 | // Affichage de la page |
---|
| 130 | // |
---|
| 131 | |
---|
| 132 | debut_page("« $titre »", "documents", "abomailmans",""); |
---|
| 133 | |
---|
| 134 | debut_gauche(); |
---|
| 135 | echo "<br /><br />\n"; |
---|
| 136 | |
---|
| 137 | debut_droite(); |
---|
| 138 | |
---|
| 139 | if ($supp_abomailman && $supp_confirme==NULL && $supp_rejet==NULL) { |
---|
| 140 | echo "<p>"; |
---|
| 141 | echo _T('charts:confirmer_supression')."</p>\n"; |
---|
| 142 | $link = parametre_url($clean_link,'supp_abomailman', $supp_abomailman); |
---|
| 143 | echo "<form method='POST' action='" |
---|
| 144 | . $link |
---|
| 145 | . "' style='border: 0px; margin: 0px;'>"; |
---|
| 146 | echo "<div style='text-align:$spip_lang_right'>"; |
---|
| 147 | echo "<input type='submit' name='supp_confirme' value=\""._T('item_oui')."\" class='fondo'>"; |
---|
| 148 | echo " "; |
---|
| 149 | echo "<input type='submit' name='supp_rejet' value=\""._T('item_non')."\" class='fondo'>"; |
---|
| 150 | echo "</div>"; |
---|
| 151 | echo "</form><br />\n"; |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | if ($id_abomailman && $supp_confirme==NULL) { |
---|
| 156 | debut_cadre_relief("../"._DIR_PLUGIN_ABOMAILMANS."/img_pack/mailman.gif"); |
---|
| 157 | |
---|
| 158 | gros_titre($titre); |
---|
| 159 | |
---|
| 160 | if ($descriptif) { |
---|
| 161 | echo "<p /><div align='left' border: 1px dashed #aaaaaa;'>"; |
---|
| 162 | echo "<strong class='verdana2'>"._T('info_descriptif')."</strong> "; |
---|
| 163 | echo propre($descriptif); |
---|
| 164 | echo "</div>\n"; |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | if ($email) { |
---|
| 168 | echo "<p /><div align='left' border: 1px dashed #aaaaaa;'>"; |
---|
| 169 | echo "<strong class='verdana2'>"._T('abomailmans:emailliste_abomailman')."</strong> "; |
---|
| 170 | echo propre($email); |
---|
| 171 | echo "</div>\n"; |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | fin_cadre_relief(); |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | // |
---|
| 183 | // Icones retour et suppression |
---|
| 184 | // |
---|
| 185 | echo "<div style='text-align:$spip_lang_right'>"; |
---|
| 186 | if ($retour) { |
---|
| 187 | icone(_T('icone_retour'), $retour, "../"._DIR_PLUGIN_ABOMAILMANS."/img_pack/mailman.gif", "rien.gif",'right'); |
---|
| 188 | } |
---|
| 189 | if ($id_abomailman && abomailmans_abomailman_administrable($id_abomailman)) { |
---|
| 190 | echo "<div style='float:$spip_lang_left'>"; |
---|
| 191 | $link = parametre_url($clean_link,'supp_abomailman', $id_abomailman); |
---|
| 192 | if (!$retour) { |
---|
| 193 | $link=parametre_url($link,'retour', urlencode(generer_url_ecrire('abomailmans_tous'))); |
---|
| 194 | } |
---|
| 195 | icone(_T("abomailmans:supprimer"), $link, "../"._DIR_PLUGIN_ABOMAILMANS."/img_pack/mailman.gif", "supprimer.gif"); |
---|
| 196 | echo "</div>"; |
---|
| 197 | } |
---|
| 198 | echo "<div style='clear:both;'></div>"; |
---|
| 199 | echo "</div>"; |
---|
| 200 | |
---|
| 201 | // |
---|
| 202 | // Edition des donnees du formulaire |
---|
| 203 | // |
---|
| 204 | if (abomailmans_abomailman_editable($id_abomailman)) { |
---|
| 205 | echo "<p>"; |
---|
| 206 | debut_cadre_formulaire(); |
---|
| 207 | |
---|
| 208 | echo "<div class='verdana2'>"; |
---|
| 209 | echo "<form method='POST' action='" |
---|
| 210 | . $abomailman_link |
---|
| 211 | . "' style='border: 0px; margin: 0px;'>"; |
---|
| 212 | |
---|
| 213 | echo "<strong><label for='titre_abomailman'>"._T("abomailmans:titre_abomailman")."</label></strong> "._T('info_obligatoire_02'); |
---|
| 214 | echo "<br />"; |
---|
| 215 | echo "<input type='text' name='titre' id='titre_abomailman' CLASS='formo' ". |
---|
| 216 | "value=\"".entites_html($titre)."\" size='40'$js_titre /><br />\n"; |
---|
| 217 | |
---|
| 218 | echo "<strong><label for='desc_abomailman'>"._T('info_descriptif')."</label></strong>"; |
---|
| 219 | echo "<br />"; |
---|
| 220 | echo "<textarea name='descriptif' id='desc_abomailman' class='forml' rows='4' cols='40' wrap='soft'>"; |
---|
| 221 | echo entites_html($descriptif); |
---|
| 222 | echo "</textarea><br />\n"; |
---|
| 223 | |
---|
| 224 | |
---|
| 225 | echo "<strong><label for='email_abomailman'>"._T("abomailmans:emailliste_abomailman")."</label></strong> "._T('info_obligatoire_02'); |
---|
| 226 | echo "<br />"; |
---|
| 227 | echo "<input type='text' name='email' id='email_abomailman' CLASS='formo' ". |
---|
| 228 | "value=\"".$email."\" size='40' /><br />\n"; |
---|
| 229 | |
---|
| 230 | echo "<div align='right'>"; |
---|
| 231 | echo "<input type='submit' name='Valider' value='"._T('bouton_valider')."' class='fondo'></div>\n"; |
---|
| 232 | |
---|
| 233 | echo "</form>"; |
---|
| 234 | |
---|
| 235 | echo "</div>\n"; |
---|
| 236 | echo "<div id=\"abomailmain_templaate\"></div>"; |
---|
| 237 | |
---|
| 238 | fin_cadre_formulaire(); |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | fin_page(); |
---|
| 243 | } |
---|
| 244 | ?> |
---|