4 * Fusionforge Mailing Lists Facility
6 * Portions Copyright 1999-2001 (c) VA Linux Systems
7 * The rest Copyright 2003-2004 (c) Guillaume Smet - Open Wide
11 * Portions Copyright 2010 (c) Mélanie Le Bail
13 require_once 'env.inc.php';
14 require_once 'pre.php';
15 require_once 'preplugins.php';
16 require_once 'plugins_utils.php';
17 require_once '../mailman_utils.php';
19 $request =& HTTPRequest::instance();
20 $group_id=$request->get('group_id');
21 $group_list_id=$request->get('group_list_id');
22 $pm = ProjectManager::instance();
23 $Group = $pm->getProject($group_id);
24 $post_changes= $request->get('post_changes');
25 $add_list=$request->get('add_list');
26 $action=$request->get('action');
27 $change_status=$request->get('change_status');
28 $list_name=$request->get('list_name');
29 $is_public=$request->get('is_public');
30 $description=$request->get('description');
31 $PHP_SELF = $request->get('PHP_SELF');
36 if (!$Group || !is_object($Group) || $Group->isError()) {
41 if (!$current_user->isMember($group_id,'A')) {
42 exit_permission_denied();
45 // RE-CREATE List with problems
47 if($action=='recreate') {
48 $mailingList = new MailmanList($group_id, $group_list_id);
49 if(!$mailingList || !is_object($mailingList)) {
50 exit_error(_('Error'), _('Error getting the list'));
52 } elseif($mailingList->isError()) {
53 exit_error(_('Error'), $mailingList->getErrorMessage());
56 $mailingList->recreate();
57 $feedback .=_('List re-created');
58 htmlRedirect('/plugins/mailman/index.php?group_id='.$group_id);
63 // Post Changes to database
65 if ($post_changes == 'y') {
69 if ($add_list == 'y') {
70 $mailingList = new MailmanList($group_id);
72 if(!$mailingList || !is_object($mailingList)) {
73 exit_error(_('Error'), _('Error getting the list'));
74 } elseif($mailingList->isError()) {
75 exit_error(_('Error'), $mailingList->getErrorMessage());
78 if(!$mailingList->create(
83 exit_error(_('Error'), $mailingList->getErrorMessage());
85 $feedback .= _('List Added');
90 } elseif ($change_status == 'y') {
91 $mailingList = new MailmanList($group_id, $group_list_id);
93 if(!$mailingList || !is_object($mailingList)) {
94 exit_error(_('Error'), _('Error getting the list'));
95 } elseif($mailingList->isError()) {
96 exit_error(_('Error'), $mailingList->getErrorMessage());
99 if(!$mailingList->update(
104 exit_error(_('Error'), $mailingList->getErrorMessage());
106 $feedback .= _('List updated');
115 mailman_header(array(
116 'title' => _('Add a Mailing List'),
117 'help'=>'CommunicationServices.html#MailingLists',
120 printf(_('Lists are named in this manner:<br /><strong>projectname-listname@%1$s</strong></p><p>It will take <span class="important">few minutes</span> for your list to be created.'), forge_get_config('lists_host'));
123 $mlFactory = new MailmanListFactory($Group);
124 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
125 exit_error(_('Error'), $mlFactory->getErrorMessage());
128 $mlArray =& $mlFactory->getMailmanLists();
130 if ($mlFactory->isError()) {
131 echo '<h1>'._('Error').' '._('Unable to get the lists') .'</h1>';
132 echo $mlFactory->getErrorMessage();
133 mail_footer(array());
141 <form method="post" action="<?php echo $PHP_SELF; ?>?group_id=<?php echo $group_id ?>">
142 <input type="hidden" name="post_changes" value="y" />
143 <input type="hidden" name="add_list" value="y" />
144 <p><strong><?php echo _('Mailing List Name')._(':'); ?></strong><br />
145 <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>
147 <strong><?php echo _('Is Public?'); ?></strong><br />
148 <input type="radio" name="is_public" value="1" checked="checked" /> <?php echo _('Yes'); ?><br />
149 <input type="radio" name="is_public" value="0" /> <?php echo _('No'); ?></p><p>
150 <strong><?php echo _('Description')._(':'); ?></strong><br />
151 <input type="text" name="description" value="" size="40" maxlength="80" /><br /></p>
153 <input type="submit" name="submit" value="<?php echo _('Add This List'); ?>" /></p>
156 mail_footer(array());
159 // Form to modify list
161 } elseif($change_status && $group_list_id) {
162 $mailingList = new MailmanList($group_id, $group_list_id);
163 if(!$mailingList || !is_object($mailingList)) {
164 exit_error(_('Error'), _('Error getting the list'));
165 } elseif($mailingList->isError()) {
166 exit_error(_('Error'), $mailingList->getErrorMessage());
168 mailman_header(array(
169 'title' => _('Mail admin'),
170 'help'=>'CommunicationServices.html#MailingLists',
174 <h3><?php echo $mailingList->getName(); ?></h3>
175 <form method="post" action="<?php echo $PHP_SELF; ?>?group_id=<?php echo $group_id; ?>&group_list_id=<?php echo $mailingList->getID(); ?>">
176 <input type="hidden" name="post_changes" value="y" />
177 <input type="hidden" name="change_status" value="y" />
179 <strong><?php echo _('Is Public?'); ?></strong><br />
180 <input type="radio" name="is_public" value="1"<?php echo ($mailingList->isPublic() == 1 ? ' checked="checked"' : ''); ?> /> <?php echo _('Yes'); ?><br />
181 <input type="radio" name="is_public" value="0"<?php echo ($mailingList->isPublic() == 0 ? ' checked="checked"' : ''); ?> /> <?php echo _('No'); ?><br />
183 <p><strong><?php echo _('Description')._(':'); ?></strong><br />
184 <input type="text" name="description" value="<?php echo $mailingList->getDescription(); ?>" size="40" maxlength="80" /><br /></p>
186 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" /></p>
189 mail_footer(array());
194 $mlFactory = new MailmanListFactory($Group);
195 if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
196 exit_error(_('Error'), $mlFactory->getErrorMessage());
199 mailman_header(array(
200 'title' => _('Mailing List Administration'),
201 'help'=>'CommunicationServices.html#MailingLists',
205 $mlArray =& $mlFactory->getMailmanLists();
207 if ($mlFactory->isError()) {
208 echo '<p>'._('Error').' '.sprintf(_('Unable to get the list %s'), $Group->getPublicName()) .'</p>';
209 echo $mlFactory->getErrorMessage();
210 mail_footer(array());
213 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>';
216 <a href="'.$PHP_SELF.'?group_id='.$group_id.'&add_list=1">'._('Add Mailing List').'</a>
219 $mlCount = count($mlArray);
223 for ($j = 0; $j < $mlCount; $j++) {
225 $currentList =& $mlArray[$j];
226 display_list_admin($currentList);
231 mail_footer(array());