[vhffs-dev] [648] Mail domain creation now use only one page.

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


Revision: 648
Author:   beuss
Date:     2007-06-16 07:53:40 +0000 (Sat, 16 Jun 2007)

Log Message:
-----------
Mail domain creation now use only one page.

Modified Paths:
--------------
    trunk/vhffs-panel/Makefile.am
    trunk/vhffs-panel/mail/create.pl
    trunk/vhffs-panel/templates/mail/create.tmpl

Removed Paths:
-------------
    trunk/vhffs-panel/mail/submit.pl


Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am	2007-06-15 18:09:27 UTC (rev 647)
+++ trunk/vhffs-panel/Makefile.am	2007-06-16 07:53:40 UTC (rev 648)
@@ -123,7 +123,6 @@
 	mail/save_catchall.pl \
 	mail/spambox.pl \
 	mail/spamvirus.pl \
-	mail/submit.pl \
 	mailinglist/add_sub.pl \
 	mailinglist/change_right.pl \
 	mailinglist/create.pl \

Modified: trunk/vhffs-panel/mail/create.pl
===================================================================
--- trunk/vhffs-panel/mail/create.pl	2007-06-15 18:09:27 UTC (rev 647)
+++ trunk/vhffs-panel/mail/create.pl	2007-06-16 07:53:40 UTC (rev 648)
@@ -39,35 +39,54 @@
 use strict;
 
 use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Main;
 use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Panel::Group;
+use Vhffs::Functions;
 
 my $panel = new Vhffs::Panel::Main();
 if(!$panel)  {
     exit 0;
 }
 
-my $vhffs = $panel->{'vhffs'};
-my $session = $panel->{'session'};
-my $maintemplate = $panel->{'template'};
-my $user = $panel->{'user'};
-my $group = $panel->{'group'};
-my $groupname = $panel->{'groupname'};
+my $vhffs = $panel->{vhffs};
+my $group = $panel->{group};
+my $user = $panel->{user};
+my $groupname = $panel->{groupname};
+my $cgi = $panel->{cgi};
 
-my $templatedir = $vhffs->get_config->get_templatedir;
+my $domain;
+my $description;
+my $submitted = defined($cgi->param('mail_submit'));
 
-my $template = new HTML::Template( filename => $templatedir."/mail/create.tmpl" );
+if($submitted) {
+    $domain = $cgi->param('domain');
+    $description = $cgi->param('description');
+    if(! Vhffs::Functions::check_domain_name($domain) ) {
+        $panel->add_error( gettext('Invalid domain name') );
+    } elsif( $description =~ /^\s*$/ ) {
+        $panel->add_error( gettext('You must enter a description') );
+    } elsif( !defined(Vhffs::Panel::Mail::create_mail( $vhffs , $domain , $description, $user , $group )) ) {
+        $panel->add_error( gettext('An error occured while creating the mail area') );
+    } else {
+        my $url = '/panel.pl?project='.$groupname.'&msg='.gettext('Mail domain successfully created !');
+        $panel->redirect($url);
+    }
+}
 
-$template->param( TITLE => gettext("Create a mail space") );
-$template->param( DOMAIN_TEXT => gettext("Domain") );
-$template->param( GROUP_NAME => gettext("Group owning this web space") );
+if( !$submitted || $panel->has_errors() ) {
+    my $templatedir = $vhffs->get_config->get_templatedir;
 
+    my $template = new HTML::Template( filename => $templatedir.'/mail/create.tmpl' );
 
-$template->param( GROUP => $group->get_groupname );
-$template->param( SEND => gettext("Send") );
-$template->param( MOTIVATION => gettext("Tell us what the use of this mail space will be") );
+    $panel->set_title( gettext('Create a mail space') );
+    $template->param( DOMAIN_TEXT => gettext('Domain') );
+    $template->param( DOMAIN_VALUE => CGI::escapeHTML($domain) );
+    $template->param( GROUP_NAME => gettext('Group owning this mail domain') );
 
-display Vhffs::Panel::Main($panel, $template->output);
+    $template->param( GROUP => $groupname );
+    $template->param( SEND => gettext('Send') );
+    $template->param( DESCRIPTION_TEXT => gettext('Tell us for what purpose you want to create this mail domain') );
+    $template->param( DESCRIPTION_VALUE => CGI::escapeHTML($description) );
+
+    display Vhffs::Panel::Main($panel, $template->output);
+}
+

Deleted: trunk/vhffs-panel/mail/submit.pl
===================================================================
--- trunk/vhffs-panel/mail/submit.pl	2007-06-15 18:09:27 UTC (rev 647)
+++ trunk/vhffs-panel/mail/submit.pl	2007-06-16 07:53:40 UTC (rev 648)
@@ -1,94 +0,0 @@
-#!%PERL% -w
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-
-use POSIX qw(locale_h);
-use HTML::Template;
-use locale;
-use Locale::gettext;
-use CGI;
-use CGI::Session;
-use strict;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Group;
-use Vhffs::Main;
-use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Panel::Group;
-
-my $panel = new Vhffs::Panel::Main;
-if(!$panel)  {
-        exit 0;
-}
-
-my $vhffs = $panel->{'vhffs'};
-my $session = $panel->{'session'};
-my $maintemplate = $panel->{'template'};
-my $user = $panel->{'user'};
-my $group = $panel->{'group'};
-my $groupname = $panel->{'groupname'};
-my $cgi = $panel->{'cgi'};
-my $message;
-
-my $domain = $cgi->param("DOMAIN");
-
-my $description = $cgi->param("USAGE");
-
-
-my $mail;
-
-my $templatedir = $vhffs->get_config->get_templatedir;
-
-if( ( ! defined $description ) || ( ! defined $domain ) )
-{
-	$message = gettext("CGI Error");
-}
-elsif( ! ( $domain =~ /^[a-zA-Z0-9\-\.]+$/ )  )
-{
-	$message = gettext("Invalid mail domain");
-}
-elsif( defined ( $mail = Vhffs::Panel::Mail::create_mail( $vhffs , $domain , $description, $user , $group ) ))
-{
-	$message = gettext("Mail area successfully created !");
-}
-else
-{
-	$message = gettext( "An error occured while creating the mail area" );
-}
-
-
-my $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
-$template->param( MESSAGE => $message );
-
-set_refresh_url Vhffs::Panel::Main($panel, "/panel.pl?project=$groupname", 0);
-display Vhffs::Panel::Main($panel, $template->output);

Modified: trunk/vhffs-panel/templates/mail/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/mail/create.tmpl	2007-06-15 18:09:27 UTC (rev 647)
+++ trunk/vhffs-panel/templates/mail/create.tmpl	2007-06-16 07:53:40 UTC (rev 648)
@@ -1,5 +1,4 @@
-<h1><TMPL_VAR NAME="TITLE"></h1>
-<form method="post" action="submit.pl" class="largeLabel">
+<form method="post" action="#">
 	<p>
 		<label>		
 			<TMPL_VAR NAME="GROUP_NAME">: 
@@ -7,18 +6,18 @@
 		<TMPL_VAR NAME="GROUP">
 	</p>
 	<p>
-		<label for="DOMAIN">
+		<label for="domain">
 			<TMPL_VAR NAME="DOMAIN_TEXT">: 
 		</label>	
-		<input type="text" name="DOMAIN" id="DOMAIN"/>
+		<input type="text" name="domain" id="domain" value="<tmpl_var name="DOMAIN_VALUE">"/>
 	</p>
 	<p>
-		<label for="USAGE">
-			<TMPL_VAR NAME="MOTIVATION">:
+		<label for="description">
+			<TMPL_VAR NAME="DESCRIPTION_TEXT">:
 		</label>	
-		<textarea name="USAGE" id="USAGE" cols="45" rows="7"></textarea>
+		<textarea name="description" id="description" cols="45" rows="7"><tmpl_var name="DESCRIPTION_VALUE"></textarea>
 	</p>
 	<p class="button" id="buttonSend">
-		<input type="submit" value="<TMPL_VAR NAME="SEND">" />
+		<input type="submit" value="<TMPL_VAR NAME="SEND">" name="mail_submit"/>
 	</p>
 </form>


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