You are here

function message_ui_permission in Message UI 7

Implements hook_permission().

File

./message_ui.module, line 247
Main file for the message UI module.

Code

function message_ui_permission() {

  // Defining the operation.
  $operations = array(
    'view',
    'edit',
    'create',
    'delete',
  );

  // Build the permissions.
  $permissions = array();
  $permissions['bypass message access control'] = array(
    'title' => t('Bypass message access control'),
    'description' => t('Grant to the user the permission to apply CRUD option on any messages. Grant this permission to trusty users!'),
  );
  $permissions['update tokens'] = array(
    'title' => t('Manage the message tokens'),
    'description' => t('Grant to the user the permission to update the tokens of the message - manually or automatically with a checkbox'),
  );
  foreach ($operations as $operation) {
    $permissions[$operation . ' any message instance'] = array(
      'title' => t(ucfirst($operation) . ' any message type'),
      'description' => t('Allowing to ' . $operation . ' message from any message type.'),
    );
    if ($types = message_ui_get_types()) {
      foreach ($types as $type => $title) {
        $permissions[$operation . ' a ' . $type . ' message instance'] = array(
          'title' => t(ucfirst($operation) . ' a new message instance for ' . $title),
          'description' => t('Allowing to ' . $operation . ' an instance for the ' . $title . ' message type'),
        );
      }
    }
  }
  return $permissions;
}