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 $gfcommon.'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 session_require_perm ('project_admin', $Group->getID()) ;
31 // Post Changes to database
33 if (getStringFromRequest('post_changes') == 'y') {
37 if (getStringFromRequest('add_list') == 'y') {
39 if (check_email_available($Group, $Group->getUnixName() . '-' . getStringFromPost('list_name'), $error_msg)) {
40 $mailingList = new MailingList($Group);
42 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
43 exit_form_double_submit();
45 if(!$mailingList || !is_object($mailingList)) {
46 form_release_key(getStringFromRequest("form_key"));
47 exit_error(_('Error'), _('Error getting the list'));
48 } elseif($mailingList->isError()) {
49 form_release_key(getStringFromRequest("form_key"));
50 exit_error(_('Error'), $mailingList->getErrorMessage());
53 if(!$mailingList->create(
54 getStringFromPost('list_name'),
55 getStringFromPost('description'),
56 getIntFromPost('is_public', 1)
58 form_release_key(getStringFromRequest("form_key"));
59 exit_error(_('Error'), $mailingList->getErrorMessage());
61 $feedback .= _('List Added');
65 form_release_key(getStringFromRequest("form_key"));
70 } elseif (getStringFromPost('change_status') == 'y') {
71 $mailingList = new MailingList($Group, getIntFromGet('group_list_id'));
73 if(!$mailingList || !is_object($mailingList)) {
74 exit_error(_('Error'), _('Error getting the list'));
75 } elseif($mailingList->isError()) {
76 exit_error(_('Error'), $mailingList->getErrorMessage());
79 if(!$mailingList->update(
80 unInputSpecialChars(getStringFromPost('description')),
81 getIntFromPost('is_public', MAIL__MAILING_LIST_IS_PUBLIC)
83 exit_error(_('Error'), $mailingList->getErrorMessage());
85 $feedback .= _('List updated');
91 // Reset admin password
93 if (getIntFromRequest('reset_pw') == 1) {
94 $mailingList = new MailingList($Group, getIntFromGet('group_list_id'));
96 if(!$mailingList || !is_object($mailingList)) {
97 exit_error(_('Error'), _('Error getting the list'));
98 } elseif($mailingList->isError()) {
99 exit_error(_('Error'), $mailingList->getErrorMessage());
102 if($mailingList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
103 if(!$mailingList->update(
104 $mailingList->getDescription(),
105 $mailingList->isPublic(),
106 MAIL__MAILING_LIST_PW_RESET_REQUESTED
108 exit_error(_('Error'), $mailingList->getErrorMessage());
110 $feedback .= _('Password reset requested');
119 if(getIntFromGet('add_list')) {
121 'title' => _('Add a Mailing List')));
122 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'));
124 $mlFactory = new MailingListFactory($Group);
125 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
126 exit_error(_('Error'), $mlFactory->getErrorMessage());
129 $mlArray =& $mlFactory->getMailingLists();
131 if ($mlFactory->isError()) {
132 echo '<h1>'._('Error').' '._('Unable to get the lists') .'</h1>';
133 echo $mlFactory->getErrorMessage();
134 mail_footer(array());
138 $tableHeaders = array(
139 _('Existing mailing lists')
144 $mlCount = count($mlArray);
146 echo $HTML->listTableTop($tableHeaders);
147 for ($j = 0; $j < $mlCount; $j++) {
148 $currentList =& $mlArray[$j];
149 if ($currentList->isError()) {
150 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>';
151 echo $currentList->getErrorMessage();
154 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '><td>'.$currentList->getName().'</td></tr>';
157 echo $HTML->listTableBottom();
163 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id ?>">
164 <input type="hidden" name="post_changes" value="y" />
165 <input type="hidden" name="add_list" value="y" />
166 <input type="hidden" name="form_key" value="<?php echo form_generate_key();?>" />
167 <p><strong><?php echo _('Mailing List Name:'); ?></strong><br />
168 <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>
170 <strong><?php echo _('Is Public?'); ?></strong><br />
171 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PUBLIC; ?>" checked="checked" /> <?php echo _('Yes'); ?><br />
172 <input type="radio" name="is_public" value="<?php echo MAIL__MAILING_LIST_IS_PRIVATE; ?>" /> <?php echo _('No'); ?></p><p>
173 <strong><?php echo _('Description:'); ?></strong><br />
174 <input type="text" name="description" value="" size="40" maxlength="80" /><br /></p>
176 <input type="submit" name="submit" value="<?php echo _('Add This List'); ?>" /></p>
179 mail_footer(array());
182 // Form to modify list
184 } elseif(getIntFromGet('change_status') && getIntFromGet('group_list_id')) {
185 $mailingList = new MailingList($Group, getIntFromGet('group_list_id'));
187 if(!$mailingList || !is_object($mailingList)) {
188 exit_error(_('Error'), _('Error getting the list'));
189 } elseif($mailingList->isError()) {
190 exit_error(_('Error'), $mailingList->getErrorMessage());
194 'title' => _('Mail admin')));
196 <h3><?php echo $mailingList->getName(); ?></h3>
197 <form method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">
198 <input type="hidden" name="post_changes" value="y" />
199 <input type="hidden" name="change_status" value="y" />
201 <strong><?php echo _('Is Public?'); ?></strong><br />
202 <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 />
203 <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 />
205 <p><strong><?php echo _('Description:'); ?></strong><br />
206 <input type="text" name="description" value="<?php echo inputSpecialChars($mailingList->getDescription()); ?>" size="40" maxlength="80" /><br /></p>
208 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" /></p>
210 <a href="deletelist.php?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">[<?php echo _('Permanently Delete List'); ?>]</a>
212 mail_footer(array());
217 $mlFactory = new MailingListFactory($Group);
218 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
219 exit_error(_('Error'), $mlFactory->getErrorMessage());
223 'title' => _('Mailing List Administration'))
226 $mlArray =& $mlFactory->getMailingLists();
228 if ($mlFactory->isError()) {
229 echo '<p>'._('Error').' '.sprintf(_('Unable to get the list %s'), $Group->getPublicName()) .'</p>';
230 echo $mlFactory->getErrorMessage();
231 mail_footer(array());
234 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>';
237 <a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&add_list=1">'._('Add Mailing List').'</a>
240 $mlCount = count($mlArray);
242 $tableHeaders = array(
248 echo $HTML->listTableTop($tableHeaders);
249 for ($i = 0; $i < $mlCount; $i++) {
250 $currentList =& $mlArray[$i];
251 if ($currentList->isError()) {
252 echo '<tr '. $HTML->boxGetAltRowStyle($i) .'><td colspan="4">';
253 echo $currentList->getErrorMessage();
256 echo '<tr '. $HTML->boxGetAltRowStyle($i) . '><td width="60%">'.
257 '<strong>'.$currentList->getName().'</strong><br />'.
258 htmlspecialchars($currentList->getDescription()).'</td>'.
259 '<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>' ;
260 echo '<td width="15%" style="text-align:center">';
261 if($currentList->getStatus() == MAIL__MAILING_LIST_IS_REQUESTED) {
262 echo _('Not activated yet');
264 echo '<a href="'.$currentList->getExternalAdminUrl().'">'._('Administrate').'</a></td>';
266 echo '<td width="15%" style="text-align:center">';
267 if($currentList->getStatus() == MAIL__MAILING_LIST_IS_CONFIGURED) {
268 print '<a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_list_id='.$currentList->getID().'&reset_pw=1">'._('Reset admin password').'</a></td>' ;
274 echo $HTML->listTableBottom();
276 mail_footer(array());