You are here

function i18npoll_get_vote in Internationalization 6

Get user vote for this node or its translations.

Returns object with nid, chorder. Has static caching as this will typically be called twice.

2 calls to i18npoll_get_vote()
i18npoll_form_alter in i18npoll/i18npoll.module
Implementation of hook_form_alter().
i18npoll_nodeapi in i18npoll/i18npoll.module
Implementation of hook_nodeapi().

File

i18npoll/i18npoll.module, line 157
Multilingual poll - Aggregates poll results for all translations.

Code

function i18npoll_get_vote($tnid) {
  global $user;
  static $vote = array();
  if (!array_key_exists($tnid, $vote)) {
    if ($user->uid) {
      $vote[$tnid] = db_fetch_object(db_query('SELECT v.nid, v.chorder FROM {poll_votes} v INNER JOIN {node} n ON n.nid = v.nid WHERE n.tnid = %d AND v.uid = %d', $tnid, $user->uid));
    }
    else {
      $vote[$tnid] = db_fetch_object(db_query("SELECT v.chorder FROM {poll_votes} v INNER JOIN {node} n ON n.nid = v.nid WHERE n.tnid = %d AND v.hostname = '%s'", $tnid, ip_address()));
    }
  }
  return $vote[$tnid];
}