3 * FusionForge mailing lists
5 * Copyright 2003, Guillaume Smet
6 * based on work Copyright 2002, Tim Perdue/GForge, LLC
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; either version 2 of the License,
13 * or (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 require_once $gfcommon.'include/Error.class.php';
27 require_once $gfcommon.'mail/MailingList.class.php';
29 class MailingListFactory extends Error {
39 * The mailing lists array.
41 * @var array $mailingLists.
49 * @param object The Group object to which these mailing lists are associated.
51 function MailingListFactory(& $Group) {
54 if (!$Group || !is_object($Group)) {
55 $this->setError(sprintf(_('%1$s:: No Valid Group Object'), 'MailingListFactory'));
58 if ($Group->isError()) {
59 $this->setError('MailingListFactory:: '.$Group->getErrorMessage());
62 $this->Group =& $Group;
68 * getGroup - get the Group object this MailingListFactory is associated with.
70 * @return object The Group object.
72 function &getGroup() {
77 * getMailingLists - get an array of MailingList objects for this Group.
79 * @param boolean $admin if we are in admin mode (we want to see deleted lists)
80 * @return array The array of MailingList objects.
82 function &getMailingLists() {
83 if (isset($this->mailingLists) && is_array($this->mailingLists)) {
84 return $this->mailingLists;
87 $public_flag = MAIL__MAILING_LIST_IS_PUBLIC;
89 $perm = & $this->Group->getPermission(session_get_user());
90 if ($perm && is_object($perm) && $perm->isMember()) {
91 $public_flag = MAIL__MAILING_LIST_IS_PRIVATE.', '.MAIL__MAILING_LIST_IS_PUBLIC;
95 . 'FROM mail_group_list '
96 . 'WHERE group_id=\''.$this->Group->getID().'\' '
97 . 'AND is_public IN ('.$public_flag.') '
98 . 'ORDER BY list_name;';
101 $result = db_query($sql);
104 $this->setError(sprintf(_('Error Getting %1$s'), _('Error Getting %1$s')).db_error());
107 $this->mailingLists = array();
108 while ($arr = db_fetch_array($result)) {
109 $this->mailingLists[] = new MailingList($this->Group, $arr['group_list_id'], $arr);
112 return $this->mailingLists;
118 // c-file-style: "bsd"