X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Flistes.inc.php;h=b5bcd15c3cbae47aae03ca29c5eb7bc92ce50e58;hb=85b2b2257110a8c77d70624f0fa9bba402d99e5f;hp=07003d822dfb0d4e073cedd65bbe27e3f52d6577;hpb=ee71865181e96e7b0754ef9e7da4b3cb26f4c1d7;p=platal.git diff --git a/include/validations/listes.inc.php b/include/validations/listes.inc.php index 07003d8..b5bcd15 100644 --- a/include/validations/listes.inc.php +++ b/include/validations/listes.inc.php @@ -1,6 +1,6 @@ liste = trim(Env::v('listname')); + $this->liste = Post::t('listname'); } if (Env::has('domainname')) { - $this->domain = trim(Env::v('domainname')); + $this->domain = Post::t('domainname'); } if (Env::has('assotype')) { - $this->asso = trim(Env::v('assotype')); + $this->asso = Post::t('assotype'); } if (!$this->asso) { $this->domain = $globals->mail->domain; } + foreach ($this->owners as $key => &$email) { + $email = Post::t('owners_' . $key); + } + foreach ($this->members as $key => &$email) { + $email = Post::t('members_' . $key); + } return true; } @@ -121,49 +127,22 @@ class ListeReq extends Validate public function commit() { - global $globals; + require_once 'emails.inc.php'; - if ($this->asso == "alias") { - $new = $this->liste . '@' . $this->domain; - XDB::query('INSERT INTO virtual (alias, type) VALUES({?}, "user")', $new); + if ($this->asso == 'alias') { foreach ($this->members as $member) { - $user = User::get($member); - if ($user != null) { - XDB::query( - "INSERT INTO virtual_redirect (vid, redirect) - SELECT vid, {?} - FROM virtual - WHERE alias = {?}", $user->forlifeEmail(), $new); - } + add_to_list_alias($member, $this->liste, $this->domain); } - return 1; - } - - $list = new MMList(S::user()->id(), 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 && !$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 virtual (alias, type) - VALUES({?}, {?})', $liste . $app . '@' . $this->domain, 'list'); - XDB::execute('INSERT INTO virtual_redirect (vid, redirect) - VALUES ({?}, {?})', XDB::insertId(), - $red . $mdir . '@listes.polytechnique.org'); - $list->mass_subscribe($liste, join(' ', $this->members)); + } else { + $list = new MMList(S::user(), $this->domain); + $success = $list->create_list($this->liste, utf8_decode($this->desc), $this->advertise, + $this->modlevel, $this->inslevel, + $this->owners, $this->members); + if ($success) { + create_list($this->liste, $this->domain); } + return $success; } - return $ret; } // }}}