You are here

function hosting_site_views_access in Hosting 6.2

Views access callback.

Parameters

$type: The display plugin.

$display: The display ID (machine_name).

$account: The current user.

1 call to hosting_site_views_access()
views_plugin_access_hosting_site::access in site/views/views_plugin_access_hosting_site.inc
Determine if the current user has access or not.
1 string reference to 'hosting_site_views_access'
views_plugin_access_hosting_site::get_access_callback in site/views/views_plugin_access_hosting_site.inc
Determine the access callback and arguments.

File

site/views/hosting_site.views.inc, line 302
Hosting site views integration.

Code

function hosting_site_views_access($type, $display, $account = NULL) {
  switch ($type) {
    case 'page':

      // TODO: Figure out why this always appears to deny access.
      return TRUE;
      break;
    case 'block':
      switch ($display) {
        case 'block_1':
          $node = menu_get_object();
          $menu_item = menu_get_item();
          if (!empty($node) && $menu_item['number_parts'] == 2) {
            return $node->type == 'platform';
          }
          break;
        case 'block_profile':
          $node = menu_get_object();
          if (!empty($node)) {
            return $node->package_type == 'profile';
          }
          break;
        case 'block_client':
          $node = menu_get_object();
          $menu_item = menu_get_item();
          if (!empty($node) && $menu_item['number_parts'] == 2) {
            return $node->type == 'client' && user_access('create site', $account);
          }
          break;
        case 'block_client2':
          $node = menu_get_object();
          $menu_item = menu_get_item();
          if (!empty($node) && $menu_item['number_parts'] == 2) {
            return $node->type == 'client' && user_access('view site', $account) && !user_access('create site', $account);
          }
          break;
        default:
          return FALSE;
      }
      break;
    default:
      return FALSE;
  }
  return FALSE;
}