Adds multiple contacts, and markets those unregistered (Closes #709).
[platal.git] / include / emails.inc.php
index db35a5d..1e32840 100644 (file)
@@ -30,7 +30,7 @@ function require_email_update(User $user, $new_email)
 {
     Platal::assert(!is_null($user), 'User cannot be null.');
 
-    return !$user->checkPerms(User::PERM_MAIL) && $new_email != $user->forlifeEmail();
+    return !$user->checkPerms(User::PERM_MAIL) && strtolower($new_email) != strtolower($user->forlifeEmail());
 }
 
 function format_email_alias($email)
@@ -189,7 +189,7 @@ function mark_broken_email($email, $admin = false)
         return;
     }
 
-    $user = XDB::fetchOneAssoc('SELECT  r1.uid, r1.broken_level != 0 AS broken, COUNT(r2.uid) AS nb_mails,
+    $user = XDB::fetchOneAssoc('SELECT  r1.uid, a.hruid, a.full_name, r1.broken_level != 0 AS broken, COUNT(r2.uid) AS nb_mails,
                                         s.email AS alias, DATE_ADD(r1.last, INTERVAL 14 DAY) < CURDATE() as notify
                                   FROM  email_redirect_account AS r1
                             INNER JOIN  accounts               AS a  ON (a.uid = r1.uid)
@@ -469,6 +469,7 @@ class Email
 
     // Basic email properties; $sufficient indicates if the email can be used as
     // an unique redirection; $redirect contains the delivery email address.
+    public $id;
     public $type;
     public $sufficient;
     public $email;
@@ -510,6 +511,11 @@ class Email
         }
         $this->sufficient = ($this->type == 'smtp' || $this->type == 'googleapps');
         $this->filter_level = ($this->type == 'imap') ? null : array_search($this->action, Bogo::$states);
+        if (array_key_exists($this->type , self::$storage_domains)) {
+            $this->id = $this->type;
+        } else {
+            $this->id = str_replace(array('@', '.'), array('_at_', '_dot_'), $this->email);
+        }
         $this->user = &$user;
     }
 
@@ -517,7 +523,7 @@ class Email
     public function activate()
     {
         if ($this->inactive) {
-            if ($is_storage = in_array($this->type, self::get_allowed_storages($this->user))) {
+            if (in_array($this->type, self::get_allowed_storages($this->user))) {
                 self::activate_storage($this->user, $this->type, $this->action);
             } else {
                 XDB::execute('UPDATE  email_redirect_account
@@ -535,7 +541,7 @@ class Email
     public function deactivate()
     {
         if ($this->active) {
-            if ($is_storage = in_array($this->type, self::get_allowed_storages($this->user))) {
+            if (in_array($this->type, self::get_allowed_storages($this->user))) {
                 self::deactivate_storage($this->user, $this->type);
             } else {
                 XDB::execute('UPDATE  email_redirect_account