[vhffs-dev] [1016] Fixed many UTF-8 problems on the panel, fixed many compilation problems, a full check of everything is required

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


Revision: 1016
Author:   gradator
Date:     2007-10-22 21:07:59 +0000 (Mon, 22 Oct 2007)

Log Message:
-----------
Fixed many UTF-8 problems on the panel, fixed many compilation problems, a full check of everything is required

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Listengine.pm
    trunk/vhffs-api/src/Vhffs/Object.pm
    trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm
    trunk/vhffs-api/src/Vhffs/Panel/Main.pm
    trunk/vhffs-panel/admin/broadcast_submit.pl
    trunk/vhffs-panel/admin/broadcast_view.pl
    trunk/vhffs-panel/group/prefs.pl
    trunk/vhffs-panel/mailinglist/prefs.pl
    trunk/vhffs-panel/object/resubmit.pl
    trunk/vhffs-panel/user/prefs.pl


Modified: trunk/vhffs-api/src/Vhffs/Listengine.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Listengine.pm	2007-10-22 12:58:47 UTC (rev 1015)
+++ trunk/vhffs-api/src/Vhffs/Listengine.pm	2007-10-22 21:07:59 UTC (rev 1016)
@@ -119,7 +119,7 @@
     push( @result , sprintf( gettext( "You asked to be subscribed to the following list:\n\n%s\n\n" ) , $list->get_listname) );
     push( @result , sprintf( gettext( "However you are (%s) already subscribed to this list.\n")  , $from ) );
     push( @result , "\n" );
-    push( @result , gettext( "The state of you subscription was not changed, you are still subscribed\n") , $hash  );
+    push( @result , gettext( "The state of you subscription was not changed, you are still subscribed\n") );
     push( @result , "\n" );
 
     return( \@result );
@@ -312,6 +312,7 @@
     my $list = shift;
     my $hash = shift;
 
+    my @result;
 
     push( @result , sprintf( gettext( "The message with the following id %s") , $hash ) );
     push( @result , sprintf( gettext( "present in the moderation queue for the list %s") , $list->get_listname ) );
@@ -330,6 +331,7 @@
     my $list = shift;
     my $hash = shift;
 
+    my @result;
 
     push( @result , sprintf( gettext( "Message with id: %s") , $hash ) );
     push( @result , sprintf( gettext( "was removed from the moderation queue from the list %s") , $list->get_listname ) );
@@ -346,6 +348,7 @@
     my $list = shift;
     my $hash = shift;
 
+    my @result;
 
     push( @result , sprintf( gettext( "Message with id: %s") , $hash ) );
     push( @result , sprintf( gettext( "present in the moderation queue for the list %s") , $list->get_listname ) );
@@ -363,6 +366,8 @@
     my $list = shift;
     my $hash = shift;
 
+    my @result;
+
     push( @result , sprintf( gettext( "Mail with id %s") , $hash ) );
     push( @result , sprintf( gettext( "in the moderation queue of the list %s") , $list->get_listname ) );
     push( @result , gettext( "was sent on the list.\n" ) );
@@ -415,7 +420,6 @@
     
     push( @result , sprintf( gettext( "A new person wants to subscribe to the following mailing list:\n  %s\n\n" ) , $list->get_listname) );
     push( @result , sprintf( gettext( "His email address is:\n  %s\n" ) , $from) );
-    push( @result , $subject );
     push( @result , "\n" );
     push( @result , gettext( "To accept this subscriber, send a message to\n" ) );
     push( @result , sprintf( gettext( "  %s-request\@%s\nwith the following subject :\n  \"subscription accept %s %s\" \n" ) , $list->get_localpart , $list->get_domain , $from, $pass) );

Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm	2007-10-22 12:58:47 UTC (rev 1015)
+++ trunk/vhffs-api/src/Vhffs/Object.pm	2007-10-22 21:07:59 UTC (rev 1016)
@@ -61,19 +61,11 @@
 
 sub new
 {
-    my $main;
-    my $owner;
-    my $id;
-    my $this;
-    my $self;
-    my $class;
+    my ( $this , $main , $id , $owner_uid , $owner_gid ) = @_;
     
-    
-    ( $this , $main , $id , $owner_uid , $owner_gid ) = @_;
-    
-    $self={};
+    my $self = {};
 
-    $class = ref($this) || $this;
+    my $class = ref($this) || $this;
     bless($self , $class );
   
     return undef if ( ! defined $main );
@@ -82,9 +74,8 @@
     $self->{'db'} = $main->get_db_object;
     $self->{'owner_uid'} = $owner_uid;
     $self->{'owner_gid'} = $owner_gid;
-    $self->{'description'} = "";
+    $self->{'description'} = '';
     
-    
     if ( defined $id )
     {
         $self->{'object_id'} = $id;
@@ -100,7 +91,7 @@
 sub _new {
     my ($class, $main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $refuse_reason, $state, $type) = @_;
     
-    $self = {};
+    my $self = {};
 
     bless($self, $class);
 
@@ -360,8 +351,8 @@
 	my $message = shift;
 	$message = $message;
 
-	$query = 'INSERT INTO vhffs_history(object_id, date, message)  VALUES(?, ?, ?)';
-	$request = $self->{'db'}->prepare( $query );
+	my $query = 'INSERT INTO vhffs_history(object_id, date, message)  VALUES(?, ?, ?)';
+	my $request = $self->{'db'}->prepare( $query );
 	$request->execute( $self->{'object_id'}, time(), $message ) or return -2;
 
 	return $self->{'db'}->last_insert_id(undef, undef, 'vhffs_history', undef);;
@@ -380,10 +371,8 @@
 	my $query = 'SELECT * FROM vhffs_history WHERE object_id=?';
 	my $request = $self->{'db'}->prepare( $query );
 
-	return undef if( ! $request->execute( $self->{'object_id'} ) );
-
-	$temp = $request->fetchall_hashref('history_id');
-	return $temp;
+	return undef unless $request->execute( $self->{'object_id'} );
+	return $request->fetchall_hashref('history_id');
 }
 
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm	2007-10-22 12:58:47 UTC (rev 1015)
+++ trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm	2007-10-22 21:07:59 UTC (rev 1016)
@@ -86,24 +86,13 @@
 	my $vhffs = shift;
 	my $object = shift;
 
-    my $config = $vhffs->get_config;
-    my $datadir = $config->get_datadir . "/avatar";
-	
-	return undef unless( defined $object );
+	return undef unless defined $object;
 
-	$digest = md5_hex( $object->get_oid );
-	$dir = $datadir . "/" . substr( $digest , 0 , 2 ) . "/" . substr( $digest , 2 , 2 ) . "/" .substr( $digest , 4 , 2 );
-	$path = $dir . "/" .$object->get_oid;
+	my $digest = md5_hex( $object->get_oid );
+	my $path = $vhffs->get_config->get_datadir.'/avatar/'.substr( $digest , 0 , 2 ).'/'.substr( $digest , 2 , 2 ).'/'.substr( $digest , 4 , 2 ).'/'.$object->get_oid;;
 
-	if( -f $path )
-	{
-		return( $path );
-	}
-	else
-	{
-		return( undef );
-	}
-
+	return undef unless -f $path;
+	return $path;
 }
 
 1;

Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2007-10-22 12:58:47 UTC (rev 1015)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2007-10-22 21:07:59 UTC (rev 1016)
@@ -289,7 +289,7 @@
 	bless( $this, $class );
 
 	my $cgi = new CGI;
-	$cgi->charset('utf-8');
+	$cgi->charset('UTF-8');
 	$this->{cgi} = $cgi;
 
 	my $vhffs = init Vhffs::Main;

Modified: trunk/vhffs-panel/admin/broadcast_submit.pl
===================================================================
--- trunk/vhffs-panel/admin/broadcast_submit.pl	2007-10-22 12:58:47 UTC (rev 1015)
+++ trunk/vhffs-panel/admin/broadcast_submit.pl	2007-10-22 21:07:59 UTC (rev 1016)
@@ -30,6 +30,7 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 
+use strict;
 use utf8;
 use POSIX qw(locale_h);
 use HTML::Template;
@@ -37,9 +38,8 @@
 use Locale::gettext;
 use CGI;
 use CGI::Session;
-use strict;
+use Encode;
 
-
 use lib '%VHFFS_LIB_DIR%';
 use Vhffs::User;
 use Vhffs::Group;
@@ -66,8 +66,8 @@
 my $projectname = $session->param("project");
 
 
-my $subject      = $cgi->param("SUBJECT");
-my $body         = $cgi->param("BODY");
+my $subject      = Encode::decode_utf8( $cgi->param('SUBJECT') );
+my $body         = Encode::decode_utf8( $cgi->param('BODY') );
 
 my $templatedir  = $vhffs->get_config->get_templatedir;
 

Modified: trunk/vhffs-panel/admin/broadcast_view.pl
===================================================================
--- trunk/vhffs-panel/admin/broadcast_view.pl	2007-10-22 12:58:47 UTC (rev 1015)
+++ trunk/vhffs-panel/admin/broadcast_view.pl	2007-10-22 21:07:59 UTC (rev 1016)
@@ -30,6 +30,7 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 
+use strict;
 use utf8;
 use POSIX qw(locale_h);
 use HTML::Template;
@@ -37,7 +38,6 @@
 use Locale::gettext;
 use CGI;
 use CGI::Session;
-use strict;
 
 use lib '%VHFFS_LIB_DIR%';
 use Vhffs::User;

Modified: trunk/vhffs-panel/group/prefs.pl
===================================================================
--- trunk/vhffs-panel/group/prefs.pl	2007-10-22 12:58:47 UTC (rev 1015)
+++ trunk/vhffs-panel/group/prefs.pl	2007-10-22 21:07:59 UTC (rev 1016)
@@ -37,6 +37,7 @@
 use Locale::gettext;
 use CGI;
 use CGI::Session;
+use Encode;
 use strict;
 
 use lib '%VHFFS_LIB_DIR%';
@@ -78,8 +79,8 @@
 		unless( $user->can_modify( $group ) ) {
 			$panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
 		} else {
-			my $description = $cgi->param( 'description' );
-			my $realname = $cgi->param( 'realname' );
+			my $description = Encode::decode_utf8( $cgi->param( 'description' ) );
+			my $realname = Encode::decode_utf8( $cgi->param( 'realname' ) );
 
 			unless( defined $description  &&  defined $realname ) {
 				$panel->add_error( gettext('CGI error') );

Modified: trunk/vhffs-panel/mailinglist/prefs.pl
===================================================================
--- trunk/vhffs-panel/mailinglist/prefs.pl	2007-10-22 12:58:47 UTC (rev 1015)
+++ trunk/vhffs-panel/mailinglist/prefs.pl	2007-10-22 21:07:59 UTC (rev 1016)
@@ -30,6 +30,7 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 
+use strict;
 use utf8;
 use POSIX qw(locale_h);
 use HTML::Template;
@@ -37,7 +38,7 @@
 use Locale::gettext;
 use CGI;
 use CGI::Session;
-use strict;
+use Encode;
 
 use lib '%VHFFS_LIB_DIR%';
 use Vhffs::User;
@@ -214,10 +215,10 @@
 
 
 sub update_ml_options {
-    my $prefix = $cgi->param('prefix');
+    my $prefix = Encode::decode_utf8( $cgi->param('prefix') );
     my $sub_ctrl = $cgi->param('subscribe_control');
     my $post_ctrl = $cgi->param('posting_control');
-    my $sig = $cgi->param('signature');
+    my $sig = Encode::decode_utf8( $cgi->param('signature') );
 
     if(!$user->can_modify($list)) {
         $panel->add_error( gettext('You are not allowed to change options (ACL rights)') );

Modified: trunk/vhffs-panel/object/resubmit.pl
===================================================================
--- trunk/vhffs-panel/object/resubmit.pl	2007-10-22 12:58:47 UTC (rev 1015)
+++ trunk/vhffs-panel/object/resubmit.pl	2007-10-22 21:07:59 UTC (rev 1016)
@@ -82,7 +82,7 @@
 
 if( $submitted && $object ) {
 
-	my $description = $cgi->param('description');
+	my $description = Encode::decode_utf8( $cgi->param('description') );
 	unless( defined $description ) {
 		$panel->add_error( gettext('CGI error') );
 	}

Modified: trunk/vhffs-panel/user/prefs.pl
===================================================================
--- trunk/vhffs-panel/user/prefs.pl	2007-10-22 12:58:47 UTC (rev 1015)
+++ trunk/vhffs-panel/user/prefs.pl	2007-10-22 21:07:59 UTC (rev 1016)
@@ -29,7 +29,7 @@
 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 # POSSIBILITY OF SUCH DAMAGE.
 
-
+use strict;
 use utf8;
 use POSIX qw(locale_h);
 use HTML::Template;
@@ -37,7 +37,7 @@
 use Locale::gettext;
 use CGI;
 use CGI::Session;
-use strict;
+use Encode;
 
 use lib '%VHFFS_LIB_DIR%';
 use Vhffs::User;
@@ -60,29 +60,29 @@
 my $submitted = defined($cgi->param('prefs_submit'));
 
 if($submitted) {
-    my $mail = $cgi->param( "MAIL" );
-    my $firstname = $cgi->param( "FIRSTNAME" );
-    my $lastname = $cgi->param( "LASTNAME" );
-    my $city = $cgi->param( "CITY" );
-    my $zipcode = $cgi->param( "ZIPCODE" );
-    my $country = $cgi->param( "COUNTRY" );
-    my $address = $cgi->param( "ADDRESS" );
-    my $pass1 = $cgi->param("PASSWORD1");
-    my $pass2 = $cgi->param("PASSWORD2");
+    my $mail = $cgi->param( 'MAIL' );
+    my $firstname = Encode::decode_utf8( $cgi->param( 'FIRSTNAME' ) );
+    my $lastname = Encode::decode_utf8( $cgi->param( 'LASTNAME' ) );
+    my $city = Encode::decode_utf8( $cgi->param( 'CITY' ) );
+    my $zipcode = Encode::decode_utf8( $cgi->param( 'ZIPCODE' ) );
+    my $country = Encode::decode_utf8( $cgi->param( 'COUNTRY' ) );
+    my $address = Encode::decode_utf8( $cgi->param( 'ADDRESS' ) );
+    my $pass1 = $cgi->param( 'PASSWORD1' );
+    my $pass2 = $cgi->param( 'PASSWORD2' );
 
-    my $theme = $cgi->param( "THEME" );
-    my $lang = $cgi->param( "LANG" );
-    my $shell = $cgi->param( "SHELL" );
+    my $theme = $cgi->param( 'THEME' );
+    my $lang = $cgi->param( 'LANG' );
+    my $shell = $cgi->param( 'SHELL' );
 
     my $pwd_change = 0;
     my $mail_change = 0;
 
 
     # Checks data and perform requested modifications
-    $panel->add_cookie( CGI->cookie( -name=>"theme", -value=>$theme, -expires=>'+10y' ) );
+    $panel->add_cookie( CGI->cookie( -name=>'theme', -value=>$theme, -expires=>'+10y' ) );
     Vhffs::Panel::User::set_theme( $user, $theme );
 
-    $panel->add_cookie( CGI->cookie( -name=>"language", -value=>$lang, -expires=>'+10y' ) );
+    $panel->add_cookie( CGI->cookie( -name=>'language', -value=>$lang, -expires=>'+10y' ) );
     Vhffs::Panel::User::set_lang( $user, $lang );
 
 


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