You are here

function replicate_ui_access in Replicate UI 7

Access control for access to replicate.

1 call to replicate_ui_access()
views_handler_field_replicate_ui_link::render_link in views/views_handler_field_replicate_ui_link.inc
Renders the link if they have permission to view it
1 string reference to 'replicate_ui_access'
replicate_ui_menu in ./replicate_ui.module
Implements hook_menu().

File

./replicate_ui.module, line 118
Provide a user interface for the Replicate API.

Code

function replicate_ui_access($type, $etid) {
  if (is_object($etid)) {
    $info = entity_get_info($type);

    // ensure we had a valid entity type or bail early
    if (!isset($info['entity keys']) || !isset($info['entity keys']['id'])) {
      return FALSE;
    }
    $etid = $etid->{$info['entity keys']['id']};
  }
  $access = FALSE;

  // make sure they can create this item and access replicate
  $entity = entity_load_single($type, $etid);

  // ensure this exists, they have access to see and create the type and access the ui
  if (!empty($entity) && entity_access('view', $type, $entity) && entity_access('create', $type, $entity) && user_access('replicate entities')) {
    $access = TRUE;
  }

  // Allow other modules to check this access.
  drupal_alter('replicate_ui_access_check', $access, $type, $entity);
  return $access;
}