By hellsnail on
when using multiple-languages on the poll content-type, I discovered that poll results were not combined between languages.
this can be fixed by adding the following 13 lines of code to your poll.module
$poll = node_load(array('type' => 'poll', 'created' => $timestamp, 'moderate' => 0, 'status' => 1));
/***
* chris hack: for i18n polls, add up the values of all other polls
* from differnet languages. NOTE: this assumes that each languages
* corresponding choices are in teh SAME ORDER!!!
*
* check for translation with $node->translation
*/
if (isset($poll->translation)) {
foreach ($poll->translation as $tr) {
$trNode = node_load(array('nid' => $tr->nid) );
foreach ($trNode->choice as $k => $choice_k) {
foreach ($poll->choice as $n => $choice_n) {
if ($poll->choice[$n]['chorder'] == $trNode->choice[$k]['chorder']) {
$poll->choice[$n]['chvotes'] += $trNode->choice[$k]['chvotes'];
break;
}
}
}
}
}
/*** END HACK ***/
if ($poll->nid) {
// poll_view() dumps the output into $poll->body.
poll_view($poll, 1, 0, 1);
}
Comments
poll.module issue
Looks like a solid fix. I recommend adding this as a bug for poll.module if you haven't already. http://drupal.org/node/add/project_issue/drupal
It would also be helpful for the maintainers if you made an actual patch for the issue. See http://drupal.org/node/22568