[vhffs-dev] [1751] No more HTML::Template in upavatar.

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


Revision: 1751
Author:   beuss
Date:     2011-05-15 17:42:00 +0200 (Sun, 15 May 2011)
Log Message:
-----------
No more HTML::Template in upavatar.

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm
    trunk/vhffs-panel/object/upavatar.pl

Modified: trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm	2011-05-15 14:54:44 UTC (rev 1750)
+++ trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm	2011-05-15 15:42:00 UTC (rev 1751)
@@ -35,7 +35,7 @@
 use utf8;
 
 use Vhffs::Functions;
-use Digest::MD5 qw(md5 md5_hex md5_base64);
+use Digest::MD5 qw(md5_hex);
 
 sub store_avatar
 {

Modified: trunk/vhffs-panel/object/upavatar.pl
===================================================================
--- trunk/vhffs-panel/object/upavatar.pl	2011-05-15 14:54:44 UTC (rev 1750)
+++ trunk/vhffs-panel/object/upavatar.pl	2011-05-15 15:42:00 UTC (rev 1751)
@@ -40,12 +40,7 @@
 use strict;
 
 use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Object;
-use Vhffs::User;
-use Vhffs::Main;
 use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Panel::User;
 use Vhffs::Panel::Avatar;
 
 my $panel = new Vhffs::Panel::Main();
@@ -56,7 +51,6 @@
 my $data;
 			   
 my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
 my $cgi = $panel->{'cgi'};
 my $type;
@@ -74,12 +68,9 @@
 $filename = $cgi->param( 'avatar' );
 $object = Vhffs::Object::get_by_oid( $vhffs , $cgioid );
 
-$message = "";
+$message;
 
-$|=1;
-
-if( $filename )
-{
+if( $filename ) {
 	$tmpfile = $cgi->tmpFileName( $filename );	
 }
 
@@ -88,51 +79,30 @@
 my $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
 
 # Commit all the changes for the current user
-if( $panel->use_avatars == 0 )
-{
+if( $panel->use_avatars == 0 ) {
 	$message = gettext( "This platform does not provide avatar support" );
-}
-elsif( ! defined $cgioid )
-{
+} elsif( ! defined $cgioid ) {
 	$message = gettext( "Object-ID error" );
-}
-elsif( ! defined( $object ) )
-{
+} elsif( ! defined( $object ) ) {
 	$message = gettext( "Cannot find object" );
-}
-elsif( !$user->can_modify( $object ) )
-{
+} elsif( !$user->can_modify( $object ) ) {
 	$message = gettext( "No enough rights" );
-}
-else
-{
+} else {
 	@rstat = stat ( $tmpfile );
 	$fsize = $rstat[7];
 
-	if(  ! defined ( $filename =~ /\.png$/ ) )
-	{
+	if( $filename !~ /\.[Pp][Nn][Gg]$/ ) {
 		$message .= gettext( "Filetype not supported, only png is supported" );
-	}
-	elsif( $fsize > 20000 )
-	{
+	} elsif( $fsize > 20000 ) {
 		$message .= gettext( "Uploaded file is too big. The maximum size is 20 Kbytes." );
-	}
-	else
-	{
-		my $return;
+	} else {
 		( $type ) = ( $filename =~ ( /\.([a-zA-Z]+$)/ ) );
-		if( ( $return =  Vhffs::Panel::Avatar::store_avatar( $vhffs , $object , $tmpfile , $type ) ) > 0 )
-		{
+		if( ( Vhffs::Panel::Avatar::store_avatar( $vhffs , $object , $tmpfile , $type ) ) > 0 ) {
 			$message = gettext( "Successfully created or updated avatar" );
-		}
-		else
-		{
+		} else {
 			$message = gettext( "Error when uploading avatar for this object" );
 		}
 	}
 }
-$template->param( MESSAGE => $message );
 
-$panel->set_refresh_url( "/panel.pl" );
-$panel->build( $template );
-$panel->display;
+$panel->render('misc/message.tt', { message => $message });


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