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 * Copyright (C) 2011-2012 Alain Peyrat - Alcatel-Lucent
9 * http://fusionforge.org/
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
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 FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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');
38 $group = group_get_object($group_id);
39 if (!$group || !is_object($group) || $group->isError()) {
43 session_require_perm ('project_admin', $group->getID()) ;
46 // Post Changes to database
48 if (getStringFromRequest('post_changes') == 'y') {
52 if (getStringFromRequest('add_list') == 'y') {
54 if (check_email_available($group, $group->getUnixName() . '-' . getStringFromPost('list_name'), $error_msg)) {
55 $mailingList = new MailingList($group);
57 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
58 exit_form_double_submit('mail');
60 if(!$mailingList || !is_object($mailingList)) {
61 form_release_key(getStringFromRequest("form_key"));
62 exit_error(_('Error getting the list'),'mail');
63 } elseif($mailingList->isError()) {
64 form_release_key(getStringFromRequest("form_key"));
65 exit_error($mailingList->getErrorMessage(),'mail');
68 if(!$mailingList->create(
69 getStringFromPost('list_name'),
70 getStringFromPost('description'),
71 getIntFromPost('is_public', 1)
73 form_release_key(getStringFromRequest("form_key"));
74 exit_error($mailingList->getErrorMessage(),'mail');
76 $feedback .= _('List Added');
80 form_release_key(getStringFromRequest("form_key"));
85 } elseif (getStringFromPost('change_status') == 'y') {
86 $mailingList = new MailingList($group, getIntFromGet('group_list_id'));
88 if(!$mailingList || !is_object($mailingList)) {
89 exit_error(_('Error getting the list'),'mail');
90 } elseif($mailingList->isError()) {
91 exit_error($mailingList->getErrorMessage(),'mail');
94 if(!$mailingList->update(
95 unInputSpecialChars(getStringFromPost('description')),
96 getIntFromPost('is_public', MAIL__MAILING_LIST_IS_PUBLIC),
97 MAIL__MAILING_LIST_IS_UPDATED
99 exit_error($mailingList->getErrorMessage(),'mail');
101 $feedback .= _('List updated');
107 // Reset admin password
109 if (getIntFromRequest('reset_pw') == 1) {
110 $mailingList = new MailingList($group, getIntFromGet('group_list_id'));
112 if(!$mailingList || !is_object($mailingList)) {
113 exit_error(_('Error getting the list'),'mail');
114 } elseif($mailingList->isError()) {
115 exit_error($mailingList->getErrorMessage(),'mail');
118 if($mailingList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
119 if(!$mailingList->update(
120 $mailingList->getDescription(),
121 $mailingList->isPublic(),
122 MAIL__MAILING_LIST_PW_RESET_REQUESTED
124 exit_error($mailingList->getErrorMessage(),'mail');
126 $feedback .= _('Password reset requested');
135 if(getIntFromGet('add_list')) {
136 mail_header(array('title' => _('Add a Mailing List')));
138 printf(_('Lists are named in this manner:<br /><strong>projectname-listname@%1$s</strong>'), forge_get_config('lists_host'));
142 print _('It will take <span class="important">6-24 Hours</span> for your list to be created.');
145 $mlFactory = new MailingListFactory($group);
146 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
147 exit_error($mlFactory->getErrorMessage(),'mail');
150 $mlArray = $mlFactory->getMailingLists();
152 if ($mlFactory->isError()) {
153 echo '<p class="error">'._('Error').' '._('Unable to get the lists') .$mlFactory->getErrorMessage().'</p>';
154 mail_footer(array());
158 $tableHeaders = array(
159 _('Existing mailing lists')
164 $mlCount = count($mlArray);
166 echo $HTML->listTableTop($tableHeaders);
167 for ($j = 0; $j < $mlCount; $j++) {
168 $currentList =& $mlArray[$j];
169 if ($currentList->isError()) {
170 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>';
171 echo $currentList->getErrorMessage();
174 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>'.$currentList->getName().'</td></tr>';
177 echo $HTML->listTableBottom();
183 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id ?>">
184 <input type="hidden" name="post_changes" value="y" />
185 <input type="hidden" name="add_list" value="y" />
186 <input type="hidden" name="form_key" value="<?php echo form_generate_key();?>" />
187 <p><strong><?php echo _('Mailing List Name:'); ?></strong><br />
188 <strong><?php echo $group->getUnixName(); ?>-<input type="text" name="list_name" value="" size="10" maxlength="12" />@<?php echo forge_get_config('lists_host'); ?></strong></p>
190 <strong><?php echo _('Is Public?'); ?></strong><br />
191 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PUBLIC; ?>" checked="checked" /> <?php echo _('Yes'); ?><br />
192 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PRIVATE; ?>" /> <?php echo _('No'); ?></p><p>
193 <strong><?php echo _('Description:'); ?></strong><br />
194 <input type="text" name="description" value="" size="40" maxlength="80" /></p>
196 <input type="submit" name="submit" value="<?php echo _('Add This List'); ?>" /></p>
199 mail_footer(array());
202 // Form to modify list
204 } elseif(getIntFromGet('change_status') && getIntFromGet('group_list_id')) {
205 $mailingList = new MailingList($group, getIntFromGet('group_list_id'));
207 if(!$mailingList || !is_object($mailingList)) {
208 exit_error(_('Error getting the list'),'mail');
209 } elseif($mailingList->isError()) {
210 exit_error($mailingList->getErrorMessage(),'mail');
214 'title' => _('Mail admin')));
216 <h3><?php echo $mailingList->getName(); ?></h3>
217 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">
218 <input type="hidden" name="post_changes" value="y" />
219 <input type="hidden" name="change_status" value="y" />
221 <strong><?php echo _('Is Public?'); ?></strong><br />
222 <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 />
223 <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'); ?>
226 <strong><?php echo _('Description:'); ?></strong><br />
227 <input type="text" name="description" value="<?php echo inputSpecialChars($mailingList->getDescription()); ?>" size="40" maxlength="80" /></p>
229 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" /></p>
231 <a href="deletelist.php?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">[<?php echo _('Permanently Delete List'); ?>]</a>
233 mail_footer(array());
238 $mlFactory = new MailingListFactory($group);
239 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
240 exit_error($mlFactory->getErrorMessage(),'mail');
244 'title' => _('Mailing List Administration'))
247 $mlArray = $mlFactory->getMailingLists();
249 if ($mlFactory->isError()) {
250 echo '<p>'._('Error').' '.sprintf(_('Unable to get the list %s'), $group->getPublicName()) .'</p>';
251 echo '<div class="error">'.$mlFactory->getErrorMessage().'</div>';
252 mail_footer(array());
255 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>';
258 <a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&add_list=1">'._('Add Mailing List').'</a>
261 $mlCount = count($mlArray);
263 $tableHeaders = array(
269 echo $HTML->listTableTop($tableHeaders);
270 for ($i = 0; $i < $mlCount; $i++) {
271 $currentList =& $mlArray[$i];
272 if ($currentList->isError()) {
273 echo '<tr '. $HTML->boxGetAltRowStyle($i) .'><td colspan="4">';
274 echo $currentList->getErrorMessage();
277 echo '<tr '. $HTML->boxGetAltRowStyle($i) . '><td>'.
278 '<strong>'.$currentList->getName().'</strong><br />'.
279 htmlspecialchars($currentList->getDescription()).'</td>'.
280 '<td class="align-center"><a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_list_id='.$currentList->getID().'&change_status=1">'._('Update').'</a></td>' ;
281 echo '<td class="align-center">';
282 if($currentList->getStatus() == MAIL__MAILING_LIST_IS_REQUESTED) {
283 echo _('Not activated yet');
285 echo '<a href="'.$currentList->getExternalAdminUrl().'">'._('Administration').'</a>';
288 echo '<td class="align-center">';
289 if($currentList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
290 print '<a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_list_id='.$currentList->getID().'&reset_pw=1">'._('Reset admin password').'</a></td>' ;
296 echo $HTML->listTableBottom();
298 mail_footer(array());