When adding members to a list, make sure to always pass a list of unique values.
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 23 Oct 2011 13:43:27 +0000 (15:43 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 23 Oct 2011 13:43:27 +0000 (15:43 +0200)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
include/validations/listes.inc.php
modules/lists.php

index 1897b05..ef19a21 100644 (file)
@@ -139,6 +139,11 @@ class ListeReq extends Validate
             $owners = User::getBulkForlifeEmails($this->owners, true,
                                                  array('ListsModule', 'no_login_callback'));
             $list = new MMList(S::user(), $this->domain);
+
+            // Make sure we send a list (array_values) of unique (array_unique)
+            // emails.
+            $owners = array_values(array_unique($owners));
+            $members = array_values(array_unique($members));
             $success = $list->create_list($this->liste, utf8_decode($this->desc), $this->advertise,
                                           $this->modlevel, $this->inslevel,
                                           $owners, $members);
index 546b572..e53ea7a 100644 (file)
@@ -644,6 +644,10 @@ class ListsModule extends PLModule
             $members = User::getBulkForlifeEmails(Env::v('add_member'),
                                                   true,
                                                   array('ListsModule', 'no_login_callback'));
+            // Make sure we send a list (array_values) of unique (array_unique)
+            // emails.
+            $members = array_values(array_unique($members));
+
             $arr = $this->client->mass_subscribe($liste, $members);
             if (is_array($arr)) {
                 foreach($arr as $addr) {
@@ -662,6 +666,10 @@ class ListsModule extends PLModule
                 $members = User::getBulkForlifeEmails($upload->getContents(),
                                                       true,
                                                       array('ListsModule', 'no_login_callback'));
+                // Make sure we send a list (array_values) of unique (array_unique)
+                // emails.
+                $members = array_values(array_unique($members));
+
                 $arr = $this->client->mass_subscribe($liste, $members);
                 if (is_array($arr)) {
                     foreach($arr as $addr) {