You are here

function mobile_tools_get_active_device_group in Mobile Tools 7.3

Same name and namespace in other branches
  1. 7.2 mobile_tools.module \mobile_tools_get_active_device_group()

Get the active device group.

Parameters

object $modifier [optional]: PURL modifier

boolean $clear [optional]: Flush cache

Return value

object Returns the active device group object, FALSE otherwise.

5 calls to mobile_tools_get_active_device_group()
mobile_tools_activate_device_group in ./mobile_tools.module
Initialize the device group
mobile_tools_context_device_group_access_check in mobile_tools_context/plugins/access/is_device_group.inc
Check for access.
mobile_tools_context_init in mobile_tools_context/mobile_tools_context.module
Implements hook_init().
mobile_tools_httpheaders_context_http_header_build in mobile_tools_httpheaders/mobile_tools_httpheaders.module
Implements hook_context_http_header_build().
mobile_tools_init in ./mobile_tools.module
Implements hook_init().

File

./mobile_tools.module, line 666
Functionality to ease the creation of mixed device environments.

Code

function mobile_tools_get_active_device_group($modifier = NULL, $clear = FALSE) {

  // @todo add logic to use the given modifier instead of scanning all of
  // them
  $device_group =& drupal_static(__FUNCTION__);
  if (!isset($device_group) or $clear) {
    $device_group = FALSE;

    // Check the active modifiers
    $active = purl_active();
    $active = _mobile_tools_get_active_purl_modifiers($active
      ->get());
    if (!empty($active)) {
      foreach ($active as $key => $object) {
        $device_group = mobile_tools_device_group_load($object->id);
        if (is_object($device_group)) {

          // @todo add extra check to see if it's the right provider
          // Only one device group can be active at a time.
          // So if we get a loaded device group, just return it.
          return $device_group;
        }
      }
    }
  }
  return $device_group;
}