function PanelizerEntityDefault::panelizer_access in Panelizer 7.3
Same name and namespace in other branches
- 7.2 plugins/entity/PanelizerEntityDefault.class.php \PanelizerEntityDefault::panelizer_access()
Determine if the user has access to the panelizer operation for this type.
5 calls to PanelizerEntityDefault::panelizer_access()
- PanelizerEntityDefault::access_admin in plugins/
entity/ PanelizerEntityDefault.class.php - PanelizerEntityDefault::hook_field_attach_form in plugins/
entity/ PanelizerEntityDefault.class.php - PanelizerEntityDefault::make_fake_tabs in plugins/
entity/ PanelizerEntityDefault.class.php - Create some fake tabs that are attached to a page output.
- PanelizerEntityDefault::page_overview in plugins/
entity/ PanelizerEntityDefault.class.php - Switched page callback to give the overview page
- PanelizerEntityDefault::render_entity in plugins/
entity/ PanelizerEntityDefault.class.php - Render the panels display for a given panelizer entity.
File
- plugins/
entity/ PanelizerEntityDefault.class.php, line 2110 - Base class for the Panelizer Entity plugin.
Class
- PanelizerEntityDefault
- Base class for the Panelizer Entity plugin.
Code
function panelizer_access($op, $bundle, $view_mode) {
$og_access = FALSE;
$entity = NULL;
if (is_object($bundle)) {
$entity = $bundle;
list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
// Additional support for Organic Groups.
// @todo move to og_panelizer_access();
if (module_exists('og')) {
if (og_is_group($this->entity_type, $entity)) {
$og_access = og_user_access($this->entity_type, $entity_id, "administer panelizer og_group {$op}");
}
else {
$og_groups = og_get_entity_groups($this->entity_type, $entity);
foreach ($og_groups as $og_group_type => $og_gids) {
foreach ($og_gids as $og_gid) {
if (og_user_access($og_group_type, $og_gid, "administer panelizer {$this->entity_type} {$bundle} {$op}")) {
$og_access = TRUE;
}
}
}
}
}
// If there is an $op, this must actually be panelized in order to pass.
// If there is no $op, then the settings page can provide us a "panelize
// it!" page even if there is no display.
if ($op && $op != 'overview' && $op != 'settings' && $op != 'choice' && empty($entity->panelizer[$view_mode])) {
return FALSE;
}
}
// Invoke hook_panelizer_access().
$panelizer_access = module_invoke_all('panelizer_access', $op, $this->entity_type, $bundle, $view_mode, $entity);
array_unshift($panelizer_access, user_access('administer panelizer'), user_access("administer panelizer {$this->entity_type} {$bundle} {$op}"));
$panelizer_access[] = $og_access;
// Invoke hook_panelizer_access_alter().
// We can't pass this many parameters to drupal_alter, so stuff them into
// an array.
$options = array(
'op' => $op,
'entity_type' => $this->entity_type,
'bundle' => $bundle,
'view_mode' => $view_mode,
'entity' => $entity,
);
drupal_alter('panelizer_access', $panelizer_access, $options);
foreach ($panelizer_access as $access) {
if ($access) {
return $access;
}
}
return FALSE;
}