Improves 59887c: uses global domain instead of polytechnique.org, improves javascript...
authorStéphane Jacob <jacou@melix.net>
Thu, 19 Jun 2008 13:14:24 +0000 (15:14 +0200)
committerStéphane Jacob <jacou@melix.net>
Thu, 19 Jun 2008 13:14:24 +0000 (15:14 +0200)
bin/lists.create_promo.php
include/validations/listes.inc.php
modules/lists.php
templates/lists/create.tpl

index 438ed90..7296798 100755 (executable)
@@ -3,6 +3,8 @@
 require_once("xorg.inc.php");
 require_once('validations.inc.php');
 
+global $globals;
+
 $opt = getopt('p:o:h');
 
 if(empty($opt['p']) || empty($opt['o']) || isset($opt['h'])) {
@@ -17,7 +19,7 @@ EOF;
 $promo = intval($opt['p']);
 $owner = $opt['o'];
 
-$req = new ListeReq(0, false, "promo$promo", "polytechnique.org", "Liste de la promotion $promo",
+$req = new ListeReq(0, false, "promo$promo", $globals->mail->domain, "Liste de la promotion $promo",
                     1 /*private*/, 2 /*moderate*/, 0 /*free subscription*/,
                     array($owner), array());
 $req->submit();
index a2fc0e6..da635b0 100644 (file)
@@ -79,6 +79,8 @@ class ListeReq extends Validate
 
     protected function handle_editor()
     {
+        global $globals;
+
         if (Env::has('listname')) {
             $this->liste = trim(Env::v('listname'));
         }
@@ -89,7 +91,7 @@ class ListeReq extends Validate
             $this->asso = trim(Env::v('assotype'));
         }
         if (!$this->asso) {
-            $this->domain = "polytechnique.org";
+            $this->domain = $globals->mail->domain;
         }
         return true;
     }
@@ -150,21 +152,19 @@ class ListeReq extends Validate
             foreach(Array($liste, $liste . "-owner", $liste . "-admin", $liste . "-bounces", $liste . "-unsubscribe") as $l) {
                 XDB::execute("INSERT INTO aliases (alias,type) VALUES({?}, 'liste')", $l);
             }
-        } else {
-            if ($ret) {
-                foreach (Array('', 'owner', 'admin', 'bounces', 'unsubscribe') as $app) {
-                    $mdir = $app == '' ? '+post' : '+' . $app;
-                    if (!empty($app)) {
-                        $app  = '-' . $app;
-                    }
-                    $red = $this->domain . '_' . $liste;
-                    XDB::execute('INSERT INTO x4dat.virtual (alias,type)
-                                            VALUES({?},{?})', $liste . $app . '@' . $this->domain, 'list');
-                    XDB::execute('INSERT INTO x4dat.virtual_redirect (vid,redirect)
-                                            VALUES ({?}, {?})', XDB::insertId(),
-                                           $red . $mdir . '@listes.polytechnique.org');
-                    $list->mass_subscribe($liste, join(' ', $this->members));
+        } elseif ($ret) {
+            foreach (Array('', 'owner', 'admin', 'bounces', 'unsubscribe') as $app) {
+                $mdir = $app == '' ? '+post' : '+' . $app;
+                if (!empty($app)) {
+                    $app  = '-' . $app;
                 }
+                $red = $this->domain . '_' . $liste;
+                XDB::execute('INSERT INTO x4dat.virtual (alias,type)
+                                        VALUES({?},{?})', $liste . $app . '@' . $this->domain, 'list');
+                XDB::execute('INSERT INTO x4dat.virtual_redirect (vid,redirect)
+                                        VALUES ({?}, {?})', XDB::insertId(),
+                                       $red . $mdir . '@listes.polytechnique.org');
+                $list->mass_subscribe($liste, join(' ', $this->members));
             }
         }
         return $ret;
index 16d7de9..4012711 100644 (file)
@@ -159,6 +159,8 @@ class ListsModule extends PLModule
 
     function handler_create(&$page)
     {
+        global $globals;
+
         $page->changeTpl('lists/create.tpl');
 
         $owners  = preg_split("/[\s]+/", Post::v('owners'), -1, PREG_SPLIT_NO_EMPTY);
@@ -214,7 +216,7 @@ class ListsModule extends PLModule
 
         if (($asso == "binet") || ($asso == "alias")) {
             $promo = Post::i('promo');
-            $domain = $promo . '.polytechnique.org';
+            $domain = $promo . '.' . $globals->mail->domain;
 
             if (($promo < 1921) || ($promo > date('Y'))) {
                 $page->trigError('La promotion est mal renseignée, elle doit être du type : 2004.');
@@ -238,14 +240,14 @@ class ListsModule extends PLModule
                 $res = XDB::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new);
             } else {
                 $res = XDB::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste);
-                $domain = "polytechnique.org";
+                $domain = $globals->mail->domain;
             }
         }
 
         $n = $res->fetchOneCell();
 
         if ($n) {
-            $page->trigError('Cette «adresse souhaitée» est déjà prise.');
+            $page->trigError('L\'«adresse souhaitée» est déjà prise.');
         }
 
         if (!Post::v('desc')) {
index 8264ec8..0f79963 100644 (file)
@@ -80,17 +80,16 @@ liste&nbsp;:
       {literal}
       $(function() {
         $(":radio[@name=asso]").change(function() {
-          if (($(":radio[@name=asso]:checked").val() == "binet") || ($(":radio[@name=asso]:checked").val() == "alias")) {
+          var asso = $(":radio[@name=asso]:checked").val();
+          if ((asso == "binet") || (asso == "alias")) {
             $(".groupex").hide();
             $(".promo").show();
+          } else if (asso == "groupex") {
+            $(".promo").hide();
+            $(".groupex").show();
           } else {
-            if ($(":radio[@name=asso]:checked").val() == "groupex") {
-              $(".groupex").show();
-              $(".promo").hide();
-            } else {
-              $(".groupex").hide();
-              $(".promo").hide();
-            }
+            $(".groupex").hide();
+            $(".promo").hide();
           }
         }).change();
       });