From dd09ce8602ddb91df81ef7715bc14b044b21b08f Mon Sep 17 00:00:00 2001 From: "Pierre Habouzit (MadCoder" Date: Wed, 29 Dec 2004 09:14:17 +0000 Subject: [PATCH] evts + epouses * epouses validation ok * evts validation ok * evts code simplifications git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-167 --- configs/mails.conf | 12 ----- htdocs/admin/evenements.php | 14 ++---- htdocs/evenements.php | 17 ++----- include/validations/epouses.inc.php | 38 +++++++-------- include/validations/evts.inc.php | 62 +++++++++-------------- templates/admin/evenements.tpl | 20 ++++---- templates/include/form.evenement.tpl | 4 -- templates/include/form.valid.epouses.tpl | 61 +++++++---------------- templates/include/form.valid.evts.tpl | 65 ++++++++---------------- templates/include/form.valid.ml.tpl | 84 -------------------------------- templates/mails/valid.epouses.tpl | 49 ------------------- templates/mails/valid.evts.tpl | 42 ---------------- upgrade/0.9.4/10_evts.sql | 3 ++ upgrade/0.9.4/update.sh | 19 ++++++++ 14 files changed, 121 insertions(+), 369 deletions(-) delete mode 100644 templates/include/form.valid.ml.tpl delete mode 100644 templates/mails/valid.epouses.tpl delete mode 100644 templates/mails/valid.evts.tpl create mode 100644 upgrade/0.9.4/10_evts.sql create mode 100755 upgrade/0.9.4/update.sh diff --git a/configs/mails.conf b/configs/mails.conf index eb3eb1e..50f3e7b 100644 --- a/configs/mails.conf +++ b/configs/mails.conf @@ -1,15 +1,3 @@ -[valid_epouses] -from="Equipe Polytechnique.org" -cc="Equipe Polytechnique.org" - -[valid_evts] -from="Equipe Polytechnique.org" -cc="Equipe Polytechnique.org" - -[valid_sondages] -from="Equipe Polytechnique.org" -cc="Equipe Polytechnique.org" - [marketing_relance] from=Pre-Inscription diff --git a/htdocs/admin/evenements.php b/htdocs/admin/evenements.php index e4a2452..afb266e 100644 --- a/htdocs/admin/evenements.php +++ b/htdocs/admin/evenements.php @@ -40,8 +40,7 @@ switch(Post::get('action')) { // le 'creation_date = creation_date' est indispensable pour que // creation_date conserve sa valeur. $req="UPDATE evenements - SET creation_date = creation_date, validation_user_id = ".Session::getInt('uid').", - validation_date = NULL, flags = CONCAT(flags,',valide') + SET creation_date = creation_date, flags = CONCAT(flags,',valide') WHERE id = $evid LIMIT 1"; $result = $globals->db->query ($req); @@ -51,8 +50,7 @@ switch(Post::get('action')) { // le 'creation_date = creation_date' est indispensable pour que // creation_date conserve sa valeur. $req="UPDATE evenements - SET creation_date = creation_date, validation_user_id = ".Session::getInt('uid').", - validation_date = NULL, flags = REPLACE(flags, 'valide','') + SET creation_date = creation_date, flags = REPLACE(flags, 'valide','') WHERE id = $evid LIMIT 1"; $result = $globals->db->query ($req); @@ -74,14 +72,13 @@ switch(Post::get('action')) { break; case "Editer": - $evt_req = $globals->db->query("SELECT titre, texte, peremption, promo_min, promo_max, validation_message FROM evenements WHERE id= $evid"); - list($titre, $texte, $peremption, $promo_min, $promo_max, $validation_message) = mysql_fetch_row($evt_req) ; + $evt_req = $globals->db->query("SELECT titre, texte, peremption, promo_min, promo_max FROM evenements WHERE id= $evid"); + list($titre, $texte, $peremption, $promo_min, $promo_max) = mysql_fetch_row($evt_req) ; $page->assign('mode', 'edit'); $page->assign('titre',$titre); $page->assign('texte',$texte); $page->assign('promo_min',$promo_min); $page->assign('promo_max',$promo_max); - $page->assign('validation_message',$validation_message); $page->assign('peremption',$peremption); $select = ""; @@ -102,9 +99,8 @@ if ($action != "Editer") { $sql = "SELECT e.id, e.titre, e.texte, DATE_FORMAT(e.creation_date,'%d/%m/%Y %T') AS creation_date, - DATE_FORMAT(e.validation_date,'%d/%m/%Y %T') AS validation_date, DATE_FORMAT(e.peremption,'%d/%m/%Y') AS peremption, - e.promo_min, e.promo_max, e.validation_message, e.validation_user_id, + e.promo_min, e.promo_max, FIND_IN_SET('valide', e.flags) AS fvalide, FIND_IN_SET('archive', e.flags) AS farch, u.promo, u.nom, u.prenom, a.alias AS forlife diff --git a/htdocs/evenements.php b/htdocs/evenements.php index 381fb66..99bfd13 100644 --- a/htdocs/evenements.php +++ b/htdocs/evenements.php @@ -39,18 +39,11 @@ $page->assign('validation_message', $validation_message); $page->assign('action', strtolower($action)); if ($action=="Confirmer") { - $sql = "INSERT INTO evenements - SET user_id = ".Session::getInt('uid').", creation_date = NULL, titre = '".addslashes($titre)."', - texte = '".addslashes($texte)."', peremption = '".$peremption."', promo_min = '$promo_min', - promo_max = '$promo_max', validation_message = '".addslashes($validation_message)."', validation_date = 0"; - - if ($res = $globals->db->query($sql)) { - require_once("validations.inc.php"); - $evtreq = new evtreq(mysql_insert_id(), $titre, $texte, $promo_min, - $promo_max, $peremption, $validation_message, Session::getInt('uid')); - $evtreq->submit(); - $page->assign('ok', true); - } + require_once("validations.inc.php"); + $evtreq = new evtreq($titre, $texte, $promo_min, $promo_max, + $peremption, $validation_message, Session::getInt('uid')); + $evtreq->submit(); + $page->assign('ok', true); } $select = ""; diff --git a/include/validations/epouses.inc.php b/include/validations/epouses.inc.php index 0c1560b..20ab95e 100644 --- a/include/validations/epouses.inc.php +++ b/include/validations/epouses.inc.php @@ -69,33 +69,28 @@ class EpouseReq extends Validate { return 'include/form.valid.epouses.tpl'; } // }}} - // {{{ function handle_formu() + // {{{ function _mail_subj() - function handle_formu() + function _mail_subj() { - if (Env::get('submit') != "Accepter" && Env::get('submit') != "Refuser") { - return false; - } + return "[Polytechnique.org/EPOUSE] Changement de nom de mariage"; + } - require_once("xorg.mailer.inc.php"); - $mymail = new XOrgMailer('valid.epouses.tpl'); - $mymail->assign('forlife', $this->forlife); + // }}} + // {{{ function _mail_body - if (Env::get('submit') == "Accepter") { - $mymail->assign('answer','yes'); - if ($this->oldepouse) { - $mymail->assign('oldepouse',$this->oldalias); + function _mail_body($isok) + { + global $globals; + if ($isok) { + $res = " La demande de changement de nom de mariage que tu as demandée vient d'être effectuée."; + if ($this->oldalias) { + $res .= "\n\n Les alias {$this->oldalias}@{$globals->mail->domain} et @{$globals->mail->domain2} ont été supprimés."; } - $mymail->assign('epouse',$this->alias); - $this->commit(); - } else { // c'était donc Refuser - $mymail->assign('answer','no'); + $res .= "\n\n Les alias {$this->alias}@{$globals->mail->domain} et @{$globals->mail->domain2} sont maintenant à ta disposition !"; + } else { + return " La demande de changement de nom de mariage que tu avais faite a été refusée."; } - - $mymail->send(); - - $this->clean(); - return "Mail envoyé"; } // }}} @@ -113,6 +108,7 @@ class EpouseReq extends Validate $f = fopen("/tmp/flag_recherche","w"); fputs($f,"1"); fclose($f); + return true; } // }}} diff --git a/include/validations/evts.inc.php b/include/validations/evts.inc.php index 5262595..e58dd78 100644 --- a/include/validations/evts.inc.php +++ b/include/validations/evts.inc.php @@ -36,11 +36,9 @@ class EvtReq extends Validate // }}} // {{{ constructor - function EvtReq($_evtid,$_titre,$_texte,$_pmin,$_pmax,$_peremption, - $_comment,$_uid,$_stamp=0) { + function EvtReq($_titre, $_texte, $_pmin, $_pmax, $_peremption, $_comment, $_uid) { global $globals; $this->Validate($_uid, false, 'evts', $_stamp); - $this->evtid = $_evtid; $this->titre = $_titre; $this->texte = $_texte; $this->pmin = $_pmin; @@ -64,51 +62,39 @@ class EvtReq extends Validate { return 'include/form.valid.evts.tpl'; } // }}} - // {{{ function handle_formu() - - function handle_formu() + // {{{ function _mail_subj + + function _mail_subj() { - global $globals; - if (Post::has('action')) { - require_once("xorg.mailer.inc.php"); - $mymail = new XOrgMailer('valid.evts.tpl'); - $mymail->assign('bestalias',$this->bestalias); - $mymail->assign('titre',$this->titre); + return "[Polytechnique.org/EVENEMENTS] Proposition d'événement"; + } - $uid = Session::getInt('uid'); + // }}} + // {{{ function _mail_body - if (Env::get('action') == "Valider") { - $globals->xdb->execute( - "UPDATE evenements - SET creation_date = creation_date, validation_user_id = {?}, - validation_date = NULL, flags = CONCAT(flags,',valide') - WHERE id={?} - LIMIT 1", $uid, $this->evtid); - $mymail->assign('answer','yes'); - $mymail->send(); - } elseif (Env::get('action') == "Invalider") { - $globals->xdb->execute( - "UPDATE evenements - SET creation_date = creation_date, validation_user_id = {?}, - validation_date = NULL, flags = REPLACE(flags,'valide','') - WHERE id='{?}' - LIMIT 1", $uid, $this->evtid); - $mymail->assign('answer', 'no'); - $mymail->send(); - } elseif (Env::get('action') == "Supprimer") { - $globals->xdb->execute("DELETE FROM evenements WHERE id={?} LIMIT 1", $this->evtid); - } - - $this->clean(); + function _mail_body($isok) + { + if ($isok) { + return " L'annonce que tu avais proposée ({$this->titre}) vient d'être validée."; + } else { + return " L'annonce que tu avais proposée ({$this->titre}) a été refusée."; } - return ""; } // }}} // {{{ function commit() function commit() - { } + { + global $globals; + $globals->xdb->execute( + "INSERT INTO evenements + SET user_id = {?}, creation_date=NULL, titre={?}, texte={?}, + peremption={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide')", + $this->_uid, $this->titre, $this->texte, + $this->peremption, $this->pmin, $this->pmax); + return true; + } // }}} } diff --git a/templates/admin/evenements.tpl b/templates/admin/evenements.tpl index 9f28502..01d0efd 100644 --- a/templates/admin/evenements.tpl +++ b/templates/admin/evenements.tpl @@ -40,22 +40,24 @@ + + + + + + diff --git a/templates/include/form.evenement.tpl b/templates/include/form.evenement.tpl index c43cf33..463f876 100644 --- a/templates/include/form.evenement.tpl +++ b/templates/include/form.evenement.tpl @@ -73,10 +73,6 @@ - - - -
- Posté par {$ev.prenom} {$ev.nom} (X{$ev.promo}) - lui écrire + Posté par {$ev.prenom} {$ev.nom} (X{$ev.promo})
- {$ev.titre}
- {$ev.texte|nl2br}
-
+ {$ev.titre} +
+ {tidy}{$ev.texte|nl2br}{/tidy} +
Création : {$ev.creation_date}
- {if $ev.fvalide} - Validation : {$ev.validation_date}
- {/if} Péremption : {$ev.peremption}
Promos : {$ev.promo_min} - {$ev.promo_max}
- Message : {$ev.validation_message}
Message pour le validateur
diff --git a/templates/include/form.valid.epouses.tpl b/templates/include/form.valid.epouses.tpl index ed45530..7f4555c 100644 --- a/templates/include/form.valid.epouses.tpl +++ b/templates/include/form.valid.epouses.tpl @@ -19,49 +19,22 @@ ***************************************************************************} -
- - - - - - - - - - - - - - {if $valid->homonyme} - - - - {/if} - - - - -
Demandeur : - forlife}" class="popup2"> - {$valid->prenom} {$valid->nom} - - {if $valid->oldepouse}({$valid->oldepouse} - {$valid->oldalias}){/if} -
Épouse :{$valid->epouse}
Nouvel alias :{$valid->alias|default:"suppression"}
- Probleme d'homonymie ! - homonyme" class="popup2">{$valid->homonyme} - -
- - - - -

- -
-

Raison du refus:

- -
-
+ + Épouse : + {$valid->epouse} + + + Nouvel alias : + {$valid->alias|default:"suppression"} + +{if $valid->homonyme} + + + Probleme d'homonymie ! + {$valid->homonyme} + + + +{/if} {* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/include/form.valid.evts.tpl b/templates/include/form.valid.evts.tpl index 94012d1..877e22f 100644 --- a/templates/include/form.valid.evts.tpl +++ b/templates/include/form.valid.evts.tpl @@ -19,50 +19,25 @@ ***************************************************************************} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Événement
- Posté par bestalias}" class="popup2"> - {$valid->prenom} {$valid->nom} (X{$valid->promo}) - - [lui écrire] -
Titre{$valid->titre}
Texte{$valid->texte}
Péremption{$valid->peremption}
Promos{$valid->pmin} - {$valid->pmax}
Commentaire{$valid->comment}
- - - - - - -
-
+ + Titre + {$valid->titre} + + + Texte + {$valid->texte} + + + Péremption + {$valid->peremption|date_format:"%d %B %Y"} + + + Promos + {$valid->pmin} - {$valid->pmax} + + + Commentaire + {$valid->comment} + {* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/include/form.valid.ml.tpl b/templates/include/form.valid.ml.tpl deleted file mode 100644 index 99af99d..0000000 --- a/templates/include/form.valid.ml.tpl +++ /dev/null @@ -1,84 +0,0 @@ -{*************************************************************************** - * Copyright (C) 2003-2004 Polytechnique.org * - * http://opensource.polytechnique.org/ * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software * - * Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - ***************************************************************************} - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Demandeur : - bestalias}" class="popup2"> - {$valid->prenom} {$valid->nom} - -
Motif :{$valid->comment|nl2br} -
- Alias : - - @polytechnique.org -
Topic : -
Propriétés : - publique}checked="checked"{/if} />Publique - libre}checked="checked"{/if} />Libre - freeins}checked="checked"{/if} />Freeins - archive}checked="checked"{/if} />Archive -
Modéros :{$valid->moderos_txt}
Membres :{$valid->membres_txt}
- - - - -

- -
-

Explication complémentaire (refus ou changement de config, ...)

- -
-
- -{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/mails/valid.epouses.tpl b/templates/mails/valid.epouses.tpl deleted file mode 100644 index 1015aa9..0000000 --- a/templates/mails/valid.epouses.tpl +++ /dev/null @@ -1,49 +0,0 @@ -{*************************************************************************** - * Copyright (C) 2003-2004 Polytechnique.org * - * http://opensource.polytechnique.org/ * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software * - * Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - ***************************************************************************} - -{config_load file="mails.conf" section="valid_epouses"} -{subject text="[Polytechnique.org/EPOUSE] Changement de nom de mariage de $forlife"} -{from full=#from#} -{to addr="$forlife@polytechnique.org"} -{cc full=#cc#} -{if $answer eq "yes"} -Chère camarade, - - La demande de changement de nom de mariage que tu as demandée vient d'être effectuée. - -{if $oldepouse} Les alias {$oldepouse}@polytechnique.org et {$oldepouse}@m4x.org ont été supprimés. -{/if} - De plus, les alias {$epouse}@polytechnique.org et {$epouse}@m4x.org ont été créés. - -Cordialement, -L'équipe X.org -{elseif $answer eq 'no'} -Chère camarade, - - La demande de changement de nom de mariage que tu avais faite a été refusée. -{if $smarty.request.motif} -La raison de ce refus est : -{$smarty.request.motif|stripslashes} -{/if} - -Cordialement, -L'équipe X.org -{/if} -{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/mails/valid.evts.tpl b/templates/mails/valid.evts.tpl deleted file mode 100644 index ff1a279..0000000 --- a/templates/mails/valid.evts.tpl +++ /dev/null @@ -1,42 +0,0 @@ -{*************************************************************************** - * Copyright (C) 2003-2004 Polytechnique.org * - * http://opensource.polytechnique.org/ * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software * - * Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - ***************************************************************************} - -{config_load file="mails.conf" section="valid_evts"} -{subject text="[Polytechnique.org/EVENEMENTS] Proposition d'événement"} -{from full=#from#} -{to addr="$bestalias@polytechnique.org"} -{cc full=#cc#} -{if $answer eq "yes"} -Cher(e) camarade, - - L'annonce que tu avais proposée ({$titre|strip_tags}) vient d'être validée. - -Cordialement, -L'équipe X.org -{elseif $answer eq 'no'} - -Cher(e) camarade, - - L'annonce que tu avais proposée ({$titre|strip_tags}) a été refusée. - -Cordialement, -L'équipe X.org -{/if} -{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/upgrade/0.9.4/10_evts.sql b/upgrade/0.9.4/10_evts.sql new file mode 100644 index 0000000..5436c9d --- /dev/null +++ b/upgrade/0.9.4/10_evts.sql @@ -0,0 +1,3 @@ +alter table evenements drop column validation_message; +alter table evenements drop column validation_user_id; +alter table evenements drop column validation_date; diff --git a/upgrade/0.9.4/update.sh b/upgrade/0.9.4/update.sh new file mode 100755 index 0000000..f351939 --- /dev/null +++ b/upgrade/0.9.4/update.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +. ../inc/pervasive.sh + +mailman_stop +mailman_templates +mailman_start + + +########################################################### +for sql in *.sql +do + echo -n $sql + $MYSQL x4dat < $sql &>/dev/null || echo -n " ERROR" + echo . +done + +########################################################### + -- 2.1.4