X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fmassmailer.inc.php;h=19996fe4befd2ba660f7a288165fe00f184160c4;hb=9466051012a24391af2b769a4c281ed5588105bc;hp=1ac9aea875c4fd15e7a35ccc91a313665cd9a858;hpb=02fdd1c889526931990ed2f1cae1fc9a8b2d9459;p=platal.git diff --git a/include/massmailer.inc.php b/include/massmailer.inc.php index 1ac9aea..19996fe 100644 --- a/include/massmailer.inc.php +++ b/include/massmailer.inc.php @@ -1,6 +1,6 @@ _table} AS n WHERE n.bits != 'new' AND {$where} - LIMIT 1"); + LIMIT 1"); if ($res->numRows() != 1) { return null; } @@ -108,7 +108,7 @@ abstract class MassMailer public function head($prenom = null, $nom = null, $sexe = null, $type = 'text') { if (is_null($prenom)) { - return $this->_head; + return $this->_head; } else { $head = $this->_head; $head = str_replace('', $sexe ? 'Chère' : 'Cher', $head); @@ -133,7 +133,7 @@ abstract class MassMailer { $this->css($page); $page->assign('is_mail', false); - $page->assign('html_version', false); + $page->assign('mail_part', 'text'); $page->assign('prenom', $prenom); $page->assign('nom', $nom); $page->assign('sexe', $sexe); @@ -145,19 +145,41 @@ abstract class MassMailer $this->css($page); $page->assign('prefix', $this->_prefix . '/' . $this->id()); $page->assign('is_mail', false); - $page->assign('html_version', true); + $page->assign('mail_part', 'html'); $page->assign('prenom', $prenom); $page->assign('nom', $nom); $page->assign('sexe', $sexe); $this->assignData($page); } + private function createHash($line, $key = null) + { + $hash = implode(time(), $line) . rand(); + $hash = md5($hash); + return $hash; + } + public function sendTo($prenom, $nom, $login, $sexe, $html, $hash = 0) { global $globals; + $alias = $login; if (strpos($login, '@') === false) { $login = "$login@{$globals->mail->domain}"; } + require_once('user.func.inc.php'); + $forlife = get_user_forlife($login, '_silent_user_callback'); + if ($forlife) { + $alias = $forlife; + } + if (strpos($alias, '@') === false && (is_null($hash) || $hash == 0)) { + + $hash = $this->createHash(array($prenom, $nom, $login, $sexe, $html, rand(), "X.org rulez")); + XDB::query("UPDATE {$this->_subscriptionTable} as ni + INNER JOIN aliases AS a ON (ni.user_id = a.id) + SET ni.hash = {?} + WHERE ni.user_id != 0 AND a.alias = {?}", + $hash, $alias); + } $mailer = new PlMailer($this->_tpl); $this->assignData($mailer); @@ -167,6 +189,8 @@ abstract class MassMailer $mailer->assign('sexe', $sexe); $mailer->assign('prefix', null); $mailer->assign('hash', $hash); + $mailer->assign('email', $login); + $mailer->assign('alias', $alias); $mailer->addTo("\"$prenom $nom\" <$login>"); $mailer->send($html); } @@ -177,13 +201,14 @@ abstract class MassMailer return "SELECT u.user_id, CONCAT(a.alias, '@{$globals->mail->domain}'), u.prenom, IF(u.nom_usage='', u.nom, u.nom_usage), FIND_IN_SET('femme', u.flags), - q.core_mail_fmt AS pref, 0 AS hash + q.core_mail_fmt AS pref, ni.hash AS hash FROM {$this->_subscriptionTable} AS ni INNER JOIN auth_user_md5 AS u USING(user_id) INNER JOIN auth_user_quick AS q ON(q.user_id = u.user_id) INNER JOIN aliases AS a ON(u.user_id=a.id AND FIND_IN_SET('bestalias',a.flags)) LEFT JOIN emails AS e ON(e.uid=u.user_id AND e.flags='active') - WHERE ni.last < {?} AND ({$this->subscriptionWhere()}) AND e.email IS NOT NULL + WHERE ni.last < {?} AND ({$this->subscriptionWhere()}) AND + (e.email IS NOT NULL OR FIND_IN_SET('googleapps', u.mail_storage)) GROUP BY u.user_id"; } @@ -204,7 +229,7 @@ abstract class MassMailer XDB::execute("UPDATE {$this->_subscriptionTable} SET last = {?} WHERE " . implode(' OR ', $sent), $this->_id); - + sleep(60); } }