You are here

function advpoll_get_recent in Advanced Poll 7

Same name and namespace in other branches
  1. 7.3 advpoll.module \advpoll_get_recent()
  2. 7.2 advpoll.module \advpoll_get_recent()
1 call to advpoll_get_recent()
advpoll_block_view in ./advpoll.module
Implements hook_block_view().

File

./advpoll.module, line 776

Code

function advpoll_get_recent() {
  $node = null;
  $result = db_query("SELECT n.nid FROM {node} n\n                      LEFT JOIN {field_data_advpoll_dates} d \n                      ON d.entity_id = n.nid \n                      LEFT JOIN {field_data_advpoll_closed} c\n                      ON c.entity_id = n.nid\n                      LEFT JOIN {field_data_advpoll_options} o\n                      ON o.entity_id = n.nid\n                      WHERE \n                      n.type LIKE '%advpoll%' AND\n                      o.advpoll_options_value <> 'electoral' AND\n                      n.status = 1 AND\n                      c.advpoll_closed_value = 'open' AND\n                      d.advpoll_dates_value < NOW() AND \n                      d.advpoll_dates_value2 > NOW() \n                      GROUP BY n.nid ORDER BY n.created DESC \n                      LIMIT 1");
  if ($result) {
    foreach ($result as $record) {
      $node = node_load($record->nid);
      break;
    }
    return drupal_render(node_view($node));
  }
}