bug 28: add changes for l10n class
authorBenny Baumann <BenBE@geshi.org>
Tue, 7 May 2013 22:02:29 +0000 (00:02 +0200)
committerBenny Baumann <BenBE@geshi.org>
Tue, 7 May 2013 22:02:29 +0000 (00:02 +0200)
includes/account.php
includes/lib/l10n.php
scripts/cron/warning.php
www/disputes.php

index f9df120..e519858 100644 (file)
                        printf(_("The password for %s has been updated successfully in the system."), sanitizeHTML($row['email']));
 
                $my_translation = L10n::get_translation();
-               L10n::set_translation(get_recipient_language(intval($_REQUEST['userid'])));
+               L10n::set__recipient_language(intval($_REQUEST['userid']));
                        $body  = sprintf(_("Hi %s,"),$row['fname'])."\n\n";
                        $body .= _("You are receiving this email because a CAcert administrator ".
                                        "has changed the password on your account.")."\n\n";
index 8325f4c..9bb5d52 100644 (file)
@@ -340,13 +340,21 @@ class L10n {
                bindtextdomain($domain, $_SESSION['_config']['filepath'].'/locale');
                textdomain($domain);
        }
-}
 
-function get_recipient_language($accoundid){
-//returns the language of a recipient to make sure that the language is correct
-//use together with
-       $query = "select * from `users` where `id`='".$id."'";
-       $res = mysql_query($query);
-       $row = mysql_fetch_assoc($res);
-       return $row['language'];
+       public static function set_recipient_language($accoundid) {
+               //returns the language of a recipient to make sure that the language is correct
+               //use together with
+               $query = "select `language` from `users` where `id`='".intval($accountid)."'";
+               $res = mysql_query($query);
+               if (mysql_num_rows($res)>=0) {
+                       $row = mysql_fetch_assoc($res);
+                       if ($row['language']==Null || $row['language']=='') {
+                               $this->set_translation('en');
+                       } else {
+                               $this->set_translation($row['language']);
+                       }
+               } else {
+                       $this->set_translation('en');
+               }
+       }
 }
index ad3383b..bbf79ac 100755 (executable)
@@ -35,7 +35,7 @@
                $res = mysql_query($query);
                while($row = mysql_fetch_assoc($res))
                {
-                       L10n::set_translation(get_recipient_language(intval(.$row['id')));
+                       L10n::set__recipient_language(intval($row['id']));
                        if($row['subject'] == "")
                        {
                                $row['crt_name'] = str_replace("../", "www/", $row['crt_name']);
@@ -103,7 +103,7 @@ echo $row['fname']." ".$row['lname']." <".$row['email']."> (memid: ".$row['memid
                $res = mysql_query($query);
                while($row = mysql_fetch_assoc($res))
                {
-                       L10n::set_translation(get_recipient_language(intval(.$row['memid')));
+                       L10n::set__recipient_language(intval($row['memid']));
                        if($row['subject'] == "")
                                $row['subject'] = $row['CN'];
 
index f203b62..916357f 100644 (file)
                mysql_query($query);
 
                $my_translation = L10n::get_translation();
-               L10n::set_translation(get_recipient_language($oldmemid));
+               L10n::set__recipient_language($oldmemid);
 
                $body = sprintf(_("You have been sent this email as the email address '%s' is being disputed. You have the option to accept or reject this request, after 2 days the request will automatically be discarded. Click the following link to accept or reject the dispute:"), $email)."\n\n";
                $body .= "https://".$_SESSION['_config']['normalhostname']."/disputes.php?type=email&emailid=$emailid&hash=$hash\n\n";
                                `oldmemid`='$oldmemid',`created`=NOW(),`hash`='$hash',`id`='$domainid'";
                mysql_query($query);
                $my_translation = L10n::get_translation();
-               L10n::set_translation(get_recipient_language($oldmemid));
+               L10n::set__recipient_language($oldmemid);
 
                $body = sprintf(_("You have been sent this email as the domain '%s' is being disputed. You have the option to accept or reject this request, after 2 days the request will automatically be discarded. Click the following link to accept or reject the dispute:"), $domain)."\n\n";
                $body .= "https://".$_SESSION['_config']['normalhostname']."/disputes.php?type=domain&domainid=$domainid&hash=$hash\n\n";
                $body .= _("Best regards")."\n"._("CAcert.org Support!");
-               L10n::set_translation(get_recipient_language($my_translation));
+               L10n::set__recipient_language($my_translation);
 
                sendmail($authaddy, "[CAcert.org] "._("Dispute Probe"), $body, "support@cacert.org", "", "", "CAcert Support");