[vhffs-dev] [645] Today is a great day, you' ll never have to reenter project description if it's wrong !

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


Revision: 645
Author:   beuss
Date:     2007-06-15 15:28:54 +0000 (Fri, 15 Jun 2007)

Log Message:
-----------
Today is a great day, you'll never have to reenter project description if it's wrong !

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/Main.pm
    trunk/vhffs-panel/group/create.pl
    trunk/vhffs-panel/panel.pl
    trunk/vhffs-panel/templates/group/create.tmpl


Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2007-06-12 17:06:47 UTC (rev 644)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2007-06-15 15:28:54 UTC (rev 645)
@@ -361,6 +361,7 @@
 		}
 	}
 
+
 	my $maintemplate = new HTML::Template( filename => $templatedir."/main/panel.tmpl" );
 	$maintemplate->param( PANEL_TITLE => sprintf( gettext( "%s's Panel" ), $config->get_host_name ) );
 	$maintemplate->param( THEME => $theme );
@@ -390,6 +391,7 @@
 		$this->{'groupname'} = $projectname;
 	}
 
+    $this->add_info( $cgi->param('msg') ) if(defined $cgi->param('msg'));
 	$maintemplate->param( HEADER => $this->generate_header );
 
 	return $this;

Modified: trunk/vhffs-panel/group/create.pl
===================================================================
--- trunk/vhffs-panel/group/create.pl	2007-06-12 17:06:47 UTC (rev 644)
+++ trunk/vhffs-panel/group/create.pl	2007-06-15 15:28:54 UTC (rev 645)
@@ -42,27 +42,50 @@
 use Vhffs::User;
 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 $vhffs = $panel->{vhffs};
+my $user = $panel->{user};
+my $cgi = $panel->{cgi};
 
 my $templatedir = $vhffs->get_config->get_templatedir;
+my $submitted = defined($cgi->param('project_submit'));
+my $groupname;
+my $description;
 
-my $template = new HTML::Template( filename => $templatedir."/group/create.tmpl" );
+if($submitted) {
+    # User posted the form, let's check it
+    $groupname = $cgi->param('project_name');
+    $description = $cgi->param('description');
+    if( $groupname !~ /^[a-z0-9]{3,12}$/ ) {
+        $panel->add_error( gettext('Groupname must contain between 3 and 12 characters, only letters or numbers in lower case') );
+    } elsif( $description =~ /^\s*$/ ) {
+        $panel->add_error( gettext('You must enter a description') );
+    } elsif( ! defined(my $group = Vhffs::Panel::Group::create_group( $groupname , $user , $vhffs, $description ) ) ) {
+        $panel->add_error( gettext('Error creating group (maybe a group with the same name already exists)') );
+    } else {
+        my $url = '/user/projects.pl?msg='.gettext('Project Successfully created !');
+        $panel->redirect($url);
+    }
+}
 
-$template->param( TITLE => gettext("Create a Project") );
-$template->param( PROJECT_NAME => gettext("Project Name") );
-$template->param( TEXT_OWNER => gettext("Owner") );
-$template->param( OWNER => $user->get_username );
-$template->param( SEND => gettext("Send") );
-$template->param( DESCRIPTION => gettext("Description") );
+if( ! $submitted || $panel->has_errors() ) {
+    my $template = new HTML::Template( filename => $templatedir.'/group/create.tmpl' );
 
-display Vhffs::Panel::Main($panel, $template->output);
+    $panel->set_title( gettext('Create a Project') );
+    $template->param( PROJECT_NAME => gettext('Project Name') );
+    $template->param( TEXT_OWNER => gettext('Owner') );
+    $template->param( OWNER => $user->get_username );
+    $template->param( SEND => gettext('Send') );
+    $template->param( DESCRIPTION => gettext('Description') );
+    $template->param( PROJECT_VALUE => CGI::escapeHTML( $groupname ) );
+    $template->param( DESCRIPTION_VALUE => CGI::escapeHTML( $description ) );
+
+    display Vhffs::Panel::Main($panel, $template->output);
+}
+

Modified: trunk/vhffs-panel/panel.pl
===================================================================
--- trunk/vhffs-panel/panel.pl	2007-06-12 17:06:47 UTC (rev 644)
+++ trunk/vhffs-panel/panel.pl	2007-06-15 15:28:54 UTC (rev 645)
@@ -102,7 +102,6 @@
 	if( defined $projectname )
 	{
 		$template = $panel->project_info;
-        $template->param( MESSAGE => $cgi->param('msg') ) if(defined $cgi->param('msg'));
 	}
 	else
 	{

Modified: trunk/vhffs-panel/templates/group/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/create.tmpl	2007-06-12 17:06:47 UTC (rev 644)
+++ trunk/vhffs-panel/templates/group/create.tmpl	2007-06-15 15:28:54 UTC (rev 645)
@@ -1,27 +1,23 @@
-<h1><TMPL_VAR NAME="TITLE"></h1>
-
-<form method="post" action="project_submit.pl">
-
-	<p>
+<form method="post" action="#">
+	<p>
 		<label>
 			<TMPL_VAR NAME="TEXT_OWNER">:
 		</label>
 		<TMPL_VAR NAME="OWNER">
 	</p>
-	<p>
-		<label for="PROJECT_NAME">
+	<p>
+		<label for="project_name">
 			<TMPL_VAR NAME="PROJECT_NAME">: 
 		</label>
-		<input type="text" size="12" maxlength="12" name="PROJECT_NAME" id="PROJECT_NAME"/>
-		</span>
+		<input type="text" size="12" maxlength="12" name="project_name" id="project_name" value="<tmpl_var name="PROJECT_VALUE">"/>
 	</p>
-	<p>
-		<label for="PROJECT_USAGE">
+	<p>
+		<label for="description">
 			<TMPL_VAR NAME="DESCRIPTION">:
 		</label>
-		<textarea name="PROJECT_USAGE" id="PROJECT_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="project_submit"/>
 	</p>
 </form>


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