From 4b0d9ef32d168be23f83752936fd19900889519f Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Sun, 11 Mar 2007 16:43:42 +0000 Subject: [PATCH] #602: Send a mail to the list owners identifying the moderator who did a subscription moderation git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1562 839d8a87-29fc-0310-9880-83ba4fa771e5 --- ChangeLog | 1 + bin/lists.rpc.py | 26 +++++++++++++++++++++++++- modules/lists.php | 36 +++++++++++++++++++++++++++++------- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b6ff78..afb27ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -44,6 +44,7 @@ Bug/Wish: * Lists: - #407: RSS feed -FRU - #515: Specify allowed characters in the name of the list -FRU + - #602: Identify the moderator who accepted/refused a subscription -FRU - #636: Remove non-X from trombi -FRU - #638: Sort trombi by promo then name -FRU diff --git a/bin/lists.rpc.py b/bin/lists.rpc.py index 65dfde7..99a7974 100755 --- a/bin/lists.rpc.py +++ b/bin/lists.rpc.py @@ -547,7 +547,6 @@ def get_pending_ops(userdesc, perms, vhost, listname): return 0 return (subs, helds) - def handle_request(userdesc, perms, vhost, listname, id, value, comment): try: mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0) @@ -565,6 +564,30 @@ def handle_request(userdesc, perms, vhost, listname, id, value, comment): mlist.Unlock() return 0 +def get_pending_sub(userdesc, perms, vhost, listname, id): + try: + mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0) + except: + return 0 + try: + if not is_admin_on(userdesc, perms, mlist): + return 0 + + mlist.Lock() + sub = 0 + id = int(id) + if id in mlist.GetSubscriptionIds(): + time, addr, fullname, passwd, digest, lang = mlist.GetRecord(id) + try: + login = re.match("^[^.]*\.[^.]*\.\d\d\d\d$", addr.split('@')[0]).group() + sub = {'id': id, 'name': quote(fullname), 'addr': addr, 'login': login } + except: + sub = {'id': id, 'name': quote(fullname), 'addr': addr } + mlist.Unlock() + except: + mlist.Unlock() + return 0 + return sub def get_pending_mail(userdesc, perms, vhost, listname, id, raw=0): try: @@ -985,6 +1008,7 @@ server.register_function(del_owner) # moderate.php server.register_function(get_pending_ops) server.register_function(handle_request) +server.register_function(get_pending_sub) server.register_function(get_pending_mail) # options.php server.register_function(get_owner_options) diff --git a/modules/lists.php b/modules/lists.php index 4d2bc63..009950b 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -446,7 +446,7 @@ class ListsModule extends PLModule function handler_moderate(&$page, $liste = null) { if (is_null($liste)) { - return PL_NOT_FOUND; + return PL_NOT_FOUND; } $domain = $this->prepare_client($page); @@ -455,12 +455,34 @@ class ListsModule extends PLModule $page->register_modifier('hdc', 'list_header_decode'); - if (Env::has('sadd')) { /* 4 = SUBSCRIBE */ - $this->client->handle_request($liste,Env::v('sadd'),4,''); - pl_redirect('lists/moderate/'.$liste); - } - if (Post::has('sdel')) { /* 2 = REJECT */ - $this->client->handle_request($liste,Post::v('sdel'),2,Post::v('reason')); + if (Env::has('sadd') || Env::has('sdel')) { + if (Env::has('sadd')) { /* 4 = SUBSCRIBE */ + $sub = $this->client->get_pending_sub($liste, Env::v('sadd')); + $this->client->handle_request($liste,Env::v('sadd'),4,''); + $info = "validée"; + } + if (Post::has('sdel')) { /* 2 = REJECT */ + $sub = $this->client->get_pending_sub($liste, Env::v('sdel')); + $this->client->handle_request($liste, Post::v('sdel'), 2, Post::v('reason')); + $info = "refusée"; + } + if ($sub) { + $mailer = new PlMailer(); + $mailer->setFrom("$liste-bounces@{$domain}"); + $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"; + if (trim(Post::v('reason'))) { + $text .= "\nLa raison invoquée est :\n" . Post::v('reason'); + } + $mailer->setTxtBody(wordwrap($text, 72)); + $mailer->send(); + } + if (Env::has('sadd')) { + pl_redirect('lists/moderate/'.$liste); + } } if (Post::has('moderate_mails') && Post::has('select_mails')) { -- 2.1.4