4 * GForge Mailing Lists Facility
6 * Portions Copyright 1999-2001 (c) VA Linux Systems
7 * The rest Copyright 2003-2004 (c) Guillaume Smet - Open Wide
11 require_once('../../env.inc.php');
12 require_once $gfwww.'include/pre.php';
13 require_once $gfwww.'mail/admin/../mail_utils.php';
15 require_once $gfcommon.'mail/MailingList.class.php';
16 require_once $gfcommon.'mail/MailingListFactory.class.php';
18 $group_id = getIntFromRequest('group_id');
23 $Group =& group_get_object($group_id);
24 if (!$Group || !is_object($Group) || $Group->isError()) {
28 $perm =& $Group->getPermission(session_get_user());
29 if (!$perm || !is_object($perm) || $perm->isError() || !$perm->isAdmin()) {
30 exit_permission_denied();
34 // Post Changes to database
36 if (getStringFromRequest('post_changes') == 'y') {
40 if (getStringFromRequest('add_list') == 'y') {
42 if (check_email_available($Group, $Group->getUnixName() . '-' . getStringFromPost('list_name'), $error_msg)) {
43 $mailingList = new MailingList($Group);
45 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
46 exit_form_double_submit();
48 if(!$mailingList || !is_object($mailingList)) {
49 form_release_key(getStringFromRequest("form_key"));
50 exit_error(_('Error'), _('Error getting the list'));
51 } elseif($mailingList->isError()) {
52 form_release_key(getStringFromRequest("form_key"));
53 exit_error(_('Error'), $mailingList->getErrorMessage());
56 if(!$mailingList->create(
57 getStringFromPost('list_name'),
58 getStringFromPost('description'),
59 getIntFromPost('is_public', 1)
61 form_release_key(getStringFromRequest("form_key"));
62 exit_error(_('Error'), $mailingList->getErrorMessage());
64 $feedback .= _('List Added');
68 form_release_key(getStringFromRequest("form_key"));
73 } elseif (getStringFromPost('change_status') == 'y') {
74 $mailingList = new MailingList($Group, getIntFromGet('group_list_id'));
76 if(!$mailingList || !is_object($mailingList)) {
77 exit_error(_('Error'), _('Error getting the list'));
78 } elseif($mailingList->isError()) {
79 exit_error(_('Error'), $mailingList->getErrorMessage());
82 if(!$mailingList->update(
83 unInputSpecialChars(getStringFromPost('description')),
84 getIntFromPost('is_public', MAIL__MAILING_LIST_IS_PUBLIC)
86 exit_error(_('Error'), $mailingList->getErrorMessage());
88 $feedback .= _('List updated');
94 // Reset admin password
96 if (getIntFromRequest('reset_pw') == 1) {
97 $mailingList = new MailingList($Group, getIntFromGet('group_list_id'));
99 if(!$mailingList || !is_object($mailingList)) {
100 exit_error(_('Error'), _('Error getting the list'));
101 } elseif($mailingList->isError()) {
102 exit_error(_('Error'), $mailingList->getErrorMessage());
105 if($mailingList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
106 if(!$mailingList->update(
107 $mailingList->getDescription(),
108 $mailingList->isPublic(),
109 MAIL__MAILING_LIST_PW_RESET_REQUESTED
111 exit_error(_('Error'), $mailingList->getErrorMessage());
113 $feedback .= _('Password reset requested');
122 if(getIntFromGet('add_list')) {
124 'title' => _('Add a Mailing List')));
125 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>'), $GLOBALS['sys_lists_host']);
127 $mlFactory = new MailingListFactory($Group);
128 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
129 exit_error(_('Error'), $mlFactory->getErrorMessage());
132 $mlArray =& $mlFactory->getMailingLists();
134 if ($mlFactory->isError()) {
135 echo '<h1>'._('Error').' '._('Unable to get the lists') .'</h1>';
136 echo $mlFactory->getErrorMessage();
137 mail_footer(array());
141 $tableHeaders = array(
142 _('Existing mailing lists')
147 $mlCount = count($mlArray);
149 echo $HTML->listTableTop($tableHeaders);
150 for ($j = 0; $j < $mlCount; $j++) {
151 $currentList =& $mlArray[$j];
152 if ($currentList->isError()) {
153 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>';
154 echo $currentList->getErrorMessage();
157 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>'.$currentList->getName().'</td></tr>';
160 echo $HTML->listTableBottom();
166 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id ?>">
167 <input type="hidden" name="post_changes" value="y" />
168 <input type="hidden" name="add_list" value="y" />
169 <input type="hidden" name="form_key" value="<?php echo form_generate_key();?>" />
170 <p><strong><?php echo _('Mailing List Name:'); ?></strong><br />
171 <strong><?php echo $Group->getUnixName(); ?>-<input type="text" name="list_name" value="" size="10" maxlength="12" />@<?php echo $GLOBALS['sys_lists_host']; ?></strong><br /></p>
173 <strong><?php echo _('Is Public?'); ?></strong><br />
174 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PUBLIC; ?>" checked="checked" /> <?php echo _('Yes'); ?><br />
175 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PRIVATE; ?>" /> <?php echo _('No'); ?></p><p>
176 <strong><?php echo _('Description:'); ?></strong><br />
177 <input type="text" name="description" value="" size="40" maxlength="80" /><br /></p>
179 <input type="submit" name="submit" value="<?php echo _('Add This List'); ?>" /></p>
182 mail_footer(array());
185 // Form to modify list
187 } elseif(getIntFromGet('change_status') && getIntFromGet('group_list_id')) {
188 $mailingList = new MailingList($Group, getIntFromGet('group_list_id'));
190 if(!$mailingList || !is_object($mailingList)) {
191 exit_error(_('Error'), _('Error getting the list'));
192 } elseif($mailingList->isError()) {
193 exit_error(_('Error'), $mailingList->getErrorMessage());
197 'title' => _('Mail admin')));
199 <h3><?php echo $mailingList->getName(); ?></h3>
200 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">
201 <input type="hidden" name="post_changes" value="y" />
202 <input type="hidden" name="change_status" value="y" />
204 <strong><?php echo _('Is Public?'); ?></strong><br />
205 <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 />
206 <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'); ?><br />
208 <p><strong><?php echo _('Description:'); ?></strong><br />
209 <input type="text" name="description" value="<?php echo inputSpecialChars($mailingList->getDescription()); ?>" size="40" maxlength="80" /><br /></p>
211 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" /></p>
213 <a href="deletelist.php?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">[<?php echo _('Permanently Delete List'); ?>]</a>
215 mail_footer(array());
220 $mlFactory = new MailingListFactory($Group);
221 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
222 exit_error(_('Error'), $mlFactory->getErrorMessage());
226 'title' => _('Mailing List Administration'))
229 $mlArray =& $mlFactory->getMailingLists();
231 if ($mlFactory->isError()) {
232 echo '<p>'._('Error').' '.sprintf(_('Unable to get the list %s'), $Group->getPublicName()) .'</p>';
233 echo $mlFactory->getErrorMessage();
234 mail_footer(array());
237 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.'), fusionforge_get_config ('core', 'forge_name')).'</p>';
240 <a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&add_list=1">'._('Add Mailing List').'</a>
243 $mlCount = count($mlArray);
245 $tableHeaders = array(
251 echo $HTML->listTableTop($tableHeaders);
252 for ($i = 0; $i < $mlCount; $i++) {
253 $currentList =& $mlArray[$i];
254 if ($currentList->isError()) {
255 echo '<tr '. $HTML->boxGetAltRowStyle($i) .'><td colspan="4">';
256 echo $currentList->getErrorMessage();
259 echo '<tr '. $HTML->boxGetAltRowStyle($i) . '><td width="60%">'.
260 '<strong>'.$currentList->getName().'</strong><br />'.
261 htmlspecialchars($currentList->getDescription()).'</td>'.
262 '<td width="15%" style="text-align:center"><a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_list_id='.$currentList->getID().'&change_status=1">'._('Update').'</a></td>' ;
263 echo '<td width="15%" style="text-align:center">';
264 if($currentList->getStatus() == MAIL__MAILING_LIST_IS_REQUESTED) {
265 echo _('Not activated yet');
267 echo '<a href="'.$currentList->getExternalAdminUrl().'">'._('Administrate').'</a></td>';
269 echo '<td width="15%" style="text-align:center">';
270 if($currentList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
271 print '<a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_list_id='.$currentList->getID().'&reset_pw=1">'._('Reset admin password').'</a></td>' ;
277 echo $HTML->listTableBottom();
279 mail_footer(array());