3 * FusionForge Mailing Lists Facility
5 * Copyright 2003 Guillaume Smet
6 * http://fusionforge.org/
10 * This file is part of FusionForge.
12 * FusionForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 This work is based on Tim Perdue's work on the forum stuff
34 require_once 'MailmanList.class.php';
35 require_once 'MailmanListDao.class.php';
36 require_once 'common/dao/CodendiDataAccess.class.php';
38 class MailmanListFactory extends Error {
48 * The mailing lists array.
50 * @var array $mailingLists.
56 * @var MailingListDao $mailingDAO.
64 * @param object The Group object to which these mailing lists are associated.
66 function MailmanListFactory(& $Group) {
67 $this->_mailingDAO = new MailmanListDao(CodendiDataAccess::instance());
70 if (!$Group || !is_object($Group)) {
73 if ($Group->isError()) {
74 $this->setError('MailmanListFactory: '.$Group->getErrorMessage());
77 $this->Group =& $Group;
83 * getGroup - get the Group object this MailmanListFactory is associated with.
85 * @return object The Group object.
87 function &getGroup() {
92 * getMailmanLists - get an array of MailmanList objects for this Group.
94 * @param boolean $admin if we are in admin mode (we want to see deleted lists)
95 * @return array The array of MailmanList objects.
97 function &getMailmanLists() {
98 $current_user=UserManager::instance()->getCurrentUser();
99 if (isset($this->mailingLists) && is_array($this->mailingLists)) {
100 return $this->mailingLists;
103 if (islogged() && $current_user->isMember($this->Group->getID())) {
108 $result =& $this->_mailingDAO->searchByGroupId($this->Group->getID());
112 $this->setError(_('Error Getting mailing list')._(': ').db_error());
115 $this->mailingLists = array();
116 while ($arr =& $result->getRow()) {
117 $this->mailingLists[] = new MailmanList($this->Group->getID(), $arr['group_list_id'], $arr);
120 return $this->mailingLists;
124 * compareInfos - replace mailman user info by forge user info
126 * @return string url of the info page
128 function compareInfos()
130 $current_user=UserManager::instance()->getCurrentUser();
131 $mail=$current_user->getEmail();
133 $passwd= $current_user->getUserPw();
134 $name= $current_user->getRealName();
135 $result =& $this->_mailingDAO->compareInfos($mail);
141 while( $arr =& $result->getRow())
143 if($arr['password']!=$passwd || $arr['name']!=$name)
153 * updateInfos - replace mailman user info by forge user info
155 * @return string url of the info page
157 function updateInfos()
159 $current_user=UserManager::instance()->getCurrentUser();
160 $mail=$current_user->getEmail();
162 $passwd= $current_user->getUserPw();
163 $name= $current_user->getRealName();
165 $result =& $this->_mailingDAO->updateInfos($mail,$passwd,$name);
169 htmlRedirect('/plugins/mailman/index.php?group_id='.$this->Group->getId());
177 // c-file-style: "bsd"