X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Flistes.inc.php;h=da635b06b6bf8b1336fdae13c33052291d732dbf;hb=f70f2bcdc077c220e40ecebaf569e097f6028743;hp=ffa56eed4ae208ffadb1d82ae31d992a54166beb;hpb=9b591cc995bc8dec34f184e30d354909ff3a306a;p=platal.git diff --git a/include/validations/listes.inc.php b/include/validations/listes.inc.php index ffa56ee..da635b0 100644 --- a/include/validations/listes.inc.php +++ b/include/validations/listes.inc.php @@ -1,6 +1,6 @@ asso = $_asso; $this->liste = $_liste; + $this->domain = $_domain; $this->desc = $_desc; $this->advertise = $_advertise; $this->modlevel = $_modlevel; @@ -75,9 +79,20 @@ class ListeReq extends Validate protected function handle_editor() { + global $globals; + if (Env::has('listname')) { $this->liste = trim(Env::v('listname')); } + if (Env::has('domainname')) { + $this->domain = trim(Env::v('domainname')); + } + if (Env::has('assotype')) { + $this->asso = trim(Env::v('assotype')); + } + if (!$this->asso) { + $this->domain = $globals->mail->domain; + } return true; } @@ -106,15 +121,51 @@ class ListeReq extends Validate public function commit() { - $list = new MMList(S::v('uid'), S::v('password')); + global $globals; + + if ($this->asso == "alias") { + $new = $this->liste . '@' . $this->domain; + XDB::query('INSERT INTO x4dat.virtual (alias,type) VALUES({?}, "user")', $new); + foreach ($this->members as $member) { + $res = XDB::query( + "SELECT a.alias, b.alias + FROM x4dat.aliases AS a + LEFT JOIN x4dat.aliases AS b ON (a.id=b.id AND b.type = 'a_vie') + WHERE a.alias={?} AND a.type!='homonyme'", $member); + list($alias, $blias) = $res->fetchOneRow(); + $alias = empty($blias) ? $alias : $blias; + XDB::query( + "INSERT INTO x4dat.virtual_redirect (vid,redirect) + SELECT vid, {?} + FROM x4dat.virtual + WHERE alias={?}", $alias . "@" . $globals->mail->domain, $new); + } + return 1; + } + + $list = new MMList(S::v('uid'), S::v('password'), $this->domain); $ret = $list->create_list($this->liste, utf8_decode($this->desc), $this->advertise, $this->modlevel, $this->inslevel, $this->owners, $this->members); $liste = strtolower($this->liste); - if ($ret) { - foreach(Array($liste, $liste."-owner", $liste."-admin", $liste."-bounces") as $l) { + if ($ret && !$this->asso) { + foreach(Array($liste, $liste . "-owner", $liste . "-admin", $liste . "-bounces", $liste . "-unsubscribe") as $l) { XDB::execute("INSERT INTO aliases (alias,type) VALUES({?}, 'liste')", $l); } + } 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; }