X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fmarketing.php;h=4757136066ea93b61ac238d9f83e5edb51de85fd;hb=39fd8f508829b3b5b27a1bd580e2dd1857602294;hp=ae2ad4a0d9fe20003c09be87832040349b14336e;hpb=cab0809050d58f8484608e91f7555ebd69dcb451;p=platal.git diff --git a/modules/marketing.php b/modules/marketing.php index ae2ad4a..4757136 100644 --- a/modules/marketing.php +++ b/modules/marketing.php @@ -1,6 +1,6 @@ $this->make_hook('private', AUTH_MDP, 'admin'), 'marketing/public' => $this->make_hook('public', AUTH_COOKIE), + 'marketing/broken' => $this->make_hook('broken', AUTH_COOKIE), ); } @@ -91,7 +92,7 @@ class MarketingModule extends PLModule WHERE user_id={?} AND perms='pending'", $uid); if (list($nom, $prenom, $promo, $matricule) = $res->fetchOneRow()) { - require_once('register.inc.php'); + require_once('user.func.inc.php'); $matricule_X = get_X_mat($matricule); $page->assign('nom', $nom); $page->assign('prenom', $prenom); @@ -122,9 +123,9 @@ class MarketingModule extends PLModule if ($action == 'relforce') { require_once('marketing.inc.php'); - mark_send_mail($uid, $value, Post::get('from'), Post::get('to'), - Post::get('title'), Post::get('message')); - $page->trig("Mail envoyé"); + mark_send_mail($uid, $value, Post::v('from'), Post::v('to'), + Post::v('title'), Post::v('message')); + $page->trig("Mail envoyé"); } if ($action == 'insrel') { @@ -139,7 +140,7 @@ class MarketingModule extends PLModule "INSERT INTO register_marketing SET uid = {?}, sender = {?}, email = {?}, date = NOW(), type = {?}", - $uid, S::v('uid'), Post::get('email'), Post::get('type')); + $uid, S::v('uid'), Post::v('email'), Post::v('type')); } $res = XDB::iterator( @@ -152,12 +153,63 @@ class MarketingModule extends PLModule $res = XDB::query("SELECT date, relance FROM register_pending WHERE uid = {?}", $uid); - if (list($pending, $relance) = $res->fetchOneCell()) { + if (list($pending, $relance) = $res->fetchOneRow()) { $page->assign('pending', $pending); $page->assign('relance', $relance); } } + function handler_broken(&$page, $uid = null) + { + require_once('user.func.inc.php'); + $page->changeTpl('marketing/broken.tpl'); + + if (is_null($uid)) { + return PL_NOT_FOUND; + } + $forlife = get_user_forlife($uid); + if (!$forlife) { + return PL_NOT_FOUND; + } elseif ($forlife == S::v('forlife')) { + pl_redirect('emails/redirect'); + } + + $res = Xdb::query("SELECT u.nom, u.prenom, u.promo, FIND_IN_SET('femme', u.flags) AS sexe, + a.alias AS forlife, b.alias AS bestalias, e.email, e.last + FROM auth_user_md5 AS u + INNER JOIN aliases AS a ON (a.id = u.user_id AND a.type = 'a_vie') + INNER JOIN aliases AS b ON (b.id = u.user_id AND FIND_IN_SET('bestalias', b.flags)) + LEFT JOIN emails AS e ON (e.flags = 'active' AND e.uid = u.user_id) + WHERE a.alias = {?} + ORDER BY e.panne_level, e.last", $forlife); + if (!$res->numRows()) { + return PL_NOT_FOUND; + } + $user = $res->fetchOneAssoc(); + $page->assign('user', $user); + + $email = null; + if (Post::has('mail')) { + require_once 'emails.inc.php'; + $email = valide_email(Post::v('mail')); + } + if (Post::has('valide') && isvalid_email_redirection($email)) { + // security stuff + check_email($email, "Proposition d'une adresse surveillee pour " . $user['forlife'] . " par " . S::v('forlife')); + if ($user['email'] && !trim(Post::v('comment'))) { + $page->trig("Il faut que tu ajoutes un commentaire à ta proposition pour justifier le " + ."besoin de changer la redirection de " . $user['prenom']); + } else { + require_once 'validations.inc.php'; + $valid = new BrokenReq(S::i('uid'), $user, $email, trim(Post::v('comment'))); + $valid->submit(); + $page->assign('sent', true); + } + } elseif ($email) { + $page->trig("L'adresse proposée n'est pas une adresse acceptable pour une redirection"); + } + } + function handler_promo(&$page, $promo = null) { $page->changeTpl('marketing/promo.tpl'); @@ -197,7 +249,7 @@ class MarketingModule extends PLModule if (Post::has('valide')) { require_once('xorg.misc.inc.php'); - $email = trim(Post::get('mail')); + $email = trim(Post::v('mail')); $res = XDB::query('SELECT COUNT(*) FROM register_marketing WHERE uid={?} AND email={?}', $uid, $email); @@ -207,13 +259,14 @@ class MarketingModule extends PLModule $page->assign('already', true); } else { $page->assign('ok', true); + check_email($email, "Une adresse surveillée est proposée au marketing par " . S::v('forlife')); XDB::execute( "INSERT INTO register_marketing (uid,sender,email,date,last,nb,type,hash) VALUES ({?}, {?}, {?}, NOW(), 0, 0, {?}, '')", - $uid, S::v('uid'), $email, Post::get('origine')); + $uid, S::v('uid'), $email, Post::v('origine')); require_once('validations.inc.php'); $req = new MarkReq(S::v('uid'), $uid, $email, - Post::get('origine')=='user'); + Post::v('origine')=='user'); $req->submit(); } } @@ -271,7 +324,7 @@ class MarketingModule extends PLModule $sent = Array(); foreach (array_keys($_POST['relance']) as $uid) { if ($tmp = relance($uid, $nbdix)) { - $sent[] = $tmp.' a été relancé'; + $sent[] = $tmp.' a été relancé'; } } $page->assign('sent', $sent);