From: Pierre Habouzit (MadCoder Date: Tue, 11 Jan 2005 16:36:27 +0000 (+0000) Subject: marketing X-Git-Tag: xorg/old~467 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=2de3b375d9093df55066431948709b8575dff4c1;p=platal.git marketing - rework a lot of things (relance for example) - add private.php/tpl git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-289 --- diff --git a/htdocs/marketing/private.php b/htdocs/marketing/private.php new file mode 100644 index 0000000..0fbf106 --- /dev/null +++ b/htdocs/marketing/private.php @@ -0,0 +1,63 @@ +xdb->query("SELECT nom, prenom, promo FROM auth_user_md5 WHERE user_id={?} AND perms='pending'", $uid); + +if (list($nom, $prenom, $promo) = $res->fetchOneRow()) { + $page->gassign('nom'); + $page->gassign('prenom'); + $page->gassign('promo'); +} else { + $page->kill('uid invalide'); +} + +if (Env::has('del')) { + $globals->xdb->execute('DELETE FROM register_marketing WHERE uid={?} AND email={?}', $uid, Env::get('del')); +} + +if (Env::has('relance')) { + require_once('marketing.inc.php'); + if (relance($uid)) { + $page->trig('relance faite'); + } +} + +$res = $globals->xdb->iterator( + "SELECT r.*, a.alias + FROM register_marketing AS r + INNER JOIN aliases AS a ON (r.sender=a.id AND a.type = 'a_vie') + WHERE uid={?} + ORDER BY date", $uid); +$page->assign('addr', $res); + +$res = $globals->xdb->query("SELECT date, relance FROM register_pending WHERE uid = {?}", $uid); +if (list($pending, $relance) = $res->fetchOneCell()) { + $page->gassign('pending'); + $page->gassign('relance'); +} + + +$page->run(); +?> diff --git a/htdocs/marketing/relance.php b/htdocs/marketing/relance.php index aa77a9e..4c10451 100644 --- a/htdocs/marketing/relance.php +++ b/htdocs/marketing/relance.php @@ -24,47 +24,22 @@ new_admin_page('marketing/relance.tpl'); /* une relance a été demandée - on envoit les mails correspondants */ if (Post::has('relancer')) { - require_once("xorg.mailer.inc.php"); - $res = $globals->xdb->query("SELECT COUNT(*) FROM auth_user_md5 WHERE deces=0"); $nbdix = $res->fetchOneCell(); - $res = $globals->xdb->iterRow( - "SELECT r.date, u.promo, u.nom, u.prenom, r.uid, r.email, r.bestalias - FROM register_pending AS r - INNER JOIN auth_user_md5 AS u ON u.user_id = r.uid"); - $sent = Array(); - - while (list($ldate, $lpromo, $lnom, $lprenom, $uid, $lemail, $lusername) = $res->next()) { - if (Post::get($uid) == "1") { - $hash = rand_url_id(12); - $pass = rand_pass(); - $pass_md5 = md5($nveau_pass); - $fdate = substr($ldate, 8, 2)."/".substr($ldate, 5, 2)."/".substr($ldate, 0, 4); - - $mymail = new XOrgMailer('marketing.relance.tpl'); - $mymail->assign('nbdix', $nbdix); - $mymail->assign('fdate', $fdate); - $mymail->assign('lusername', $lusername); - $mymail->assign('nveau_pass', $pass); - $mymail->assign('baseurl', $globals->baseurl); - $mymail->assign('lins_id', $hash); - $mymail->assign('lemail', $lemail); - $mymail->assign('subj', $lusername."@polytechnique.org"); - - $globals->xdb->execute("UPDATE register_pending SET hash={?}, password={?}, relance=NOW() WHERE uid={?}", - $hash, $pass, $uid); - $mymail->send(); - - $sent[] = "$lprenom $lnom ($lpromo) a été relancé !"; + $sent = Array(); + foreach (array_keys($_POST['relance']) as $uid) { + if ($tmp = relance($uid, $nbdix)) { + $sent[] = $tmp.' a été relancé'; } } - $page->assign_by_ref('sent', $sent); + $page->assign('sent', $sent); } $sql = "SELECT r.date, r.relance, r.uid, u.promo, u.nom, u.prenom FROM register_pending AS r INNER JOIN auth_user_md5 AS u ON r. uid = u.user_id + WHERE hash!='INSCRIT' ORDER BY date DESC"; $page->assign('relance', $globals->xdb->iterator($sql)); diff --git a/include/marketing.inc.php b/include/marketing.inc.php index b23d0b3..b4522b1 100644 --- a/include/marketing.inc.php +++ b/include/marketing.inc.php @@ -19,7 +19,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -// {{{ function user_cmp +// {{{ function mark_send_mail function mark_send_mail($uid, $email) { @@ -31,4 +31,46 @@ function mark_send_mail($uid, $email) } // }}} +// {{{ function relance + +function relance($uid, $nbx = -1) +{ + require_once('xorg.mailer.inc.php'); + global $globals; + + if ($nbx < 0) { + $res = $globals->xdb->query("SELECT COUNT(*) FROM auth_user_md5 WHERE deces=0"); + $nbx = $res->fetchOneCell(); + } + + $res = $globals->xdb->query( + "SELECT r.date, u.promo, u.nom, u.prenom, r.email, r.bestalias + FROM register_pending AS r + INNER JOIN auth_user_md5 AS u ON u.user_id = r.uid + WHERE hash!='INSCRIT' AND uid={?} AND TO_DAYS(relance) < TO_DAYS(NOW())", $uid); + if (!list($date, $promo, $nom, $prenom, $email, $alias) = $res->fetchOneRow()) { + return false; + } + + $hash = rand_url_id(12); + $pass = rand_pass(); + $pass_md5 = md5($pass); + $fdate = strftime('%d %B %Y', strtotime($date)); + + $mymail = new XOrgMailer('marketing.relance.tpl'); + $mymail->assign('nbdix', $nbx); + $mymail->assign('fdate', $fdate); + $mymail->assign('lusername', $alias); + $mymail->assign('nveau_pass', $pass); + $mymail->assign('baseurl', $globals->baseurl); + $mymail->assign('lins_id', $hash); + $mymail->assign('lemail', $email); + $mymail->assign('subj', $alias.'@'.$globals->mail->domain); + $mymail->send(); + $globals->xdb->execute('UPDATE register_pending SET hash={?}, password={?}, relance=NOW() WHERE uid={?}', $hash, $pass_md5, $uid); + + return "$prenom $nom ($promo)"; +} + +// }}} ?> diff --git a/plugins/modifier.date_format.php b/plugins/modifier.date_format.php index 72c8b08..66211d7 100644 --- a/plugins/modifier.date_format.php +++ b/plugins/modifier.date_format.php @@ -21,22 +21,21 @@ function smarty_modifier_date_format($string, $format = '%x', $default_date=null) { - if (empty($format) && empty($default_date)) return; - $f = empty($format) ? $default_date : $format; - $f = str_replace('%X', '%T', str_replace('%x', '%d %B %Y', $f)); + $d = empty($string) ? $default_date : $string; + if (empty($format) || preg_match('/^[ 0\-]*$/', $d)) return; + $f = str_replace('%X', '%T', str_replace('%x', '%d %B %Y', $format)); - if (preg_match('/^\d{14}$/', $string)) { - $t = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2), - substr($string,4,2),substr($string,6,2),substr($string,0,4)); + if (preg_match('/^\d{14}$/', $d)) { + $t = mktime(substr($d,8,2), substr($d,10,2), substr($d,12,2), substr($d,4,2), substr($d,6,2), substr($d,0,4)); } else { - $t = strtotime($string); + $t = strtotime($d); } if ( $t != -1 ) { return strftime($f , $t); } else { require_once('Date.php'); - $date = new Date($string); + $date = new Date($d); return $date->format($f); } } diff --git a/templates/mails/marketing.utilisateur.tpl b/templates/mails/marketing.utilisateur.tpl index 00e767a..15b9015 100644 --- a/templates/mails/marketing.utilisateur.tpl +++ b/templates/mails/marketing.utilisateur.tpl @@ -30,7 +30,7 @@ Cher camarade, Ta fiche n'est pas à jour dans l'annuaire des Polytechniciens sur Internet. Pour la mettre à jour, il te suffit de visiter cette page ou de copier cette adresse dans la barre de ton navigateur : ========================================================== -{$baseurl}/register/maj.php?n={$user_id} +{$baseurl}/register/?hash={$user_id} ========================================================== Il ne te faut que 5 minutes sur http://www.polytechnique.org/ pour rejoindre les {$num_users} camarades branchés grâce au système de reroutage de l'X et qui permet de joindre un camarade en connaissant seulement son nom et son prénom... et de bénéficier pour la vie d'une adresse prestigieuse {$mailorg}@polytechnique.org et son alias discret {$mailorg}@m4x.org (m4x = mail for X). diff --git a/templates/marketing/private.tpl b/templates/marketing/private.tpl new file mode 100644 index 0000000..ceb2afb --- /dev/null +++ b/templates/marketing/private.tpl @@ -0,0 +1,72 @@ +{*************************************************************************** + * 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 * + ***************************************************************************} + + +

Marketing de {$prenom} {$nom}

+ +{if $pending} + +

Inscription en cours

+ +

+Cet utilisateur a une inscription en cours depuis le {$pending|date_format}. +

+

+{if $relance eq '0000-00-00'} +il n'a jamais été relancé. +{else} +sa dernière relance date du {$relance|date_format} +{/if} +

+ +

[le relancer]

+ +{/if} + +

Adresses connues

+ + + + + + + + + + + {iterate from=$addr item=a} + + + + + + + + + {/iterate} + + + + +
AdresseMarketeurDateEnvoisNb. 
{$a.email}{$a.alias} {if $a.type eq user}(*){/if}{$a.date|date_format|default:'-'}{$a.last|date_format|default:'-'}{$a.nb|default:"-"} + del +
(*): mail perso
+ +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/marketing/relance.tpl b/templates/marketing/relance.tpl index 338e239..0af3ac0 100644 --- a/templates/marketing/relance.tpl +++ b/templates/marketing/relance.tpl @@ -43,7 +43,7 @@ {if $it.relance eq "0000-00-00"}Jamais{else}{$it.relance}{/if} - + {/iterate} diff --git a/upgrade/0.9.4/20_register.sql b/upgrade/0.9.4/20_register.sql index 6b33c79..bf257dd 100644 --- a/upgrade/0.9.4/20_register.sql +++ b/upgrade/0.9.4/20_register.sql @@ -21,7 +21,7 @@ CREATE TABLE register_pending ( INDEX (hash) ); -create table register_marketing ( +create table register_marketing (/*{{{*/ uid int not null default 0, sender int not null default 0, email varchar(255) not null default '', @@ -68,4 +68,15 @@ replace into register_marketing (uid, sender, email, date, last, nb, type, hash) where date_ins = 0 and deces = 0; drop table envoidirect; -drop table marketing; +drop table marketing;/*}}}*/ + +insert into register_pending (uid, forlife, bestalias, mailorg2, password, email, date, relance, naissance, hash) + select u.user_id, e.username, + IF(e.loginbis, e.loginbis, REPLACE(REPLACE(e.username, '.19', ''), '.20', '')), + IF(e.loginbis, REPLACE(REPLACE(e.username, '.19', ''), '.20', ''), NULL), + e.password, email, e.date, relance, e.naissance, ins_id + from en_cours AS e + inner join auth_user_md5 AS u USING( matricule ) + where u.perms = 'pending'; + +drop table en_cours;