3 * GForge Mailing Lists Facility
5 * Copyright 2003 Guillaume Smet
10 * This file is part of GForge.
12 * GForge 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 * GForge 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
23 * along with GForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 This work is based on Tim Perdue's work on the forum stuff
33 require_once('common/include/Error.class.php');
34 require_once('common/mail/MailingList.class.php');
36 class MailingListFactory extends Error {
46 * The mailing lists array.
48 * @var array $mailingLists.
56 * @param object The Group object to which these mailing lists are associated.
58 function MailingListFactory(& $Group) {
61 if (!$Group || !is_object($Group)) {
62 $this->setError(sprintf(_('%1$s:: No Valid Group Object'), 'MailingListFactory'));
65 if ($Group->isError()) {
66 $this->setError('MailingListFactory:: '.$Group->getErrorMessage());
69 $this->Group =& $Group;
75 * getGroup - get the Group object this MailingListFactory is associated with.
77 * @return object The Group object.
79 function &getGroup() {
84 * getMailingLists - get an array of MailingList objects for this Group.
86 * @param boolean $admin if we are in admin mode (we want to see deleted lists)
87 * @return array The array of MailingList objects.
89 function &getMailingLists() {
90 if (isset($this->mailingLists) && is_array($this->mailingLists)) {
91 return $this->mailingLists;
94 $public_flag = MAIL__MAILING_LIST_IS_PUBLIC;
96 $perm = & $this->Group->getPermission(session_get_user());
97 if ($perm && is_object($perm) && $perm->isMember()) {
98 $public_flag = MAIL__MAILING_LIST_IS_PRIVATE.', '.MAIL__MAILING_LIST_IS_PUBLIC;
102 . 'FROM mail_group_list '
103 . 'WHERE group_id=\''.$this->Group->getID().'\' '
104 . 'AND is_public IN ('.$public_flag.') '
105 . 'ORDER BY list_name;';
108 $result = db_query($sql);
111 $this->setError(sprintf(_('Error Getting %1$s'), _('Error Getting %1$s')).db_error());
114 $this->mailingLists = array();
115 while ($arr = db_fetch_array($result)) {
116 $this->mailingLists[] = new MailingList($this->Group, $arr['group_list_id'], $arr);
119 return $this->mailingLists;
125 // c-file-style: "bsd"