2 /***************************************************************************
3 * Copyright (C) 2003-2010 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class ReminderMl
extends Reminder
24 public function HandleAction($action)
28 S
::assert_xsrf_token();
29 $subs = array_keys(Post
::v('sub_ml'));
30 $current_domain = null
;
32 $res = XDB
::iterRow("SELECT sub, domain
34 WHERE uid = {?} AND type = 'list'
37 while (list($sub, $domain) = $res->next()) {
38 if (array_shift($subs) == "$sub@$domain") {
39 if ($domain != $current_domain) {
40 $current_domain = $domain;
42 $client = new MMList(S
::v('uid'), S
::v('password'), $domain);
43 $client->subscribe($sub);
52 $this->UpdateOnDismiss();
61 public function Prepare(&$page)
63 parent
::Prepare($page);
65 $res = XDB
::iterRow("SELECT sub, domain
67 WHERE uid = {?} AND type = 'list'
70 $current_domain = null
;
72 while (list($sub, $domain) = $res->next()) {
73 if ($current_domain != $domain) {
74 $current_domain = $domain;
75 $client = new MMList(S
::v('uid'), S
::v('password'), $domain);
77 list($details, ) = $client->get_members($sub);
78 $lists["$sub@$domain"] = $details;
80 $page->assign_by_ref('lists', $lists);
83 public function template()
85 return 'reminder/ml.tpl';
87 public function title()
89 return "Inscription aux listes de diffusion";
92 public static function IsCandidate(User
&$user, $candidate)
94 $res = XDB
::query("SELECT COUNT(*) AS lists
96 WHERE uid = {?} AND type = 'list'",
99 $mlCount = $res->fetchOneCell();
101 Reminder
::MarkCandidateAsAccepted($user->id(), $candidate);
103 return ($mlCount > 0);
107 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: