You are here

function event_filter_node in Event 5.2

Same name and namespace in other branches
  1. 5 event.module \event_filter_node()

Parameters

$node:

$types:

$terms:

Return value

boolean

1 call to event_filter_node()
event_calendar_ical in ./event.module
Creates an ical feed of events.

File

./event.module, line 1235

Code

function event_filter_node($node, $types, $terms) {
  $event_types = event_get_types();
  if (isset($types)) {

    // content type filters set
    if (isset($terms)) {

      // taxonomy and content type filters set
      if (in_array($node->type, $types) && event_taxonomy_filter($node, $terms)) {

        // this node is the content type and taxonomy term requested
        if (count($types) == 1 && in_array($node->type, $event_types['solo'])) {

          // only display solo types if there is only one event type requested
          return TRUE;
        }
        elseif (in_array($node->type, $event_types['all'])) {
          return TRUE;
        }
      }
    }
    else {

      // only content type filters
      if (in_array($node->type, $types)) {
        if (count($types) == 1 && in_array($node->type, $event_types['solo'])) {

          // only display solo types if there is only one event type requested
          return TRUE;
        }
        elseif (in_array($node->type, $event_types['all'])) {
          return TRUE;
        }
      }
    }
  }
  elseif (isset($terms)) {

    // no types, only taxonomy filters
    if (event_taxonomy_filter($node, $terms) && in_array($node->type, $event_types['all'])) {
      return TRUE;
    }
  }
  else {

    // no filters set, only show events with content types states of 'all'
    if (in_array($node->type, $event_types['all'])) {
      return TRUE;
    }
  }
  return FALSE;
}