You are here

function _advpoll_is_active in Advanced Poll 5

Same name and namespace in other branches
  1. 6.3 advpoll.module \_advpoll_is_active()
  2. 6 advpoll.module \_advpoll_is_active()
  3. 6.2 advpoll.module \_advpoll_is_active()

Helper function to check if a poll is active.

8 calls to _advpoll_is_active()
advpoll_cancel in ./advpoll.module
Callback for canceling a vote.
advpoll_menu in ./advpoll.module
Implementation of hook_menu().
advpoll_page in ./advpoll.module
advpoll_view in ./advpoll.module
Implementation of hook_view().
advpoll_voting_binary_form_validate in modes/binary.inc
Check if the submitted key exists, just to make sure the form is not bypassed.

... See full list

File

./advpoll.module, line 1142
Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.

Code

function _advpoll_is_active($node, $return_status = FALSE) {
  $active = TRUE;
  $status = 'open';
  $start_date = $node->start_date;
  $end_date = $node->end_date;

  // Check if poll is closed.
  if (!$node->active) {
    $active = FALSE;
    $status = 'closed';
  }
  if ($active && $start_date > 0) {

    // Check that start date is in the past.
    if (!($active = time() >= $start_date)) {
      $status = 'pending';
    }
  }
  if ($active && $end_date > 0) {

    // Check that end date is in the future.
    if (!($active = time() < $end_date)) {
      $status = 'passed';
    }
  }
  return $return_status ? $status : $active;
}