3 * Mailing Lists Facility
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2003-2004 (c) Guillaume Smet - Open Wide
7 * Copyright 2010 (c) Franck Villaume - Capgemini
8 * 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
23 * along with FusionForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 require_once('../../env.inc.php');
29 require_once $gfcommon.'include/pre.php';
30 require_once $gfwww.'mail/admin/../mail_utils.php';
32 require_once $gfcommon.'mail/MailingList.class.php';
33 require_once $gfcommon.'mail/MailingListFactory.class.php';
35 $group_id = getIntFromRequest('group_id');
37 $feedback = getStringFromRequest('feedback');
40 $group = group_get_object($group_id);
41 if (!$group || !is_object($group) || $group->isError()) {
45 session_require_perm ('project_admin', $group->getID()) ;
48 // Post Changes to database
50 if (getStringFromRequest('post_changes') == 'y') {
54 if (getStringFromRequest('add_list') == 'y') {
56 if (check_email_available($group, $group->getUnixName() . '-' . getStringFromPost('list_name'), $error_msg)) {
57 $mailingList = new MailingList($group);
59 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
60 exit_form_double_submit('mail');
62 if(!$mailingList || !is_object($mailingList)) {
63 form_release_key(getStringFromRequest("form_key"));
64 exit_error(_('Error getting the list'),'mail');
65 } elseif($mailingList->isError()) {
66 form_release_key(getStringFromRequest("form_key"));
67 exit_error($mailingList->getErrorMessage(),'mail');
70 if(!$mailingList->create(
71 getStringFromPost('list_name'),
72 getStringFromPost('description'),
73 getIntFromPost('is_public', 1)
75 form_release_key(getStringFromRequest("form_key"));
76 exit_error($mailingList->getErrorMessage(),'mail');
78 $feedback .= _('List Added');
82 form_release_key(getStringFromRequest("form_key"));
87 } elseif (getStringFromPost('change_status') == 'y') {
88 $mailingList = new MailingList($group, getIntFromGet('group_list_id'));
90 if(!$mailingList || !is_object($mailingList)) {
91 exit_error(_('Error getting the list'),'mail');
92 } elseif($mailingList->isError()) {
93 exit_error($mailingList->getErrorMessage(),'mail');
96 if(!$mailingList->update(
97 unInputSpecialChars(getStringFromPost('description')),
98 getIntFromPost('is_public', MAIL__MAILING_LIST_IS_PUBLIC)
100 exit_error($mailingList->getErrorMessage(),'mail');
102 $feedback .= _('List updated');
108 // Reset admin password
110 if (getIntFromRequest('reset_pw') == 1) {
111 $mailingList = new MailingList($group, getIntFromGet('group_list_id'));
113 if(!$mailingList || !is_object($mailingList)) {
114 exit_error(_('Error getting the list'),'mail');
115 } elseif($mailingList->isError()) {
116 exit_error($mailingList->getErrorMessage(),'mail');
119 if($mailingList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
120 if(!$mailingList->update(
121 $mailingList->getDescription(),
122 $mailingList->isPublic(),
123 MAIL__MAILING_LIST_PW_RESET_REQUESTED
125 exit_error($mailingList->getErrorMessage(),'mail');
127 $feedback .= _('Password reset requested');
136 if(getIntFromGet('add_list')) {
138 'title' => _('Add a Mailing List')));
139 printf(_('<p>Lists are named in this manner:<br /><strong>projectname-listname@%1$s</strong></p><p>It will take <span class="important">6-24 Hours</span> for your list to be created.</p>'), forge_get_config('lists_host'));
141 $mlFactory = new MailingListFactory($group);
142 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
143 exit_error($mlFactory->getErrorMessage(),'mail');
146 $mlArray =& $mlFactory->getMailingLists();
148 if ($mlFactory->isError()) {
149 echo '<h1>'._('Error').' '._('Unable to get the lists') .'</h1>';
150 echo '<div class="error">'.$mlFactory->getErrorMessage().'</div>';
151 mail_footer(array());
155 $tableHeaders = array(
156 _('Existing mailing lists')
161 $mlCount = count($mlArray);
163 echo $HTML->listTableTop($tableHeaders);
164 for ($j = 0; $j < $mlCount; $j++) {
165 $currentList =& $mlArray[$j];
166 if ($currentList->isError()) {
167 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>';
168 echo $currentList->getErrorMessage();
171 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>'.$currentList->getName().'</td></tr>';
174 echo $HTML->listTableBottom();
180 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id ?>">
181 <input type="hidden" name="post_changes" value="y" />
182 <input type="hidden" name="add_list" value="y" />
183 <input type="hidden" name="form_key" value="<?php echo form_generate_key();?>" />
184 <p><strong><?php echo _('Mailing List Name:'); ?></strong><br />
185 <strong><?php echo $group->getUnixName(); ?>-<input type="text" name="list_name" value="" size="10" maxlength="12" />@<?php echo forge_get_config('lists_host'); ?></strong><br /></p>
187 <strong><?php echo _('Is Public?'); ?></strong><br />
188 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PUBLIC; ?>" checked="checked" /> <?php echo _('Yes'); ?><br />
189 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PRIVATE; ?>" /> <?php echo _('No'); ?></p><p>
190 <strong><?php echo _('Description:'); ?></strong><br />
191 <input type="text" name="description" value="" size="40" maxlength="80" /><br /></p>
193 <input type="submit" name="submit" value="<?php echo _('Add This List'); ?>" /></p>
196 mail_footer(array());
199 // Form to modify list
201 } elseif(getIntFromGet('change_status') && getIntFromGet('group_list_id')) {
202 $mailingList = new MailingList($group, getIntFromGet('group_list_id'));
204 if(!$mailingList || !is_object($mailingList)) {
205 exit_error(_('Error getting the list'),'mail');
206 } elseif($mailingList->isError()) {
207 exit_error($mailingList->getErrorMessage(),'mail');
211 'title' => _('Mail admin')));
213 <h3><?php echo $mailingList->getName(); ?></h3>
214 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">
215 <input type="hidden" name="post_changes" value="y" />
216 <input type="hidden" name="change_status" value="y" />
218 <strong><?php echo _('Is Public?'); ?></strong><br />
219 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PUBLIC; ?>"<?php echo ($mailingList->isPublic() == MAIL__MAILING_LIST_IS_PUBLIC ? ' checked="checked"' : ''); ?> /> <?php echo _('Yes'); ?><br />
220 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PRIVATE; ?>"<?php echo ($mailingList->isPublic() == MAIL__MAILING_LIST_IS_PRIVATE ? ' checked="checked"' : ''); ?> /> <?php echo _('No'); ?>
222 <p><strong><?php echo _('Description:'); ?></strong><br />
223 <input type="text" name="description" value="<?php echo inputSpecialChars($mailingList->getDescription()); ?>" size="40" maxlength="80" /><br /></p>
225 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" /></p>
227 <a href="deletelist.php?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">[<?php echo _('Permanently Delete List'); ?>]</a>
229 mail_footer(array());
234 $mlFactory = new MailingListFactory($group);
235 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
236 exit_error($mlFactory->getErrorMessage(),'mail');
240 'title' => _('Mailing List Administration'))
243 $mlArray =& $mlFactory->getMailingLists();
245 if ($mlFactory->isError()) {
246 echo '<p>'._('Error').' '.sprintf(_('Unable to get the list %s'), $group->getPublicName()) .'</p>';
247 echo '<div class="error">'.$mlFactory->getErrorMessage().'</div>';
248 mail_footer(array());
251 echo '<p>'.sprintf(_('You can administrate lists from here. Please note that private lists can still be viewed by members of your project, but are not listed on %1$s.'), forge_get_config ('forge_name')).'</p>';
254 <a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&add_list=1">'._('Add Mailing List').'</a>
257 $mlCount = count($mlArray);
259 $tableHeaders = array(
265 echo $HTML->listTableTop($tableHeaders);
266 for ($i = 0; $i < $mlCount; $i++) {
267 $currentList =& $mlArray[$i];
268 if ($currentList->isError()) {
269 echo '<tr '. $HTML->boxGetAltRowStyle($i) .'><td colspan="4">';
270 echo $currentList->getErrorMessage();
273 echo '<tr '. $HTML->boxGetAltRowStyle($i) . '><td width="60%">'.
274 '<strong>'.$currentList->getName().'</strong><br />'.
275 htmlspecialchars($currentList->getDescription()).'</td>'.
276 '<td style="text-align:center"><a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_list_id='.$currentList->getID().'&change_status=1">'._('Update').'</a></td>' ;
277 echo '<td style="text-align:center">';
278 if($currentList->getStatus() == MAIL__MAILING_LIST_IS_REQUESTED) {
279 echo _('Not activated yet');
281 echo '<a href="'.$currentList->getExternalAdminUrl().'">'._('Administrate').'</a></td>';
283 echo '<td style="text-align:center">';
284 if($currentList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
285 print '<a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_list_id='.$currentList->getID().'&reset_pw=1">'._('Reset admin password').'</a></td>' ;
291 echo $HTML->listTableBottom();
293 mail_footer(array());