bug 985: replace occurences of $_SESSION['_config']['translations']
authorMichael Tänzer <neo@nhng.de>
Sun, 16 Oct 2011 04:09:25 +0000 (06:09 +0200)
committerMichael Tänzer <neo@nhng.de>
Sun, 16 Oct 2011 04:09:25 +0000 (06:09 +0200)
this includes a little rewrite of reminder handling

Signed-off-by: Michael Tänzer <neo@nhng.de>
includes/account.php
includes/general_stuff.php
pages/account/41.php
pages/wot/5.php
pages/wot/9.php
www/wot.php

index 24c61d8..ebae1f6 100644 (file)
@@ -16,6 +16,7 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
        require_once("../includes/loggedin.php");
+       require_once("../includes/lib/l10n.php");
 
        loadem("account");
 
        {
                csrf_check("mainlang");
                $lang = mysql_real_escape_string($_REQUEST['lang']);
-               foreach($_SESSION['_config']['translations'] as $key => $val)
+               foreach(L10n::$translations as $key => $val)
                {
                        if($key == $lang)
                        {
index 088c39e..b4795e0 100644 (file)
@@ -16,6 +16,8 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
+require_once($_SESSION['_config']['filepath'].'/includes/lib/l10n.php');
+
 if(!function_exists("showheader"))
 {
        function showbodycontent($title = "CAcert.org", $title2 = "")
@@ -60,7 +62,7 @@ google_color_border = "FFFFFF";
     <? include("about_menu.php"); ?>
     <div class="relatedLinks">
       <h3 class="pointer" onclick="explode('trans')">+ <?=_("Translations")?></h3>
-      <ul class="menu" id="trans"><? foreach($_SESSION['_config']['translations'] as $key => $val) { ?><li><a href="<?=$_SERVER['SCRIPT_NAME']?>?id=<?=intval(array_key_exists('id',$_REQUEST)?$_REQUEST['id']:0)?>&amp;lang=<?=$key?>"><?=$val?></a></li><? } ?></ul>
+      <ul class="menu" id="trans"><? foreach(L10n::$translations as $key => $val) { ?><li><a href="<?=$_SERVER['SCRIPT_NAME']?>?id=<?=intval(array_key_exists('id',$_REQUEST)?$_REQUEST['id']:0)?>&amp;lang=<?=$key?>"><?=$val?></a></li><? } ?></ul>
     </div>
     <? if(array_key_exists('mconn',$_SESSION) && $_SESSION['mconn']) { ?>
     <div class="relatedLinks">
index e44eec9..d2cfc8c 100644 (file)
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/ ?>
+*/
+
+require_once($_SESSION['_config']['filepath'].'/includes/lib/l10n.php');
+?>
+
 <form method="post" action="account.php">
 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper" width="400">
   <tr>
     <td class="DataTD"><?=_("My prefered language")?>:</td>
     <td class="DataTD"><select name="lang">
 <?
-echo $_SESSION['_config']['language'];
-       foreach($_SESSION['_config']['translations'] as $key => $val)
+       foreach(L10n::$translations as $key => $val)
        {
                echo "<option value='$key'";
-               if($key == $_SESSION['_config']['language'])
+               if($key == L10n::get_translation())
                        echo " selected";
                echo ">$val</option>\n";
        }
index 6c53d00..4b574af 100644 (file)
@@ -16,6 +16,7 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
        include_once("../includes/shutdown.php");
+       require_once("../includes/lib/l10n.php");
 ?>
 <? 
   if(array_key_exists('error',$_SESSION['_config']) && $_SESSION['_config']['error'] != "") 
@@ -39,7 +40,7 @@
 <?
        if($_SESSION['_config']['reminder-lang'] == "")
                $_SESSION['_config']['reminder-lang'] = $_SESSION['profile']['language'];
-        foreach($_SESSION['_config']['translations'] as $key => $val)
+        foreach(L10n::$translations as $key => $val)
         {
                 echo "<option value='$key'";
                 if($key == $_SESSION['_config']['reminder-lang'])
index b974c5d..bfa7a98 100644 (file)
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/ ?>
-<?
+*/
+       
+       require_once($_SESSION['_config']['filepath'].'/includes/lib/l10n.php');
+       
+
        $res = mysql_query("select * from `users` where `id`='".intval($_REQUEST['userid'])."' and `listme`='1'");
        if(mysql_num_rows($res) <= 0)
        {
@@ -47,7 +50,7 @@
 <? if($userlang != "") { ?>
   <tr>
     <td class="DataTD"><?=_("Language")?>:</td>
-    <td class="DataTD" align="left"><? printf(_("%s prefers to be contacted in %s"), $user['fname'], $_SESSION['_config']['translations'][$userlang]) ?></td>
+    <td class="DataTD" align="left"><? printf(_("%s prefers to be contacted in %s"), $user['fname'], L10n::$translations[$userlang]) ?></td>
   </tr>
 <? } ?>
 <?
index 7fa572f..33ce4bb 100644 (file)
@@ -17,6 +17,7 @@
 */ ?>
 <?
        require_once("../includes/loggedin.php");
+       require_once("../includes/lib/l10n.php");
 
        loadem("account");
 
        if($oldid == 5 && array_key_exists('reminder',$_POST) && $_POST['reminder'] != "")
        {
                $body = "";
-                if($_POST['reminder-lang'] != "" && $_POST['reminder-lang'] != "en_AU")
-                {
-                        $userlang = $_POST['reminder-lang'];
-                       $_SESSION['_config']['reminder-lang'] = $_POST['reminder-lang'];
-                        putenv("LANG=".$userlang);
-                        setlocale(LC_ALL, $userlang);
-
-                       $body .= $_SESSION['_config']['translations'][$userlang].":\n\n";
+               
+               $my_translation = L10n::get_translation();
+               
+               $_SESSION['_config']['reminder-lang'] = $_POST['reminder-lang'];
+               
+               $reminder_translations[] = $_POST['reminder-lang'];
+               if ( !in_array("en", $reminder_translations, $strict=true) ) {
+                       $reminder_translations[] = "en";
+               }
+               
+               foreach ($reminder_translations as $translation) {
+                       L10n::set_translation($translation);
+                       
+                       $body .= L10n::$translations[$translation].":\n\n";
                        $body .= sprintf(_("This is a short reminder that you filled out forms to become trusted with CAcert.org, and %s has attempted to issue you points. Please create your account at %s as soon as possible and then notify %s so that the points can be issued."), $_SESSION['profile']['fname']." (".$_SESSION['profile']['email'].")", "http://www.cacert.org", $_SESSION['profile']['fname'])."\n\n";
                        $body .= _("Best regards")."\n";
-                       $body .= _("CAcert Support Team");
-
-                       $body .= "\n\nEnglish:\n\n";
-                }
-
-               $body .= sprintf("This is a short reminder that you filled out forms to become trusted with CAcert.org, and %s has attempted to issue you points. Please create your account at %s as soon as possible and then notify %s so that the points can be issued.", $_SESSION['profile']['fname']." (".$_SESSION['profile']['email'].")", "http://www.cacert.org", $_SESSION['profile']['fname'])."\n\n";
-               $body .= "Best regards"."\n";
-               $body .= "CAcert Support Team";
-
+                       $body .= _("CAcert Support Team")."\n\n";
+               }
+               
+               L10n::set_translation($reminder_translations[0]); // for the subject
                sendmail($_POST['email'], "[CAcert.org] "._("Reminder Notice"), $body, $_SESSION['profile']['email'], "", "", $_SESSION['profile']['fname']);
-
-                if($_POST['reminder-lang'] != "" && $_POST['reminder-lang'] != "en_AU")
-                {
-                        $userlang = $_SESSION['profile']['language'];
-                        putenv("LANG=".$userlang);
-                        setlocale(LC_ALL, $userlang);
-                }
-
+               
+               L10n::set_translation($my_translation);
+               
                $_SESSION['_config']['remindersent'] = 1;
                $_SESSION['_config']['error'] = _("A reminder notice has been sent.");