2 /***************************************************************************
3 * Copyright (C) 2003-2010 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
24 class ListeReq
extends Validate
40 public $rules = "Refuser les listes de binets si elles ne sont pas datées (oui : apv2002@, non : apv@).
41 Refuser également des listes qui pourraient nous servir (admin, postmaster…)";
45 public function __construct(User
&$_user, $_asso, $_liste, $_domain, $_desc, $_advertise,
46 $_modlevel, $_inslevel, $_owners, $_members, $_stamp=0)
48 parent
::__construct($_user, false
, 'liste', $_stamp);
51 $this->liste
= $_liste;
52 $this->domain
= $_domain;
54 $this->advertise
= $_advertise;
55 $this->modlevel
= $_modlevel;
56 $this->inslevel
= $_inslevel;
57 $this->owners
= $_owners;
58 $this->members
= $_members;
62 // {{{ function formu()
64 public function formu()
66 return 'include/form.valid.listes.tpl';
70 // {{{ function editor()
72 public function editor()
74 return 'include/form.valid.edit-listes.tpl';
78 // {{{ function handle_editor()
80 protected function handle_editor()
84 if (Env
::has('listname')) {
85 $this->liste
= trim(Env
::v('listname'));
87 if (Env
::has('domainname')) {
88 $this->domain
= trim(Env
::v('domainname'));
90 if (Env
::has('assotype')) {
91 $this->asso
= trim(Env
::v('assotype'));
94 $this->domain
= $globals->mail
->domain
;
100 // {{{ function _mail_subj
102 protected function _mail_subj()
104 return "[Polytechnique.org/LISTES] Demande de la liste {$this->liste}@{$this->domain}";
108 // {{{ function _mail_body
110 protected function _mail_body($isok)
113 return " Suite à ta demande de création de liste de diffusion, nous avons créé l'adresse {$this->liste}@{$this->domain}, qui est maintenant à ta disposition.";
115 return " La demande que tu avais faite pour la liste de diffusion {$this->liste}@{$this->domain} a été refusée.";
120 // {{{ function commit()
122 public function commit()
126 if ($this->asso
== "alias") {
127 $new = $this->liste
. '@' . $this->domain
;
128 XDB
::query('INSERT INTO virtual (alias, type) VALUES({?}, "user")', $new);
129 foreach ($this->members
as $member) {
130 $user = User
::get($member);
133 "INSERT INTO virtual_redirect (vid, redirect)
136 WHERE alias = {?}", $user->forlifeEmail(), $new);
142 $list = new MMList(S
::user()->id(), $this->domain
);
143 $ret = $list->create_list($this->liste
, utf8_decode($this->desc
), $this->advertise
,
144 $this->modlevel
, $this->inslevel
,
145 $this->owners
, $this->members
);
146 $liste = strtolower($this->liste
);
147 if ($ret && !$this->asso
) {
148 foreach(Array($liste, $liste . "-owner", $liste . "-admin", $liste . "-bounces", $liste . "-unsubscribe") as $l) {
149 XDB
::execute("INSERT INTO aliases (alias, type) VALUES({?}, 'liste')", $l);
152 foreach (Array('', 'owner', 'admin', 'bounces', 'unsubscribe') as $app) {
153 $mdir = $app == '' ?
'+post' : '+' . $app;
157 $red = $this->domain
. '_' . $liste;
158 XDB
::execute('INSERT INTO virtual (alias, type)
159 VALUES({?}, {?})', $liste . $app . '@' . $this->domain
, 'list');
160 XDB
::execute('INSERT INTO virtual_redirect (vid, redirect)
161 VALUES ({?}, {?})', XDB
::insertId(),
162 $red . $mdir . '@listes.polytechnique.org');
163 $list->mass_subscribe($liste, join(' ', $this->members
));
174 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: