You are here

function log_permission in Log entity 7

Implements hook_permission().

File

./log.module, line 15
Log - A general purpose record keeping system.

Code

function log_permission() {
  $perms = array(
    'administer log module' => array(
      'title' => t('Administer log module'),
      'description' => t('Gives full access to everything in the log module.'),
      'restrict access' => TRUE,
    ),
    'administer log types' => array(
      'title' => t('Administer log types'),
      'restrict access' => TRUE,
    ),
    'view all logs' => array(
      'title' => t('View all log entities'),
      'description' => t('Allows users to view the full list of log entities.'),
    ),
  );

  // Add permissions for each log type.
  foreach (log_types() as $log_type) {
    $type = $log_type->type;
    $ops = array(
      'view',
      'edit',
      'delete',
    );
    $scopes = array(
      'any',
      'own',
    );
    $perms += array(
      "create {$type} log entities" => array(
        'title' => t('Create new %type_name log entities', array(
          '%type_name' => $log_type->label,
        )),
      ),
    );
    foreach ($ops as $op) {
      foreach ($scopes as $scope) {
        $perms += array(
          "{$op} {$scope} {$type} log entities" => array(
            'title' => drupal_ucfirst($op) . ' ' . $scope . ' ' . t('%type_name log entities', array(
              '%type_name' => $log_type->label,
            )),
          ),
        );
      }
    }
  }
  return $perms;
}