[vhffs-dev] [481] Modified get_string_from_status_id (not sure this is the exact name) to use an array instead of an elseif construct.

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


Revision: 481
Author:   beuss
Date:     2007-02-18 19:33:30 +0000 (Sun, 18 Feb 2007)

Log Message:
-----------
Modified get_string_from_status_id (not sure this is the exact name) to use an array instead of an elseif construct.

Modified Paths:
--------------
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Functions.pm


Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Functions.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Functions.pm	2007-02-18 14:39:36 UTC (rev 480)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Functions.pm	2007-02-18 19:33:30 UTC (rev 481)
@@ -44,6 +44,20 @@
 my $password;
 srand(time ^ $$);
 
+my @STATUS_STRINGS;
+$STATUS_STRINGS[Vhffs::Constants::WAITING_FOR_VALIDATION] = 'Waiting for validation';
+$STATUS_STRINGS[Vhffs::Constants::VALIDATION_REFUSED] = 'Validation refused';
+$STATUS_STRINGS[Vhffs::Constants::WAITING_FOR_CREATION] = 'Waiting for creation';
+$STATUS_STRINGS[Vhffs::Constants::CREATING_ERROR] = 'Creation error';
+$STATUS_STRINGS[Vhffs::Constants::CREATED] = 'Created';
+$STATUS_STRINGS[Vhffs::Constants::ACTIVATED] = 'Activated';
+$STATUS_STRINGS[Vhffs::Constants::SUSPENDED] = 'Suspended';
+$STATUS_STRINGS[Vhffs::Constants::SUSPENDED_BEFORE_DELETED] = 'Suspended before deletion';
+$STATUS_STRINGS[Vhffs::Constants::WAITING_FOR_MODIFICATION] = 'Waiting for modification';
+$STATUS_STRINGS[Vhffs::Constants::MODIFICATION_ERROR] = 'Modification error';
+$STATUS_STRINGS[Vhffs::Constants::MODIFICATION_APPLIED] = 'Modification applied';
+$STATUS_STRINGS[Vhffs::Constants::TO_DELETE] = 'Will be deleted';
+
 sub hash_mxdomain
 {
 	my $domain = shift;
@@ -360,56 +374,8 @@
 
 sub status_string_from_status_id
 {
-	my $status = shift;
-
-	if( $status == Vhffs::Constants::WAITING_FOR_VALIDATION )
-	{
-		return gettext("Waiting for validation");
-	}
-	elsif( $status == Vhffs::Constants::VALIDATION_REFUSED )
-	{
-		return gettext("Validation refused");
-	}
-	elsif( $status == Vhffs::Constants::WAITING_FOR_CREATION )
-	{
-		return gettext("Waiting for creation");
-	}
-	elsif( $status == Vhffs::Constants::CREATING_ERROR )
-	{
-		return gettext("Creating error");
-	}
-	elsif( $status == Vhffs::Constants::CREATED )
-	{   
-		return gettext("Created");
-	}
-	elsif( $status == Vhffs::Constants::ACTIVATED )
-	{
-		return gettext("Activated");
-	}
-	elsif( $status == Vhffs::Constants::SUSPENDED )
-	{   
-		return gettext("Suspended");
-	}
-	elsif( $status == Vhffs::Constants::SUSPENDED_BEFORE_DELETED )
-	{
-		return gettext("Suspended before deletion");
-	}
-	elsif( $status == Vhffs::Constants::WAITING_FOR_MODIFICATION )
-	{
-		return gettext("Waiting for modification");
-	}
-	elsif( $status == Vhffs::Constants::MODIFICATION_ERROR )
-	{
-		return gettext("Modification error");
-	}
-	elsif( $status == Vhffs::Constants::MODIFICATION_APPLIED )
-	{
-		return gettext("Modification applied");
-	}
-	elsif( $status == Vhffs::Constants::TO_DELETE )
-	{
-		return gettext("Will be deleted");
-	}
+    my $status = shift;
+    return gettext($STATUS_STRINGS[$status]);
 }
 
 sub mail_template


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