From 032b244ed3fd10b934697f2636fc9a4574822408 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Thu, 19 Jun 2008 15:14:24 +0200 Subject: [PATCH] Improves 59887c: uses global domain instead of polytechnique.org, improves javascript and some other small things --- bin/lists.create_promo.php | 4 +++- include/validations/listes.inc.php | 30 +++++++++++++++--------------- modules/lists.php | 8 +++++--- templates/lists/create.tpl | 15 +++++++-------- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/bin/lists.create_promo.php b/bin/lists.create_promo.php index 438ed90..7296798 100755 --- a/bin/lists.create_promo.php +++ b/bin/lists.create_promo.php @@ -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(); diff --git a/include/validations/listes.inc.php b/include/validations/listes.inc.php index a2fc0e6..da635b0 100644 --- a/include/validations/listes.inc.php +++ b/include/validations/listes.inc.php @@ -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; diff --git a/modules/lists.php b/modules/lists.php index 16d7de9..4012711 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -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')) { diff --git a/templates/lists/create.tpl b/templates/lists/create.tpl index 8264ec8..0f79963 100644 --- a/templates/lists/create.tpl +++ b/templates/lists/create.tpl @@ -80,17 +80,16 @@ liste : {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(); }); -- 2.1.4