From: Stéphane Jacob Date: Sat, 2 Apr 2011 23:01:08 +0000 (+0200) Subject: Lists and administrates aliases on main domain (Closes #1459). X-Git-Tag: xorg/1.1.1~131 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=2ed80014aff1d92128b842e6ec806ec31b7dab30;p=platal.git Lists and administrates aliases on main domain (Closes #1459). Signed-off-by: Stéphane Jacob --- diff --git a/ChangeLog b/ChangeLog index 5fd4551..8fb9376 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ ================================================================================ VERSION 1.1.1 XX XX XXXX +Bug/Wish: + + * Emails: + - #1459: Lists and administrates aliases on main domain -JAC + From 1.1.0 branch: * Search: diff --git a/modules/lists.php b/modules/lists.php index e1bfb11..eec6fa2 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -44,6 +44,7 @@ class ListsModule extends PLModule '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'), + 'admin/aliases' => $this->make_hook('aaliases', AUTH_MDP, 'admin') ); } @@ -886,6 +887,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: diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index e491163..fbb6ad3 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -51,6 +51,8 @@ MLs   |   + aliases +   |   MX défaillants   |   Perdus de vue diff --git a/templates/lists/admin_aliases.tpl b/templates/lists/admin_aliases.tpl new file mode 100644 index 0000000..8e9dfd6 --- /dev/null +++ b/templates/lists/admin_aliases.tpl @@ -0,0 +1,50 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2011 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +

Aliases

+ + + + + + {if $aliases|@count} + {foreach from=$aliases item=alias} + + + + {/foreach} + {else} + + + + {/if} +
Aliases
{$alias}
Aucun alias
+ +
+ {xsrf_token_field} +

+ + +

+
+ +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/lists/admin_edit_alias.tpl b/templates/lists/admin_edit_alias.tpl new file mode 100644 index 0000000..1ec1f16 --- /dev/null +++ b/templates/lists/admin_edit_alias.tpl @@ -0,0 +1,92 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2011 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +

[Retour à la liste des aliases]

+ +

Membres de {$alias}

+ + + {if $members.users|@count} + {foreach from=$members.users item=member} + + + + + + {/foreach} + {/if} + {if $members.nonusers|@count} + {foreach from=$members.nonusers item=member} + + + + + + {/foreach} + {/if} + {if $members.users|@count eq 0 && $members.nonusers|@count eq 0} + + + + {/if} + + + + + + +
+ {if $member->hasProfile()} + {$member->fullName()} + {else} + {$member->fullName()} + {/if} + {$member->promo()} + + {icon name=delete title="retirer membre"} + +
{$member} + + {icon name=delete title="retirer membre"} + +
+ aucun membre… +
Ajouter
+
+ {xsrf_token_field} +
+ +   + +
+
+
+ + +
+ {xsrf_token_field} +

+ +

+
+ +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}