From: Stéphane Jacob Date: Fri, 4 Mar 2011 13:17:47 +0000 (+0100) Subject: Enables emails for other types of users. X-Git-Tag: xorg/1.1.0~69 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=f036c8966e64d9f2bb3923bbeb278353bc7e1083;p=platal.git Enables emails for other types of users. Signed-off-by: Stéphane Jacob --- diff --git a/bin/cron/homonyms.php b/bin/cron/homonyms.php index 068d3b2..cfc5b0d 100755 --- a/bin/cron/homonyms.php +++ b/bin/cron/homonyms.php @@ -34,7 +34,7 @@ while ($old = $resRobot->next()) { FROM homonyms_list AS h INNER JOIN accounts AS a ON (h.uid = a.uid) WHERE hrmid = {?}', - 'h.' . $old['email'] . '.polytechnique.org'); + 'h.' . $old['email'] . '.' . Platal::globals()->mail->domain); $hruids = $res->fetchColumn(); $homonym = User::getSilent($old['uid']); diff --git a/bin/cron/profile_modification.php b/bin/cron/profile_modification.php index 7101c42..c2c9e52 100755 --- a/bin/cron/profile_modification.php +++ b/bin/cron/profile_modification.php @@ -24,13 +24,12 @@ require_once 'connect.db.inc.php'; require_once 'plmailer.php'; global $globals; -$res = XDB::iterator('SELECT p.hrpid, pm.pid, a.full_name, pm.field, pm.oldText, pm.newText, p.sex, pd.yourself, s.email +$res = XDB::iterator('SELECT p.hrpid, pm.pid, a.full_name, pm.field, pm.oldText, pm.newText, p.sex, pd.yourself, ap.uid FROM profile_modifications AS pm INNER JOIN accounts AS a ON (pm.uid = a.uid) INNER JOIN profiles AS p ON (pm.pid = p.pid) INNER JOIN profile_display AS pd ON (pm.pid = pd.pid) INNER JOIN account_profiles AS ap ON (pm.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) - INNER JOIN email_source_account AS s ON (a.uid = s.uid AND FIND_IN_SET(\'bestalias\', s.flags)) WHERE pm.type = \'third_party\' AND pm.field != \'deathdate\' ORDER BY pm.pid, pm.field, pm.timestamp'); @@ -41,7 +40,7 @@ if ($res->total() > 0) { $pid = $values['pid']; $sex = ($values['sex'] == 'female') ? 1 : 0; $yourself = $values['yourself']; - $alias = $values['email']; + $user = User::getSilentWithUID($values['uid']); $hrpid = $values['hrpid']; $modifications = array(); $modifications[] = array( @@ -54,7 +53,7 @@ if ($res->total() > 0) { while ($values = $res->next()) { if ($values['pid'] != $pid) { $mailer = new PlMailer('profile/notification.mail.tpl'); - $mailer->addTo($alias . '@' . $globals->mail->domain); + $mailer->addTo($user); $mailer->assign('modifications', $modifications); $mailer->assign('yourself', $yourself); $mailer->assign('hrpid', $hrpid); @@ -66,7 +65,7 @@ if ($res->total() > 0) { $pid = $values['pid']; $sex = ($values['sex'] == 'female') ? 1 : 0; $yourself = $values['yourself']; - $alias = $values['alias']; + $user = User::getSilentWithUID($values['uid']); $hrpid = $values['hrpid']; $modifications[] = array( 'full_name' => $values['full_name'], @@ -76,7 +75,7 @@ if ($res->total() > 0) { ); } $mailer = new PlMailer('profile/notification.mail.tpl'); - $mailer->addTo($alias . '@' . $globals->mail->domain); + $mailer->addTo($user); $mailer->assign('modifications', $modifications); $mailer->assign('yourself', $yourself); $mailer->assign('hrpid', $hrpid); diff --git a/classes/user.php b/classes/user.php index 8b4160b..1eaa12f 100644 --- a/classes/user.php +++ b/classes/user.php @@ -31,6 +31,13 @@ class User extends PlUser const PERM_MAIL = 'mail'; const PERM_PAYMENT = 'payment'; + public static $sub_mail_domains = array( + 'x' => '', + 'master' => 'master.', + 'phd' => 'doc.', + 'all' => 'alumni.' + ); + private $_profile_fetched = false; private $_profile = null; @@ -88,7 +95,7 @@ class User extends PlUser $login = trim(strtolower($login)); if (strstr($login, '@') === false) { $email = $login; - $domain = $globals->mail->domain; + $domain = $this->mainEmailDomain(); } else { list($email, $domain) = explode('@', $login); } @@ -153,10 +160,10 @@ class User extends PlUser $uids = array_map(array('XDB', 'escape'), $uids); return XDB::iterator('SELECT a.uid, a.hruid, a.registration_date, h.uid IS NOT NULL AS homonym, - IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', MAX(df.name))) AS forlife, - IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', MIN(df.name))) AS forlife_alternate, - IF(eb.email IS NULL, NULL, CONCAT(eb.email, \'@\', MAX(db.name))) AS bestalias, - IF(eb.email IS NULL, NULL, CONCAT(eb.email, \'@\', MIN(db.name))) AS bestalias_alternate, + IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', mf.name)) AS forlife, + IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', df.name)) AS forlife_alternate, + IF(eb.email IS NULL, NULL, CONCAT(eb.email, \'@\', mb.name)) AS bestalias, + IF(eb.email IS NULL, NULL, CONCAT(eb.email, \'@\', db.name)) AS bestalias_alternate, (er.redirect IS NULL AND a.state = \'active\') AS lost, a.email, a.full_name, a.directory_name, a.display_name, a.sex = \'female\' AS gender, IF(a.state = \'active\', CONCAT(at.perms, \',\', IF(a.user_perms IS NULL, \'\', a.user_perms)), \'\') AS perms, @@ -170,10 +177,12 @@ class User extends PlUser INNER JOIN account_types AS at ON (at.type = a.type) LEFT JOIN email_source_account AS ef ON (ef.uid = a.uid AND ef.type = \'forlife\') LEFT JOIN email_virtual_domains AS mf ON (ef.domain = mf.id) - LEFT JOIN email_virtual_domains AS df ON (df.aliasing = mf.id) + LEFT JOIN email_virtual_domains AS df ON (df.aliasing = mf.id AND + df.name LIKE CONCAT(\'%\', {?}) AND df.name NOT LIKE \'alumni.%\') LEFT JOIN email_source_account AS eb ON (eb.uid = a.uid AND eb.flags = \'bestalias\') LEFT JOIN email_virtual_domains AS mb ON (eb.domain = mb.id) - LEFT JOIN email_virtual_domains AS db ON (db.aliasing = mb.id) + LEFT JOIN email_virtual_domains AS db ON (db.aliasing = mb.id AND + db.name LIKE CONCAT(\'%\', {?}) AND db.name NOT LIKE \'alumni.%\') LEFT JOIN email_redirect_account AS er ON (er.uid = a.uid AND er.flags = \'active\' AND er.broken_level < 3 AND er.type != \'imap\' AND er.type != \'homonym\') LEFT JOIN homonyms_list AS h ON (h.uid = a.uid) @@ -184,7 +193,7 @@ class User extends PlUser ' . $joins . ' WHERE a.uid IN (' . implode(', ', $uids) . ') GROUP BY a.uid - ' . $order); + ' . $order, $globals->mail->domain2, $globals->mail->domain2); } // Implementation of the data loader. @@ -338,6 +347,24 @@ class User extends PlUser $this->id(), $profile->id()); } + /** Determines main email domain for this user. + */ + public function mainEmailDomain() + { + if (array_key_exists($this->type, self::$sub_mail_domains)) { + return self::$sub_mail_domains[$this->type] . Platal::globals()->mail->domain; + } + } + + /** Determines alternate email domain for this user. + */ + public function alternateEmailDomain() + { + if (array_key_exists($this->type, self::$sub_mail_domains)) { + return self::$sub_mail_domains[$this->type] . Platal::globals()->mail->domain2; + } + } + /** Fetch existing auxiliary alias. */ public function emailAlias() @@ -797,45 +824,45 @@ class User extends PlUser } } - // Implementation of the static email locality checker. - public static function isForeignEmailAddress($email) + public static function isMainMailDomain($domain) { global $globals; - if (strpos($email, '@') === false) { - return false; - } - list($user, $dom) = explode('@', $email); - return $dom != $globals->mail->domain && - $dom != $globals->mail->domain2 && - $dom != $globals->mail->alias_dom && - $dom != $globals->mail->alias_dom2; + $is_main_domain = false; + foreach (self::$sub_mail_domains as $sub_domain) { + $is_main_domain = $is_main_domain || $domain != ($sub_domain . $globals->mail->domain) && $domain != ($sub_domain . $globals->mail->domain2); + } + return $is_main_domain; } - public static function isVirtualEmailAddress($email) + public static function isAliasMailDomain($domain) { global $globals; + + return $domain == $globals->mail->alias_dom || $domain == $globals->mail->alias_dom2; + } + + // Implementation of the static email locality checker. + public static function isForeignEmailAddress($email) + { if (strpos($email, '@') === false) { return false; } - list($user, $dom) = explode('@', $email); - return $dom == $globals->mail->alias_dom - || $dom == $globals->mail->alias_dom2; + list(, $domain) = explode('@', $email); + return !(self::isMainMailDomain($domain) || self::isAliasMailDomain($domain)); } /* Tries to find pending accounts with an hruid close to $login. */ public static function getPendingAccounts($login, $iterator = false) { - global $globals; - if (strpos($login, '@') === false) { return null; } list($login, $domain) = explode('@', $login); - if ($domain && $domain != $globals->mail->domain && $domain != $globals->mail->domain2) { + if ($domain && !self::isMainMailDomain($domain)) { return null; } diff --git a/classes/xorgsession.php b/classes/xorgsession.php index d9ede7c..25ade0d 100644 --- a/classes/xorgsession.php +++ b/classes/xorgsession.php @@ -81,11 +81,10 @@ class XorgSession extends PlSession { if ($login_type == 'alias') { $res = XDB::query('SELECT a.uid, a.password - FROM accounts AS a - INNER JOIN email_source_account AS e ON (e.uid = a.uid) - INNER JOIN email_virtual_domains AS d ON (e.domain = d.id) - WHERE e.email = {?} AND d.name = {?}', - $login, Platal::globals()->mail->domain); + FROM accounts AS a + INNER JOIN email_source_account AS e ON (e.uid = a.uid) + WHERE e.email = {?}', + $login); } else { $res = XDB::query('SELECT uid, password FROM accounts diff --git a/core b/core index feb45d1..a6522bb 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit feb45d1d9fc152beff746c83048ff7704cc27ea2 +Subproject commit a6522bb9e59e898a417a7da1acdd31ba45838c86 diff --git a/include/emails.inc.php b/include/emails.inc.php index 5f98fff..f5cb685 100644 --- a/include/emails.inc.php +++ b/include/emails.inc.php @@ -217,7 +217,7 @@ function valide_email($str) return; } list($ident, $dom) = explode('@', $em); - if ($dom == $globals->mail->domain || $dom == $globals->mail->domain2) { + if (User::isMainMailDomain($dom)) { list($ident1) = explode('_', $ident); list($ident) = explode('+', $ident1); } @@ -231,8 +231,7 @@ function valide_email($str) */ function isvalid_email_redirection($email) { - return isvalid_email($email) && - !preg_match("/@(polytechnique\.(org|edu)|melix\.(org|net)|m4x\.org)$/", $email); + return isvalid_email($email) && !preg_match("/@polytechnique\.edu$/", $email) && User::isForeignEmailAddress($email); } // function ids_from_mails() {{{1 @@ -240,37 +239,43 @@ function isvalid_email_redirection($email) // given email when we found a matching user. function ids_from_mails(array $emails) { - global $globals; - // Removes duplicates, if any. $emails = array_unique($emails); // Formats and splits by domain type (locally managed or external) emails. - $domain_emails = array(); - $other_emails = array(); + $main_domain_emails = array(); + $aux_domain_emails = array(); + $other_emails = array(); foreach ($emails as $email) { if (strpos($email, '@') === false) { - $user = $email; - $domain = $globals->mail->domain2; + $main_domain_emails[] = $email; } else { - list($user, $domain) = explode('@', $email); - } - if ($domain == $globals->mail->alias_dom || $domain == $globals->mail->alias_dom2 - || $domain == $globals->mail->domain || $domain == $globals->mail->domain2) { - list($user) = explode('+', $user); - list($user) = explode('_', $user); - $domain_emails[$email] = strtolower($user . '@' . $domain); - } else { - $other_emails[$email] = strtolower($user . '@' . $domain); + if (User::isForeignEmailAddress($email)) { + $other_emails[$email] = strtolower($user . '@' . $domain); + } else { + list($local_part, $domain) = explode('@', $email); + list($local_part) = explode('+', $local_part); + list($local_part) = explode('_', $local_part); + if (User::isMainMailDomain($domain)) { + $main_domain_emails[$email] = strtolower($local_part); + } elseif (User::isAliasMailDomain($domain)) { + $aux_domain_emails[$email] = strtolower($local_part); + } + } } } // Retrieves emails from our domains. - $domain_uids = XDB::fetchAllAssoc('email', - 'SELECT email, uid - FROM email_source_account - WHERE email IN {?}', - array_unique($domain_emails)); + $main_domain_uids = XDB::fetchAllAssoc('email', + 'SELECT email, uid + FROM email_source_account + WHERE email IN {?} AND type != \'alias_aux\'', + array_unique($main_domain_emails)); + $aux_domain_uids = XDB::fetchAllAssoc('email', + 'SELECT email, uid + FROM email_source_account + WHERE email IN {?} AND type = \'alias_aux\'', + array_unique($aux_domain_emails)); // Retrieves emails from redirections. $other_uids = XDB::fetchAllAssoc('redirect', @@ -281,15 +286,17 @@ function ids_from_mails(array $emails) // Associates given emails with the corresponding uid. $uids = array(); - foreach (array_merge($domain_emails, $other_emails) as $email => $canonical_email) { - if (array_key_exists($canonical_email, $domain_uids)) { - $uids[$email] = $domain_uids[$canonical_email]; - } elseif (array_key_exists($canonical_email, $other_uids)) { - $uids[$email] = $other_uids[$canonical_email]; - } + foreach ($main_domain_emails as $email => $key) { + $uids[$email] = $main_domain_uids[$key]; + } + foreach ($aux_domain_emails as $email => $key) { + $uids[$email] = $aux_domain_uids[$key]; + } + foreach ($other_emails as $email => $key) { + $uids[$email] = $other_uids[$key]; } - return $uids; + return array_unique($uids); } // class Bogo {{{1 diff --git a/include/marketing.inc.php b/include/marketing.inc.php index 28fc7e6..e91b730 100644 --- a/include/marketing.inc.php +++ b/include/marketing.inc.php @@ -67,8 +67,8 @@ class Marketing 'sexe' => $user->isFemale(), 'mail' => $email, 'to' => '"' . $user->fullName() . '" <' . $email . '>', - 'forlife_email' => $user->login() . '@' . $globals->mail->domain, - 'forlife_email2' => $user->login() . '@' . $globals->mail->domain2, + 'forlife_email' => $user->forlifeEmail(), + 'forlife_email2' => $user->forlifeEmailAlternate() ); } @@ -217,7 +217,7 @@ class Marketing $mymail->assign('baseurl', $globals->baseurl); $mymail->assign('lins_id', $hash); $mymail->assign('lemail', $email); - $mymail->assign('subj', $alias.'@'.$globals->mail->domain); + $mymail->assign('subj', ucfirst($globals->mail->domain) . ' : ' . $alias); $mymail->send(); XDB::execute('UPDATE register_pending SET hash={?}, password={?}, relance=NOW() diff --git a/include/name.func.inc.php b/include/name.func.inc.php index 09f8b71..8ac831d 100644 --- a/include/name.func.inc.php +++ b/include/name.func.inc.php @@ -247,7 +247,7 @@ function compare_basename($a, $b) { return name_to_basename($a) == name_to_basename($b); } -function set_alias_names(&$sn_new, $sn_old, $pid, $uid, $update_new = false, $new_alias = null) +function set_alias_names(&$sn_new, $sn_old, $pid, PlUser $user, $update_new = false, $new_alias = null) { $has_new = false; foreach ($sn_new as $typeid => $sn) { @@ -298,18 +298,16 @@ function set_alias_names(&$sn_new, $sn_old, $pid, $uid, $update_new = false, $ne } } if ($update_new) { - XDB::execute('DELETE s - FROM email_source_account AS s - INNER JOIN email_virtual_domains AS d ON (s.domain = d.id) - WHERE FIND_IN_SET(\'usage\', s.flags) AND s.uid = {?} AND d.name = {?}', - $uid, Platal::globals()->mail->domain); + XDB::execute('DELETE FROM email_source_account + WHERE FIND_IN_SET(\'usage\', flags) AND uid = {?} AND type = \'alias\'', + $user->id()); } if ($new_alias) { XDB::execute('INSERT INTO email_source_account (email, uid, type, flags, domain) SELECT {?}, {?}, \'alias\', \'usage\', id FROM email_virtual_domains WHERE name = {?}', - $new_alias, $uid, Platal::globals()->mail->domain); + $new_alias, $user->id(), $user->mainEmailDomain()); } Profile::rebuildSearchTokens($pid, false); return $has_new; diff --git a/include/validations/homonymes.inc.php b/include/validations/homonymes.inc.php index 7f181ef..14a6f49 100644 --- a/include/validations/homonymes.inc.php +++ b/include/validations/homonymes.inc.php @@ -26,11 +26,7 @@ class HomonymeReq extends Validate // {{{ properties public $loginbis; - public $warning = true; - - public $homonymes_hruid; - public $rules = "Accepter, sauf cas particulier d'utilisateur dont l'homonymie est traité plus … manuellement."; // }}} @@ -44,7 +40,6 @@ class HomonymeReq extends Validate $this->refuse = false; $this->loginbis = $_loginbis; - $this->homonymes_hruid = $_homonymes_hruid; } // }}} @@ -68,10 +63,9 @@ class HomonymeReq extends Validate protected function _mail_subj() { - global $globals; return "[Polytechnique.org/Support] " . ($this->warning ? "Dans une semaine : suppression de l'alias " : "Mise en place du robot") - . " $loginbis@" . $globals->mail->domain; + . " $loginbis@" . $this->user->mainEmailDomain(); } // }}} @@ -79,16 +73,15 @@ class HomonymeReq extends Validate protected function _mail_body($isok) { - global $globals; return " Comme nous t'en avons informé par email il y a quelques temps, pour respecter nos engagements en terme d'adresses email devinables, -tu te verras bientôt retirer l'alias ".$this->loginbis."@".$globals->mail->domain." pour +tu te verras bientôt retirer l'alias " . $this->loginbis . "@" . $this->user->mainEmailDomain() . " pour ne garder que " . $this->user->forlifeEmail() . ". -Toute personne qui écrira à ".$this->loginbis."@".$globals->mail->domain." recevra la -réponse d'un robot qui l'informera que ".$this->loginbis."@".$globals->mail->domain." +Toute personne qui écrira à " . $this->loginbis . "@" . $this->user->mainEmailDomain() . " recevra la +réponse d'un robot qui l'informera que " . $this->loginbis . "@" . $this->user->mainEmailDomain() . " est ambigu pour des raisons d'homonymie et signalera ton email exact."; } @@ -122,22 +115,17 @@ est ambigu pour des raisons d'homonymie et signalera ton email exact."; { Platal::load('admin', 'homonyms.inc.php'); if (!$this->warning) { - global $globals; require_once 'emails.inc.php'; - XDB::execute('DELETE e - FROM email_source_account AS e - INNER JOIN email_virtual_domains AS d ON (e.domain = d.id) - WHERE e.email = {?} AND d.name = {?}', - $this->loginbis, $globals->mail->domain); + XDB::execute('DELETE FROM email_source_account + WHERE email = {?} AND type = \'alias\'', + $this->loginbis); XDB::execute('INSERT INTO email_source_other (hrmid, email, domain, type, expire) - SELECT CONCAT(\'h.\', {?}, \'.\', {?}), {?}, id, \'homonym\', NOW() + SELECT {?}, {?}, id, \'homonym\', NOW() FROM email_virtual_domains WHERE name = {?}', - $this->loginbis, $globals->mail->domain, $this->loginbis, $globals->mail->domain); - XDB::execute('INSERT IGNORE INTO homonyms_list (hrmid, uid) - VALUES ({?}, {?})', - 'h.' . $this->loginbis . '.' . $globals->mail->domain, $this->user->id()); + 'h.' . $this->loginbis . '.' . Platal::globals()->mail->domain, + $this->loginbis, $this->user->mainEmailDomain()); fix_bestalias($this->user); } diff --git a/include/validations/names.inc.php b/include/validations/names.inc.php index 3f00f83..4d6eb66 100644 --- a/include/validations/names.inc.php +++ b/include/validations/names.inc.php @@ -30,6 +30,7 @@ class NamesReq extends ProfileValidate public $sn_old; public $sn_new; public $display_names; + public $mail_domain; public $old_alias; public $new_alias; public $sn_types; @@ -49,6 +50,7 @@ class NamesReq extends ProfileValidate $this->sn_new = $_search_names; $this->new_alias = true; $this->display_names = array(); + $this->mail_domain = $this->profileOwner->mainEmailDomain(); build_display_names($this->display_names, $_search_names, $this->profile->isFemale(), $_private_name_end, $this->new_alias); @@ -59,17 +61,15 @@ class NamesReq extends ProfileValidate } if (!is_null($this->profileOwner)) { - $this->old_alias = XDB::fetchOneCell('SELECT s.email - FROM email_source_account AS s - INNER JOIN email_virtual_domains AS d ON (s.domain = d.id) - WHERE s.uid = {?} AND s.type = \'alias\' AND FIND_IN_SET(\'usage\', s.flags) AND d.name = {?}', - $this->profileOwner->id(), Platal::globals()->mail->domain); + $this->old_alias = XDB::fetchOneCell('SELECT email + FROM email_source_account + WHERE uid = {?} AND type = \'alias\' AND FIND_IN_SET(\'usage\', flags)', + $this->profileOwner->id()); if ($this->old_alias != $this->new_alias) { - $used = XDB::fetchOneCell('SELECT COUNT(s.uid) - FROM email_source_account AS s - INNER JOIN email_virtual_domains AS d ON (s.domain = d.id) - WHERE s.email = {?} AND d.name = {?}', - $this->new_alias, Platal::globals()->mail->domain); + $used = XDB::fetchOneCell('SELECT COUNT(uid) + FROM email_source_account + WHERE email = {?} AND type != \'alias_aux\'', + $this->new_alias); if ($used) { $this->new_alias = null; } @@ -98,16 +98,15 @@ class NamesReq extends ProfileValidate protected function _mail_body($isok) { - global $globals; if ($isok) { $res = " Le changement de nom que tu as demandé vient d'être effectué."; if (!is_null($this->profileOwner)) { if ($this->old_alias != $this->new_alias) { if ($this->old_alias) { - $res .= "\n\n Les alias {$this->old_alias}@{$globals->mail->domain} et @{$globals->mail->domain2} ont été supprimés."; + $res .= "\n\n L'alias {$this->old_alias}@{$this->mail_domain} a été supprimé."; } if ($this->new_alias) { - $res .= "\n\n Les alias {$this->new_alias}@{$globals->mail->domain} et @{$globals->mail->domain2} sont maintenant à ta disposition !"; + $res .= "\n\n L'alias {$this->new_alias}@{$this->mail_domain} est maintenant à ta disposition !"; } } if ($globals->mailstorage->googleapps_domain) { @@ -135,7 +134,7 @@ class NamesReq extends ProfileValidate if (!is_null($this->profileOwner)) { set_alias_names($this->sn_new, $this->sn_old, $this->profile->id(), - $this->profileOwner->id(), true, $this->new_alias); + $this->profileOwner, true, $this->new_alias); // Update the local User object, to pick up the new bestalias. $this->profileOwner = User::getSilentWithUID($this->profileOwner->id()); diff --git a/include/validations/paiements.inc.php b/include/validations/paiements.inc.php index a7c4fbd..4656f32 100644 --- a/include/validations/paiements.inc.php +++ b/include/validations/paiements.inc.php @@ -188,25 +188,20 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais list($nom, $diminutif, $evt) = $res->fetchOneRow(); require_once dirname(__FILE__) . '/../../modules/xnetevents/xnetevents.inc.php'; $participants = get_event_participants(get_event_detail($this->evt, false, $this->asso_id), null); - foreach ($participants as &$u) { + foreach ($participants as $u) { if (!$u['notify_payment']) { continue; } $topay = $u['montant'] - $u['paid']; if ($topay > 0) { $mailer = new PlMailer('xnetevents/newpayment.mail.tpl'); + $mail->addTo($u['user']); $mailer->assign('asso', $nom); $mailer->assign('diminutif', $diminutif); $mailer->assign('evt', $evt); $mailer->assign('payment', $id); - $mailer->assign('prenom', $u['prenom']); + $mailer->assign('prenom', $u['user']->firstName()); $mailer->assign('topay', $topay); - - if (strpos($u['email'], '@') === false) { - $mailer->assign('to', $u['email'] . '@' . $globals->mail->domain); - } else { - $mailer->assign('to', $u['email']); - } $mailer->send(); } } diff --git a/modules/admin.php b/modules/admin.php index e22ecba..d063d71 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -604,7 +604,7 @@ class AdminModule extends PLModule if (strpos($alias, '@') !== false) { list($alias, $domain) = explode('@', $alias); } else { - $domain = $globals->mail->domain; + $domain = $user->mainEmailDomain(); } // Checks for alias' user validity. @@ -620,15 +620,15 @@ class AdminModule extends PLModule } else { $page->trigError("Impossible d'ajouter l'alias '$alias@$domain', il est probablement déjà attribué."); } - } elseif ($domain == $globals->mail->domain || $domain == $globals->mail->domain2) { + } elseif ($domain == $user->mainEmailDomain()) { XDB::execute('INSERT INTO email_source_account (email, uid, domain, type, flags) - SELECT {?}, {?}, id, \'alias_aux\', \'\' + SELECT {?}, {?}, id, \'alias\', \'\' FROM email_virtual_domains WHERE name = {?}', - $alias, $user->id(), $globals->mail->alias_dom); + $alias, $user->id(), $domain); $page->trigSuccess("Nouvel alias '$alias' ajouté"); } else { - $page->trigError("Le domaine '$domain' n'est pas valide"); + $page->trigError("Le domaine '$domain' n'est pas valide pour cet utilisateur."); } } else if (!Post::blank('del_alias')) { $delete_alias = Post::t('del_alias'); @@ -637,7 +637,7 @@ class AdminModule extends PLModule FROM email_source_account AS s INNER JOIN email_virtual_domains AS m ON (s.domain = m.id) INNER JOIN email_virtual_domains AS d ON (d.aliasing = m.id) - WHERE s.email = {?} AND s.uid = {?} AND d.name = {?} AND type = \'alias\'', + WHERE s.email = {?} AND s.uid = {?} AND d.name = {?} AND type != \'forlife\'', $email, $user->id(), $domain); XDB::execute('UPDATE email_redirect_account AS r INNER JOIN email_virtual_domains AS m ON (m.name = {?}) @@ -938,7 +938,6 @@ class AdminModule extends PLModule function handler_homonyms($page, $op = 'list', $target = null) { - global $globals; $page->changeTpl('admin/homonymes.tpl'); $page->setTitle('Administration - Homonymes'); $this->load("homonyms.inc.php"); @@ -973,19 +972,15 @@ class AdminModule extends PLModule case 'correct': S::assert_xsrf_token(); - XDB::execute('DELETE e - FROM email_source_account AS e - INNER JOIN email_virtual_domains AS d ON (e.domain = d.id) - WHERE e.email = {?} AND d.name = {?}', - $loginbis, $globals->mail->domain); + XDB::execute('DELETE FROM email_source_account + WHERE email = {?} AND type = \'alias\'', + $loginbis); XDB::execute('INSERT INTO email_source_other (hrmid, email, domain, type, expire) - SELECT CONCAT(\'h.\', {?}, \'.\', {?}), {?}, id, \'homonym\', NOW() + SELECT {?}, {?}, id, \'homonym\', NOW() FROM email_virtual_domains WHERE name = {?}', - $loginbis, $globals->mail->domain, $loginbis, $globals->mail->domain); - XDB::execute('INSERT IGNORE INTO homonyms_list (hrmid, uid) - VALUES ({?}, {?})', - 'h.' . $loginbis . '.' . $globals->mail->domain, $target); + 'h.' . $loginbis . '.' . Platal::globals()->mail->domain, + $loginbis, $user->mainEmailDomain()); fix_bestalias($user); send_robot_homonyme($user, $loginbis); $op = 'list'; @@ -1000,10 +995,8 @@ class AdminModule extends PLModule FROM email_source_other AS o INNER JOIN homonyms_list AS h ON (o.hrmid = h.hrmid) INNER JOIN email_source_account AS f ON (h.uid = f.uid AND f.type = \'forlife\') - INNER JOIN email_virtual_domains AS d ON (f.domain = d.id) - WHERE o.expire IS NOT NULL AND d.name = {?} - ORDER BY homonym, forlife', - $globals->mail->domain); + WHERE o.expire IS NOT NULL + ORDER BY homonym, forlife'); $homonyms = array(); while ($item = $res->next()) { $homonyms[$item['homonym']][] = $item; @@ -1016,10 +1009,8 @@ class AdminModule extends PLModule INNER JOIN homonyms_list AS l ON (e.uid = l.uid) INNER JOIN homonyms_list AS h ON (l.hrmid = h.hrmid) INNER JOIN email_source_account AS f ON (h.uid = f.uid AND f.type = \'forlife\') - INNER JOIN email_virtual_domains AS d ON (f.domain = d.id) - WHERE e.expire IS NOT NULL AND d.name = {?} - ORDER BY homonym, forlife', - $globals->mail->domain); + WHERE e.expire IS NOT NULL + ORDER BY homonym, forlife'); $homonyms_to_fix = array(); while ($item = $res->next()) { $homonyms_to_fix[$item['homonym']][] = $item; diff --git a/modules/admin/homonyms.inc.php b/modules/admin/homonyms.inc.php index d96e735..ea4a1c7 100644 --- a/modules/admin/homonyms.inc.php +++ b/modules/admin/homonyms.inc.php @@ -33,7 +33,7 @@ function send_warning_homonyme(PlUser $user, $loginbis) { $mymail = new PlMailer(); $mymail->setFrom($FROM); $mymail->addCc($cc); - $mymail->setSubject("Dans 2 semaines, suppression de $loginbis@" . $globals->mail->domain); + $mymail->setSubject("Dans 2 semaines, suppression de $loginbis@" . $user->mainEmailDomain()); $mymail->setTxtBody(Env::v('mailbody')); $mymail->sendTo($user); } @@ -44,7 +44,7 @@ function send_robot_homonyme(PlUser $user, $loginbis) { $FROM = "\"Support Polytechnique.org\" <$cc>"; $mymail = new PlMailer(); $mymail->setFrom($FROM); - $mymail->setSubject("Mise en place du robot $loginbis@" . $globals->mail->domain); + $mymail->setSubject("Mise en place du robot $loginbis@" . $user->mainEmailDomain()); $mymail->addCc($cc); $mymail->setTxtBody(Env::v('mailbody')); $mymail->sendTo($user); diff --git a/modules/carnet.php b/modules/carnet.php index 06b3a2e..172e654 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -373,7 +373,7 @@ class CarnetModule extends PLModule 'timestamp' => $date, 'date' => date('Ymd', $date), 'tomorrow' => date('Ymd', $tomorrow), - 'hruid' => $profile->hrid(), + 'email' => $profile->owner()->bestEmail(), 'summary' => 'Anniversaire de ' . $profile->fullName(true) ); } diff --git a/modules/email.php b/modules/email.php index d59ee1d..d412b2a 100644 --- a/modules/email.php +++ b/modules/email.php @@ -103,6 +103,13 @@ class EmailModule extends PLModule // Display active redirections. $redirect = new Redirect($user); $page->assign('mails', $redirect->active_emails()); + + // User's mail domains. + $mail_domains = array($user->alternateEmailDomain()); + $mail_domains[] = User::$sub_mail_domains['all'] . $globals->mail->domain; + $mail_domains[] = User::$sub_mail_domains['all'] . $globals->mail->domain2; + $page->assign('main_email_domain', $user->mainEmailDomain()); + $page->assign('mail_domains', $mail_domains); } function handler_alias($page, $action = null, $value = null) @@ -643,11 +650,8 @@ class EmailModule extends PLModule S::assert_xsrf_token(); $email = Post::t('email'); - list(, $domain) = explode('@', $email); - $domain = strtolower($domain); - if ($domain == $globals->mail->alias_dom || $domain == $globals->mail->alias_dom2 - || $domain == $globals->mail->domain || $domain == $globals->mail->domain2) { + if (!User::isForeignEmailAddress($email)) { $page->assign('neuneu', true); } else { $user = mark_broken_email($email); @@ -822,7 +826,7 @@ class EmailModule extends PLModule if ($user = mark_broken_email($email, true)) { if ($user['nb_mails'] > 0) { $mail = new PlMailer('emails/broken.mail.tpl'); - $mail->addTo('"' . $user['full_name'] . '" <' . $user['alias'] . '@' . Platal::globals()->mail->domain . '>'); + $mail->addTo($user); $mail->assign('user', $user); $mail->assign('email', $email); $mail->send(); diff --git a/modules/lists.php b/modules/lists.php index 5c4ec4d..ba62594 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -571,7 +571,7 @@ class ListsModule extends PLModule static public function no_login_callback($login) { - global $list_unregistered, $globals; + global $list_unregistered; $users = User::getPendingAccounts($login, true); if ($users && $users->total()) { @@ -580,8 +580,8 @@ class ListsModule extends PLModule } $list_unregistered[$login] = $users; } else { - list($name, $dom) = @explode('@', $login); - if ($dom == $globals->mail->domain || $dom == $globals->mail->domain2) { + list($name, $domain) = @explode('@', $login); + if (User::isMainMailDomain($domain)) { User::_default_user_callback($login); } } @@ -668,8 +668,9 @@ class ListsModule extends PLModule S::assert_xsrf_token(); if (strpos(Env::v('del_member'), '@') === false) { - $this->client->mass_unsubscribe( - $liste, array(Env::v('del_member').'@'.$globals->mail->domain)); + if ($del_member = User::getSilent(Env::t('del_member'))) { + $this->client->mass_unsubscribe($liste, array($del_member->forlifeEmail())); + } } else { $this->client->mass_unsubscribe($liste, array(Env::v('del_member'))); } @@ -693,7 +694,9 @@ class ListsModule extends PLModule S::assert_xsrf_token(); if (strpos(Env::v('del_owner'), '@') === false) { - $this->client->del_owner($liste, Env::v('del_owner').'@'.$globals->mail->domain); + if ($del_owner = User::getSilent(Env::t('del_owner'))) { + $this->client->mass_unsubscribe($liste, array($del_owner->forlifeEmail())); + } } else { $this->client->del_owner($liste, Env::v('del_owner')); } diff --git a/modules/marketing.php b/modules/marketing.php index 822b7ae..300d6f7 100644 --- a/modules/marketing.php +++ b/modules/marketing.php @@ -315,8 +315,8 @@ class MarketingModule extends PLModule $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 + 'forlife_email' => $user->forlifeEmail(), + 'forlife_email2' => $user->forlifeEmailAlternate() )); $text = str_replace('%%hash%%', '', $text); $text = str_replace('%%personal_notes%%', '', $text); diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index 8453ae0..b984472 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -217,7 +217,7 @@ class ProfileSettingSearchNames implements ProfileSetting INNER JOIN profile_name_enum AS e ON (s.typeid = e.id) WHERE s.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags)", $page->pid()); - $has_new = set_alias_names($this->search_names, $sn_old, $page->pid(), $page->owner->id()); + $has_new = set_alias_names($this->search_names, $sn_old, $page->pid(), $page->owner); // Only requires validation if modification in public names if ($has_new) { diff --git a/modules/register.php b/modules/register.php index 36868db..95b896f 100644 --- a/modules/register.php +++ b/modules/register.php @@ -52,7 +52,7 @@ class RegisterModule extends PLModule $nameTypes = DirEnum::getOptions(DirEnum::NAMETYPES); $nameTypes = array_flip($nameTypes); $res = XDB::query("SELECT a.uid, pd.promo, pnl.name AS lastname, pnf.name AS firstname, p.xorg_id AS xorgid, - p.birthdate_ref AS birthdateRef, FIND_IN_SET('watch', a.flags) AS watch, m.hash + p.birthdate_ref AS birthdateRef, FIND_IN_SET('watch', a.flags) AS watch, m.hash, a.type FROM register_marketing AS m INNER JOIN accounts AS a ON (m.uid = a.uid) INNER JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET('owner', ap.perms)) @@ -65,6 +65,7 @@ class RegisterModule extends PLModule if ($res->numRows() == 1) { $subState->merge($res->fetchOneRow()); + $subState->set('main_mail_domain', User::$sub_mail_domains[$subState->v('type')]); $subState->set('yearpromo', substr($subState->s('promo'), 1, 4)); XDB::execute('INSERT INTO register_mstats (uid, sender, success) @@ -305,6 +306,7 @@ class RegisterModule extends PLModule $birthdate, $lastname, $firstname, $promo, $sex, $birthdate_ref, $eduType) = $res->fetchOneRow(); $isX = ($eduType == 'x'); $yearpromo = substr($promo, 1, 4); + $mail_domain = User::$sub_mail_domains[$eduType]; // Prepare the template for display. $page->changeTpl('register/end.tpl'); @@ -339,18 +341,18 @@ class RegisterModule extends PLModule SELECT {?}, {?}, \'forlife\', \'\', id FROM email_virtual_domains WHERE name = {?}', - $forlife, $uid, $globals->mail->domain); + $forlife, $uid, $mail_domain); XDB::execute('INSERT INTO email_source_account (email, uid, type, flags, domain) SELECT {?}, {?}, \'alias\', \'bestalias\', id FROM email_virtual_domains WHERE name = {?}', - $bestalias, $uid, $globals->mail->domain); + $bestalias, $uid, $mail_domain); if ($emailXorg2) { XDB::execute('INSERT INTO email_source_account (email, uid, type, flags, domain) SELECT {?}, {?}, \'alias\', \'\', id FROM email_virtual_domains WHERE name = {?}', - $emailXorg2, $uid, $globals->mail->domain); + $emailXorg2, $uid, $mail_domain); } XDB::commit(); diff --git a/modules/register/register.inc.php b/modules/register/register.inc.php index bd6f860..7a8b21f 100644 --- a/modules/register/register.inc.php +++ b/modules/register/register.inc.php @@ -152,31 +152,29 @@ function createAliases($subState) . "mail->domain}\">support@{$globals->mail->domain}."; } - $count = XDB::numRows('SELECT * - FROM email_source_account AS s - INNER JOIN email_virtual_domains AS d ON (s.domain = d.id) - WHERE s.email = {?} AND d.name = {?}', - $emailXorg, $globals->mail->domain); + $count = XDB::numRows('SELECT uid, expire + FROM email_source_account + WHERE email = {?} AND type != \'alias_aux\'', + $emailXorg); if ($count) { - list($h_id, $h_type, $expire) = $res->fetchOneRow(); - if ($h_type != 'homonyme' and empty($expire)) { - XDB::execute('UPDATE email_source_account AS e - INNER JOIN email_virtual_domains AS d ON (e.domain = d.id) - SET e.expire = ADDDATE(NOW(), INTERVAL 1 MONTH) - WHERE e.email = {?} AND d.name = {?}', - $emailXorg, $globals->mail->domain); + list($h_id, $expire) = $res->fetchOneRow(); + if (empty($expire)) { + XDB::execute('UPDATE email_source_account + SET expire = ADDDATE(NOW(), INTERVAL 1 MONTH) + WHERE email = {?} AND type != \'alias_aux\'', + $emailXorg); $hrmid = 'h.' . $emailXorg . '.' . $globals->mail->domain; XDB::execute('INSERT IGNORE INTO homonyms_list (hrmid, uid) VALUES ({?}, {?}), ({?}, {?})', $hrmid, $h_id, $hrmid, $subState->i('uid')); - $als = XDB::fetchColumn('SELECT * - FROM email_source_account AS s - INNER JOIN email_virtual_domains AS d ON (s.domain = d.id) - WHERE s.uid = {?} AND d.name = {?} AND s.expire IS NULL', - $h_id, $globals->mail->domain); + $als = XDB::fetchColumn('SELECT email + FROM email_source_account + WHERE uid = {?} AND type != \'alias_aux\' AND expire IS NULL', + $h_id); + $homonym = User::getSilentWithUID($h_id); $mailer = new PlMailer('register/lostalias.mail.tpl'); - $mailer->addTo($emailXorg . '@' . $globals->mail->domain); + $mailer->addTo($homonym); $mailer->setSubject("Perte de ton alias $emailXorg dans un mois !"); $mailer->assign('emailXorg', $emailXorg); $mailer->assign('als', join(', ', $als)); @@ -219,7 +217,7 @@ function finishRegistration($subState) $mymail->assign('to', $subState->s('email')); $mymail->assign('baseurl', $globals->baseurl); $mymail->assign('hash', $hash); - $mymail->assign('subject', $subState->s('bestalias') . '@' . $globals->mail->domain); + $mymail->assign('subject', ucfirst($globals->mail->domain) . ' : ' . $subState->s('bestalias')); $mymail->send(); } diff --git a/templates/admin/homonymes.tpl b/templates/admin/homonymes.tpl index 9f9fed5..8babe84 100644 --- a/templates/admin/homonymes.tpl +++ b/templates/admin/homonymes.tpl @@ -109,11 +109,11 @@ Comme nous t'en avons informé par email il y a quelques temps, pour respecter nos engagements en terme d'adresses email devinables, -tu te verras bientôt retirer l'alias {$loginbis}@{#globals.mail.domain#} pour +tu te verras bientôt retirer l'alias {$loginbis}@{$user->mainEmailDomain()} pour ne garder que {$user->forlifeEmail()}. -Toute personne qui écrira à {$loginbis}@{#globals.mail.domain#} recevra la -réponse d'un robot qui l'informera que {$loginbis}@{#globals.mail.domain#} +Toute personne qui écrira à {$loginbis}@{$user->mainEmailDomain()} recevra la +réponse d'un robot qui l'informera que {$loginbis}@{$user->mainEmailDomain()} est ambigu pour des raisons d'homonymie et signalera ton email exact. L'équipe Polytechnique.org @@ -135,7 +135,7 @@ L'équipe Polytechnique.org {xsrf_token_field} - +
Mettre en place le robot {$loginbis}@{#globals.mail.domain#}Mettre en place le robot {$loginbis}@{$user->mainEmailDomain()}
@@ -144,13 +144,13 @@ L'équipe Polytechnique.org Comme nous t'en avons informé par email il y a quelques temps, nous t'avons retiré de façon définitive l'adresse -{$loginbis}@{#globals.mail.domain#}. +{$loginbis}@{$user->mainEmailDomain()}. -Toute personne qui écrit à {$loginbis}@{#globals.mail.domain#} reçoit la -réponse d'un robot qui l'informe que {$loginbis}@{#globals.mail.domain#} +Toute personne qui écrit à {$loginbis}@{$user->mainEmailDomain()} reçoit la +réponse d'un robot qui l'informe que {$loginbis}@{$user->mainEmailDomain()} est ambigu pour des raisons d'homonymie et indique ton email exact. -Tu peux faire l'essai toi-même en écrivant à {$loginbis}@{#globals.mail.domain#}. +Tu peux faire l'essai toi-même en écrivant à {$loginbis}@{$user->mainEmailDomain()}. L'équipe Polytechnique.org {#globals.baseurl#} diff --git a/templates/carnet/calendar.tpl b/templates/carnet/calendar.tpl index 9fe21f5..9a0b411 100644 --- a/templates/carnet/calendar.tpl +++ b/templates/carnet/calendar.tpl @@ -1,40 +1,40 @@ -{**************************************************************************} -{* *} -{* Copyright (C) 2003-2011 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 *} -{* *} -{**************************************************************************} -BEGIN:VCALENDAR -{display_ical name="prodid" value="-//Polytechnique.org//Plat-al//FR"} -VERSION:2.0 -CALSCALE:GREGORIAN -METHOD:PUBLISH -{display_ical name="x-wr-calname" value="Anniversaires des X"} -X-WR-TIMEZONE:Europe/Paris -{iterate from=$events item=e} -BEGIN:VEVENT -DTSTAMP:{$e.timestamp|date_format:"%Y%m%dT%H%M%SZ"} -DTSTART;VALUE=DATE:{$e.date} -DTEND;VALUE=DATE:{$e.tomorrow} -UID:anniv-{$e.date}-{$e.hruid}@{#globals.mail.domain#} -RRULE:FREQ=YEARLY;INTERVAL=1 -CLASS:PUBLIC -{display_ical name="summary" value=$e.summary} -END:VEVENT -{/iterate} +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2011 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 *} +{* *} +{**************************************************************************} +BEGIN:VCALENDAR +{display_ical name="prodid" value="-//Polytechnique.org//Plat-al//FR"} +VERSION:2.0 +CALSCALE:GREGORIAN +METHOD:PUBLISH +{display_ical name="x-wr-calname" value="Anniversaires des X"} +X-WR-TIMEZONE:Europe/Paris +{iterate from=$events item=e} +BEGIN:VEVENT +DTSTAMP:{$e.timestamp|date_format:"%Y%m%dT%H%M%SZ"} +DTSTART;VALUE=DATE:{$e.date} +DTEND;VALUE=DATE:{$e.tomorrow} +UID:anniv-{$e.date}-{$e.email} +RRULE:FREQ=YEARLY;INTERVAL=1 +CLASS:PUBLIC +{display_ical name="summary" value=$e.summary} +END:VEVENT +{/iterate} END:VCALENDAR{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/core/password_prompt.tpl b/templates/core/password_prompt.tpl index 207e9dd..4aa0549 100644 --- a/templates/core/password_prompt.tpl +++ b/templates/core/password_prompt.tpl @@ -52,7 +52,7 @@ - {$a.email} et {if $a.alias}@{#globals.mail.alias_dom2#}{else}@{#globals.mail.domain2#}{/if} {if $a.forlife}(**){/if}{if $a.hundred_year}(*){/if} +  {if $a.forlife}(**){/if}{if $a.hundred_year}(*){/if} {if $a.expire}(expire le {$a.expire|date_format}){/if} {if $a.alias}(changer ou supprimer mon alias melix){/if}
@@ -61,9 +64,9 @@
(M4X signifie mail for X, son intérêt est de te doter d'une adresse à vie - moins "voyante" que l'adresse @{#globals.mail.domain#}). + moins "voyante" que l'adresse {$main_email_domain}). {if !$alias} - Tu peux ouvrir en supplément une adresse synonyme de ton adresse @{#globals.mail.domain#}, + Tu peux ouvrir en supplément une adresse synonyme de ton adresse @{$main_email_domain}, sur les domaines @{#globals.mail.alias_dom#} et @{#globals.mail.alias_dom2#} (melix = Mél X).
{/if} @@ -79,12 +82,12 @@

{if $homonyme} -Tu as un homonyme X donc tu ne peux pas profiter de l'alias {$homonyme}@{#globals.mail.domain#}. Si quelqu'un essaie +Tu as un homonyme donc tu ne peux pas profiter de l'alias {$homonyme}@{$main_email_domain}. Si quelqu'un essaie d'envoyer un email à cette adresse par mégarde il recevra une réponse d'un robot lui expliquant l'ambiguité et lui proposant les adresses des différents homonymes. {else} -Si tu venais à avoir un homonyme X, l'alias «prenom.nom»@{#globals.mail.domain#} sera désactivé. Si bien que -ton homonyme et toi-même ne disposeraient plus que des adresses de la forme «prenom.nom.promo»@{#globals.mail.domain#}. +Si tu venais à avoir un homonyme, l'alias «prenom.nom»@{$main_email_domain} sera désactivé. Si bien que +ton homonyme et toi-même ne disposeraient plus que des adresses de la forme «prenom.nom.promo»@{$main_email_domain}. {/if}

diff --git a/templates/platal/recovery.tpl b/templates/platal/recovery.tpl index f98ecf0..cce7750 100644 --- a/templates/platal/recovery.tpl +++ b/templates/platal/recovery.tpl @@ -28,7 +28,7 @@

Un certificat d'authentification vient de t'être attribué et a été envoyé vers les redirections de -ton adresse en {#globals.mail.domain#}. Ce certificat te permet d'accéder à un formulaire de changement de mot de passe. +ton adresse {#globals.mail.domain#}. Ce certificat te permet d'accéder à un formulaire de changement de mot de passe. Il expire dans six heures. Tu dois donc consulter tes emails avant son expiration et utiliser le certificat comme expliqué dans l'email pour changer ton mot de passe.

diff --git a/templates/register/lostalias.mail.tpl b/templates/register/lostalias.mail.tpl index bc1ebc6..928897a 100644 --- a/templates/register/lostalias.mail.tpl +++ b/templates/register/lostalias.mail.tpl @@ -32,7 +32,7 @@ conserver ton alias {$emailXorg} qui correspond maintenant à deux personnes. Tu gardes tout de même l'usage de cet alias pour un mois encore à compter de ce jour. -Lorsque cet alias sera désactivé, l'adresse {$emailXorg}@polytechnique.org renverra vers un robot qui indiquera qu'il y a plusieurs personnes portant le même nom ; cela évite que l'un des homonymes reçoive des courriels destinés à l'autre. +Lorsque cet alias sera désactivé, l'adresse {$emailXorg} renverra vers un robot qui indiquera qu'il y a plusieurs personnes portant le même nom ; cela évite que l'un des homonymes reçoive des courriels destinés à l'autre. Pour te connecter au site, tu pourras utiliser comme identifiant n'importe lequel de tes autres alias : {$als}. Commence dès aujourd'hui à communiquer à tes correspondants la nouvelle adresse que tu comptes utiliser ! diff --git a/templates/register/step3.tpl b/templates/register/step3.tpl index f0396df..ae9cf64 100644 --- a/templates/register/step3.tpl +++ b/templates/register/step3.tpl @@ -30,16 +30,16 @@ {if $smarty.session.subState.emailXorg2}

Tu n'as pour le moment aucun homonyme dans notre base de données. Nous allons - donc te donner l'adresse {$smarty.session.subState.bestalias}@{#globals.mail.domain#}, - en plus de ton adresse à vie {$smarty.session.subState.forlife}@{#globals.mail.domain#}. - Note que tu pourrais perdre l'adresse {$smarty.session.subState.bestalias}@{#globals.mail.domain#} + donc te donner l'adresse {$smarty.session.subState.bestalias}@{$smarty.session.subState.main_mail_domain}, + en plus de ton adresse à vie {$smarty.session.subState.forlife}@{$smarty.session.subState.main_mail_domain}. + Note que tu pourrais perdre l'adresse {$smarty.session.subState.bestalias}@{$smarty.session.subState.main_mail_domain} si un homonyme s'inscrivait, même si cela reste assez rare.

{else}

Tu as déjà un homonyme inscrit dans notre base de données, dans une autre promotion. Nous allons - donc te donner l'adresse {$smarty.session.subState.bestalias}@{#globals.mail.domain#}, en plus - de ton adresse à vie {$smarty.session.subState.forlife}@{#globals.mail.domain#}. + donc te donner l'adresse {$smarty.session.subState.bestalias}@{$smarty.session.subState.main_mail_domain}, en plus + de ton adresse à vie {$smarty.session.subState.forlife}@{$smarty.session.subState.main_mail_domain}.

{/if} diff --git a/templates/xnetevents/calendar.tpl b/templates/xnetevents/calendar.tpl index c40815f..e76c6d7 100644 --- a/templates/xnetevents/calendar.tpl +++ b/templates/xnetevents/calendar.tpl @@ -34,11 +34,7 @@ ORGANIZER;CN="{$e.prenom} {$e.nom}":MAILTO:{$e.alias}@polytechnique.org UID:event-{$e.short_name}-{$e.eid}@{$asso->diminutif}.polytechnique.org {if $admin} {foreach from=$participants item=m} -{if $m.x} -ATTENDEE;CN="{$m.prenom} {$m.nom} (X{$m.promo})":MAILTO:{$m.email}@{#globals.mail.domain#} -{else} -ATTENDEE;CN="{$m.prenom} {$m.nom} (non-X)":MAILTO:{$m.email} -{/if} +ATTENDEE;CN="{$m.user->fullName('promo')}":MAILTO:{$m.user->bestEmail()} {/foreach} {/if} {if $e.accept_nonmembre} diff --git a/upgrade/1.1.0/02_new_mail_insertion.sql b/upgrade/1.1.0/02_new_mail_insertion.sql index 5c63181..a51987c 100644 --- a/upgrade/1.1.0/02_new_mail_insertion.sql +++ b/upgrade/1.1.0/02_new_mail_insertion.sql @@ -40,6 +40,28 @@ INSERT INTO email_virtual_domains (name, aliasing) FROM email_virtual_domains WHERE name = 'x-consult.polytechnique.org'; +INSERT INTO email_virtual_domains (name, aliasing) + VALUES ('alumni.polytechnique.org', @p_domain_id), ('alumni.m4x.org', @p_domain_id), + ('master.polytechnique.org', 1), ('doc.polytechnique.org', 1); +SET @master_domain_id = 0; +SET @doc_domain_id = 0; +SELECT @master_domain_id := id + FROM email_virtual_domains + WHERE name = 'master.polytechnique.org'; +SELECT @doc_domain_id := id + FROM email_virtual_domains + WHERE name = 'doc.polytechnique.org'; +UPDATE email_virtual_domains + SET aliasing = @master_domain_id + WHERE name = 'master.polytechnique.org'; +UPDATE email_virtual_domains + SET aliasing = @doc_domain_id + WHERE name = 'doc.polytechnique.org'; +INSERT INTO email_virtual_domains (name, aliasing) + VALUES ('alumni.polytechnique.org', @master_domain_id), ('alumni.m4x.org', @master_domain_id), + ('alumni.polytechnique.org', @doc_domain_id), ('alumni.m4x.org', @doc_domain_id), + ('master.m4x.org', @master_domain_id), ('doc.m4x.org', @doc_domain_id); + -- 2/ Feeds email_source_account INSERT INTO email_source_account (uid, domain, email, type, flags, expire) SELECT uid, @p_domain_id, alias, IF(type = 'a_vie', 'forlife', 'alias'), REPLACE(flags, 'epouse', 'marital'), expire