function oa_section_context_init in Open Atrium Core 7.2
Implements hook_init Put the section context into session variable
File
- modules/
oa_section_context/ oa_section_context.module, line 41 - Provides hook implementations and functionality for oa_section_context.
Code
function oa_section_context_init() {
global $user;
// don't create a session for anonymous users unless session already started
// needed to allow Varnish to cache anonymous pages
if ($user->uid == 0 && !drupal_session_started()) {
return;
}
$set_session = oa_section_get_section_context();
if ($set_session && ($node = node_load($set_session)) && node_access('view', $node)) {
$_SESSION[OA_SESSION_SECTION] = $set_session;
}
elseif (isset($_SESSION[OA_SESSION_SECTION])) {
unset($_SESSION[OA_SESSION_SECTION]);
}
}