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)) {
71 $this->setError(sprintf(_('%1$s:: No Valid Group Object'), 'MailmanListFactory'));
74 if ($Group->isError()) {
75 $this->setError('MailmanListFactory:: '.$Group->getErrorMessage());
78 $this->Group =& $Group;
84 * getGroup - get the Group object this MailmanListFactory is associated with.
86 * @return object The Group object.
88 function &getGroup() {
93 * getMailmanLists - get an array of MailmanList objects for this Group.
95 * @param boolean $admin if we are in admin mode (we want to see deleted lists)
96 * @return array The array of MailmanList objects.
98 function &getMailmanLists() {
99 $current_user=UserManager::instance()->getCurrentUser();
100 if (isset($this->mailingLists) && is_array($this->mailingLists)) {
101 return $this->mailingLists;
104 if (islogged() && $current_user->isMember($this->Group->getID())) {
109 $result =& $this->_mailingDAO->searchByGroupId($this->Group->getID());
113 $this->setError(sprintf(_('Error Getting %1$s'), _('Error Getting %1$s')).db_error());
116 $this->mailingLists = array();
117 while ($arr =& $result->getRow()) {
118 $this->mailingLists[] = new MailmanList($this->Group->getID(), $arr['group_list_id'], $arr);
121 return $this->mailingLists;
125 * compareInfos - replace mailman user info by forge user info
127 * @return string url of the info page
129 function compareInfos()
131 $current_user=UserManager::instance()->getCurrentUser();
132 $mail=$current_user->getEmail();
134 $passwd= $current_user->getUserPw();
135 $name= $current_user->getRealName();
136 $result =& $this->_mailingDAO->compareInfos($mail);
142 while( $arr =& $result->getRow())
144 if($arr['password']!=$passwd || $arr['name']!=$name)
154 * updateInfos - replace mailman user info by forge user info
156 * @return string url of the info page
158 function updateInfos()
160 $current_user=UserManager::instance()->getCurrentUser();
161 $mail=$current_user->getEmail();
163 $passwd= $current_user->getUserPw();
164 $name= $current_user->getRealName();
166 $result =& $this->_mailingDAO->updateInfos($mail,$passwd,$name);
170 htmlRedirect('/plugins/mailman/index.php?group_id='.$this->Group->getId());
179 // c-file-style: "bsd"