[vhffs-dev] [659] Svn repository creation now uses only one page. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 659
Author: beuss
Date: 2007-07-04 16:01:11 +0000 (Wed, 04 Jul 2007)
Log Message:
-----------
Svn repository creation now uses only one page.
Modified Paths:
--------------
trunk/vhffs-panel/Makefile.am
trunk/vhffs-panel/svn/create.pl
trunk/vhffs-panel/templates/svn/create.tmpl
Removed Paths:
-------------
trunk/vhffs-panel/svn/svn_submit.pl
Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am 2007-07-04 15:06:47 UTC (rev 658)
+++ trunk/vhffs-panel/Makefile.am 2007-07-04 16:01:11 UTC (rev 659)
@@ -163,7 +163,6 @@
svn/index.pl \
svn/prefs_save.pl \
svn/prefs.pl \
- svn/svn_submit.pl \
user/delete.pl \
user/prefs.pl \
user/projects.pl \
Modified: trunk/vhffs-panel/svn/create.pl
===================================================================
--- trunk/vhffs-panel/svn/create.pl 2007-07-04 15:06:47 UTC (rev 658)
+++ trunk/vhffs-panel/svn/create.pl 2007-07-04 16:01:11 UTC (rev 659)
@@ -50,30 +50,50 @@
exit 0;
}
-my $vhffs = $panel->{'vhffs'};
-my $session = $panel->{'session'};
-my $maintemplate = $panel->{'template'};
-my $user = $panel->{'user'};
-my $group = $panel->{'group'};
+my $vhffs = $panel->{vhffs};
+my $templatedir = $panel->{templatedir};
+my $groupname = $panel->{groupname};
+my $cgi = $panel->{cgi};
-my $templatedir = $vhffs->get_config->get_templatedir;
-my $template;
-if( ! defined $group )
-{
- $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
- $template->param( MESSAGE => gettext("CGI Error") );
+my $submitted = $cgi->param('svn_submit');
+
+my $reponame;
+my $description;
+
+if($submitted) {
+ my $user = $panel->{user};
+ my $group = $panel->{group};
+ $reponame = $cgi->param('reponame');
+ $description = $cgi->param('description');
+ if(!(defined $reponame && defined $description)) {
+ $panel->add_error( gettext('CGI error') );
+ } elsif( !Vhffs::Services::Svn::check_name($reponame) ) {
+ $panel->add_error( gettext('Invalid reponame. It must contain between 3 and 64 characters, only lowercase letters and numbers') );
+ } elsif( $description =~ /^\s*$/) {
+ $panel->add_error( gettext('You must enter a description') );
+ } elsif( defined Vhffs::Panel::Svn::create_svn( $vhffs, $reponame, $description, $user, $group ) ) {
+ my $url = '/panel.pl?project='.$panel->{groupname}.'&msg='.gettext('The SVN object was successfully created !');
+ $panel->redirect($url);
+ } else {
+ $panel->add_error( gettext('An error occured while creating the svn repository') );
+ }
+} else {
+ $reponame = '';
+ $description = '';
}
-else
-{
- $template = new HTML::Template( filename => $templatedir."/svn/create.tmpl" );
- $template->param( TITLE => gettext("Create a Subversion Repository") );
+if(!$submitted || $panel->has_errors) {
+ my $template = new HTML::Template( filename => $templatedir.'/svn/create.tmpl' );
+
+ $panel->set_title( gettext("Create a Subversion Repository") );
$template->param( REPOSITORY_NAME => gettext("Repository Name") );
+ $template->param( REPOSITORY_VALUE => CGI::escapeHTML($reponame) );
$template->param( GROUP_NAME => gettext("Group owning this Subversion repository") );
-
- $template->param( GROUP => $group->get_groupname );
+ $template->param( GROUP => $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);
}
-display Vhffs::Panel::Main($panel, $template->output);
+
Deleted: trunk/vhffs-panel/svn/svn_submit.pl
===================================================================
--- trunk/vhffs-panel/svn/svn_submit.pl 2007-07-04 15:06:47 UTC (rev 658)
+++ trunk/vhffs-panel/svn/svn_submit.pl 2007-07-04 16:01:11 UTC (rev 659)
@@ -1,91 +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 $repo_name = $cgi->param("REPOSITORY_NAME");
-my $description = $cgi->param("DESCRIPTION");
-
-my $templatedir = $vhffs->get_config->get_templatedir;
-
-my $svn;
-
-if( ! defined( $repo_name ) ) {
- $message = gettext("CGI Error !");
-} elsif( ( length( $repo_name ) < 3 ) || ( ! ( $repo_name =~ /^[a-z0-9]+$/)) ) {
- $message = gettext("The repository name is too short. It must contains at least 3 caracters, and must only contain letters and numbers");
-} elsif( ( $svn = Vhffs::Panel::Svn::create_svn( $vhffs , $repo_name , $description, $user , $group ) ) < 0 ) {
- if( $svn == -2 ) {
- $message = gettext( "This repository name already exists" );
- } elsif( $svn == -3 ) {
- $message = gettext( "An error occured while setting up the ACL" );
- } else {
- $message = gettext( "An error occured while creating the object" );
- }
-} else {
- $message = gettext("The Subversion object was successfully created !");
-}
-
-
-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/svn/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/svn/create.tmpl 2007-07-04 15:06:47 UTC (rev 658)
+++ trunk/vhffs-panel/templates/svn/create.tmpl 2007-07-04 16:01:11 UTC (rev 659)
@@ -1,6 +1,4 @@
-<h1><TMPL_VAR NAME="TITLE"></h1>
-
-<form method="post" action="svn_submit.pl">
+<form method="post" action="#">
<p>
<label>
<TMPL_VAR NAME="GROUP_NAME">:
@@ -8,18 +6,18 @@
<TMPL_VAR NAME="GROUP">
</p>
<p>
- <label for="REPOSITORY_NAME">
+ <label for="reponame">
<TMPL_VAR NAME="REPOSITORY_NAME">:
</label>
- <input type="text" name="REPOSITORY_NAME" id="REPOSITORY_NAME" />
+ <input type="text" name="reponame" id="reponame" value="<tmpl_var name="REPOSITORY_VALUE">"/>
</p>
<p>
- <label for="PROJECT_USAGE">
- <TMPL_VAR NAME="DESCRIPTION">:
- </label>
- <textarea name="DESCRIPTION" id="PROJECT_USAGE" cols="45" rows="7"></textarea>
+ <label for="PROJECT_USAGE">
+ <TMPL_VAR NAME="description">:
+ </label>
+ <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="svn_submit"/>
</p>
</form>