[vhffs-dev] [463] Fixed listengine API due to the drop of vhffs_ml_lang table

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


Revision: 463
Author:   gradator
Date:     2007-02-16 21:29:45 +0000 (Fri, 16 Feb 2007)

Log Message:
-----------
Fixed listengine API due to the drop of vhffs_ml_lang table

Modified Paths:
--------------
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm
    branches/vhffs_4.1/vhffs-compat/4.0.sql
    branches/vhffs_4.1/vhffs-listengine/src/listengine.pl


Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm	2007-02-16 20:56:20 UTC (rev 462)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm	2007-02-16 21:29:45 UTC (rev 463)
@@ -418,15 +418,14 @@
 }
 
 
-sub get_lang_for_sub
+sub get_language_for_sub
 {
     my $vhffs = shift;
     my $sub = shift;
     my $query;
     my $request;
 
-
-    $query = "SELECT lang FROM vhffs_ml_lang WHERE member='".$sub."'";
+    $query = "SELECT language FROM vhffs_ml_subscribers WHERE member='".$sub."'";
     $request = $vhffs->{'db'}->prepare( $query );
     return undef if ( $request->execute <= 0 );
     
@@ -435,41 +434,19 @@
 }
 
 
-sub set_lang_for_sub
+sub set_language_for_sub
 {
     my $vhffs = shift;
     my $sub = shift;
-    my $lang = shift;
+    my $language = shift;
     my $query,
     my $request;
 
-	if( $lang =~ /^fr$|^fr_FR$|^french$/ )
-	{
-		$lang = "fr_FR";
-	}
-	elsif( $lang =~ /^es$|^es_ES$|^spanish$/ )
-	{
-		$lang = "es_ES";
-	}
-	else
-	{
-		$lang = "en_US";
-	}
+    $language = "en_US" unless( $language =~ /^[\w]+$/ );
 
-    $query = "SELECT * FROM vhffs_ml_lang WHERE member='".$sub."'";
+    $query = "UPDATE vhffs_ml_subscribers SET language='".$language."' WHERE member='".$sub."'";
     $request = $vhffs->{'db'}->prepare( $query );
-    if ( $request->execute <= 0 )
-    {
-	$query = "INSERT INTO vhffs_ml_lang VALUES( '".$sub."' , '".$lang."' )";
-    }
-    else
-    {
-	$query = "UPDATE vhffs_ml_lang SET lang='".$lang."' WHERE member='".$sub."'";
-    }
-
-    $request = $vhffs->{'db'}->prepare( $query );
     $request->execute or return -1;
-
 }
 
 sub get_localpart

Modified: branches/vhffs_4.1/vhffs-compat/4.0.sql
===================================================================
--- branches/vhffs_4.1/vhffs-compat/4.0.sql	2007-02-16 20:56:20 UTC (rev 462)
+++ branches/vhffs_4.1/vhffs-compat/4.0.sql	2007-02-16 21:29:45 UTC (rev 463)
@@ -69,13 +69,13 @@
     FROM vhffs_user_info ui
     WHERE ui.uid = vhffs_users.uid;
 
--- DROP TABLE vhffs_users_info;
+DROP TABLE vhffs_user_info;
 
 -- merge vhffs_notes to vhffs_users
 ALTER TABLE vhffs_users ADD COLUMN note int4;
 UPDATE vhffs_users SET note = n.note FROM vhffs_notes n WHERE n.object_id = vhffs_users.object_id;
 
--- DROP TABLE vhffs_notes;
+DROP TABLE vhffs_notes;
 
 -- merge vhffs_panel_user_prefs to vhffs_users
 ALTER TABLE vhffs_users ADD COLUMN language varchar(16);
@@ -84,7 +84,7 @@
     FROM vhffs_panel_user_prefs up
     WHERE up.uid = vhffs_users.uid;
 
--- DROP TABLE vhffs_panel_user_prefs;
+DROP TABLE vhffs_panel_user_prefs;
 
 -- merge vhffs_groups_info to vhffs_groups
 ALTER TABLE vhffs_groups ADD COLUMN owner_uid int4;
@@ -93,7 +93,7 @@
     FROM vhffs_groups_info gi
     WHERE gi.gid = vhffs_groups.gid;
 
--- DROP TABLE vhffs_groups_info
+DROP TABLE vhffs_groups_info;
 
 -- merge vhffs_ml_prefs to vhffs_ml
 ALTER TABLE vhffs_ml ADD COLUMN admin varchar(250);
@@ -114,13 +114,13 @@
     FROM vhffs_ml_prefs mlp
     WHERE mlp.ml_id = vhffs_ml.ml_id;
 
--- DROP TABLE vhffs_ml_prefs
+DROP TABLE vhffs_ml_prefs;
 
 -- merge vhffs_ml_lang to vhffs_ml_subscribers
 ALTER TABLE vhffs_ml_subscribers ADD COLUMN language varchar(16);
 UPDATE vhffs_ml_subscribers SET language = mll.lang FROM vhffs_ml_lang mll WHERE mll.member = vhffs_ml_subscribers.member;
 
--- DROP TABLE vhffs_ml_lang
+DROP TABLE vhffs_ml_lang;
 
 -- update vhffs_forum view
 DROP VIEW vhffs_forum;

Modified: branches/vhffs_4.1/vhffs-listengine/src/listengine.pl
===================================================================
--- branches/vhffs_4.1/vhffs-listengine/src/listengine.pl	2007-02-16 20:56:20 UTC (rev 462)
+++ branches/vhffs_4.1/vhffs-listengine/src/listengine.pl	2007-02-16 21:29:45 UTC (rev 463)
@@ -623,7 +623,7 @@
     my $temp;
     my $members = $list->get_members;
 
-	$lang = Vhffs::Services::Mailing::get_lang_for_sub( $vhffs , $from );
+	$lang = Vhffs::Services::Mailing::get_language_for_sub( $vhffs , $from );
 	#If the user specified a lang, we change it to get internationalized messages
 	if( defined $lang )
 	{
@@ -654,17 +654,17 @@
     }
     elsif( ( $lang ) = $subject =~ /^lang\s([a-zA-Z\_\-]+)$/ )
     {
-		#Try to change the language for this subscriber on whole listengine subsystem
-		if( Vhffs::Services::Mailing::set_lang_for_sub( $vhffs , $from , $lang ) < 0 )
-		{
-		    $email = Mail::Internet->new( [ <> ],
+	#Try to change the language for this subscriber on whole listengine subsystem
+	unless( Vhffs::Services::Mailing::set_language_for_sub( $vhffs , $from , $lang ) )
+	{
+		$email = Mail::Internet->new( [ <> ],
 					 Body => Vhffs::Listengine::Intl::lang_change_error( $from , $lang )
 					 );
-		    $email->replace('From' ,  $LISTMASTER );
-		    $email->replace('To' ,  $from );
-		    $email->replace('Subject' , gettext("listengine help") );
-		    $email->replace('Date' , gmtime()." +00");
-		    sendmail( $email , $from );
+		$email->replace('From' ,  $LISTMASTER );
+		$email->replace('To' ,  $from );
+		$email->replace('Subject' , gettext("listengine help") );
+		$email->replace('Date' , gmtime()." +00");
+		sendmail( $email , $from );
 	}
 	else
 	{
@@ -896,7 +896,7 @@
     my $mail = shift;
     my ( $from ) = ( $mail->get('From') =~ /(([\+\.a-zA-Z_\-0-9^\s]+)@([\.a-zA-Z_\-0-9^\s]+)\.(\w+))/);
 
-    my $lang = Vhffs::Services::Mailing::get_lang_for_sub( $vhffs , $from );
+    my $lang = Vhffs::Services::Mailing::get_language_for_sub( $vhffs , $from );
     if( defined $lang )
     {	
 	#Change current locale to user preferences if defined


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