[vhffs-dev] [1832] No more HTML::Template in admin/su

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


Revision: 1832
Author:   beuss
Date:     2011-05-31 22:04:21 +0200 (Tue, 31 May 2011)
Log Message:
-----------
No more HTML::Template in admin/su

Modified Paths:
--------------
    trunk/vhffs-panel/admin/su.pl
    trunk/vhffs-panel/templates/Makefile.am

Added Paths:
-----------
    trunk/vhffs-panel/templates/admin/misc/su.tt

Removed Paths:
-------------
    trunk/vhffs-panel/templates/admin/misc/su.tmpl

Modified: trunk/vhffs-panel/admin/su.pl
===================================================================
--- trunk/vhffs-panel/admin/su.pl	2011-05-31 20:04:07 UTC (rev 1831)
+++ trunk/vhffs-panel/admin/su.pl	2011-05-31 20:04:21 UTC (rev 1832)
@@ -32,7 +32,6 @@
 
 use utf8;
 use POSIX qw(locale_h);
-use HTML::Template;
 use locale;
 use Locale::gettext;
 use CGI;
@@ -40,66 +39,33 @@
 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::Admin;
 use Vhffs::Constants;
 
-my $panel = new Vhffs::Panel::Main();
-exit 0 unless $panel;
-my $session = $panel->get_session;
-exit 0 unless $session;
+my $panel = new Vhffs::Panel::Admin();
 
-my $vhffs = $panel->{'vhffs'};
-my $cgi = $panel->{'cgi'};
-my $templatedir = $panel->{templatedir};
+my $vhffs = $panel->{vhffs};
+my $cgi = $panel->{cgi};
 
 my $username = $cgi->param('user');
 
-if( $panel->{user}->is_admin != 1 )
-{
-	
-	my $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$template->param( MESSAGE =>  gettext( 'You\'re not an administrator' ) );
-	$panel->build( $template );
-}
-else
-{
-	unless( defined $username )  {
-		my $template = new HTML::Template( filename => $templatedir."/panel/admin/misc/su.tmpl" );
-		$template->param( TITLE => gettext("Change user-id") );	
-		$template->param( TEXT => gettext("Username") );
-		$template->param( TEXT_SUBMIT => gettext("Su !") );
-		$panel->build( $template );
-	}
-	else
-	{
-		my $message = '';
+if(defined $username) {
+    my $user = Vhffs::User::get_by_username( $vhffs , $username );
+    if(defined $user) {
+        my $session = $panel->get_session;
+        $session->clear('username');
+        $session->clear('uid');
+        $session->param('username', $user->get_username);
+        $session->param('uid', $user->get_uid);
+        $session->flush();
 
-		my $user = Vhffs::User::get_by_username( $vhffs , $username );
-		if( defined $user )
-		{
-			$session->clear('username');
-			$session->clear('uid');
-			$session->param('username', $user->get_username);
-			$session->param('uid', $user->get_uid);
-			$session->flush();
-
-			$panel = new Vhffs::Panel::Main();
-			$session = $panel->get_session;
-			$message = gettext( sprintf( 'Su successful with name %s' , $user->get_username) );
-		}
-		else
-		{
-			$message = sprintf( gettext( 'User %s does not exist' ) , $username  );
-		}
-
-		my $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-		$template->param( MESSAGE => $message );
-		$panel->build( $template );
-	}
+        $panel->render('misc/message.tt', {
+            message => gettext( sprintf( 'Su successful with name %s' , $user->get_username) ),
+            refresh_url => '/panel.pl'
+        });
+    } else {
+        $panel->add_error( gettext('User %s does not exist'), $username);
+    }
 }
 
-$panel->display;
+$panel->render('admin/misc/su.tt');

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-31 20:04:07 UTC (rev 1831)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-31 20:04:21 UTC (rev 1832)
@@ -4,7 +4,6 @@
 	admin/main/general.tmpl \
 	admin/main/main.tmpl \
 	admin/misc/list.tmpl \
-	admin/misc/su.tmpl \
 	admin/object/search.tmpl \
 	admin/tag/create.tmpl \
 	admin/tag/edit.tmpl \
@@ -37,6 +36,7 @@
 	admin/misc/list.tt \
 	admin/misc/search.tt \
 	admin/misc/stats.tt \
+	admin/misc/su.tt \
 	admin/moderation/index.tt \
 	admin/object/edit.tt \
 	admin/object/list.tt \

Deleted: trunk/vhffs-panel/templates/admin/misc/su.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/misc/su.tmpl	2011-05-31 20:04:07 UTC (rev 1831)
+++ trunk/vhffs-panel/templates/admin/misc/su.tmpl	2011-05-31 20:04:21 UTC (rev 1832)
@@ -1,13 +0,0 @@
-<h1><TMPL_VAR ESCAPE=1 NAME="TITLE"></h1>
-
-<form method="post" action="/admin/su.pl" accept-charset="utf-8">
-	<p>
-		<label for="TEXT">
-			<TMPL_VAR ESCAPE=1 NAME="TEXT">
-		</label>
-		<input type="text" name="user" id="user" />
-	</p>
-	<p class="button" id="buttonSend">
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_SUBMIT">" />
-	</p>
-</form>

Added: trunk/vhffs-panel/templates/admin/misc/su.tt
===================================================================
--- trunk/vhffs-panel/templates/admin/misc/su.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/admin/misc/su.tt	2011-05-31 20:04:21 UTC (rev 1832)
@@ -0,0 +1,9 @@
+<h1>[% 'Change user ID' | i18n | html %]</h1>
+
+<form method="post" action="/admin/su.pl" accept-charset="utf-8">
+	<p><label for="TEXT">[% 'Username:' | i18n | html %]</label>
+		<input type="text" name="user" id="user" /></p>
+	<p class="button" id="buttonSend">
+		<input type="submit" value="[% 'Su!' | i18n | html %]" />
+	</p>
+</form>


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