You are here

public function PanelizerEntityDefault::hook_permission in Panelizer 7.2

Same name and namespace in other branches
  1. 7.3 plugins/entity/PanelizerEntityDefault.class.php \PanelizerEntityDefault::hook_permission()

Implements a delegated hook_permission.

Overrides PanelizerEntityInterface::hook_permission

File

plugins/entity/PanelizerEntityDefault.class.php, line 191
Base class for the Panelizer Entity plugin.

Class

PanelizerEntityDefault
Base class for the Panelizer Entity plugin.

Code

public function hook_permission(&$items) {
  $entity_info = entity_get_info($this->entity_type);

  // Make a permission for each bundle we control.
  foreach ($this->plugin['bundles'] as $bundle => $settings) {

    // This is before the if because it shows up regardless of whether
    // or not a type is panelized.
    $items["administer panelizer {$this->entity_type} {$bundle} defaults"] = array(
      'title' => t('%entity_name %bundle_name: Administer Panelizer default panels, allowed content and settings.', array(
        '%entity_name' => $entity_info['label'],
        '%bundle_name' => $entity_info['bundles'][$bundle]['label'],
      )),
      'description' => t('Users with this permission can fully administer panelizer for this entity bundle.'),
    );
    if (empty($settings['status'])) {
      continue;
    }
    $items["administer panelizer {$this->entity_type} {$bundle} content"] = array(
      'title' => t('%entity_name %bundle_name: Administer Panelizer content', array(
        '%entity_name' => $entity_info['label'],
        '%bundle_name' => $entity_info['bundles'][$bundle]['label'],
      )),
    );
    $items["administer panelizer {$this->entity_type} {$bundle} context"] = array(
      'title' => t('%entity_name %bundle_name: Administer Panelizer context', array(
        '%entity_name' => $entity_info['label'],
        '%bundle_name' => $entity_info['bundles'][$bundle]['label'],
      )),
    );
    $items["administer panelizer {$this->entity_type} {$bundle} layout"] = array(
      'title' => t('%entity_name %bundle_name: Administer Panelizer layout', array(
        '%entity_name' => $entity_info['label'],
        '%bundle_name' => $entity_info['bundles'][$bundle]['label'],
      )),
    );
    $items["administer panelizer {$this->entity_type} {$bundle} settings"] = array(
      'title' => t('%entity_name %bundle_name: Administer Panelizer settings', array(
        '%entity_name' => $entity_info['label'],
        '%bundle_name' => $entity_info['bundles'][$bundle]['label'],
      )),
    );
    if (!empty($settings['choice'])) {
      $items["administer panelizer {$this->entity_type} {$bundle} choice"] = array(
        'title' => t('%entity_name %bundle_name: Choose panels', array(
          '%entity_name' => $entity_info['label'],
          '%bundle_name' => $entity_info['bundles'][$bundle]['label'],
        )),
        'description' => t('Allows the user to choose which default panel the entity uses.'),
      );
    }
  }
}