[vhffs-dev] [660] Webarea creation now uses only one page.

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


Revision: 660
Author:   beuss
Date:     2007-07-04 17:45:32 +0000 (Wed, 04 Jul 2007)

Log Message:
-----------
Webarea creation now uses only one page.

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

Removed Paths:
-------------
    trunk/vhffs-panel/web/web_submit.pl


Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am	2007-07-04 16:01:11 UTC (rev 659)
+++ trunk/vhffs-panel/Makefile.am	2007-07-04 17:45:32 UTC (rev 660)
@@ -170,8 +170,7 @@
 	web/delete.pl \
 	web/index.pl \
 	web/prefs_save.pl \
-	web/prefs.pl \
-	web/web_submit.pl
+	web/prefs.pl
 
 panelthemesdir = @PANELDIR@
 nobase_panelthemes_DATA = \

Modified: trunk/vhffs-panel/templates/web/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/web/create.tmpl	2007-07-04 16:01:11 UTC (rev 659)
+++ trunk/vhffs-panel/templates/web/create.tmpl	2007-07-04 17:45:32 UTC (rev 660)
@@ -1,6 +1,4 @@
-<h1><TMPL_VAR NAME="TITLE"></h1>
-
-<form method="post" action="web_submit.pl" class="largeLabel">
+<form method="post" action="#" class="largeLabel">
 	<p>
 		<label>		
 			<TMPL_VAR NAME="GROUP_NAME">: 
@@ -8,21 +6,21 @@
 		<TMPL_VAR NAME="GROUP">
 	</p>
 	<p>
-		<label for="SERVERNAME">		
+		<label for="servername">		
 			<TMPL_VAR NAME="SERVERNAME_TEXT">:
 		</label>
-		<input type="text" name="SERVERNAME" id="USAGE" value="<TMPL_VAR NAME="SERVERNAME_VALUE">"/>
+		<input type="text" name="servername" id="servername" value="<TMPL_VAR NAME="SERVERNAME_VALUE">"/>
 	</p>
 	<p class="warning">
 		<TMPL_VAR NAME="SERVERNAME_WARNING">
 	</p>
 	<p>
-		<label for="USAGE">		
-			<TMPL_VAR NAME="MOTIVATION">:
+		<label for="description">		
+			<TMPL_VAR NAME="DESCRIPTION">:
 		</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="web_submit" />
 	</p>
 </form>

Modified: trunk/vhffs-panel/web/create.pl
===================================================================
--- trunk/vhffs-panel/web/create.pl	2007-07-04 16:01:11 UTC (rev 659)
+++ trunk/vhffs-panel/web/create.pl	2007-07-04 17:45:32 UTC (rev 660)
@@ -50,34 +50,53 @@
     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 $templatedir = $vhffs->get_config->get_templatedir;
+my $vhffs = $panel->{vhffs};
+my $groupname = $panel->{groupname};
+my $templatedir = $panel->{templatedir};
+my $cgi = $panel->{cgi};
 
-my $template = new HTML::Template( filename => $templatedir."/web/create.tmpl" );
-my $config = $vhffs->get_config;
-my $default_domain = $config->get_default_apache_domain;
+my $submitted = defined($cgi->param('web_submit'));
+
 my $servername;
+my $description;
 
-
-if( defined $default_domain )
-{
-	$servername = gettext("<new site>.") . $default_domain;	
-	$template->param( SERVERNAME_VALUE => $servername);
+if($submitted) {
+    my $user = $panel->{user};
+    my $group = $panel->{group};
+    $servername = $cgi->param('servername');
+    $description = $cgi->param('description');
+    if(! (defined $servername && defined $description) ) {
+        $panel->add_error( gettext('CGI error') );
+    } elsif( !Vhffs::Functions::check_domain_name($servername) ) {
+        $panel->add_error( gettext('Invalid servername (doesn\'t conform to domain names rules)') );
+    } elsif( $description =~ /^\s*$/ ) {
+        $panel->add_error( gettext('You must enter a description') );
+    } elsif( defined(Vhffs::Panel::Web::create_web( $vhffs, $servername, $description, $user, $group)) ) {
+        my $url = '/panel.pl?project='.$panel->{groupname}.'&msg='.gettext('The webarea was successfully created !');
+        $panel->redirect($url);
+    } else {
+        $panel->add_error( gettext('Error creating webarea.') );
+    }
+} else {
+    my $config = $vhffs->get_config;
+    my $default_domain = $config->get_default_apache_domain;
+    if( defined $default_domain ) {
+    	$servername = gettext("<new site>.") . $default_domain;	
+    }
 }
 
-$template->param( TITLE => gettext("Create a web space") );
-$template->param( SERVERNAME_TEXT => gettext("Adress (ServerName directive)") );
-$template->param( SERVERNAME_WARNING => gettext("Be careful, if you want create www.domain.tld, you should create a webspace with servername as domain.tld. VHFFS redirect all request from www.domain.tld to domain.tld") );
-$template->param( GROUP_NAME => gettext("Group owning this web space") );
+if(!$submitted || $panel->has_errors()) {
+    my $template = new HTML::Template( filename => $templatedir.'/web/create.tmpl' );
+    $panel->set_title( gettext("Create a web space") );
+    $template->param( SERVERNAME_TEXT => gettext("Adress (ServerName directive)") );
+    $template->param( SERVERNAME_WARNING => gettext("Be careful, if you want create www.domain.tld, you should create a webspace with domain.tld as servername. VHFFS redirect all request from www.domain.tld to domain.tld") );
+    $template->param( SERVERNAME_VALUE => CGI::escapeHTML($servername) );
+    $template->param( GROUP_NAME => gettext("Group owning this web space") );
 
+    $template->param( GROUP => $groupname );
+    $template->param( SEND => gettext("Send") );
+    $template->param( DESCRIPTION => gettext("Tell us what the use of this web space will be") );
+    $template->param( DESCRIPTION_VALUE => CGI::escapeHTML($description) );
 
-$template->param( GROUP => $group->get_groupname );
-$template->param( SEND => gettext("Send") );
-$template->param( MOTIVATION => gettext("Tell us what the use of this web space will be") );
-
-display Vhffs::Panel::Main($panel, $template->output);
+    display Vhffs::Panel::Main($panel, $template->output);
+}

Deleted: trunk/vhffs-panel/web/web_submit.pl
===================================================================
--- trunk/vhffs-panel/web/web_submit.pl	2007-07-04 16:01:11 UTC (rev 659)
+++ trunk/vhffs-panel/web/web_submit.pl	2007-07-04 17:45:32 UTC (rev 660)
@@ -1,99 +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 $templatedir = $panel->{templatedir};
-my $user = $panel->{'user'};
-my $group = $panel->{'group'};
-my $groupname = $panel->{'groupname'};
-my $cgi = $panel->{'cgi'};
-my $message;
-
-my $servername = $cgi->param("SERVERNAME");
-
-my $description = $cgi->param("USAGE");
-my $template;
-
-
-
-if( ( ! defined $servername ) || ( ! defined $description ) )
-{
-	$message = gettext( "CGI Error!" );
-}
-elsif( ( ! ( $servername =~ /^[a-z0-9](([a-z0-9]\-{0,1})+\.)+[a-z]{2,4}$/ ) ) || ( $servername =~ /\.\./ ) )
-# [a-z](([a-z0-9]\-{0,1})+\.{0,1})+[a-z]{2,4} ?
-{
-	$message = gettext( "Servername error. Please enter a valid servername" );
-}
-else
-{
-
-	my $web = Vhffs::Panel::Web::create_web( $vhffs, $servername, $description, $user, $group );
-	
-	if( defined $web )
-	{
-		$message = gettext("Web area successfully created !");
-	}
-	else
-	{
-		$message = gettext( "Error while creating the webarea, it probably already exists !" );
-	}
-}
-
-$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( $panel , $template->output );


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