X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fmarketing.php;h=d5f9ed8b8d3ade24c8ffb4e3a9bdbf412529d1e0;hb=28c20b86be8b40cecba0d83080879f81c49e07ad;hp=10c87910ce16cfd2c1642c7ec8addbdaba5b0058;hpb=38c6fe960bcd94f129da664c22609e24c64516eb;p=platal.git
diff --git a/modules/marketing.php b/modules/marketing.php
index 10c8791..d5f9ed8 100644
--- a/modules/marketing.php
+++ b/modules/marketing.php
@@ -1,6 +1,6 @@
profile()->xorg_id;
- require_once('user.func.inc.php');
- $matricule_X = get_X_mat($matricule);
+ $matricule_X = Profile::getSchoolId($matricule);
$page->assign('full_name', $user->fullName());
$page->assign('promo', $user->promo());
@@ -124,8 +123,8 @@ class MarketingModule extends PLModule
$res = XDB::iterator(
"SELECT r.*, a.alias
FROM register_marketing AS r
- LEFT JOIN aliases AS a ON (r.sender=a.id AND a.type = 'a_vie')
- WHERE uid={?}
+ LEFT JOIN aliases AS a ON (r.sender = a.uid AND a.type = 'a_vie')
+ WHERE r.uid = {?}
ORDER BY date", $user->id());
$page->assign('addr', $res);
@@ -154,13 +153,15 @@ class MarketingModule extends PLModule
pl_redirect('emails/redirect');
}
- $res = XDB::query(
- "SELECT u.deces = '0000-00-00' AS alive, e.last,
- IF(e.email IS NOT NULL, e.email, IF(FIND_IN_SET('googleapps', u.mail_storage), 'googleapps', NULL)) AS email
- FROM auth_user_md5 AS u
- LEFT JOIN emails AS e ON (e.flags = 'active' AND e.uid = u.user_id)
- WHERE u.user_id = {?}
- ORDER BY e.panne_level, e.last", $user->id());
+ $res = XDB::query('SELECT p.deathdate IS NULL AS alive, e.last,
+ IF(e.email IS NOT NULL, e.email,
+ IF(FIND_IN_SET(\'googleapps\', eo.storage), \'googleapps\', NULL)) AS email
+ FROM email_options AS eo
+ LEFT JOIN account_profiles AS ap ON (ap.uid = eo.uid AND FIND_IN_SET(\'owner\', ap.perms))
+ LEFT JOIN profiles AS p ON (p.pid = ap.pid)
+ LEFT JOIN emails AS e ON (e.flags = \'active\' AND e.uid = eo.uid)
+ WHERE eo.uid = {?}
+ ORDER BY e.panne_level, e.last', $user->id());
if (!$res->numRows()) {
return PL_NOT_FOUND;
}
@@ -204,13 +205,13 @@ class MarketingModule extends PLModule
$page->changeTpl('marketing/promo.tpl');
if (is_null($promo)) {
- $promo = S::v('promo');
+ $promo = S::v('promo', S::user()->promo());
}
$page->assign('promo', $promo);
- $uf = new UserFilter(new UFC_And(new UFC_Promo('=', UserFilter::DISPLAY, $promo),
- new UFC_Not(new UFC_Registered())),
- array(new UFO_Name(UserFilter::LASTNAME), new UFO_Name(UserFilter::FIRSTNAME)));
+ $uf = new UserFilter(new PFC_And(new UFC_Promo('=', UserFilter::DISPLAY, $promo),
+ new PFC_Not(new UFC_Registered())),
+ array(new UFO_Name(Profile::LASTNAME), new UFO_Name(Profile::FIRSTNAME)));
$users = $uf->getUsers();
$page->assign('nonins', $users);
}
@@ -239,7 +240,7 @@ class MarketingModule extends PLModule
require_once 'emails.inc.php';
if (!isvalid_email_redirection($email)) {
- $page->trigError("Email invalide !");
+ $page->trigError('Email invalide !');
} else {
// On cherche les marketings précédents sur cette adresse
// email, en se restreignant au dernier mois
@@ -249,10 +250,30 @@ class MarketingModule extends PLModule
} else {
$page->assign('ok', true);
check_email($email, "Une adresse surveillée est proposée au marketing par " . S::user()->login());
- $market = new Marketing($user->id(), $email, 'default', null, Post::v('origine'), S::v('uid'));
+ $market = new Marketing($user->id(), $email, 'default', null, Post::v('origine'), S::v('uid'),
+ Post::v('origine') == 'user' ? Post::v('personal_notes') : null);
$market->add();
}
}
+ } else {
+ global $globals;
+ require_once 'marketing.inc.php';
+
+ $sender = User::getSilent(S::v('uid'));
+ $market = new AnnuaireMarketing(null, true);
+ $text = $market->getText(array(
+ 'sexe' => $user->isFemale(),
+ 'forlife_email' => $user->login() . '@' . $globals->mail->domain,
+ 'forlife_email2' => $user->login() . '@' . $globals->mail->domain2
+ ));
+ $text = str_replace('%%hash%%', '', $text);
+ $text = str_replace('%%personal_notes%%', '', $text);
+ $text = str_replace('%%sender%%',
+ "" . $sender->fullName() . '', $text);
+ $page->assign('text', nl2br($text));
+ // TODO (JAC): define a unique Xorg signature for all the emails we send.
+ $page->assign('xorg_signature', "L'équipe de Polytechnique.org,
Le portail des élèves & anciens élèves de l'Ãcole polytechnique");
+ $page->assign('perso_signature', $sender->fullName());
}
}
@@ -280,11 +301,13 @@ class MarketingModule extends PLModule
if (!is_null($promo)) {
- $it = XDB::iterator('SELECT m.uid, m.email
+ $it = XDB::iterator('SELECT m.uid, m.email, s.alias AS forlife
FROM register_marketing AS m
INNER JOIN account_profiles AS ap ON (m.uid = ap.uid AND FIND_IN_SET(\'owner\', ap.perms))
INNER JOIN profile_display AS pd ON (pd.pid = ap.pid)
- WHERE pd.promo = {?}', $promo);
+ LEFT JOIN aliases AS s ON (m.sender = s.uid AND s.type = \'a_vie\')
+ WHERE pd.promo = {?}
+ ORDER BY pd.sort_name', $promo);
$page->assign('addr', $it);
}
}