[vhffs-dev] [658] Repository creation now use only one page |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 658
Author: beuss
Date: 2007-07-04 15:06:47 +0000 (Wed, 04 Jul 2007)
Log Message:
-----------
Repository creation now use only one page
Modified Paths:
--------------
trunk/vhffs-panel/Makefile.am
trunk/vhffs-panel/repository/create.pl
trunk/vhffs-panel/templates/repository/create.tmpl
Removed Paths:
-------------
trunk/vhffs-panel/repository/repository_submit.pl
Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am 2007-07-04 13:06:54 UTC (rev 657)
+++ trunk/vhffs-panel/Makefile.am 2007-07-04 15:06:47 UTC (rev 658)
@@ -158,7 +158,6 @@
repository/index.pl \
repository/prefs_save.pl \
repository/prefs.pl \
- repository/repository_submit.pl \
svn/create.pl \
svn/delete.pl \
svn/index.pl \
Modified: trunk/vhffs-panel/repository/create.pl
===================================================================
--- trunk/vhffs-panel/repository/create.pl 2007-07-04 13:06:54 UTC (rev 657)
+++ trunk/vhffs-panel/repository/create.pl 2007-07-04 15:06:47 UTC (rev 658)
@@ -51,24 +51,47 @@
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 = $panel->{templatedir};
+my $cgi = $panel->{cgi};
-my $templatedir = $vhffs->get_config->get_templatedir;
+my $submitted = $cgi->param('repo_submit');
-my $template = new HTML::Template( filename => $templatedir."/repository/create.tmpl" );
+my $description;
-$template->param( TITLE => gettext("Create a Download Repository") );
-$template->param( REPOSITORY_NAME => gettext("Repository Name") );
-$template->param( GROUP_NAME => gettext("Group owning this repository") );
+if($submitted) {
+ my $user = $panel->{user};
+ my $group = $panel->{group};
+ my $vhffs = $panel->{vhffs};
+ $description = $cgi->param('description');
+ if(!defined $description) {
+ $panel->add_error( gettext('CGI error') );
+ } elsif($description =~ /^\s*$/) {
+ $panel->add_error( gettext('You must enter a description') );
+ } elsif( defined Vhffs::Panel::Repository::create_repository( $vhffs, $groupname, $user, $group ) ) {
+ my $url = '/panel.pl?project='.$panel->{groupname}.'&msg='.gettext('The repository was successfully created !');
+ $panel->redirect($url);
+ } else {
+ $panel->add_error( gettext('An error occured while creating the object. Check that this group doesn\'t already have a download repository') );
+ }
+} else {
+ $description = '';
+}
+if(!$submitted || $panel->has_errors()) {
+ my $template = new HTML::Template( filename => $templatedir."/repository/create.tmpl" );
-$template->param( GROUP => $group->get_groupname );
-$template->param( NAME => $group->get_groupname );
-$template->param( SEND => gettext("Send") );
-$template->param( DESCRIPTION => gettext("Description") );
+ $panel->set_title( gettext('Create a Download Repository') );
+ $template->param( REPOSITORY_NAME => gettext("Repository Name") );
+ $template->param( GROUP_NAME => gettext("Group owning this repository") );
-display Vhffs::Panel::Main($panel, $template->output);
+
+ $template->param( GROUP => $groupname );
+ $template->param( NAME => $groupname );
+ $template->param( SEND => gettext("Send") );
+ $template->param( DESCRIPTION => gettext("Description") );
+ $template->param( DESCRIPTION_VALUE => CGI::escapeHTML($description) );
+
+ display Vhffs::Panel::Main($panel, $template->output);
+}
+
Deleted: trunk/vhffs-panel/repository/repository_submit.pl
===================================================================
--- trunk/vhffs-panel/repository/repository_submit.pl 2007-07-04 13:06:54 UTC (rev 657)
+++ trunk/vhffs-panel/repository/repository_submit.pl 2007-07-04 15:06:47 UTC (rev 658)
@@ -1,101 +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.
-
-
-# This file is a part of VHFFS project
-# Please consider the entire project
-
-# Author: Sylvain Rochet
-
-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 $description = $cgi->param("DESCRIPTION");
-my $templatedir = $vhffs->get_config->get_templatedir;
-
-my $repo_name = $group->get_groupname;
-
-if( ! ( $repo_name =~ /^[a-z0-9]+$/ ) )
-{
- $message = "Your repository name is not correct. It must contains only caracter and numbers";
-}
-elsif( length( $repo_name ) < 3 )
-{
- $message = "Your repository name is not correct. It must contains at least 3 caracters";
-}
-else
-{
- #Create Download Repository
- my $repo = Vhffs::Panel::Repository::create_repository( $vhffs , "$repo_name" , $user , $group );
- if( defined $repo )
- {
- $repo->set_description( $description );
- $repo->commit;
- $message = gettext("The Download repository object was successfully created !");
- }
- else
- {
- $message = gettext( "An error occured while creating the object.It probably already exists" );
- }
-}
-
-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/repository/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/repository/create.tmpl 2007-07-04 13:06:54 UTC (rev 657)
+++ trunk/vhffs-panel/templates/repository/create.tmpl 2007-07-04 15:06:47 UTC (rev 658)
@@ -1,6 +1,4 @@
-<h1><TMPL_VAR NAME="TITLE"></h1>
-
-<form method="post" action="repository_submit.pl">
+<form method="post" action="#">
<p>
<label>
<TMPL_VAR NAME="GROUP_NAME">:
@@ -14,12 +12,12 @@
<TMPL_VAR NAME="NAME">
</p>
<p>
- <label for="PROJECT_USAGE">
+ <label for="description">
<TMPL_VAR NAME="DESCRIPTION">:
</label>
- <textarea name="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">" />
+ <input type="submit" value="<TMPL_VAR NAME="SEND">" name="repo_submit"/>
</p>
</form>