S::assert_xsrf_token();
}
- $asso = Post::v('asso');
- $liste = Post::v('liste');
+ $asso = Post::t('asso');
+ $list = strtolower(Post::t('liste'));
- if (empty($liste)) {
+ if (empty($list)) {
$page->trigError('Le champ « adresse souhaitée » est vide.');
}
- if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) {
+ if (!preg_match("/^[a-zA-Z0-9\-]*$/", $list)) {
$page->trigError('Le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets.');
}
- if (($asso == "binet") || ($asso == "alias")) {
+ if (($asso == 'binet') || ($asso == 'alias')) {
$promo = Post::i('promo');
$domain = $promo . '.' . $globals->mail->domain;
$page->trigError('La promotion est mal renseignée, elle doit être du type : 2004.');
}
- $new = $liste . '@' . $domain;
- $res = XDB::query('SELECT COUNT(*) FROM virtual WHERE alias={?}', $new);
-
- } else {
- if ($asso == "groupex") {
- $groupex_name = Post::v('groupex_name');
-
- $res_groupe = XDB::query('SELECT mail_domain FROM groups WHERE nom={?}', $groupex_name);
- $domain = $res_groupe->fetchOneCell();
+ } elseif ($asso == 'groupex') {
+ $domain = XDB::fetchOneCell('SELECT mail_domain
+ FROM groups
+ WHERE nom = {?}',
+ Post::t('groupex_name'));
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 virtual WHERE alias={?}', $new);
- } else {
- $res = XDB::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste);
- $domain = $globals->mail->domain;
- }
+ } else {
+ $domain = $globals->mail->domain;
}
- $n = $res->fetchOneCell();
-
- if ($n) {
+ require_once 'emails.inc.php';
+ if (list_exist($list, $domain)) {
$page->trigError("L'« adresse souhaitée » est déjà prise.");
}
- if (!Post::v('desc')) {
+ if (!Post::t('desc')) {
$page->trigError('Le sujet est vide.');
}
$page->trigError('Il n\'y a pas de gestionnaire.');
}
- if (count($members)<4) {
+ if (count($members) < 4) {
$page->trigError('Il n\'y a pas assez de membres.');
}
if (!$page->nb_errs()) {
$page->trigSuccess('Demande de création envoyée !');
$page->assign('created', true);
- $req = new ListeReq(S::user(), $asso, $liste, $domain,
- Post::v('desc'), Post::i('advertise'),
+ $req = new ListeReq(S::user(), $asso, $list, $domain,
+ Post::t('desc'), Post::i('advertise'),
Post::i('modlevel'), Post::i('inslevel'),
$owners, $members);
$req->submit();
}
$domain = $this->prepare_client($page);
- if ($domain == $globals->mail->domain || $domain == $globals->mail->domain2) {
- $domain = '';
- $table = 'aliases';
- $type = 'liste';
- } else {
- $domain = '@' . $domain;
- $table = 'virtual';
- $type = 'list';
- }
-
$page->changeTpl('lists/delete.tpl');
if (Post::v('valid') == 'OUI') {
S::assert_xsrf_token();
if ($this->client->delete_list($liste, Post::b('del_archive'))) {
- foreach (array('', '-owner', '-admin', '-bounces', '-unsubscribe') as $app) {
- XDB::execute("DELETE FROM $table
- WHERE type={?} AND alias={?}",
- $type, $liste.$app.$domain);
- }
+ require_once 'emails.inc.php';
+
+ delete_list($liste, $domain);
$page->assign('deleted', true);
$page->trigSuccess('La liste a été détruite !');
} else {