You are here

function user_relationships_permission in User Relationships 7

Implements hook_permission().

File

./user_relationships.module, line 287
User Relationships API. Module shell.

Code

function user_relationships_permission() {
  $permissions = array(
    'administer user relationships' => array(
      'title' => t('Administer User Relationships'),
      'description' => t('Allows to administer user relationships and view relationships of all users.'),
    ),
  );
  foreach (user_relationships_types_load() as $type) {
    $permissions['can have ' . $type->machine_name . ' relationships'] = array(
      'title' => t('Have %name relationships', array(
        '%name' => $type->name,
      )),
      'description' => t('The user may have relationships of this type.'),
    );
    $permissions['maintain ' . $type->machine_name . ' relationships'] = array(
      'title' => t('Maintain %name relationships', array(
        '%name' => $type->name,
      )),
      'description' => t('The user may approve or decline relationship requests of this type.'),
    );
    $permissions['can request ' . $type->machine_name . ' relationships'] = array(
      'title' => t('Request %name relationships', array(
        '%name' => $type->name,
      )),
      'description' => t('The user may request relationships of this type.'),
    );
    $permissions['delete ' . $type->machine_name . ' relationships'] = array(
      'title' => t('Delete %name relationships', array(
        '%name' => $type->name,
      )),
      'description' => t('The user may delete current relationships of this type.'),
    );
  }
  return $permissions;
}