You are here

function advpoll_get_poll_info_blocks in Advanced Poll 7.3

Same name and namespace in other branches
  1. 7 advpoll.module \advpoll_get_poll_info_blocks()
  2. 7.2 advpoll.module \advpoll_get_poll_info_blocks()

Adds poll blocks to the list of blocks.

Parameters

array $blocks: The list of available blocks.

Return value

Block objects.

1 call to advpoll_get_poll_info_blocks()
advpoll_block_info in ./advpoll.module
Implements hook_block_info().

File

./advpoll.module, line 984

Code

function advpoll_get_poll_info_blocks($blocks) {
  $result = db_query("\n    SELECT n.title, n.nid FROM {node} n\n    LEFT JOIN {field_data_advpoll_dates} d\n    ON d.revision_id = n.vid\n    LEFT JOIN {field_data_advpoll_closed} c\n    ON c.revision_id = n.vid\n    LEFT JOIN {field_data_advpoll_options} o\n    ON o.revision_id = n.vid\n    WHERE\n    n.type = 'advpoll' AND\n    o.advpoll_options_value = 'block' AND\n    n.status = 1 AND\n    c.advpoll_closed_value = 'open' AND\n    d.advpoll_dates_value < NOW()\n    AND d.advpoll_dates_value2 > NOW()\n    ORDER BY n.created DESC\n  ");
  if ($result) {
    foreach ($result as $record) {
      $blocks['advpoll_block_' . $record->nid] = array(
        'info' => t('Advanced Poll: @title', array(
          '@title' => $record->title,
        )),
        'cache' => DRUPAL_NO_CACHE,
      );
    }
  }
  return $blocks;
}