Main Page | Directories | File List | File Members

majordomo_interface.php

Go to the documentation of this file.
00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: majordomo_interface.php 5359 2006-02-14 08:47:46Z toddy $
00006 #
00007 #  Copyright 2002-2003 (c) CERN LCG/SPI.
00008 # 
00009 # The Savane project is free software; you can redistribute it and/or
00010 # modify it under the terms of the GNU General Public License
00011 # as published by the Free Software Foundation; either version 2
00012 # of the License, or (at your option) any later version.
00013 #
00014 # The Savane project is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 # GNU General Public License for more details.
00018 #
00019 # You should have received a copy of the GNU General Public License
00020 # along with the Savane project; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 
00024 require "../include/pre.php";
00025 
00026 global $feedback;
00027 
00028 # this module enables Savannah to communicate with the
00029 # Majordomo (http://www.greatcircle.com/majordomo) mailing list
00030 # manager. Commands to the manager are submitted via email.
00031 
00032 
00033 #----------------------------------------------------------------
00034 # compose message body containing the commands
00035 # for the mailing list server
00036 function maillist_body($addresses,$list_name,$task) 
00037 {
00038         
00039   
00040   switch($task) 
00041     {
00042 
00043     case 'subscribe': 
00044       {
00045         $command="subscribe";
00046         break;
00047       }
00048     case 'unsubscribe': 
00049       {
00050         $command="unsubscribe";
00051         break;
00052       }
00053     default: 
00054       {
00055         $command="error";
00056       }
00057       
00058     }
00059 
00060   # FIXME: foreach exists only in  PHP >= 4
00061   foreach($addresses as $name) 
00062     {
00063       $body .= $command." ".$list_name." ".$name."\n";
00064     }
00065 
00066   $body .= "end\n";
00067   return($body);
00068 }
00069 #----------------------------------------------------------------
00070 
00071 $addresses=array();
00072 
00073 $sql="SELECT * FROM mail_group_list WHERE list_name='$list' ";
00074 $result = db_query ($sql);
00075 $group_id = db_result($result,0,'group_id');
00076 $list_name=$list;
00077 
00078 $res_grp = db_query("SELECT unix_group_name FROM groups WHERE group_id='$group_id'");
00079 $group_name = db_result($res_grp,0,'unix_group_name');
00080 
00081 if (!$group_id) 
00082 { exit_no_group(); }
00083 
00084 $project = project_get_object($group_id);
00085 exit_test_usesmail($group_id);
00086 
00087  
00088 if(!$result || db_numrows($result) != 1) 
00089 {
00090   exit_error('Data Base error (numrows='.db_numrows($result).')');
00091 }
00092 
00093 if (!$mailserver)
00094 {
00095   exit_error("No mailserver configured for the group type this group belongs. Please, contact administrators");
00096 }
00097 # Current, mailserver cannot be guessed, it must be given in the link
00098 #$mailserver=$project->getTypeMailingListHost().$project->getTypeMailingListAddress();  
00099 $subject="mailing list order";
00100 
00101 
00102 if (user_isloggedin()) 
00103 {
00104   if($func== 'send') 
00105     {
00106     mail($mailserver,$subject,$body,"From: ".$user_email);
00107     
00108     #    $location .= "/".$location.$GLOBALS['sys_default_dir']."/mail/index.php";
00109     #$location .= "?group_id=".$group_id;
00110     #print $location;
00111     #exit;
00112     session_redirect($GLOBALS[sys_home]."mail/?group=".$group_name);
00113     exit;
00114     
00115     } 
00116   else 
00117     {
00118       
00119       $addresses[]=user_getemail(user_getid());
00120       $body=maillist_body($addresses,$list_name,$func);
00121       
00122       # Display mail form
00123       # FIXME: does not follow the CODING_STYLE (was written before the
00124       # CODING STYLE)
00125      site_project_header(array('group'=>$group_id,'title'=>'Mailing Lists for '.$project->getName(),'context'=>'mail'));
00126 
00127         ?>
00128         &nbsp;
00129         <P>
00130         <H3>Send a Message to the Mailing List Server</H3>
00131         <P>
00132         <FORM ACTION="<?php print $PHP_SELF ?>?func=send" METHOD="POST">
00133         <INPUT TYPE="HIDDEN" NAME="group_id" VALUE="<?php print $group_id ?>">
00134         <INPUT TYPE="HIDDEN" NAME="list_id" VALUE="<?php print $list_id ?>">
00135         <INPUT TYPE="HIDDEN" NAME="list" VALUE="<?php print $list_name ?>">
00136         <INPUT TYPE="HIDDEN" NAME="mailserver" VALUE="<?php print $mailserver ?>">
00137 
00138         <strong>Your Email Address:</strong><BR>
00139         <strong><?php print user_getemail(user_getid())?></strong>
00140         <INPUT TYPE="HIDDEN" NAME="user_email" VALUE="<?php print user_getemail(user_getid()); ?>">
00141         <P>
00142         <strong>Your Name:</strong><BR>
00143         <strong><?php 
00144 
00145         $my_name=user_getrealname(user_getid());
00146 
00147         print $my_name; ?></strong>
00148         <INPUT TYPE="HIDDEN" NAME="name" VALUE="<?php print $my_name; ?>">
00149         <P>
00150         <strong>Mail Server Address:</strong> <?php print $mailserver ?>
00151         <P>
00152         <strong>Subject:</strong> <?php print $subject ?> <BR>
00153         <P>
00154         <strong>Message:</strong><BR>
00155         <TEXTAREA NAME="body" ROWS="15" COLS="60" WRAP="HARD"><?php print $body ?></TEXTAREA>
00156         <P>
00157         <CENTER>
00158         <INPUT TYPE="SUBMIT" NAME="func" VALUE="send">
00159         </CENTER>
00160         </FORM>
00161         <?php
00162                              
00163                              }
00164 
00165 } 
00166 else 
00167 {
00168   $HTML->header(array('title'=>_("Error")));
00169   
00170   print '<H3>For security reasons you can only send a message through
00171         this interface if you are logged in as a user!</H3>
00172         <P>
00173         You can subscribe to this list without logging in by
00174         sending an email message containing the following
00175         lines to the mail server <strong>'.$mailserver.'</strong>
00176         (you will have to replace the generic address with your email
00177         address).';
00178 
00179   $addresses[]="your.address@your.domain";
00180   $body=maillist_body($addresses,$list_name,$func);
00181   print '<pre>'.$body.'</pre>';
00182 
00183 }
00184 site_project_footer(array());
00185 ?>

Generated on Sun Feb 26 13:23:04 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4