X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Femail.php;h=a3f7b2bf31f2d7384c06ba6afae22936c26a17b9;hb=00ba8a742be0cfc70eef7c6aaaccebe7134ec087;hp=197ae8ec42f94701de1cb3ddc910b61747feddf1;hpb=1285cf5413df654ccac839b9d9a32c4df2cee95a;p=platal.git diff --git a/modules/email.php b/modules/email.php index 197ae8e..a3f7b2b 100644 --- a/modules/email.php +++ b/modules/email.php @@ -24,14 +24,14 @@ class EmailModule extends PLModule function handlers() { return array( - 'emails' => $this->make_hook('emails', AUTH_COOKIE), - 'emails/alias' => $this->make_hook('alias', AUTH_MDP), - 'emails/antispam' => $this->make_hook('antispam', AUTH_MDP), + 'emails' => $this->make_hook('emails', AUTH_COOKIE, 'mail'), + 'emails/alias' => $this->make_hook('alias', AUTH_MDP, 'mail'), + 'emails/antispam' => $this->make_hook('antispam', AUTH_MDP, 'mail'), 'emails/broken' => $this->make_hook('broken', AUTH_COOKIE), - 'emails/redirect' => $this->make_hook('redirect', AUTH_MDP), - 'emails/send' => $this->make_hook('send', AUTH_MDP), + 'emails/redirect' => $this->make_hook('redirect', AUTH_MDP, 'mail'), + 'emails/send' => $this->make_hook('send', AUTH_MDP, 'mail'), 'emails/antispam/submit' => $this->make_hook('submit', AUTH_COOKIE), - 'emails/test' => $this->make_hook('test', AUTH_COOKIE, 'user', NO_AUTH), + 'emails/test' => $this->make_hook('test', AUTH_COOKIE, 'mail', NO_AUTH), 'emails/rewrite/in' => $this->make_hook('rewrite_in', AUTH_PUBLIC), 'emails/rewrite/out' => $this->make_hook('rewrite_out', AUTH_PUBLIC), @@ -106,8 +106,6 @@ class EmailModule extends PLModule function handler_alias(&$page, $action = null, $value = null) { - require_once 'validations.inc.php'; - global $globals; $page->changeTpl('emails/alias.tpl'); @@ -171,9 +169,9 @@ class EmailModule extends PLModule } //vérifier que l'alias n'est pas déja en demande - $it = new ValidateIterator(); + $it = Validate::iterate('alias'); while($req = $it->next()) { - if ($req->type == 'alias' and $req->alias == $alias_mail) { + if ($req->alias == $alias_mail) { $page->trigError("L'alias $alias_mail a déja été demandé. Tu ne peux donc pas l'obtenir pour l'instant."); return ; @@ -194,7 +192,7 @@ class EmailModule extends PLModule if ($user->hasProfile()) { XDB::execute("UPDATE profiles SET alias_pub = {?} - WHERE pid = {?}", + WHERE pid = {?}", $value, $user->profile()->id()); } $visibility = ($value == 'public'); @@ -387,8 +385,9 @@ class EmailModule extends PLModule $_POST['to_contacts'] = explode(';', @$_POST['to_contacts']); $_POST['cc_contacts'] = explode(';', @$_POST['cc_contacts']); $data = serialize($_POST); - XDB::execute("REPLACE INTO email_send_save - VALUES ({?}, {?})", + XDB::execute('INSERT INTO email_send_save (uid, data) + VALUES ({?}, {?}) + ON DUPLICATE KEY UPDATE data = VALUES(data)', S::user()->id('uid'), $data); } exit; @@ -619,13 +618,13 @@ class EmailModule extends PLModule $storage = new EmailStorage(S::user(), 'imap'); $storage->activate(); $page->assign('ok', true); - $page->assign('prenom', S::v('prenom')); - $page->assign('sexe', S::v('femme')); + $page->assign('yourself', S::user()->displayName()); + $page->assign('sexe', S::user()->isFemale()); } else if (!S::logged() && $user) { $storage = new EmailStorage($user, 'imap'); $storage->activate(); $page->assign('ok', true); - $page->assign('prenom', $user->displayName()); + $page->assign('yourself', $user->displayName()); $page->assign('sexe', $user->isFemale()); } } @@ -794,15 +793,16 @@ class EmailModule extends PLModule { $page->changeTpl('emails/lost.tpl'); - // TODO: Order by promo. $page->assign('lost_emails', - XDB::iterator("SELECT a.uid, a.hruid - FROM accounts AS a - INNER JOIN email_options AS eo ON (eo.uid = a.uid) - LEFT JOIN emails AS e ON (a.uid = e.uid AND FIND_IN_SET('active', e.flags)) - WHERE e.uid IS NULL AND FIND_IN_SET('googleapps', eo.storage) = 0 AND - a.state = 'active' - ORDER BY a.hruid")); + XDB::iterator('SELECT a.uid, a.hruid, pd.promo + FROM accounts AS a + INNER JOIN email_options AS eo ON (eo.uid = a.uid) + LEFT JOIN emails AS e ON (a.uid = e.uid AND FIND_IN_SET(\'active\', e.flags)) + LEFT JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET(\'owner\', perms)) + LEFT JOIN profile_display AS pd ON (ap.pid = pd.pid) + WHERE e.uid IS NULL AND FIND_IN_SET(\'googleapps\', eo.storage) = 0 + AND a.state = \'active\' + ORDER BY pd.promo, a.hruid')); } function handler_broken_addr(&$page)