You are here

function pollim_ajax_vote in Poll Improved 7

1 string reference to 'pollim_ajax_vote'
pollim_menu in ./pollim.module
Implements hook_menu().

File

./pollim.module, line 410
Module for the Pollim Entity - a starting point to create your own Entity and associated administration interface

Code

function pollim_ajax_vote($pollim) {
  if (!pollim_ip_check($pollim
    ->internalIdentifier(), ip_address())) {
    print "<p class='messages error'>" . t('IP address blocked') . "</p>";
    exit;
  }
  $choice = $_REQUEST['data'];
  $entity = entity_create('pollim_vote', array(
    'pollim_id' => $pollim->pollim_id,
    'timestamp' => time(),
    'hostname' => ip_address(),
    'data' => $choice,
  ));
  $entity
    ->save();
  $controller = entity_get_controller('pollim');
  $content = $controller
    ->view(array(
    $pollim->pollim_id => $pollim,
  ));
  $output = render($content);
  $output .= '<p class="message">' . t('Thanks for your vote!') . '</p>';
  print $output;
  exit;
}