c78b75128a2f4a1ab56ebeee0051067eb456032a
2 /***************************************************************************
3 * Copyright (C) 2003-2011 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 MailingList
26 public $address; // Fully qualified address of the list
27 public $mbox; // mailbox for the list
28 public $domain; // domain for the list
29 protected $mmclient; // The XML-RPC client for Mailman requests
31 public function __construct($mbox, $domain, $user, $pass='')
34 $this->domain
= $domain;
35 $this->address
= "$mbox@$domain";
37 if ($user instanceof PlUser
) {
38 $this->mmclient
= new MMList($user, $this->domain
);
40 $this->mmclient
= new MMList($user, $pass, $this->domain
);
44 /** Instantiate a MailingList from its address.
46 * $user and $pass are connection parameters for MailMan.
48 public static function fromAddress($address, $user, $pass='')
50 if (strstr($address, '@') !== false
) {
51 list($mbox, $domain) = explode('@', $address);
55 $domain = $globals->mail
->domain
;
57 return new MailingList($mbox, $domain, $user, $pass);
60 /** Retrieve the MailingList associated with a given promo.
62 * $user and $pass are connection parameters for MailMan.
64 public static function promo($promo, $user, $pass='')
67 $mail_domain = $globals->mail
->domain
;
68 return new MailingList('promo', "$promo.$mail_domain", $user, $pass);
71 /** Subscribe the current user to the list
73 public function subscribe()
75 return $this->mmclient
->subscribe($this->mbox
);
78 /** Unsubscribe the current user from the list
80 public function unsubscribe()
82 return $this->mmclient
->unsubscribe($this->mbox
);
85 /** Retrieve owners for the list.
87 * TODO: document the return type
89 public function getOwners()
91 return $this->mmclient
->get_owners($this->mbox
);
94 /** Retrieve members of the list.
96 * TODO: document the return type
98 public function getMembers()
100 return $this->mmclient
->get_members($this->mbox
);
103 /** Retrieve a subset of list members.
105 * TODO: document the return type
107 public function getMembersLimit($page, $number_per_page)
109 return $this->mmclient
->get_members_limit($this->mbox
, $page, $number_per_page);
114 public function create($description, $advertise,
115 $moderation_level, $subscription_level, $owners, $members)
117 return $this->mmclient
->create_list($this->mbox
, utf8_decode($description),
118 $advertise, $moderation_level, $subscription_level,
125 // vim:set et sw=4 sts=4 sws=4 enc=utf-8: