2 /***************************************************************************
3 * Copyright (C) 2003-2009 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 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);
44 $client->subscribe($sub);
53 $this->UpdateOnDismiss();
62 protected function GetDisplayText() {}
64 public function Display(&$page)
66 header('Content-Type: text/html; charset=utf-8');
67 $page->changeTpl('reminder/ml.tpl', NO_SKIN
);
68 $page->assign('baseurl', $this->GetBaseUrl());
70 $res = XDB
::iterRow("SELECT sub, domain
72 WHERE uid = {?} AND type = 'list'
75 $current_domain = null
;
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);
82 list($details, ) = $client->get_members($sub);
83 $lists["$sub@$domain"] = $details;
85 $page->assign_by_ref('lists', $lists);
88 public static function IsCandidate(User
&$user, $candidate)
90 $res = XDB
::execute("SELECT COUNT(*) AS lists
92 WHERE uid = {?} AND type = 'list'",
95 $mlCount = $res->fetchOneCell();
97 Reminder
::MarkCandidateAsAccepted($user->id(), $candidate);
99 return ($mlCount > 0);
103 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: