function opening_hours_present_on_node in Opening hours 7
Same name and namespace in other branches
- 6 opening_hours.module \opening_hours_present_on_node()
Check if any opening hours has been input on a node.
Used for hiding the opening_hours block on pages where it will never display any data.
Parameters
int $nid: Node ID to check.
Return value
bool TRUE if opening hours are present, FALSE if not.
2 calls to opening_hours_present_on_node()
- opening_hours_node_view in ./
opening_hours.module - Implements hook_node_view().
- opening_hours_week_content_type_render in plugins/
content_types/ week.inc - Render the block.
1 string reference to 'opening_hours_present_on_node'
- opening_hours_crud_api_page in includes/
opening_hours.pages.inc - The CRUD API for communication with Backbone.
File
- ./
opening_hours.module, line 282 - Opening hours module.
Code
function opening_hours_present_on_node($nid, $reset = FALSE) {
static $presence = array();
// Load Drupal’s cache if $presence array is empty.
if (!$reset && empty($presence) && ($cache = cache_get('opening_hours_present_on_node'))) {
if (is_array($cache->data)) {
$presence = $cache->data;
}
}
// Check the static cache.
if (!isset($presence[$nid]) || $reset) {
$presence[$nid] = (bool) db_query("\n SELECT instance_id FROM {opening_hours} WHERE nid = :nid LIMIT 1\n ", array(
':nid' => $nid,
))
->fetchField();
cache_set('opening_hours_present_on_node', $presence);
}
return $presence[$nid];
}