- #761: Fix user comment in moderation mail sent by mailman -FRU
- #810: Fix encoding of admin pages -FRU
- #813: Fix display of the sample mail refusal message -JAC
+ - #817: Automation of the management of associations' ML -JAC
- #839: Fix warning when adding an external address -FRU
- Larger click target to toggle emails in the validation interface -ALK
$promo = intval($opt['p']);
$owner = $opt['o'];
-$req = new ListeReq(0, "promo$promo", "Liste de la promotion $promo",
+$req = new ListeReq(0, false, "promo$promo", "polytechnique.org", "Liste de la promotion $promo",
1 /*private*/, 2 /*moderate*/, 0 /*free subscription*/,
array($owner), array());
$req->submit();
public $liste;
public $desc;
+ public $asso;
+ public $domain;
public $advertise;
public $modlevel;
// }}}
// {{{ constructor
- public function __construct($_uid, $_liste, $_desc, $_advertise, $_modlevel,
- $_inslevel, $_owners, $_members, $_stamp=0)
+ public function __construct($_uid, $_asso, $_liste, $_domain, $_desc, $_advertise,
+ $_modlevel, $_inslevel, $_owners, $_members, $_stamp=0)
{
parent::__construct($_uid, false, 'liste', $_stamp);
+ $this->asso = $_asso;
$this->liste = $_liste;
+ $this->domain = $_domain;
$this->desc = $_desc;
$this->advertise = $_advertise;
$this->modlevel = $_modlevel;
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 = "polytechnique.org";
+ }
return true;
}
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", $liste."-unsubscribe") 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);
}
+ } 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));
+ }
+ }
}
return $ret;
}
return;
}
+ $asso = Post::v('asso');
$liste = Post::v('liste');
if (empty($liste)) {
- $page->trigError('champs «adresse souhaitée» vide');
+ $page->trigError('Le champ «adresse souhaitée» est vide.');
}
if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) {
- $page->trigError('le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets');
+ $page->trigError('Le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets.');
}
- $res = XDB::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste);
- $n = $res->fetchOneCell();
+ if (($asso == "binet") || ($asso == "alias")) {
+ $promo = Post::i('promo');
+ $domain = $promo . '.polytechnique.org';
+
+ if (($promo < 1921) || ($promo > date('Y'))) {
+ $page->trigError('La promotion est mal renseignée, elle doit être du type : 2004.');
+ }
+
+ $new = $liste . '@' . $domain;
+ $res = XDB::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new);
+
+ } else {
+ if ($asso == "groupex") {
+ $groupex_name = Post::v('groupex_name');
+
+ $res_groupe = XDB::query('SELECT mail_domain FROM groupex.asso WHERE nom={?}', $groupex_name);
+ $domain = $res_groupe->fetchOneCell();
+
+ if (!$domain) {
+ $page->trigError('Il n\'y a aucun groupe de ce nom sur Polytechnique.net.');
+ }
+
+ $new = $liste . '@' . $domain;
+ $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";
+ }
+ }
+
+ $n = $res->fetchOneCell();
if ($n) {
- $page->trigError('cet alias est déjà pris');
+ $page->trigError('Cette «adresse souhaitée» est déjà prise.');
}
if (!Post::v('desc')) {
- $page->trigError('le sujet est vide');
+ $page->trigError('Le sujet est vide.');
}
if (!count($owners)) {
- $page->trigError('pas de gestionnaire');
+ $page->trigError('Il n\'y a pas de gestionnaire.');
}
if (count($members)<4) {
- $page->trigError('pas assez de membres');
+ $page->trigError('Il n\'y a pas assez de membres.');
}
if (!$page->nb_errs()) {
$page->assign('created', true);
require_once 'validations.inc.php';
- $req = new ListeReq(S::v('uid'), $liste,
+ $req = new ListeReq(S::v('uid'), $asso, $liste, $domain,
Post::v('desc'), Post::i('advertise'),
Post::i('modlevel'), Post::i('inslevel'),
$owners, $members);
{* *}
{**************************************************************************}
-<input type="text" name="listname" size="25" maxlength="200" value="{$valid->liste}" />
+<strong>Nom de la liste :</strong>
+<input type="text" name="listname" size="25" maxlength="200" value="{$valid->liste}" /><br />
+<strong>Type de liste :</strong>
+<label><input type="radio" name="assotype" value="binet" {if $valid->asso eq "binet"}checked="checked"{/if} />binet</label>
+<label><input type="radio" name="assotype" value="" {if !$valid->asso}checked="checked"{/if} />quelconque</label>
+<label><input type="radio" name="assotype" value="alias" {if $valid->asso eq "alias"}checked="checked"{/if} />alias</label>
+<label><input type="radio" name="assotype" value="groupex" {if $valid->asso eq "groupex"}checked="checked"{/if} />groupe X</label><br />
+<strong>Domaine :</strong> <input type="text" name="domainname" size="25" maxlength="200" value="{$valid->domain}" />
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
<tr class="pair">
<td class="titre">Liste :</td>
- <td>{$valid->liste}@polytechnique.org</td>
+ <td>{$valid->liste}@{$valid->domain}</td>
</tr>
<tr class="pair">
<td class="titre">Desc :</td>
</td>
</tr>
<tr class="pair">
+ <td class="titre">Type de liste :</td>
+ <td style="border: 1px dotted inherit">
+ {$valid->asso}
+ </td>
+</tr>
+<tr class="pair">
<td class="titre">Propriétés :</td>
<td>
<table cellpadding='2' cellspacing='0'>
<tr>
- <td>visibilité:</td>
+ <td>visibilité :</td>
<td>{if $valid->advertise}publique{else}privée{/if}</td>
</tr>
<tr>
- <td>diffusion:</td>
+ <td>diffusion :</td>
<td>{if $valid->modlevel eq 2}modérée{elseif $valid->modlevel}restreinte{else}libre{/if}</td>
</tr>
<tr>
- <td>inscription:</td>
+ <td>inscription :</td>
<td>{if $valid->inslevel}modérée{else}libre{/if}</td>
</tr>
</table>
<form action='lists/create' method='post'>
<table class='bicol' cellspacing='0' cellpadding='2'>
<tr>
- <th colspan='2'>Caractéristiques de la Liste</th>
+ <th colspan='5'>Caractéristiques de la liste</th>
+ </tr>
+ <tr>
+ <td class='titre'>C'est une liste pour :</td>
+ <td colspan='2'><input type='radio' name='asso' value='binet'
+ {if $smarty.post.asso eq 'binet' && $smarty.post}checked='checked'{/if} />un binet</td>
+ <td colspan='2'><input type='radio' name='asso' value=''
+ {if !$smarty.post.asso || !$smarty.post}checked='checked'{/if} />une liste de portée générale ou d'amis</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td colspan='2'><input type='radio' name='asso' value='groupex'
+ {if $smarty.post.asso eq 'groupex' && $smarty.post}checked='checked'{/if} />un groupe X</td>
+ <td colspan='2'><input type='radio' name='asso' value='alias'
+ {if $smarty.post.asso eq 'alias' && $smarty.post}checked='checked'{/if} />un alias psc, ...</td>
+ </tr>
+ <tr class='promo'>
+ <td class='titre'>Promotion :</td>
+ <td><input type='text' name='promo' size='4' maxlength='4'
+ {if $smarty.post.promo}value='{$smarty.post.promo}'{else}value='{$smarty.session.promo}'{/if} />
+ <td class='smaller' colspan='3'>Par exemple : 2004</td>
+ </tr>
+ <tr class='groupex'>
+ <td class='titre'>Nom du groupe X :</td>
+ <td colspan='4'>
+ <input type='text' name='groupex_name' value='{$smarty.post.groupex_name}' /><br />
+ <span class='smaller'><strong>Attention :</strong> le nom du groupe doit être écrit comme sur <a
+ href="http://www.polytechnique.net">Polytechnique.net</a>.</span>
+ </td>
</tr>
<tr>
<td class='titre'>Adresse souhaitée :</td>
- <td>
- <input type='text' name='liste' value='{$smarty.post.liste}' />@polytechnique.org
+ <td colspan='4'>
+ <input type='text' name='liste' size='15' value='{$smarty.post.liste}' />@<span class='promo'><span id='promotion'></span>.</span><span class='groupex'><span class='smaller'>diminutifdugroupe</span>.</span>polytechnique.org
</td>
</tr>
+ <script type="text/javascript">//<![CDATA[
+ {literal}
+ $(function() {
+ $(":radio[@name=asso]").change(function() {
+ if (($(":radio[@name=asso]:checked").val() == "binet") || ($(":radio[@name=asso]:checked").val() == "alias")) {
+ $(".groupex").hide();
+ $(".promo").show();
+ } else {
+ if ($(":radio[@name=asso]:checked").val() == "groupex") {
+ $(".groupex").show();
+ $(".promo").hide();
+ } else {
+ $(".groupex").hide();
+ $(".promo").hide();
+ }
+ }
+ }).change();
+ });
+ $(function() {
+ $(":text[@name=promo]").change(function () {
+ var str = $(":text[@name=promo]").val();
+ $("span#promotion").text(str);
+ }).change();
+ });
+ {/literal}
+ // ]]></script>
<tr>
<td class='titre'>Sujet (bref) :</td>
- <td>
- <input type='text' name='desc' size='50' value="{$smarty.post.desc}" />
+ <td colspan='4'>
+ <input type='text' name='desc' size='50' value='{$smarty.post.desc}' />
</td>
</tr>
<tr>
<td class='titre'>Propriétés :</td>
- <td>
- <table style='width: 100%'>
- <tr>
- <td>visibilité :</td>
- <td><input type='radio' name='advertise' value='0'
- {if $smarty.post.advertise eq 0 && $smarty.post}checked='checked'{/if} />publique</td>
- <td><input type='radio' name='advertise' value='1'
- {if $smarty.post.advertise neq 0 || !$smarty.post}checked='checked'{/if} />privée</td>
- <td></td>
- </tr>
- <tr>
- <td>diffusion :</td>
- <td><input type='radio' name='modlevel' value='0'
- {if !$smarty.post.modlevel}checked='checked'{/if} />libre</td>
- <td><input type='radio' name='modlevel' value='1'
- {if $smarty.post.modlevel eq 1}checked='checked'{/if} />restreinte</td>
- <td><input type='radio' name='modlevel' value='2'
- {if $smarty.post.modlevel eq 2}checked='checked'{/if} />modérée</td>
- </tr>
- <tr>
- <td>inscription :</td>
- <td><input type='radio' name='inslevel' value='0'
- {if $smarty.post.inslevel eq 0 && $smarty.post}checked='checked'{/if} />libre</td>
- <td><input type='radio' name='inslevel' value='1'
- {if $smarty.post.inslevel neq 0 || !$smarty.post}checked='checked'{/if} />modérée</td>
- <td></td>
- </tr>
- </table>
- </td>
+ <td>visibilité :</td>
+ <td><input type='radio' name='advertise' value='0'
+ {if $smarty.post.advertise eq 0 && $smarty.post}checked='checked'{/if} />publique</td>
+ <td><input type='radio' name='advertise' value='1'
+ {if $smarty.post.advertise neq 0 || !$smarty.post}checked='checked'{/if} />privée</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class='smaller' colspan='4'>(est-ce que les non membres peuvent voir l'existence de cette liste ?)</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>diffusion :</td>
+ <td><input type='radio' name='modlevel' value='0'
+ {if !$smarty.post.modlevel}checked='checked'{/if} />libre</td>
+ <td><input type='radio' name='modlevel' value='1'
+ {if $smarty.post.modlevel eq 1}checked='checked'{/if} />restreinte</td>
+ <td><input type='radio' name='modlevel' value='2'
+ {if $smarty.post.modlevel eq 2}checked='checked'{/if} />modérée</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class='smaller' colspan='4'>(l'envoi d'un mail à cette liste est-il libre, modéré
+ lorsque l'expéditeur n'appartient pas à la liste ou modéré dans tous les cas ?)</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>inscription :</td>
+ <td><input type='radio' name='inslevel' value='0'
+ {if $smarty.post.inslevel eq 0 && $smarty.post}checked='checked'{/if} />libre</td>
+ <td><input type='radio' name='inslevel' value='1'
+ {if $smarty.post.inslevel neq 0 || !$smarty.post}checked='checked'{/if} />modérée</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class='smaller' colspan='4'>(détermine si les inscriptions à la liste sont modérées
+ par les modérateurs de la liste ou non.)</td>
</tr>
- <tr><th colspan='2'>Membres et Gestionnaires</th></tr>
+ <tr><th colspan='5'>Membres et gestionnaires</th></tr>
<tr>
- <td class='titre'>Gestionnaires</td>
- <td>
+ <td class='titre'>Gestionnaires :</td>
+ <td colspan='4'>
<input type='hidden' name='owners' value='{$owners}' />
{$owners|nl2br|default:"<span class='erreur'>pas de gestionnaires</span>"}
<br />
</td>
</tr>
<tr>
- <td class='titre'>Membres</td>
- <td>
+ <td class='titre'>Membres :</td>
+ <td colspan='4'>
<input type='hidden' name='members' value='{$members}' />
{$members|nl2br|default:"<span class='erreur'>pas de membres</span>"}
<br />
</td>
</tr>
<tr>
- <td colspan="2">
+ <td colspan='5'>
<small>Tu peux entrer une liste de membres en entrant plusieurs adresses séparées par des espaces.</small>
</td>
</tr>