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 Alain Peyrat - Alcatel-Lucent
9 * http://fusionforge.org/
11 * This file is part of FusionForge.
13 * FusionForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * FusionForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with FusionForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 require_once('../../env.inc.php');
30 require_once $gfcommon.'include/pre.php';
31 require_once $gfwww.'mail/admin/../mail_utils.php';
33 require_once $gfcommon.'mail/MailingList.class.php';
34 require_once $gfcommon.'mail/MailingListFactory.class.php';
36 $group_id = getIntFromRequest('group_id');
38 $feedback = getStringFromRequest('feedback');
41 $group = group_get_object($group_id);
42 if (!$group || !is_object($group) || $group->isError()) {
46 session_require_perm ('project_admin', $group->getID()) ;
49 // Post Changes to database
51 if (getStringFromRequest('post_changes') == 'y') {
55 if (getStringFromRequest('add_list') == 'y') {
57 if (check_email_available($group, $group->getUnixName() . '-' . getStringFromPost('list_name'), $error_msg)) {
58 $mailingList = new MailingList($group);
60 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
61 exit_form_double_submit('mail');
63 if(!$mailingList || !is_object($mailingList)) {
64 form_release_key(getStringFromRequest("form_key"));
65 exit_error(_('Error getting the list'),'mail');
66 } elseif($mailingList->isError()) {
67 form_release_key(getStringFromRequest("form_key"));
68 exit_error($mailingList->getErrorMessage(),'mail');
71 if(!$mailingList->create(
72 getStringFromPost('list_name'),
73 getStringFromPost('description'),
74 getIntFromPost('is_public', 1)
76 form_release_key(getStringFromRequest("form_key"));
77 exit_error($mailingList->getErrorMessage(),'mail');
79 $feedback .= _('List Added');
83 form_release_key(getStringFromRequest("form_key"));
88 } elseif (getStringFromPost('change_status') == 'y') {
89 $mailingList = new MailingList($group, getIntFromGet('group_list_id'));
91 if(!$mailingList || !is_object($mailingList)) {
92 exit_error(_('Error getting the list'),'mail');
93 } elseif($mailingList->isError()) {
94 exit_error($mailingList->getErrorMessage(),'mail');
97 if(!$mailingList->update(
98 unInputSpecialChars(getStringFromPost('description')),
99 getIntFromPost('is_public', MAIL__MAILING_LIST_IS_PUBLIC)
101 exit_error($mailingList->getErrorMessage(),'mail');
103 $feedback .= _('List updated');
109 // Reset admin password
111 if (getIntFromRequest('reset_pw') == 1) {
112 $mailingList = new MailingList($group, getIntFromGet('group_list_id'));
114 if(!$mailingList || !is_object($mailingList)) {
115 exit_error(_('Error getting the list'),'mail');
116 } elseif($mailingList->isError()) {
117 exit_error($mailingList->getErrorMessage(),'mail');
120 if($mailingList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
121 if(!$mailingList->update(
122 $mailingList->getDescription(),
123 $mailingList->isPublic(),
124 MAIL__MAILING_LIST_PW_RESET_REQUESTED
126 exit_error($mailingList->getErrorMessage(),'mail');
128 $feedback .= _('Password reset requested');
137 if(getIntFromGet('add_list')) {
138 mail_header(array('title' => _('Add a Mailing List')));
140 printf(_('Lists are named in this manner:<br /><strong>projectname-listname@%1$s</strong>'), forge_get_config('lists_host'));
144 print _('It will take <span class="important">6-24 Hours</span> for your list to be created.');
147 $mlFactory = new MailingListFactory($group);
148 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
149 exit_error($mlFactory->getErrorMessage(),'mail');
152 $mlArray =& $mlFactory->getMailingLists();
154 if ($mlFactory->isError()) {
155 echo '<p class="error">'._('Error').' '._('Unable to get the lists') .$mlFactory->getErrorMessage().'</p>';
156 mail_footer(array());
160 $tableHeaders = array(
161 _('Existing mailing lists')
166 $mlCount = count($mlArray);
168 echo $HTML->listTableTop($tableHeaders);
169 for ($j = 0; $j < $mlCount; $j++) {
170 $currentList =& $mlArray[$j];
171 if ($currentList->isError()) {
172 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>';
173 echo $currentList->getErrorMessage();
176 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>'.$currentList->getName().'</td></tr>';
179 echo $HTML->listTableBottom();
185 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id ?>">
186 <input type="hidden" name="post_changes" value="y" />
187 <input type="hidden" name="add_list" value="y" />
188 <input type="hidden" name="form_key" value="<?php echo form_generate_key();?>" />
189 <p><strong><?php echo _('Mailing List Name:'); ?></strong><br />
190 <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>
192 <strong><?php echo _('Is Public?'); ?></strong><br />
193 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PUBLIC; ?>" checked="checked" /> <?php echo _('Yes'); ?><br />
194 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PRIVATE; ?>" /> <?php echo _('No'); ?></p><p>
195 <strong><?php echo _('Description:'); ?></strong><br />
196 <input type="text" name="description" value="" size="40" maxlength="80" /><br /></p>
198 <input type="submit" name="submit" value="<?php echo _('Add This List'); ?>" /></p>
201 mail_footer(array());
204 // Form to modify list
206 } elseif(getIntFromGet('change_status') && getIntFromGet('group_list_id')) {
207 $mailingList = new MailingList($group, getIntFromGet('group_list_id'));
209 if(!$mailingList || !is_object($mailingList)) {
210 exit_error(_('Error getting the list'),'mail');
211 } elseif($mailingList->isError()) {
212 exit_error($mailingList->getErrorMessage(),'mail');
216 'title' => _('Mail admin')));
218 <h3><?php echo $mailingList->getName(); ?></h3>
219 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">
220 <input type="hidden" name="post_changes" value="y" />
221 <input type="hidden" name="change_status" value="y" />
223 <strong><?php echo _('Is Public?'); ?></strong><br />
224 <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 />
225 <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'); ?>
227 <p><strong><?php echo _('Description:'); ?></strong><br />
228 <input type="text" name="description" value="<?php echo inputSpecialChars($mailingList->getDescription()); ?>" size="40" maxlength="80" /><br /></p>
230 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" /></p>
232 <a href="deletelist.php?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">[<?php echo _('Permanently Delete List'); ?>]</a>
234 mail_footer(array());
239 $mlFactory = new MailingListFactory($group);
240 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
241 exit_error($mlFactory->getErrorMessage(),'mail');
245 'title' => _('Mailing List Administration'))
248 $mlArray =& $mlFactory->getMailingLists();
250 if ($mlFactory->isError()) {
251 echo '<p>'._('Error').' '.sprintf(_('Unable to get the list %s'), $group->getPublicName()) .'</p>';
252 echo '<div class="error">'.$mlFactory->getErrorMessage().'</div>';
253 mail_footer(array());
256 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>';
259 <a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&add_list=1">'._('Add Mailing List').'</a>
262 $mlCount = count($mlArray);
264 $tableHeaders = array(
270 echo $HTML->listTableTop($tableHeaders);
271 for ($i = 0; $i < $mlCount; $i++) {
272 $currentList =& $mlArray[$i];
273 if ($currentList->isError()) {
274 echo '<tr '. $HTML->boxGetAltRowStyle($i) .'><td colspan="4">';
275 echo $currentList->getErrorMessage();
278 echo '<tr '. $HTML->boxGetAltRowStyle($i) . '><td width="60%">'.
279 '<strong>'.$currentList->getName().'</strong><br />'.
280 htmlspecialchars($currentList->getDescription()).'</td>'.
281 '<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>' ;
282 echo '<td style="text-align:center">';
283 if($currentList->getStatus() == MAIL__MAILING_LIST_IS_REQUESTED) {
284 echo _('Not activated yet');
286 echo '<a href="'.$currentList->getExternalAdminUrl().'">'._('Administration').'</a>';
289 echo '<td style="text-align:center">';
290 if($currentList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
291 print '<a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_list_id='.$currentList->getID().'&reset_pw=1">'._('Reset admin password').'</a></td>' ;
297 echo $HTML->listTableBottom();
299 mail_footer(array());