CMS MADE SIMPLE FORGE

Polls Made Simple

 

[#2633] When I press "Peak Results" the module forgets the lang parameter setting and uses default language instead

avatar
Created By: John Ericson (johnericson)
Date Submitted: Fri Nov 14 11:13:49 -0500 2008

Assigned To:
Version: v1.1
CMSMS Version: None
Severity: Major
Resolution: None
State: Closed
Summary:
When I press "Peak Results" the module forgets the lang parameter setting and uses default language instead
Detailed Description:
Problem:
--------------

When I press "Peak Results" (or "Visa resultat in swedish) the module shows the
result in english instead of swedish. Instead of using the lang variable that I
supplied it uses the global setting.

Why it happens:
-------------------------

The lang parameter is not supplied in the Ajax calls.

Solution:
--------------

diff -r -u Polls.1.2.0.orig/Polls.module.php Polls.0.2.0.new/Polls.module.php
--- Polls.0.2.0.orig/Polls.module.php	2007-10-24 09:13:20.000000000 +0200
+++ Polls.0.2.0.new/Polls.module.php	2008-11-14 16:59:00.046875000 +0100
@@ -252,15 +252,23 @@
 		return $output;
 	}
 
+	function ParseVars($vars) {
+		if (array_key_exists("lang", $vars))
+			$this->curlang = $vars["lang"];
+	}
+
 	function PeekPoll($vars) {
+		$this->ParseVars($vars);
 		return $this->GetResultOutput($vars["pollid"]);
 	}
 
 	function ReturnToPoll($vars) {
+		$this->ParseVars($vars);
 		return $this->GetPollOutput($vars["pollid"]);
 	}
 
 	function ExecuteVote($vars) {
+		$this->ParseVars($vars);
 		if ($this->UserAlreadyVoted($vars["pollid"])) {
 			return $this->GetResultOutput($vars["pollid"]);
 		}
diff -r -u Polls.0.2.0.orig/action.default.php
Polls.0.2.0.new/action.default.php
--- Polls.0.2.0.orig/action.default.php	2007-10-24 09:13:20.000000000 +0200
+++ Polls.0.2.0.new/action.default.php	2008-11-14 16:29:12.042625000 +0100
@@ -13,12 +13,16 @@
 	}
 }
 
+$pollparams = array();
+$pollparams["pollid"] = $pollid;
+$pollparams["lang"]   = $params['lang'];
+
 $ajax=$this->GetModuleInstance("AjaxMadeSimple");
-$ajax->RegisterAjaxRequester($this->GetName(),"poll_".$pollid,"pollcontent_".$pollid,"ExecuteVote","",array("pollid"=>$pollid),array("pollvotingchoice_".$pollid=>"radio","vote"=>""));
+$ajax->RegisterAjaxRequester($this->GetName(),"poll_".$pollid,"pollcontent_".$pollid,"ExecuteVote","",$pollparams,array("pollvotingchoice_".$pollid=>"radio","vote"=>""));
 //echo "hiii";
 if ($this->GetPreference("showpeekbutton","")!="") {
- 
$ajax->RegisterAjaxRequester($this->GetName(),"peek_".$pollid,"pollcontent_".$pollid,"PeekPoll","",array("pollid"=>$pollid),array("peek"=>""));
- 
$ajax->RegisterAjaxRequester($this->GetName(),"return_".$pollid,"pollcontent_".$pollid,"ReturnToPoll","",array("pollid"=>$pollid),array("returntovote"=>""));
+ 
$ajax->RegisterAjaxRequester($this->GetName(),"peek_".$pollid,"pollcontent_".$pollid,"PeekPoll","",$pollparams,array("peek"=>""));
+ 
$ajax->RegisterAjaxRequester($this->GetName(),"return_".$pollid,"pollcontent_".$pollid,"ReturnToPoll","",$pollparams,array("returntovote"=>""));
 }
 
 if ($this->UserAlreadyVoted($pollid)) {
@@ -27,4 +31,4 @@
   echo $this->GetPollOutput($pollid);
 }
 
-?>
\ No newline at end of file
+?>
Only in Polls.0.2.0.new/lang: sv_SE.php


Implementation:
-------------------------

I call the Polls module like this:
{cms_module module="polls" poll_id="Veckans fråga" lang="sv_SE"}

Versions:
---------------

I use version 0.2.0 of Polls (I can only chose 1.0 and 1.1 when I submit this
bug).
CMS version is 1.3.1.
My default language in my CMS installation is en_US.


History

Updates

Updated: 2013-01-01 13:39
resolution_id: => 5
cmsms_version_id: => -1
state: Open => Closed