Fix organizer display for events created by xnet accounts.
[platal.git] / modules / email.php
index 09d840a..360c462 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2013 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -41,7 +41,7 @@ class EmailModule extends PLModule
             'admin/emails/duplicated' => $this->make_hook('duplicated',  AUTH_PASSWD, 'admin'),
             'admin/emails/watch'      => $this->make_hook('duplicated',  AUTH_PASSWD, 'admin'),
             'admin/emails/lost'       => $this->make_hook('lost',        AUTH_PASSWD, 'admin'),
-            'admin/emails/broken'     => $this->make_hook('broken_addr', AUTH_PASSWD, 'admin'),
+            'admin/emails/broken'     => $this->make_hook('broken_addr', AUTH_PASSWD, 'admin,edit_directory'),
         );
     }
 
@@ -98,9 +98,23 @@ class EmailModule extends PLModule
                               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.uid = {?}
-                                ORDER BY  !alias, s.email",
+                                ORDER BY  !alias, s.email, d.name",
                                  $user->id());
-        $page->assign('aliases', $aliases);
+        $aliases_forlife = array();
+        $aliases_hundred = array();
+        $aliases_other = array();
+        while ($a = $aliases->next()) {
+            if ($a['forlife']) {
+                $aliases_forlife[] = $a;
+            } elseif ($a['hundred_year']) {
+                $aliases_hundred[] = $a;
+            } else {
+                $aliases_other[] = $a;
+            }
+        }
+        $page->assign('aliases_forlife', $aliases_forlife);
+        $page->assign('aliases_hundred', $aliases_hundred);
+        $page->assign('aliases_other', $aliases_other);
 
         $alias = XDB::fetchOneCell('SELECT  COUNT(email)
                                       FROM  email_source_account
@@ -791,7 +805,8 @@ class EmailModule extends PLModule
                                                                               AND er.type != \'imap\' AND er.type != \'homonym\')
                                   LEFT JOIN  account_profiles       AS ap ON (ap.uid = a.uid AND FIND_IN_SET(\'owner\', ap.perms))
                                   LEFT JOIN  profile_display        AS pd ON (ap.pid = pd.pid)
-                                      WHERE  a.state = \'active\' AND er.redirect IS NULL AND FIND_IN_SET(\'mail\', at.perms)
+                                  LEFT JOIN  profiles               AS p ON (ap.pid = p.pid)
+                                      WHERE  a.state = \'active\' AND er.redirect IS NULL AND FIND_IN_SET(\'mail\', at.perms) AND p.deathdate IS NULL
                                    GROUP BY  a.uid
                                    ORDER BY  pd.promo, a.hruid'));
     }
@@ -924,5 +939,5 @@ class EmailModule extends PLModule
     }
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>