[vhffs-dev] [728] mass subscribes on mailing lists is now possible through web panel

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 728
Author:   gradator
Date:     2007-07-17 06:58:29 +0000 (Tue, 17 Jul 2007)

Log Message:
-----------
mass subscribes on mailing lists is now possible through web panel

Modified Paths:
--------------
    trunk/vhffs-panel/mailinglist/add_sub.pl
    trunk/vhffs-panel/mailinglist/prefs.pl
    trunk/vhffs-panel/templates/mailinglist/prefs.tmpl


Modified: trunk/vhffs-panel/mailinglist/add_sub.pl
===================================================================
--- trunk/vhffs-panel/mailinglist/add_sub.pl	2007-07-16 20:51:06 UTC (rev 727)
+++ trunk/vhffs-panel/mailinglist/add_sub.pl	2007-07-17 06:58:29 UTC (rev 728)
@@ -48,10 +48,9 @@
 use Vhffs::Services::Mailing;
 use Vhffs::Acl;
 use Vhffs::Constants;
+
 my $panel = new Vhffs::Panel::Main();
-if(!$panel)  {
-        exit 0;
-}
+exit 0 unless $panel;
 
 my $vhffs = $panel->{'vhffs'};
 my $session = $panel->{'session'};
@@ -62,11 +61,11 @@
 my $cgi = $panel->{'cgi'};
 my $domain = $cgi->param("DOMAIN");
 my $lpart = $cgi->param("LOCALPART");
-my $member = $cgi->param("MEMBER");
+my $memberlist = $cgi->param("MEMBERS");
 
 my $template;
 my $subtemplate;
-my $message;
+my $message = "";
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 
@@ -74,7 +73,8 @@
 
 $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 
-if( ( ! defined $lpart ) ||( ! defined $domain )  )
+
+if( ( ! defined $lpart ) || ( ! defined $domain ) || ( ! defined $memberlist ) )
 {
 	$message = gettext( "CGI Error!");
 }
@@ -90,28 +90,30 @@
 {
 	$message = gettext("You're not allowed to do this (ACL rights)");
 }
-elsif( Vhffs::Functions::valid_mail( $member ) < 0 )
-{
-	$message = gettext("Not valid mail");
-}
-else
-{
-	if( $list->add_sub( $member , Vhffs::Constants::ML_RIGHT_SUB )  < 0 )
-	{
-		$message = gettext( "This member already exists on this list !" );
+
+my @members = split (/^/, $memberlist);
+chomp (@members);
+map(s/^\s*(\S*)\s*$/$1/, @members);
+@members = grep (!/^$/, @members);
+
+my $member;
+foreach $member ( @members )  {
+
+	if( Vhffs::Functions::valid_mail( $member ) < 0 )  {
+		$message .= sprintf( gettext("%s is not a valid mail"), $member );
 	}
-	else
-	{
-		$message = gettext( "Successfully added" );
-        Vhffs::Functions::send_mail(
-            $vhffs->get_config->get_listengine_listmaster,
-            $member,
-            sprintf(gettext('[%s] You\'ve been added to the list %s'), $list->get_prefix, $list->get_localpart.'@'.$list->get_domain),
-            sprintf(gettext("Greetings,\n\nYou've been added to the list %s on platform %s.\n\nYou may get some help on listengine by sending an email to %s-request\@%s with subject help.\n\nCheers."), $list->get_localpart.'@'.$list->get_domain, $vhffs->get_config->get_host_name, $list->get_localpart, $list->get_domain),
-            $vhffs);
+	elsif( $list->add_sub( $member , Vhffs::Constants::ML_RIGHT_SUB )  < 0 ) {
+		$message .= sprintf( gettext( "%s is already subscribed" ), $member );
 	}
-#	$message = $list->add_sub( $member , 0 );
-
+	else {
+		$message .= sprintf( gettext( "%s has been successfully added" ), $member );
+		Vhffs::Functions::send_mail(
+			$vhffs->get_config->get_listengine_listmaster,
+			$member,
+			sprintf(gettext('[%s] You\'ve been added to the list %s'), $list->get_prefix, $list->get_localpart.'@'.$list->get_domain),
+			sprintf(gettext("Greetings,\n\nYou've been added to the list %s on platform %s.\n\nYou may get some help on listengine by sending an email to %s-request\@%s with subject help.\n\nCheers."), $list->get_localpart.'@'.$list->get_domain, $vhffs->get_config->get_host_name, $list->get_localpart, $list->get_domain),
+			$vhffs);
+	}
 }
 
 $template->param( MESSAGE => $message );

Modified: trunk/vhffs-panel/mailinglist/prefs.pl
===================================================================
--- trunk/vhffs-panel/mailinglist/prefs.pl	2007-07-16 20:51:06 UTC (rev 727)
+++ trunk/vhffs-panel/mailinglist/prefs.pl	2007-07-17 06:58:29 UTC (rev 728)
@@ -151,9 +151,9 @@
 	
 	$template->param( TITLE_MEMBERS => gettext("Manage members") );
 	$template->param( TITLE_LIST_MEMBERS => gettext("List all members") );
-	$template->param( TITLE_ADD_MEMBER => gettext("Add a member") );
-	$template->param( TEXT_ADD_MEMBER => gettext("Email adress") );
-	$template->param( BUTTON_ADD_MEMBER => gettext("Add !") );
+	$template->param( TITLE_ADD_MEMBERS => gettext("Add members") );
+	$template->param( TEXT_ADD_MEMBERS => gettext("Addresses (one per line)") );
+	$template->param( BUTTON_ADD_MEMBERS => gettext("Add them !") );
 	$template->param( CHECK_OPENARCHIVE => "checked" ) if( $list->get_open_archive == 1 );
 	$template->param( CHECK_REPLYTO => "checked" ) if( $list->get_replyto == 1 );
 

Modified: trunk/vhffs-panel/templates/mailinglist/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/mailinglist/prefs.tmpl	2007-07-16 20:51:06 UTC (rev 727)
+++ trunk/vhffs-panel/templates/mailinglist/prefs.tmpl	2007-07-17 06:58:29 UTC (rev 728)
@@ -86,20 +86,20 @@
 	<tmpl_var name="LIST_MEMBERS">
 </table>
 
-<h3><tmpl_var name="TITLE_ADD_MEMBER"></h3>
+<h3><tmpl_var name="TITLE_ADD_MEMBERS"></h3>
 
 <form method="post" action="add_sub.pl">
 
 	<p>
 		<label for="USERNAME">
-			<tmpl_var name="TEXT_ADD_MEMBER">
+			<tmpl_var name="TEXT_ADD_MEMBERS">
 		</label>
-		<input type="text" name="MEMBER" id="USERNAME" />
+		<textarea name="MEMBERS" rows="7" cols="50"></textarea>
 	</p>
 	<p class="button">
 		<input type="hidden" name="DOMAIN" value="<tmpl_var name="VALUE_DOMAIN">" />
 		<input type="hidden" name="LOCALPART" value="<tmpl_var name="VALUE_LOCALPART">" />
-		<input type="submit" value="<tmpl_var name="BUTTON_ADD_MEMBER">" />
+		<input type="submit" value="<tmpl_var name="BUTTON_ADD_MEMBERS">" />
 	</p>
 </form>
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/