public function JuiceboxXmlField::access in Juicebox HTML5 Responsive Image Galleries 7.2
Check access to the Drupal data that will be used to build the gallery.
Return value
boolean Returns TRUE if access is allowed for the current user and FALSE if not. Can also return NULL if access cannot be determined.
Overrides JuiceboxXmlInterface::access
File
- plugins/
JuiceboxXmlField.inc, line 61 - Juicebox XML loader that's used to load (and build via loaded methods) the XML associated with a Drupal field formatter plugin.
Class
- JuiceboxXmlField
- Class to load and build the XML associated with a Drupal field formatter plugin.
Code
public function access() {
$access = TRUE;
// Check field-level access.
if (!isset($this->fieldAccess)) {
$field = field_info_field($this->fieldName);
$this->fieldAccess = field_access('view', $field, $this->entityType, $this->entity);
}
$access = $access && $this->fieldAccess;
// Check entity-level access.
if (!isset($this->entityAccess)) {
// If the Entity API module is installed we can use entity_access() to
// check access for numerous entity types via their access callbacks.
// All core entities, and many custom ones, can be handled here.
if (module_exists('entity')) {
$this->entityAccess = entity_access('view', $this->entityType, $this->entity);
}
else {
switch ($this->entityType) {
case 'node':
$this->entityAccess = node_access('view', $this->entity);
break;
case 'user':
$this->entityAccess = user_view_access($this->entity);
break;
default:
// Log a warning and return NULL if we can't do a conclusive
// check.
watchdog('juicebox', 'Could not verify view access for entity type %type while building Juicebox data. This may have resulted in a broken gallery display. You may be able to remove this error by installing the Entity API module and ensuring that an access callback exists for entities of type %type.', array(
'%type' => $entity_type,
), WATCHDOG_ERROR);
return;
}
}
}
$access = $access && $this->entityAccess;
return $access;
}