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
12 require_once('../../env.inc.php');
13 require_once $gfwww.'include/pre.php';
14 require_once $gfwww.'mail/admin/../mail_utils.php';
16 require_once $gfcommon.'mail/MailingList.class.php';
17 require_once $gfcommon.'mail/MailingListFactory.class.php';
19 $group_id = getIntFromRequest('group_id');
24 $Group =& group_get_object($group_id);
25 if (!$Group || !is_object($Group) || $Group->isError()) {
29 $perm =& $Group->getPermission(session_get_user());
30 if (!$perm || !is_object($perm) || $perm->isError() || !$perm->isAdmin()) {
31 exit_permission_denied();
35 // Post Changes to database
37 if (getStringFromRequest('post_changes') == 'y') {
41 if (getStringFromRequest('add_list') == 'y') {
42 $mailingList = new MailingList($Group);
44 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
45 exit_form_double_submit();
47 if(!$mailingList || !is_object($mailingList)) {
48 form_release_key(getStringFromRequest("form_key"));
49 exit_error(_('Error'), _('Error getting the list'));
50 } elseif($mailingList->isError()) {
51 form_release_key(getStringFromRequest("form_key"));
52 exit_error(_('Error'), $mailingList->getErrorMessage());
55 if(!$mailingList->create(
56 getStringFromPost('list_name'),
57 getStringFromPost('description'),
58 getIntFromPost('is_public', 1)
60 form_release_key(getStringFromRequest("form_key"));
61 exit_error(_('Error'), $mailingList->getErrorMessage());
63 $feedback .= _('List Added');
68 } elseif (getStringFromPost('change_status') == 'y') {
69 $mailingList = new MailingList($Group, getIntFromGet('group_list_id'));
71 if(!$mailingList || !is_object($mailingList)) {
72 exit_error(_('Error'), _('Error getting the list'));
73 } elseif($mailingList->isError()) {
74 exit_error(_('Error'), $mailingList->getErrorMessage());
77 if(!$mailingList->update(
78 unInputSpecialChars(getStringFromPost('description')),
79 getIntFromPost('is_public', MAIL__MAILING_LIST_IS_PUBLIC)
81 exit_error(_('Error'), $mailingList->getErrorMessage());
83 $feedback .= _('List updated');
92 if(getIntFromGet('add_list')) {
94 'title' => _('Add a Mailing List')));
95 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']);
97 $mlFactory = new MailingListFactory($Group);
98 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
99 exit_error(_('Error'), $mlFactory->getErrorMessage());
102 $mlArray =& $mlFactory->getMailingLists();
104 if ($mlFactory->isError()) {
105 echo '<h1>'._('Error').' '._('Unable to get the lists') .'</h1>';
106 echo $mlFactory->getErrorMessage();
107 mail_footer(array());
111 $tableHeaders = array(
112 _('Existing mailing lists')
117 $mlCount = count($mlArray);
119 echo $HTML->listTableTop($tableHeaders);
120 for ($j = 0; $j < $mlCount; $j++) {
121 $currentList =& $mlArray[$j];
122 if ($currentList->isError()) {
123 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>';
124 echo $currentList->getErrorMessage();
127 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>'.$currentList->getName().'</td></tr>';
130 echo $HTML->listTableBottom();
136 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id ?>">
137 <input type="hidden" name="post_changes" value="y" />
138 <input type="hidden" name="add_list" value="y" />
139 <input type="hidden" name="form_key" value="<?php echo form_generate_key();?>">
140 <p><strong><?php echo _('Mailing List Name:'); ?></strong><br />
141 <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>
143 <strong><?php echo _('Is Public?'); ?></strong><br />
144 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PUBLIC; ?>" checked="checked" /> <?php echo _('Yes'); ?><br />
145 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PRIVATE; ?>" /> <?php echo _('No'); ?></p><p>
146 <strong><?php echo _('Description:'); ?></strong><br />
147 <input type="text" name="description" value="" size="40" maxlength="80" /><br /></p>
149 <input type="submit" name="submit" value="<?php echo _('Add This List'); ?>" /></p>
152 mail_footer(array());
155 // Form to modify list
157 } elseif(getIntFromGet('change_status') && getIntFromGet('group_list_id')) {
158 $mailingList = new MailingList($Group, getIntFromGet('group_list_id'));
160 if(!$mailingList || !is_object($mailingList)) {
161 exit_error(_('Error'), _('Error getting the list'));
162 } elseif($mailingList->isError()) {
163 exit_error(_('Error'), $mailingList->getErrorMessage());
167 'title' => _('Mail admin')));
169 <h3><?php echo $mailingList->getName(); ?></h3>
170 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">
171 <input type="hidden" name="post_changes" value="y" />
172 <input type="hidden" name="change_status" value="y" />
174 <strong><?php echo _('Is Public?'); ?></strong><br />
175 <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 />
176 <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 />
178 <p><strong><?php echo _('Description:'); ?></strong><br />
179 <input type="text" name="description" value="<?php echo inputSpecialChars($mailingList->getDescription()); ?>" size="40" maxlength="80" /><br /></p>
181 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" /></p>
183 <a href="deletelist.php?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">[<?php echo _('Permanently Delete List'); ?>]</a>
185 mail_footer(array());
190 $mlFactory = new MailingListFactory($Group);
191 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
192 exit_error(_('Error'), $mlFactory->getErrorMessage());
196 'title' => _('Mailing List Administration'))
199 $mlArray =& $mlFactory->getMailingLists();
201 if ($mlFactory->isError()) {
202 echo '<p>'._('Error').' '.sprintf(_('Unable to get the list %s'), $Group->getPublicName()) .'</p>';
203 echo $mlFactory->getErrorMessage();
204 mail_footer(array());
207 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.'), $GLOBALS['sys_name']).'</p>';
210 <a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&add_list=1">'._('Add Mailing List').'</a>
213 $mlCount = count($mlArray);
215 $tableHeaders = array(
220 echo $HTML->listTableTop($tableHeaders);
221 for ($i = 0; $i < $mlCount; $i++) {
222 $currentList =& $mlArray[$i];
223 if ($currentList->isError()) {
224 echo '<tr '. $HTML->boxGetAltRowStyle($i) .'><td colspan="3">';
225 echo $currentList->getErrorMessage();
228 echo '<tr '. $HTML->boxGetAltRowStyle($i) . '><td width="60%">'.
229 '<strong>'.$currentList->getName().'</strong><br />'.
230 htmlspecialchars($currentList->getDescription()).'</td>'.
231 '<td width="20%" style="text-align:center"><a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_list_id='.$currentList->getID().'&change_status=1">'._('Update').'</a></td>'.
232 '<td width="20%" style="text-align:center">';
233 if($currentList->getStatus() == MAIL__MAILING_LIST_IS_REQUESTED) {
234 echo _('Not activated yet');
236 echo '<a href="'.$currentList->getExternalAdminUrl().'">'._('Administrate').'</a></td>';
241 echo $HTML->listTableBottom();
243 mail_footer(array());