X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Flists.php;h=6dcef3472679bb371bf6321c28559d721ee7754d;hb=c9566e01c2add8f12a858abe0fbb0bc6b8e3c0d4;hp=fa3232baeee394ecca37c9bec53f6a53a8ddac0f;hpb=a6391000e89c59f3c26d1a62bb06857df706bf50;p=platal.git
diff --git a/modules/lists.php b/modules/lists.php
index fa3232b..6dcef34 100644
--- a/modules/lists.php
+++ b/modules/lists.php
@@ -1,6 +1,6 @@
$this->make_hook('lists', AUTH_MDP),
- 'lists/ajax' => $this->make_hook('ajax', AUTH_MDP, 'user', NO_AUTH),
- 'lists/create' => $this->make_hook('create', AUTH_MDP),
-
- 'lists/members' => $this->make_hook('members', AUTH_COOKIE),
- 'lists/csv' => $this->make_hook('csv', AUTH_COOKIE),
- 'lists/annu' => $this->make_hook('annu', AUTH_COOKIE),
- 'lists/archives' => $this->make_hook('archives', AUTH_COOKIE),
- 'lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS),
-
- 'lists/moderate' => $this->make_hook('moderate', AUTH_MDP),
- 'lists/admin' => $this->make_hook('admin', AUTH_MDP),
- 'lists/options' => $this->make_hook('options', AUTH_MDP),
- 'lists/delete' => $this->make_hook('delete', AUTH_MDP),
-
- 'lists/soptions' => $this->make_hook('soptions', AUTH_MDP),
- 'lists/check' => $this->make_hook('check', AUTH_MDP),
- 'admin/lists' => $this->make_hook('admin_all', AUTH_MDP, 'admin'),
+ 'lists' => $this->make_hook('lists', AUTH_PASSWD, 'user'),
+ 'lists/ajax' => $this->make_hook('ajax', AUTH_PASSWD, 'user', NO_AUTH),
+ 'lists/create' => $this->make_hook('create', AUTH_PASSWD, 'lists'),
+
+ 'lists/members' => $this->make_hook('members', AUTH_COOKIE, 'user'),
+ 'lists/csv' => $this->make_hook('csv', AUTH_COOKIE, 'user'),
+ 'lists/annu' => $this->make_hook('annu', AUTH_COOKIE, 'user'),
+ 'lists/archives' => $this->make_hook('archives', AUTH_COOKIE, 'user'),
+ 'lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS),
+
+ 'lists/moderate' => $this->make_hook('moderate', AUTH_PASSWD, 'user'),
+ 'lists/admin' => $this->make_hook('admin', AUTH_PASSWD, 'user'),
+ 'lists/options' => $this->make_hook('options', AUTH_PASSWD, 'user'),
+ 'lists/delete' => $this->make_hook('delete', AUTH_PASSWD, 'user'),
+
+ 'lists/soptions' => $this->make_hook('soptions', AUTH_PASSWD, 'user'),
+ 'lists/check' => $this->make_hook('check', AUTH_PASSWD, 'user'),
+ 'admin/lists' => $this->make_hook('admin_all', AUTH_PASSWD, 'admin'),
+ 'admin/aliases' => $this->make_hook('aaliases', AUTH_PASSWD, 'admin')
);
}
- function prepare_client(&$page, $user = null)
+ function prepare_client($page, $user = null)
{
global $globals;
@@ -64,7 +65,7 @@ class ListsModule extends PLModule
{
list($subs,$mails) = $this->client->get_pending_ops($list);
$res = XDB::query("SELECT mid
- FROM ml_moderate
+ FROM email_list_moderate
WHERE ml = {?} AND domain = {?}",
$list, $domain);
$mids = $res->fetchColumn();
@@ -76,7 +77,7 @@ class ListsModule extends PLModule
return array($subs, $mails);
}
- function handler_lists(&$page)
+ function handler_lists($page)
{
function filter_owner($list)
{
@@ -91,7 +92,6 @@ class ListsModule extends PLModule
$domain = $this->prepare_client($page);
$page->changeTpl('lists/index.tpl');
- $page->addJsLink('ajax.js');
$page->setTitle('Listes de diffusion');
@@ -112,29 +112,30 @@ class ListsModule extends PLModule
if ($promo >= 1900 and $promo < 2100) {
$this->client->subscribe("promo$promo");
} else {
- $page->trigSuccess("promo incorrecte, il faut une promo sur 4 chiffres.");
+ $page->trigError("promo incorrecte, il faut une promo sur 4 chiffres.");
}
}
- $listes = $this->client->get_lists();
- $owner = array_filter($listes, 'filter_owner');
- $listes = array_diff_key($listes, $owner);
- $member = array_filter($listes, 'filter_member');
- $listes = array_diff_key($listes, $member);
- foreach ($owner as $key=>$liste) {
- list($subs,$mails) = $this->get_pending_ops($domain, $liste['list']);
- $owner[$key]['subscriptions'] = $subs;
- $owner[$key]['mails'] = $mails;
+ if (!is_null($listes = $this->client->get_lists())) {
+ $owner = array_filter($listes, 'filter_owner');
+ $listes = array_diff_key($listes, $owner);
+ $member = array_filter($listes, 'filter_member');
+ $listes = array_diff_key($listes, $member);
+ foreach ($owner as $key => $liste) {
+ list($subs, $mails) = $this->get_pending_ops($domain, $liste['list']);
+ $owner[$key]['subscriptions'] = $subs;
+ $owner[$key]['mails'] = $mails;
+ }
+ $page->register_modifier('hdc', 'list_header_decode');
+ $page->assign_by_ref('owner', $owner);
+ $page->assign_by_ref('member', $member);
+ $page->assign_by_ref('public', $listes);
}
- $page->register_modifier('hdc', 'list_header_decode');
- $page->assign_by_ref('owner', $owner);
- $page->assign_by_ref('member', $member);
- $page->assign_by_ref('public', $listes);
}
- function handler_ajax(&$page, $list = null)
+ function handler_ajax($page, $list = null)
{
- header('Content-Type: text/html; charset="UTF-8"');
+ pl_content_headers("text/html");
$domain = $this->prepare_client($page);
$page->changeTpl('lists/liste.inc.tpl', NO_SKIN);
S::assert_xsrf_token();
@@ -162,20 +163,26 @@ class ListsModule extends PLModule
$page->assign_by_ref('liste', $liste);
}
- function handler_create(&$page)
+ function handler_create($page)
{
global $globals;
$page->changeTpl('lists/create.tpl');
- $user_promo = S::i('promo');
+ $user_promo = S::user()->profile()->yearPromo();
$year = date('Y');
$month = date('m');
+ // scolar year starts in september
+ $scolarmonth = ($year - $user_promo) * 12 + ($month - 8);
$young_promo = $very_young_promo = 0;
- if ((($year > $user_promo) && ($month > 3)) && ($year < $user_promo + 5)) {
+ // binet are accessible only in april in the first year and until
+ // march of the 5th year
+ if ($scolarmonth >= 8 && $scolarmonth < 56) {
$young_promo = 1;
}
- if ((($year > $user_promo) && ($month > 7)) && (($year < $user_promo + 1) && ($month < 8))) {
+ // PSC aliases are accesible only between september and june of the second
+ // year of scolarity
+ if ($scolarmonth >= 12 && $scolarmonth < 22) {
$very_young_promo = 1;
}
$page->assign('young_promo', $young_promo);
@@ -233,53 +240,43 @@ class ListsModule extends PLModule
S::assert_xsrf_token();
}
- $asso = Post::v('asso');
- $liste = Post::v('liste');
+ $asso = Post::t('asso');
+ $list = strtolower(Post::t('liste'));
- if (empty($liste)) {
- $page->trigError('Le champ «adresse souhaitée» est vide.');
+ 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;
if (($promo < 1921) || ($promo > date('Y'))) {
- $page->trigError('La promotion est mal renseignée, elle doit être du type : 2004.');
+ $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();
+ } 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 x4dat.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) {
- $page->trigError('L\'«adresse souhaitée» est déjà prise.');
+ 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.');
}
@@ -287,22 +284,22 @@ class ListsModule extends PLModule
$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);
- require_once 'validations.inc.php';
- $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();
}
}
- function handler_members(&$page, $liste = null)
+ function handler_members($page, $liste = null)
{
if (is_null($liste)) {
return PL_NOT_FOUND;
@@ -337,30 +334,26 @@ class ListsModule extends PLModule
$page->assign_by_ref('owners', $moderos);
$page->assign('nb_m', count($mem));
} else {
- $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails");
+ $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails.");
}
}
- function handler_csv(PlPage &$page, $liste = null)
+ function handler_csv(PlPage $page, $liste = null)
{
if (is_null($liste)) {
return PL_NOT_FOUND;
}
$this->prepare_client($page);
$members = $this->client->get_members($liste);
- $list = list_fetch_names(list_extract_members($members[1]));
- header('Content-Type: text/x-csv; charset=utf-8;');
- header('Pragma: ');
- header('Cache-Control: ');
+ $list = list_fetch_basic_info(list_extract_members($members[1]));
+ pl_cached_content_headers('text/x-csv', 'iso-8859-1', 1);
- echo "email,nom,prenom,promo\n";
- foreach ($list as $member) {
- echo @$member['email'] . ',' . @$member['nom'] . ',' . @$member['prenom'] . ',' . @$member['promo'] . "\n";
- }
- exit;
+ echo utf8_decode("Nom;Prénom;Promotion\n");
+ echo utf8_decode(implode("\n", $list));
+ exit();
}
- function handler_annu(&$page, $liste = null, $action = null, $subaction = null)
+ function handler_annu($page, $liste = null, $action = null, $subaction = null)
{
if (is_null($liste)) {
return PL_NOT_FOUND;
@@ -381,34 +374,40 @@ class ListsModule extends PLModule
$owners = $this->client->get_owners($liste);
if (!is_array($owners)) {
- $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails");
+ $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails.");
}
- global $platal;
list(,$members) = $this->client->get_members($liste);
- $users = array();
- foreach ($members as $m) {
- $users[] = $m[1];
+
+ if ($action == 'moderators') {
+ $users = $owners;
+ $show_moderators = true;
+ $action = $subaction;
+ $subaction = '';
+ } else {
+ $show_moderators = false;
+ $users = array();
+ foreach ($members as $m) {
+ $users[] = $m[1];
+ }
}
+
require_once 'userset.inc.php';
- $view = new ArraySet($users);
- $view->addMod('trombi', 'Trombinoscope', true, array('with_promo' => true));
+ $view = new UserArraySet($users);
+ $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true));
+ $view->addMod('listmember', 'Annuaire', true);
if (empty($GLOBALS['IS_XNET_SITE'])) {
$view->addMod('minifiche', 'Mini-fiches', false);
}
- $view->addMod('geoloc', 'Planisphère');
+ $view->addMod('map', 'Planisphère');
$view->apply("lists/annu/$liste", $page, $action, $subaction);
- if ($action == 'geoloc' && $subaction) {
- return;
- }
$page->changeTpl('lists/annu.tpl');
- $moderos = list_sort_owners($owners[1]);
$page->assign_by_ref('details', $owners[0]);
- $page->assign_by_ref('owners', $moderos);
+ $page->assign('show_moderators', $show_moderators);
}
- function handler_archives(&$page, $liste = null, $action = null, $artid = null)
+ function handler_archives($page, $liste = null, $action = null, $artid = null)
{
global $globals;
@@ -437,7 +436,7 @@ class ListsModule extends PLModule
}
}
- function handler_rss(&$page, $liste = null, $alias = null, $hash = null)
+ function handler_rss($page, $liste = null, $alias = null, $hash = null)
{
if (!$liste) {
return PL_NOT_FOUND;
@@ -472,12 +471,12 @@ class ListsModule extends PLModule
return false;
}
Get::kill('mid');
- return XDB::execute("INSERT IGNORE INTO ml_moderate
+ return XDB::execute("INSERT IGNORE INTO email_list_moderate
VALUES ({?}, {?}, {?}, {?}, {?}, NOW(), {?}, NULL)",
$liste, $domain, $mid, S::i('uid'), $action, Post::v('reason'));
}
- function handler_moderate(&$page, $liste = null)
+ function handler_moderate($page, $liste = null)
{
if (is_null($liste)) {
return PL_NOT_FOUND;
@@ -508,8 +507,7 @@ class ListsModule extends PLModule
$mailer->addTo("$liste-owner@{$domain}");
$mailer->addHeader('Reply-To', "$liste-owner@{$domain}");
$mailer->setSubject("L'inscription de {$sub['name']} a été $info");
- $text = "L'inscription de {$sub['name']} à la liste $liste@{$domain} a été $info par " . S::v('prenom') . ' '
- . S::v('nom') . '(' . S::v('promo') . ")\n";
+ $text = "L'inscription de {$sub['name']} à la liste $liste@{$domain} a été $info par " . S::user()->fullName(true) . ".\n";
if (trim(Post::v('reason'))) {
$text .= "\nLa raison invoquée est :\n" . Post::v('reason');
}
@@ -530,8 +528,9 @@ class ListsModule extends PLModule
}
} elseif (Env::has('mid')) {
if (Get::has('mid') && !Env::has('mok') && !Env::has('mdel')) {
+ require_once 'banana/moderate.inc.php';
+
$page->changeTpl('lists/moderate_mail.tpl');
- require_once('banana/moderate.inc.php');
$params = array('listname' => $liste, 'domain' => $domain,
'artid' => Get::i('mid'), 'part' => Get::v('part'), 'action' => Get::v('action'));
$params['client'] = $this->client;
@@ -546,7 +545,7 @@ class ListsModule extends PLModule
return;
}
- $mail = $this->moderate_mail($domain, $liste, Env::i('mid'));
+ $this->moderate_mail($domain, $liste, Env::i('mid'));
} elseif (Env::has('sid')) {
if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
foreach($subs as $user) {
@@ -572,30 +571,29 @@ class ListsModule extends PLModule
$page->assign_by_ref('subs', $subs);
$page->assign_by_ref('mails', $mails);
} else {
- $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer");
+ $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer.");
}
}
static public function no_login_callback($login)
{
- require_once 'user.func.inc.php';
- global $list_unregistered, $globals;
+ global $list_unregistered;
- $users = get_not_registered_user($login, true);
+ $users = User::getPendingAccounts($login, true);
if ($users && $users->total()) {
if (!isset($list_unregistered)) {
$list_unregistered = array();
}
$list_unregistered[$login] = $users;
} else {
- list($name, $dom) = @explode('@', $login);
- if ($dom == $globals->mail->domain || $dom == $globals->mail->domain2) {
+ list($name, $domain) = @explode('@', $login);
+ if (User::isMainMailDomain($domain)) {
User::_default_user_callback($login);
}
}
}
- function handler_admin(&$page, $liste = null)
+ function handler_admin($page, $liste = null)
{
global $globals;
@@ -620,8 +618,9 @@ class ListsModule extends PLModule
case 'marketu': case 'markets':
require_once 'emails.inc.php';
+ $user = User::get($uids[$key]);
$mail = valide_email($mails[$key]);
- if (isvalid_email_redirection($mail)) {
+ if (isvalid_email_redirection($mail, $user)) {
$from = ($action == 'marketu') ? 'user' : 'staff';
$market = Marketing::get($uids[$key], $mail);
if (!$market) {
@@ -643,8 +642,12 @@ class ListsModule extends PLModule
S::assert_xsrf_token();
$members = User::getBulkForlifeEmails(Env::v('add_member'),
- false,
+ true,
array('ListsModule', 'no_login_callback'));
+ // Make sure we send a list (array_values) of unique (array_unique)
+ // emails.
+ $members = array_values(array_unique($members));
+
$arr = $this->client->mass_subscribe($liste, $members);
if (is_array($arr)) {
foreach($arr as $addr) {
@@ -661,8 +664,12 @@ class ListsModule extends PLModule
$page->trigError('Une erreur s\'est produite lors du téléchargement du fichier');
} else {
$members = User::getBulkForlifeEmails($upload->getContents(),
- false,
+ true,
array('ListsModule', 'no_login_callback'));
+ // Make sure we send a list (array_values) of unique (array_unique)
+ // emails.
+ $members = array_values(array_unique($members));
+
$arr = $this->client->mass_subscribe($liste, $members);
if (is_array($arr)) {
foreach($arr as $addr) {
@@ -676,8 +683,9 @@ class ListsModule extends PLModule
S::assert_xsrf_token();
if (strpos(Env::v('del_member'), '@') === false) {
- $this->client->mass_unsubscribe(
- $liste, array(Env::v('del_member').'@'.$globals->mail->domain));
+ if ($del_member = User::getSilent(Env::t('del_member'))) {
+ $this->client->mass_unsubscribe($liste, array($del_member->forlifeEmail()));
+ }
} else {
$this->client->mass_unsubscribe($liste, array(Env::v('del_member')));
}
@@ -701,7 +709,9 @@ class ListsModule extends PLModule
S::assert_xsrf_token();
if (strpos(Env::v('del_owner'), '@') === false) {
- $this->client->del_owner($liste, Env::v('del_owner').'@'.$globals->mail->domain);
+ if ($del_owner = User::getSilent(Env::t('del_owner'))) {
+ $this->client->mass_unsubscribe($liste, array($del_owner->forlifeEmail()));
+ }
} else {
$this->client->del_owner($liste, Env::v('del_owner'));
}
@@ -723,12 +733,12 @@ class ListsModule extends PLModule
} else {
$page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.
"
- ." Si tu penses qu'il s'agit d'une erreur, "
- ."contact le support");
+ . " Si tu penses qu'il s'agit d'une erreur, "
+ . "contact le support.");
}
}
- function handler_options(&$page, $liste = null)
+ function handler_options($page, $liste = null)
{
if (is_null($liste)) {
return PL_NOT_FOUND;
@@ -795,7 +805,7 @@ class ListsModule extends PLModule
}
}
- function handler_delete(&$page, $liste = null)
+ function handler_delete($page, $liste = null)
{
global $globals;
if (is_null($liste)) {
@@ -803,32 +813,20 @@ class ListsModule extends PLModule
}
$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 !');
+ $page->trigSuccess('La liste a été détruite !');
} else {
$page->kill('Une erreur est survenue lors de la suppression de la liste.
'
. 'Contact les administrateurs du site pour régler le problème : '
- . 'support@polytechnique.org');
+ . 'support@polytechnique.org.');
}
} elseif (list($details,$options) = $this->client->get_owner_options($liste)) {
if (!$details['own']) {
@@ -838,11 +836,11 @@ class ListsModule extends PLModule
$page->assign_by_ref('options', $options);
$page->assign('bogo_level', $this->client->get_bogo_level($liste));
} else {
- $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer");
+ $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.");
}
}
- function handler_soptions(&$page, $liste = null)
+ function handler_soptions($page, $liste = null)
{
if (is_null($liste)) {
return PL_NOT_FOUND;
@@ -867,11 +865,11 @@ class ListsModule extends PLModule
$page->assign_by_ref('details', $details);
$page->assign_by_ref('options', $options);
} else {
- $page->kill("La liste n'existe pas");
+ $page->kill("La liste n'existe pas.");
}
}
- function handler_check(&$page, $liste = null)
+ function handler_check($page, $liste = null)
{
if (is_null($liste)) {
return PL_NOT_FOUND;
@@ -890,11 +888,11 @@ class ListsModule extends PLModule
$page->assign_by_ref('details', $details);
$page->assign_by_ref('options', $options);
} else {
- $page->kill("La liste n'existe pas");
+ $page->kill("La liste n'existe pas.");
}
}
- function handler_admin_all(&$page)
+ function handler_admin_all($page)
{
$page->changeTpl('lists/admin_all.tpl');
$page->setTitle('Administration - Mailing lists');
@@ -903,6 +901,62 @@ class ListsModule extends PLModule
$listes = $this->client->get_all_lists();
$page->assign_by_ref('listes', $listes);
}
+
+ function handler_aaliases($page, $alias = null)
+ {
+ global $globals;
+ require_once 'emails.inc.php';
+ $page->setTitle('Administration - Aliases');
+
+ if (Post::has('new_alias')) {
+ pl_redirect('admin/aliases/' . Post::t('new_alias') . '@' . $globals->mail->domain);
+ }
+
+ // If no alias, list them all.
+ if (is_null($alias)) {
+ $page->changeTpl('lists/admin_aliases.tpl');
+ $page->assign('aliases', array_merge(iterate_list_alias($globals->mail->domain), iterate_list_alias($globals->mail->domain2)));
+ return;
+ }
+
+ list($local_part, $domain) = explode('@', $alias);
+ if (!($globals->mail->domain == $domain || $globals->mail->domain2 == $domain)
+ || !preg_match("/^[a-zA-Z0-9\-\.]*$/", $local_part)) {
+ $page->trigErrorRedirect('Le nom de l\'alias est erroné.', $globals->asso('diminutif') . 'admin/aliases');
+ }
+
+ // Now we can perform the action.
+ if (Post::has('del_alias')) {
+ S::assert_xsrf_token();
+
+ delete_list_alias($local_part, $domain);
+ $page->trigSuccessRedirect($alias . ' supprimé.', 'admin/aliases');
+ }
+
+ if (Post::has('add_member')) {
+ S::assert_xsrf_token();
+
+ if (add_to_list_alias(Post::t('add_member'), $local_part, $domain)) {
+ $page->trigSuccess('Ajout réussit.');
+ } else {
+ $page->trigError('Ajout infructueux.');
+ }
+ }
+
+ if (Get::has('del_member')) {
+ S::assert_xsrf_token();
+
+ if (delete_from_list_alias(Get::t('del_member'), $local_part, $domain)) {
+ $page->trigSuccess('Suppression réussie.');
+ } else {
+ $page->trigError('Suppression infructueuse.');
+ }
+ }
+
+ $page->changeTpl('lists/admin_edit_alias.tpl');
+ $page->assign('members', list_alias_members($local_part, $domain));
+ $page->assign('alias', $alias);
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: