[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gforge-commits] gforge/www/mail/admin index.php,1.11,1.12
From: |
gsmet |
Subject: |
[Gforge-commits] gforge/www/mail/admin index.php,1.11,1.12 |
Date: |
Thu, 15 Jan 2004 04:31:35 -0600 |
Update of /cvsroot/gforge/gforge/www/mail/admin
In directory db.perdue.net:/tmp/cvs-serv27479/www/mail/admin
Modified Files:
index.php
Log Message:
rewrote mailing list management (patch #643)
Index: index.php
===================================================================
RCS file: /cvsroot/gforge/gforge/www/mail/admin/index.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- index.php 8 Oct 2003 15:44:19 -0000 1.11
+++ index.php 15 Jan 2004 10:31:33 -0000 1.12
@@ -1,241 +1,239 @@
<?php
-/**
- *
- * SourceForge Mailing Lists Facility
- *
- * SourceForge: Breaking Down the Barriers to Open Source Development
- * Copyright 1999-2001 (c) VA Linux Systems
- * http://sourceforge.net
- *
- * @version $Id$
- *
- */
+/**
+ * GForge Mailing Lists Facility
+ *
+ * Portions Copyright 1999-2001 (c) VA Linux Systems
+ * The rest Copyright 2003 (c) Guillaume Smet
+ *
+ * @version $Id$
+ */
require_once('pre.php');
require_once('../mail_utils.php');
-if ($group_id && user_ismember($group_id,'A')) {
-
- if ($post_changes) {
- /*
- Update the DB to reflect the changes
- */
+require_once('common/include/escapingUtils.php');
+require_once('common/mail/MailingList.class');
+require_once('common/mail/MailingListFactory.class');
- if ($add_list) {
- $list_password = substr(md5($GLOBALS['session_hash'] .
time() . rand(0,40000)),0,16);
+$group_id = getIntFromGet('group_id');
- $list_name=stripslashes($list_name);
+$feedback = '';
- if (!$list_name || strlen($list_name) < 4) {
- exit_error('Error','Must Provide List Name That
Is 4 or More Characters Long');
+if ($group_id) {
+ $Group =& group_get_object($group_id);
+ if (!$Group || !is_object($Group) || $Group->isError()) {
+ exit_no_group();
+ }
+
+ if(! MailingListFactory::userCanAdminMailingLists($Group)) {
+ exit_permission_denied();
+ }
+
+ if (getStringFromPost('post_changes') == 'y') {
+ if (getStringFromPost('add_list') == 'y') {
+ $mailingList = new MailingList($Group);
+
+ if(!$mailingList || !is_object($mailingList)) {
+ exit_error($Language->getText('general',
'error'), $Language->getText('mail_admin', 'error_getting_list'));
+ } elseif($mailingList->isError()) {
+ exit_error($Language->getText('general',
'error'), $mailingList->getErrorMessage());
}
-
$new_list_name=strtolower(group_getunixname($group_id).'-'.$list_name);
-
- //see if that's a valid email address
- if
(validate_email($new_list_name.'@'.$GLOBALS['sys_lists_host'])) {
-
- $result=db_query("SELECT * FROM mail_group_list
WHERE lower(list_name)='$new_list_name'");
-
- if (db_numrows($result) > 0) {
-
- $feedback .= " ERROR - List Already
Exists ";
-
- } else {
- $sql = "INSERT INTO mail_group_list "
- .
"(group_id,list_name,is_public,password,list_admin,status,description) VALUES ("
- . "$group_id,"
- . "'$new_list_name',"
- . "'$is_public',"
- . "'$list_password',"
- . "'".user_getid()."',"
- . "1,"
- . "'". htmlspecialchars($description)
."')";
-
-
- $result=db_query($sql);
- if (!$result) {
- $feedback .= " Error Adding
List ";
- echo db_error();
- } else {
- $feedback .= " List Added ";
- }
-
- // get email addr
- $res_email = db_query("SELECT email
FROM users WHERE user_id='".user_getid()."'");
- if (db_numrows($res_email) < 1) {
- exit_error("Invalid
userid","Does not compute.");
- }
- $row_email = db_fetch_array($res_email);
-
- // mail password to admin
- $message = "A mailing list will be
created on ".$GLOBALS['sys_name']." in 6-24 hours \n"
- . "and you are the list
administrator.\n\n"
- . "This list is: $new_list_name@"
.$GLOBALS['sys_lists_host'] ."\n\n"
- . "Your mailing list info is at:\n"
- .
"http://".$GLOBALS['sys_lists_host']."/mailman/listinfo/$new_list_name\n\n"
- . "List administration can be found
at:\n"
- .
"https://".$GLOBALS['sys_lists_host']."/mailman/admin/$new_list_name\n\n"
- . "Your list password is:
$list_password\n"
- . "You are encouraged to change this
password as soon as possible.\n\n"
- . "Thank you for registering your
project with ".$GLOBALS['sys_name'].".\n\n"
- . " -- the ".$GLOBALS['sys_name']."
staff\n";
-
-
util_send_message($row_email['email'],$GLOBALS['sys_name']." New Mailing
List",$message,"address@hidden");
-
- $feedback .= " Email sent with details
to: $row_email[email] ";
- }
+
+ if(!$mailingList->create(
+ getStringFromPost('list_name'),
+ getStringFromPost('description'),
+ getIntFromPost('is_public', 1)
+ )) {
+ exit_error($Language->getText('general',
'error'), $mailingList->getErrorMessage());
} else {
-
- $feedback .= " Invalid List Name ";
-
+ $feedback .=
$Language->getText('mail_admin_addlist', 'list_added');
}
-
- } else if ($change_status) {
- /*
- Change a list to public/private and description
- */
- $sql="UPDATE mail_group_list SET
is_public='$is_public', ".
- "description='". htmlspecialchars($description)
."' ".
- "WHERE group_list_id='$group_list_id' AND
group_id='$group_id'";
- $result=db_query($sql);
- if (!$result || db_affected_rows($result) < 1) {
- $feedback .= " Error Updating Status ";
- echo db_error();
+
+ } elseif (getStringFromPost('change_status') == 'y') {
+ $mailingList = new MailingList($Group,
getIntFromPost('group_list_id'));
+
+ if(!$mailingList || !is_object($mailingList)) {
+ exit_error($Language->getText('general',
'error'), $Language->getText('mail_admin', 'error_getting_list'));
+ } elseif($mailingList->isError()) {
+ exit_error($Language->getText('general',
'error'), $mailingList->getErrorMessage());
+ }
+
+ if(!$mailingList->update(
+
unInputSpecialChars(getStringFromPost('description')),
+ getIntFromPost('is_public',
MAIL__MAILING_LIST_IS_PUBLIC)
+ )) {
+ exit_error($Language->getText('general',
'error'), $mailingList->getErrorMessage());
} else {
- $feedback .= " Status Updated Successfully ";
+ $feedback .=
$Language->getText('mail_admin_updatelist', 'list_updated');
}
}
}
- if ($add_list) {
- /*
- Show the form for adding forums
- */
- mail_header(array('title'=>'Add a Mailing
List','pagename'=>'mail_admin_add_list'));
+ if(getIntFromGet('add_list')) {
+ mail_header(array(
+ 'title' => $Language->getText('mail_admin_addlist',
'pagetitle'),
+ 'pagename' => 'mail_admin_addlist'
+ ));
- echo '
- <p>Lists are named in this manner:
- <br /><strong>projectname-listname@'.
$GLOBALS['sys_lists_host'] .'</strong></p>
- <p>It will take <strong><span style="color:red">6-24
Hours</span></strong> for your list
- to be created.</p>
- <p> </p>';
- $result=db_query("SELECT list_name FROM mail_group_list WHERE
group_id='$group_id'");
- ShowResultSet($result,'Existing Mailing Lists');
+ echo $Language->getText('mail_admin_addlist',
'list_information', array($GLOBALS['sys_lists_host']));
+
+ $mlFactory = new MailingListFactory($Group);
+ if (!$mlFactory || !is_object($mlFactory) ||
$mlFactory->isError()) {
+ exit_error($Language->getText('general','error'),
$mlFactory->getErrorMessage());
+ }
+
+ $mlArray =& $mlFactory->getMailingLists(true);
- echo '<form method="post" action="'.$PHP_SELF.'">
+ if ($mlFactory->isError()) {
+ echo '<h1>'.$Language->getText('general','error').'
'.$Language->getText('mail', 'unable_to_get_lists') .'</h1>';
+ echo $mlFactory->getErrorMessage();
+ mail_footer(array());
+ exit;
+ }
+
+ $tableHeaders = array(
+ $Language->getText('mail_admin_addlist',
'existing_mailing_lists')
+ );
+
+ echo $HTML->listTableTop($tableHeaders);
+
+ $mlCount = count($mlArray);
+ for ($j = 0; $j < $mlCount; $j++) {
+ $currentList =& $mlArray[$j];
+ if ($currentList->isError()) {
+ echo '<tr '. $HTML->boxGetAltRowStyle($j) .
'><td>';
+ echo $currentList->getErrorMessage();
+ echo '</td></tr>';
+ } else {
+ echo '<tr '. $HTML->boxGetAltRowStyle($j) .
'><td>'.$currentList->getName().'</td></tr>';
+ }
+ }
+
+ echo $HTML->listTableBottom();
+
+ ?>
+ <form method="post" action="<?php echo
getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id ?>">
<input type="hidden" name="post_changes" value="y" />
<input type="hidden" name="add_list" value="y" />
- <input type="hidden" name="group_id"
value="'.$group_id.'" />
- <p><strong>Mailing List Name:</strong><br />
- <strong>'.group_getunixname($group_id).'-<input
type="text" name="list_name" value="" size="10" maxlength="12"
/>@'.$GLOBALS['sys_lists_host'].'</strong><br /></p>
+ <p><strong><?php echo
$Language->getText('mail_admin_addlist', 'form_name'); ?></strong><br />
+ <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>
<p>
- <strong>Is Public?</strong><br />
- <input type="radio" name="is_public" value="1"
checked="checked" /> Yes<br />
- <input type="radio" name="is_public" value="0" />
No</p><p>
- <strong>Description:</strong><br />
+ <strong><?php echo
$Language->getText('mail_admin_addlist', 'form_ispublic'); ?></strong><br />
+ <input type="radio" name="is_public" value="<?php echo
MAIL__MAILING_LIST_IS_PUBLIC; ?>" checked="checked" /> <?php echo
$Language->getText('general', 'yes'); ?><br />
+ <input type="radio" name="is_public" value="<?php echo
MAIL__MAILING_LIST_IS_PRIVATE; ?>" /> <?php echo $Language->getText('general',
'no'); ?></p><p>
+ <strong><?php echo
$Language->getText('mail_admin_addlist', 'form_description'); ?></strong><br />
<input type="text" name="description" value=""
size="40" maxlength="80" /><br /></p>
<p>
- <strong><span style="color:red">Once created, this list
will ALWAYS be attached to your project
- and cannot be deleted!</span></strong></p>
+ <strong><span style="color:red"><?php echo
$Language->getText('mail_admin_addlist', 'warning'); ?></span></strong></p>
<p>
- <input type="submit" name="submit" value="Add This
List" /></p>
- </form>';
-
- mail_footer(array());
-
- } else if ($change_status) {
- /*
- Change a forum to public/private
- */
- mail_header(array('title'=>'Update Mailing
Lists','pagename'=>'mail_admin_change_status'));
+ <input type="submit" name="submit" value="<?php echo
$Language->getText('mail_admin_addlist', 'form_addlist'); ?>" /></p>
+ </form>
+ <?php
- $sql="SELECT list_name,group_list_id,is_public,description ".
- "FROM mail_group_list ".
- "WHERE group_id='$group_id'".
- "ORDER BY list_name";
- $result=db_query($sql);
- $rows=db_numrows($result);
+ } elseif(getIntFromGet('change_status')) {
+
+ $mlFactory = new MailingListFactory($Group);
- if (!$result || $rows < 1) {
- echo '
- <p>No lists found for this project';
- echo db_error();
+ if(!$mlFactory || !is_object($mlFactory) ||
$mlFactory->isError()) {
+ exit_error($Language->getText('general','error'),
$mlFactory->getErrorMessage());
+ }
+
+ mail_header(array(
+ 'title' => $Language->getText('mail_admin_updatelist',
'pagetitle'),
+ 'pagename' => 'mail_admin_updatelist'
+ ));
+
+ $mlArray =& $mlFactory->getMailingLists(true);
+ $mlCount = count($mlArray);
+
+ if($mlCount == 0) {
+ echo '<p>'.$Language->getText('mail_admin_updatelist',
'no_list_found').'</p>';
} else {
- echo '
- <p>
- 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 '.$GLOBALS['sys_name'].'.</p>';
+ echo '<p>'.$Language->getText('mail_admin_updatelist',
'information', array($GLOBALS['sys_name'])).'</p>';
- $title_arr=array();
- $title_arr[]='List';
- $title_arr[]='Status';
- $title_arr[]='';
- $title_arr[]='';
+ $tableHeaders = array();
+ $tableHeaders[] =
$Language->getText('mail_admin_updatelist', 'list');
+ $tableHeaders[] =
$Language->getText('mail_admin_updatelist', 'status');
+ $tableHeaders[] = '';
+ $tableHeaders[] = '';
- echo $GLOBALS['HTML']->listTableTop ($title_arr);
+ echo $HTML->listTableTop($tableHeaders);
- for ($i=0; $i<$rows; $i++) {
- echo '
- <tr '.
$GLOBALS['HTML']->boxGetAltRowStyle($i)
.'><td>'.db_result($result,$i,'list_name').'</td>';
- echo '<td colspan="3">
- <form action="'.$PHP_SELF.'"
method="post">
- <input type="hidden"
name="post_changes" value="y" />
- <input type="hidden"
name="change_status" value="y" />
- <input type="hidden"
name="group_list_id" value="'.db_result($result,$i,'group_list_id').'" />
- <input type="hidden" name="group_id"
value="'.$group_id.'" />
- <table width="100%"><tr>
- <td>
- <div style="font-size:smaller">
- <strong>Is Public?</strong><br
/>
- <input type="radio"
name="is_public" value="1"'.((db_result($result,$i,'is_public')=='1')?'
checked="checked"':'').' /> Yes<br />
- <input type="radio"
name="is_public" value="0"'.((db_result($result,$i,'is_public')=='0')?'
checked="checked"':'').' /> No<br />
- <input type="radio"
name="is_public" value="9"'.((db_result($result,$i,'is_public')=='9')?'
checked="checked"':'').' /> Deleted<br />
- </div></td><td align="right">
- <div style="font-size:smaller">
- <input type="submit"
name="submit" value="Update" /></div>
- </td>
- <td align="center"><a href="http://'.
$GLOBALS['sys_lists_host'] .'/mailman/admin/'
-
.db_result($result,$i,'list_name').'">[Administrate this list in GNU
Mailman]</a>
- </td></tr>
- <tr '.
$GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td colspan="3">
-
<strong>Description:</strong><br />
- <input type="text"
name="description" value="'.
-
db_result($result,$i,'description') .'" size="40" maxlength="80" /><br />
- </td></tr></table></form></td></tr>';
+ for ($i = 0; $i < $mlCount; $i++) {
+ $currentList =& $mlArray[$i];
+ ?>
+ <tr <?php echo
$HTML->boxGetAltRowStyle($i); ?>>
+ <td><?php echo
$currentList->getName(); ?></td>
+ <td colspan="3">
+ <form action="<?php
echo getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id ?>"
method="post">
+ <input
type="hidden" name="post_changes" value="y" />
+ <input
type="hidden" name="change_status" value="y" />
+ <input
type="hidden" name="group_list_id" value="<?php echo $currentList->getID(); ?>"
/>
+ <input
type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
+ <table width="100%">
+ <tr>
+ <td>
+
<div style="font-size:smaller">
+
<strong><?php echo $Language->getText('mail_admin_updatelist',
'form_ispublic'); ?></strong><br />
+
<input type="radio" name="is_public" value="<?php echo
MAIL__MAILING_LIST_IS_PUBLIC; ?>"<?php echo ($currentList->isPublic() ==
MAIL__MAILING_LIST_IS_PUBLIC ? ' checked="checked"' : ''); ?> /> <?php echo
$Language->getText('general', 'yes'); ?><br />
+
<input type="radio" name="is_public" value="<?php echo
MAIL__MAILING_LIST_IS_PRIVATE; ?>"<?php echo ($currentList->isPublic() ==
MAIL__MAILING_LIST_IS_PRIVATE ? ' checked="checked"' : ''); ?> /> <?php echo
$Language->getText('general', 'no'); ?><br />
+
<input type="radio" name="is_public" value="<?php echo
MAIL__MAILING_LIST_IS_DELETED; ?>"<?php echo ($currentList->isPublic() ==
MAIL__MAILING_LIST_IS_DELETED ? ' checked="checked"' : ''); ?> /> <?php echo
$Language->getText('general', 'deleted'); ?><br />
+
</div>
+ </td>
+ <td
align="right">
+
<div style="font-size:smaller">
+
<input type="submit" name="submit" value="<?php echo
$Language->getText('mail_admin_updatelist', 'form_updatelist'); ?>" />
+
</div>
+ </td>
+ <td
align="center">
+
<a href="<?php echo $currentList->getExternalAdminUrl(); ?>">
+
<?php echo $Language->getText('mail_admin_updatelist',
'admin_in_mailman'); ?>
+
</a>
+ </td>
+ </tr>
+ <tr <?php echo
$HTML->boxGetAltRowStyle($i); ?>>
+ <td colspan="3">
+ <strong><?php
echo $Language->getText('mail_admin_updatelist', 'form_description');
?></strong><br />
+
<input type="text" name="description" value="<?php echo
inputSpecialChars($currentList->getDescription()); ?>" size="40" maxlength="80"
/><br />
+ </td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+ <?php
}
- echo $GLOBALS['HTML']->listTableBottom();
+ echo $HTML->listTableBottom();
}
- mail_footer(array());
-
-
} else {
/*
Show main page for choosing
- either moderotor or delete
+ either add or update
*/
- mail_header(array('title'=>'Mailing List
Administration','pagename'=>'mail_admin'));
-
- echo '
- <p>
- <a
href="'.$PHP_SELF.'?group_id='.$group_id.'&add_list=1">Add Mailing
List</a><br />
- <a
href="'.$PHP_SELF.'?group_id='.$group_id.'&change_status=1">Administrate/Update
Lists</a>
- </p>';
- mail_footer(array());
+ mail_header(array(
+ 'title' => $Language->getText('mail_admin',
'pagetitle'),
+ 'pagename' => 'mail_admin')
+ );
+ ?>
+ <ul>
+ <li>
+ <a href="<?php echo
getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id;
?>&add_list=1"><?php echo $Language->getText('mail_admin', 'add_list');
?></a>
+ </li>
+ <li>
+ <a href="<?php echo
getStringFromServer('PHP_SELF'); ?>?group_id=<?php echo $group_id;
?>&change_status=1"><?php echo $Language->getText('mail_admin',
'update_list'); ?></a>
+ </li>
+ </ul>
+ <?php
}
-
+
+ mail_footer(array());
+
} else {
- /*
- Not logged in or insufficient privileges
- */
- if (!$group_id) {
- exit_no_group();
- } else {
- exit_permission_denied();
- }
+ exit_no_group();
}
-?>
+?>
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gforge-commits] gforge/www/mail/admin index.php,1.11,1.12,
gsmet <=
- Prev by Date:
[Gforge-commits] gforge/common/mail MailingList.class, NONE, 1.1 MailingListFactory.class, NONE, 1.1
- Next by Date:
[Gforge-commits] gforge/www/mail mail_utils.php, 1.3, 1.4 index.php, 1.6, 1.7 mail_nav.php, 1.3, NONE
- Previous by thread:
[Gforge-commits] gforge/common/mail MailingList.class, NONE, 1.1 MailingListFactory.class, NONE, 1.1
- Next by thread:
[Gforge-commits] gforge/www/mail mail_utils.php, 1.3, 1.4 index.php, 1.6, 1.7 mail_nav.php, 1.3, NONE
- Index(es):