Commit | Line | Data |
---|---|---|
5dfdc904 SJ |
1 | <?php |
2 | /*************************************************************************** | |
3 | * Copyright (C) 2003-2009 Polytechnique.org * | |
4 | * http://opensource.polytechnique.org/ * | |
5 | * * | |
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. * | |
10 | * * | |
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. * | |
15 | * * | |
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 * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
22 | class ReminderMl extends Reminder | |
23 | { | |
24 | public function HandleAction($action) | |
25 | { | |
26 | switch ($action) { | |
27 | case 'suscribe': | |
28 | S::assert_xsrf_token(); | |
29 | $subs = array_keys(Post::v('sub_ml')); | |
30 | $current_domain = null; | |
31 | ||
32 | $res = XDB::iterRow("SELECT sub, domain | |
33 | FROM register_subs | |
34 | WHERE uid = {?} AND type = 'list' | |
35 | ORDER BY domain", | |
36 | S::i('uid')); | |
37 | while (list($sub, $domain) = $res->next()) { | |
38 | if (array_shift($subs) == "$sub@$domain") { | |
39 | list($sub, $domain) = explode('@', $list); | |
40 | if ($domain != $current_domain) { | |
41 | $current_domain = $domain; | |
42 | $client = new MMList(S::v('uid'), S::v('password'), $domain); | |
43 | } | |
44 | $client->subscribe($sub); | |
45 | } | |
46 | } | |
47 | ||
48 | $this->UpdateOnYes(); | |
49 | pl_redirect('lists'); | |
50 | break; | |
51 | ||
52 | case 'dismiss': | |
53 | $this->UpdateOnDismiss(); | |
54 | break; | |
55 | ||
56 | case 'no': | |
57 | $this->UpdateOnNo(); | |
58 | break; | |
59 | } | |
60 | } | |
61 | ||
62 | protected function GetDisplayText() {} | |
63 | ||
64 | public function Display(&$page) | |
65 | { | |
66 | header('Content-Type: text/html; charset=utf-8'); | |
67 | $page->changeTpl('reminder/ml.tpl', NO_SKIN); | |
68 | $page->assign('baseurl', $this->GetBaseUrl()); | |
69 | ||
70 | $res = XDB::iterRow("SELECT sub, domain | |
71 | FROM register_subs | |
72 | WHERE uid = {?} AND type = 'list' | |
73 | ORDER BY domain", | |
74 | S::i('uid')); | |
75 | $current_domain = null; | |
76 | $lists = array(); | |
77 | while (list($sub, $domain) = $res->next()) { | |
78 | if ($current_domain != $domain) { | |
79 | $current_domain = $domain; | |
80 | $client = new MMList(S::v('uid'), S::v('password'), $domain); | |
81 | } | |
82 | list($details, ) = $client->get_members($sub); | |
83 | $lists["$sub@$domain"] = $details; | |
84 | } | |
85 | $page->assign_by_ref('lists', $lists); | |
86 | } | |
87 | ||
88 | public static function IsCandidate(User &$user) | |
89 | { | |
90 | $res = XDB::execute("SELECT COUNT(*) AS lists | |
91 | FROM register_subs | |
92 | WHERE uid = {?} AND type = 'list'", | |
93 | $user->id()); | |
94 | ||
95 | return $res->fetchOneCell(); | |
96 | } | |
97 | } | |
98 | ||
99 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: | |
100 | ?> |