You are here

function mobile_tools_get_active_device_group in Mobile Tools 7.2

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

Get the active device group

Return value

array Returns the active device groups, FALSE otherwise.

6 calls to mobile_tools_get_active_device_group()
mobile_tools_block_message in ./mobile_tools.module
Helper function returning the configurable message for the notification
mobile_tools_context_condition_mobile::execute in mobile_tools_context/mobile_tools_context.condition_mobile.inc
Process condition logic
mobile_tools_context_init in mobile_tools_context/mobile_tools_context.module
Implements hook_init().
mobile_tools_device_redirect in ./mobile_tools.module
Redirect the user based on the device/site type combination
mobile_tools_html_head_alter in ./mobile_tools.module
Implements hook_html_head_alter().

... See full list

File

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

Code

function mobile_tools_get_active_device_group() {

  // There are a few triggers which can point to the active device group
  // @todo add static cache
  // Next check for an active Space
  // @todo configure to handle multiple active spaces
  $space = spaces_get_space();
  if (isset($spaces->type)) {
    return array(
      'id' => $spaces->id,
      'type' => $spaces->type,
    );
  }
  else {

    // In case the device group is requested before the Space is initialized
    // we detect based on the active PURL modifiers
    $device_groups = array();
    $active = purl_active();
    $active = _mobile_tools_get_active_purl_modifiers($active
      ->get());
    if (!empty($active)) {
      foreach ($active as $key => $object) {
        $device_groups[] = array(
          'id' => $object->id,
          'type' => MOBILE_TOOLS_DEVICE_GROUP_PREFIX . $object->id,
        );
      }
      return $device_groups;
    }
  }
  return FALSE;
}