[vhffs-dev] [579] DNS creation now use one page and display filled in data if an error occurs .

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


Revision: 579
Author:   beuss
Date:     2007-04-18 21:48:41 +0000 (Wed, 18 Apr 2007)

Log Message:
-----------
DNS creation now use one page and display filled in data if an error occurs.
Fixed a tiny layout issue in cvs create template.

Modified Paths:
--------------
    trunk/vhffs-panel/dns/create.pl
    trunk/vhffs-panel/templates/cvs/create.tmpl
    trunk/vhffs-panel/templates/dns/create.tmpl

Removed Paths:
-------------
    trunk/vhffs-panel/dns/dns_submit.pl


Modified: trunk/vhffs-panel/dns/create.pl
===================================================================
--- trunk/vhffs-panel/dns/create.pl	2007-04-18 20:46:39 UTC (rev 578)
+++ trunk/vhffs-panel/dns/create.pl	2007-04-18 21:48:41 UTC (rev 579)
@@ -12,6 +12,7 @@
 use lib '%VHFFS_LIB_DIR%';
 use Vhffs::User;
 use Vhffs::Main;
+use Vhffs::Functions;
 use Vhffs::Panel::Main;
 use Vhffs::Panel::Menu;
 use Vhffs::Panel::Group;
@@ -27,18 +28,46 @@
 my $user = $panel->{'user'};
 my $group = $panel->{'group'};
 
+my $cgi = $panel->{cgi};
+my $domain_name = $cgi->param('DOMAIN_NAME');
+my $description = $cgi->param('DESCRIPTION');
+
+my $submitted = defined($cgi->param('dns_submit'));
+
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $template = new HTML::Template( filename => $templatedir."/dns/create.tmpl" );
+if($submitted) {
+    if( !Vhffs::Functions::check_domain_name($domain_name) ) {
+        $panel->add_error( gettext('Invalid domain name') );
+    } elsif( $description =~ /^\s*$/ ) {
+        $panel->add_error( gettext('You must enter a description') );
+    } else {
+        my $dns = Vhffs::Panel::DNS::create_dns( $vhffs, $domain_name, $description, $user, $group );
+        if( defined $dns ) {
+            my $url = '/panel.pl?project='.$panel->{groupname}.'&msg='.gettext('The DNS object was successfully created !');
+            $panel->redirect($url);
+        } else {
+          $panel->add_error( gettext('An error occured while creating the object. The domain is not correct or aleady exists in Vhffs database') );
+        }
+    }
+}
 
-$template->param( TITLE => gettext("Create a DNS ") );
-$template->param( DOMAIN_NAME => gettext("Domain Name") );
-$template->param( INFOS_DNS => gettext("Be careful ! You must give the reason why you want to host this domain on our servers.") );
-$template->param( DNS_SERVER => gettext("DNS servers:") );
-$template->param( GROUP_NAME => gettext("Group owning this DNS") );
-$template->param( GROUP => $group->get_groupname );
+if(!$submitted || $panel->has_errors()) {
+    my $template = new HTML::Template( filename => $templatedir.'/dns/create.tmpl' );
 
-$template->param( SEND => gettext("Send") );
-$template->param( DESCRIPTION => gettext("Description") );
+    $panel->set_title( gettext('Create a DNS') );
 
-display Vhffs::Panel::Main($panel, $template->output);
+    $template->param( DOMAIN_NAME => gettext('Domain Name') );
+    $template->param( DOMAIN_NAME_VALUE => $domain_name );
+
+    $template->param( INFOS_DNS => gettext('Be careful ! You must give the reason why you want to host this domain on our servers.') );
+    $template->param( DNS_SERVER => gettext('DNS servers:') );
+    $template->param( GROUP_NAME => gettext('Group owning this DNS') );
+    
+    $template->param( GROUP => $group->get_groupname );
+    $template->param( SEND => gettext('Send') );
+    $template->param( DESCRIPTION => gettext('Description') );
+    $template->param( DESCRIPTION_VALUE => $description );
+
+    display Vhffs::Panel::Main($panel, $template->output);
+}

Deleted: trunk/vhffs-panel/dns/dns_submit.pl
===================================================================
--- trunk/vhffs-panel/dns/dns_submit.pl	2007-04-18 20:46:39 UTC (rev 578)
+++ trunk/vhffs-panel/dns/dns_submit.pl	2007-04-18 21:48:41 UTC (rev 579)
@@ -1,87 +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_name = $cgi->param("DOMAIN_NAME");
-my $description = $cgi->param("DESCRIPTION");
-
-my $templatedir = $vhffs->get_config->get_templatedir;
-
-
-
-if( ! ( $domain_name =~ /^[a-z0-9\.\-]+$/ ) )
-{
-	$message = gettext('Invalid domain name');
-} else {
-    my $dns = Vhffs::Panel::DNS::create_dns( $vhffs, $domain_name, $description, $user, $group );
-    if( defined $dns ) {
-    	$message = gettext('The DNS object was successfully created !');
-    } else {
-    	$message = gettext('An error occured while creating the object. The domain is not correct or aleady exists in Vhffs database');
-    }
-}
-
-
-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/cvs/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/cvs/create.tmpl	2007-04-18 20:46:39 UTC (rev 578)
+++ trunk/vhffs-panel/templates/cvs/create.tmpl	2007-04-18 21:48:41 UTC (rev 579)
@@ -1,5 +1,3 @@
-<h1><TMPL_VAR NAME="TITLE"></h1>
-
 <form method="post" action="create.pl">
 	<p>
 		<label>		

Modified: trunk/vhffs-panel/templates/dns/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/dns/create.tmpl	2007-04-18 20:46:39 UTC (rev 578)
+++ trunk/vhffs-panel/templates/dns/create.tmpl	2007-04-18 21:48:41 UTC (rev 579)
@@ -1,6 +1,4 @@
-<h1><TMPL_VAR NAME="TITLE"></h1>
-
-<form method="post" action="dns_submit.pl">
+<form method="post" action="create.pl">
 	<p>
 		<TMPL_VAR NAME="INFOS_DNS">
 	</p>
@@ -20,15 +18,15 @@
 		<label for="DOMAIN_NAME">		
 			<TMPL_VAR NAME="DOMAIN_NAME">: 
 		</label>
-		<input type="text" name="DOMAIN_NAME" id="DOMAIN_NAME"/>
+		<input type="text" name="DOMAIN_NAME" id="DOMAIN_NAME" value="<tmpl_var name="DOMAIN_NAME_VALUE">"/>
 	</p>
 	<p>
 		<label for="PROJECT_USAGE">		
 			<TMPL_VAR NAME="DESCRIPTION">:
 		</label>
-		<textarea name="DESCRIPTION" id="DESCRIPTION" 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">" />
+	<p class="button">
+		<input type="submit" value="<TMPL_VAR NAME="SEND">" name="dns_submit" />
 	</p>
 </form>


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