[vhffs-dev] [1776] No more HTML::Template in cvs/prefs

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


Revision: 1776
Author:   beuss
Date:     2011-05-19 13:10:11 +0200 (Thu, 19 May 2011)
Log Message:
-----------
No more HTML::Template in cvs/prefs

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Services/Cvs.pm
    trunk/vhffs-panel/Makefile.am
    trunk/vhffs-panel/cvs/prefs.pl
    trunk/vhffs-panel/templates/Makefile.am

Removed Paths:
-------------
    trunk/vhffs-panel/cvs/delete.pl
    trunk/vhffs-panel/templates/cvs/prefs.tmpl

Modified: trunk/vhffs-api/src/Vhffs/Services/Cvs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Cvs.pm	2011-05-19 11:10:00 UTC (rev 1775)
+++ trunk/vhffs-api/src/Vhffs/Services/Cvs.pm	2011-05-19 11:10:11 UTC (rev 1776)
@@ -180,7 +180,12 @@
 	return $self->{'cvsroot'};
 }
 
+sub get_reponame {
+    my ($self) = @_;
+    return $self->get_cvsroot;
+}
 
+
 sub set_cvsroot
 {
 	my ($self , $value) = @_;	

Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am	2011-05-19 11:10:00 UTC (rev 1775)
+++ trunk/vhffs-panel/Makefile.am	2011-05-19 11:10:11 UTC (rev 1776)
@@ -872,7 +872,6 @@
 	admin/stats.pl \
 	admin/su.pl \
 	cvs/create.pl \
-	cvs/delete.pl \
 	cvs/index.pl \
 	cvs/prefs.pl \
 	dns/create.pl \

Deleted: trunk/vhffs-panel/cvs/delete.pl
===================================================================
--- trunk/vhffs-panel/cvs/delete.pl	2011-05-19 11:10:00 UTC (rev 1775)
+++ trunk/vhffs-panel/cvs/delete.pl	2011-05-19 11:10:11 UTC (rev 1776)
@@ -1,104 +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 utf8;
-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::Main;
-use Vhffs::Group;
-use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Panel::Group;
-use Vhffs::Services::Cvs;
-
-my $panel = new Vhffs::Panel::Main();
-exit 0 unless $panel;
-my $session = $panel->get_session;
-exit 0 unless $session;
-
-my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
-my $user = $panel->{'user'};
-my $cgi = $panel->{'cgi'};
-my $templatedir = $panel->{'templatedir'};
-
-my $message;
-
-my $owner = $cgi->param('PROJECT_OWNER' );
-my $repo = $cgi->param( 'REPO_NAME' );
-my $sure = $cgi->param( 'DELETE' );
-
-my $cvs;
-
-unless( defined $repo && defined $sure )
-{
-	$message = sprintf( gettext('CGI Error !') );
-}
-elsif( !defined($cvs = Vhffs::Services::Cvs::get_by_cvsroot($vhffs, $repo) ) )
-{
-	$message = gettext( 'Cannot retrieve informations about this CVS repository' );
-}
-elsif( ! $user->can_delete( $cvs ) )
-{
-	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
-}
-elsif( $sure == 0 )
-{
-	$message = gettext( 'This CVS repository will NOT be deleted' );
-}
-else
-{
-	$cvs->set_status( Vhffs::Constants::TO_DELETE );
-	if( $cvs->commit < 0 )
-	{
-		$message = gettext('An error occured while deleting the CVS repository');
-	}  
-	else  
-	{
-		$message = gettext('This CVS will be deleted');
-	}
-}
-
-my $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-$template->param( MESSAGE => $message );
-
-$panel->build( $template );
-$panel->display;

Modified: trunk/vhffs-panel/cvs/prefs.pl
===================================================================
--- trunk/vhffs-panel/cvs/prefs.pl	2011-05-19 11:10:00 UTC (rev 1775)
+++ trunk/vhffs-panel/cvs/prefs.pl	2011-05-19 11:10:11 UTC (rev 1776)
@@ -32,7 +32,6 @@
 
 use utf8;
 use POSIX qw(locale_h);
-use HTML::Template;
 use locale;
 use Locale::gettext;
 use CGI;
@@ -41,12 +40,9 @@
 
 
 use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Main;
 use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Panel::Object;
 use Vhffs::Services::Cvs;
+use Vhffs::Constants;
 
 my $panel = new Vhffs::Panel::Main();
 exit 0 unless $panel;
@@ -64,58 +60,33 @@
 my $cvs;
 
 unless( defined $repo_name ) {
-	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext( 'CGI Error !' ) );
+    $panel->render('misc/message.tt', { message => gettext( 'CGI Error !' ) } );
 } elsif( !defined($cvs = Vhffs::Services::Cvs::get_by_cvsroot($vhffs, $repo_name) ) ) {
-	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext( 'Cannot get informations on this object' ) );
+    $panel->render('misc/message.tt', { message => gettext( 'Cannot get informations on this object' ) } );
 } elsif( ! $user->can_view($cvs) ) {
-	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
+    $panel->render('misc/message.tt', { message => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) } );
 } else {
-
-	if( defined $cgi->param('cvs_public_submit') ) {
+	if( defined $cgi->param('save_prefs_submit') ) {
 		unless( $user->can_modify($cvs) ) {
 			$panel->add_error( gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
 		} elsif( !defined($cgi->param('public')) ) {
 			$panel->add_error( gettext("CGI Error !") );
 		} else {
-			$cvs->set_public($cgi->param('public'));
-			$cvs->set_status(Vhffs::Constants::WAITING_FOR_MODIFICATION);
-			if($cvs->commit > 0) {
-				$panel->add_info(gettext("CVS repository updated"));
-			} else {
-				$panel->add_error(gettext("An error occured during CVS repository update"));
-			}
+            my $want_public = int($cgi->param('public'));
+            if($want_public != $cvs->is_public) {
+                $cvs->set_public($want_public);
+    			$cvs->set_status(Vhffs::Constants::WAITING_FOR_MODIFICATION);
+                if($cvs->commit > 0) {
+                    $panel->add_info(gettext("CVS repository updated"));
+                } else {
+                    $panel->add_error(gettext("An error occured during CVS repository update"));
+                }
+            }
 		}
 	}
 
-	$template = new HTML::Template( filename => $templatedir."/panel/cvs/prefs.tmpl" );
-
-	$panel->set_title( gettext('Admin CVS Repository') );
-
-	$template->param( TEXT_REPONAME => $cvs->get_cvsroot );
-	$template->param( VALUE_OID => $cvs->get_oid );
-	$template->param( TEXT_PUBLIC => gettext("Is this CVS repository public ??") );
-	$template->param( PUBLIC_YES => gettext("Yes") );
-	$template->param( PUBLIC_NO => gettext("No") );
-	$template->param( TEXT_SEND => gettext("Modify") );
-	$template->param( TEXT_DELETE_CVS => gettext("Delete this project") );
-	$template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. This cvs repository will be DESTROYED.") );
-	$template->param( ASK_DELETE_CVS => gettext("Are you SURE you want DELETE this cvs repository ?") );
-	$template->param( YES => gettext("Yes I'm sure of what I do") );
-	$template->param( NO => gettext("No, I'm not sure, I prefer to keep this project.") );
-	$template->param( TEXT_DELETE => gettext("Delete") );
-
-	$template->param( TEXT_ACL_ADMIN => "Admin Rights on this object (ACL)" );
-	$template->param( EXPLAIN_ADMIN_ACL => "You can Manage rights on this service for each user in the VHFFS database. Please read help before manage it." );
-	$template->param( ADMIN_ACL => "Ok, go to ACL admin" );
-
-	$template->param( PUBLIC => $cvs->is_public );
-
-	my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $cvs );
-	$template->param( ADMIN_PART => $adminpart->output ) if( $adminpart );
+    my $vars = {};
+    $vars->{repository} = $cvs;
+    $vars->{type} = 'cvs';
+    $panel->render( 'scm/prefs.tt', $vars );
 }
-
-$panel->build( $template );
-$panel->display;

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-19 11:10:00 UTC (rev 1775)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-19 11:10:11 UTC (rev 1776)
@@ -57,7 +57,6 @@
 	admin/web/search.tmpl \
 	admin/cron/part.tmpl \
 	admin/cron/search.tmpl \
-	cvs/prefs.tmpl \
 	menu/context.tmpl \
 	menu/context-group.tmpl \
 	menu/context-modo.tmpl \

Deleted: trunk/vhffs-panel/templates/cvs/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/cvs/prefs.tmpl	2011-05-19 11:10:00 UTC (rev 1775)
+++ trunk/vhffs-panel/templates/cvs/prefs.tmpl	2011-05-19 11:10:11 UTC (rev 1776)
@@ -1,63 +0,0 @@
-<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_REPONAME"></h2>
-
-<form method="post" action="/cvs/prefs.pl" accept-charset="utf-8">
-	<p>
-		<label>
-			<TMPL_VAR ESCAPE=1 NAME="TEXT_PUBLIC">
-		</label>
-		<select name="public" size="2" multiple="multiple">
-		<option value="1" <TMPL_IF NAME="PUBLIC">selected="selected"</TMPL_IF>><TMPL_VAR ESCAPE=1 NAME="PUBLIC_YES">
-		<option value="0" <tmpl_unless name="PUBLIC">selected="selected"</tmpl_unless>><TMPL_VAR ESCAPE=1 NAME="PUBLIC_NO">
-		</select>
-	</p>
-	
-
-	<p class="button" id="buttonSend">
-		<input type="hidden" name="name" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_REPONAME">" />
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_SEND">" name="cvs_public_submit"/>
-	</p>
-</form>
-
-
-<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_ADMIN"></h2>
-
-<form method="post" action="../acl/view.pl" accept-charset="utf-8">
-<p><TMPL_VAR ESCAPE=1 NAME="EXPLAIN_ADMIN_ACL"></p>
-
-	<p class="button" id="buttonSendAcl">
-        <input type="hidden" name="target_oid" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_OID">"/>
-        <input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="ADMIN_ACL">" />
-	</p>
-</form>
-
-
-<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_DELETE_CVS"></h2>
-
-<form method="post" action="delete.pl" accept-charset="utf-8">
-	<fieldset class="delete">
-		<legend><TMPL_VAR ESCAPE=1 NAME="ASK_DELETE_CVS">:</legend>
-		
-		<p class="warning"><TMPL_VAR ESCAPE=1 NAME="TEXT_BEFORE_DELETE"></p>
-
-		<p>
-			<input type="radio" name="DELETE" id="DELETE_NO" value="0" checked="checked" />
-			<label for="DELETE_NO">
-				<TMPL_VAR ESCAPE=1 NAME="NO">
-			</label>
-		</p>
-		<p>
-			<input type="radio" name="DELETE" id="DELETE_YES" value="1" />	
-			<label for="DELETE_YES">
-				<TMPL_VAR ESCAPE=1 NAME="YES">
-			</label>
-		</p>
-	</fieldset>
-		
-		
-	<p class="button" id="buttonSend">
-		<input type="hidden" name="REPO_NAME" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_REPONAME">" />
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_DELETE">" />
-	</p>
-</form>
-
-<TMPL_VAR ESCAPE=0 NAME="ADMIN_PART">


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