Table editor fills the new entry form with the default values of the fields
[platal.git] / modules / lists.php
index e00ecc0..cc6a747 100644 (file)
@@ -81,7 +81,7 @@ class ListsModule extends PLModule
 
         function filter_member($list)
         {
-            return $list['ins'];
+            return $list['sub'];
         }
 
         $this->prepare_client($page);
@@ -436,12 +436,16 @@ class ListsModule extends PLModule
             $this->client->handle_request($liste,Env::v('sadd'),4,'');
             pl_redirect('lists/moderate/'.$liste);
         }
-
         if (Post::has('sdel')) { /* 2 = REJECT */
             $this->client->handle_request($liste,Post::v('sdel'),2,Post::v('reason'));
         }
 
-        if (Env::has('mid')) {
+        if (Post::has('moderate_mails') && Post::has('select_mails')) {
+            $mails = array_keys(Post::v('select_mails'));
+            foreach($mails as $mail) {
+                $this->moderate_mail($domain, $liste, $mail);
+            }
+        } elseif (Env::has('mid')) {
             $mail = $this->moderate_mail($domain, $liste, Env::i('mid'));
 
             if (Get::has('mid') && is_array($mail)) {
@@ -458,7 +462,6 @@ class ListsModule extends PLModule
                 return;
             }   
         } elseif (Env::has('sid')) {
-
             if (list($subs,$mails) = $this->client->get_pending_ops($liste)) {
                 foreach($subs as $user) {
                     if ($user['id'] == Env::v('sid')) {
@@ -600,23 +603,36 @@ class ListsModule extends PLModule
 
     function handler_delete(&$page, $liste = null)
     {
+        global $globals;
         if (is_null($liste)) {
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client($page);
+        $domain = $this->prepare_client($page);
+        if ($domain == $globals->mail->domain || $domain == $globals->mail->domain2) {
+            $domain = '';
+            $table  = 'aliases';
+            $type   = 'liste';
+        } else {
+            $domain = '@' . $domain;
+            $table  = 'virtual';
+            $type   = 'list';
+        }
 
         $page->changeTpl('listes/delete.tpl');
-
-        if (Post::v('valid') == 'OUI'
-        && $this->client->delete_list($liste, Post::b('del_archive')))
-        {
-            foreach (array('', '-owner', '-admin', '-bounces') as $app) {
-                XDB::execute("DELETE FROM  aliases
-                                              WHERE  type='liste' AND alias='{?}'",
-                                       $liste.$app);
+        if (Post::v('valid') == 'OUI') {
+            if ($this->client->delete_list($liste, Post::b('del_archive'))) {
+                foreach (array('', '-owner', '-admin', '-bounces') as $app) {
+                    XDB::execute("DELETE FROM  $table
+                                        WHERE  type={?} AND alias={?}",
+                                 $type, $liste.$app.$domain);
+                }
+                $page->assign('deleted', true);
+            } else {
+                $page->kill('Une erreur est survenue lors de la suppression de la liste.<br />'
+                         . 'Contact les administrateurs du site pour régler le problème : '
+                         . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>');
             }
-            $page->assign('deleted', true);
         } elseif (list($details,$options) = $this->client->get_owner_options($liste)) {
             $page->assign_by_ref('details', $details);
             $page->assign_by_ref('options', $options);