You are here

function profile2_permission in Profile 2 7.2

Same name and namespace in other branches
  1. 7 profile2.module \profile2_permission()

Implements hook_permission().

File

./profile2.module, line 309
Support for configurable user profiles.

Code

function profile2_permission() {
  $permissions = array(
    'administer profile types' => array(
      'title' => t('Administer profile types'),
      'description' => t('Create and delete fields on user profiles, and set their permissions.'),
    ),
    'administer profiles' => array(
      'title' => t('Administer profiles'),
      'description' => t('Edit and view all user profiles.'),
    ),
    'view own profile revisions' => array(
      'title' => t('View own profile revisions'),
    ),
    'revert own profile revisions' => array(
      'title' => t('Revert own profile revisions'),
    ),
    'delete own profile revisions' => array(
      'title' => t('Delete own profile revisions'),
    ),
    'view any profile revisions' => array(
      'title' => t('View any profile revisions'),
    ),
    'revert any profile revisions' => array(
      'title' => t('Revert any profile revisions'),
    ),
    'delete any profile revisions' => array(
      'title' => t('Delete any profile revisions'),
    ),
    'allow to choose profile2 revision creation' => array(
      'title' => t('Allow to choose profile2 revision creation'),
    ),
  );

  // Generate per profile type permissions.
  foreach (profile2_get_types() as $type) {
    $type_name = check_plain($type->type);
    $permissions += array(
      "edit own {$type_name} profile" => array(
        'title' => t('%type_name: Edit own profile', array(
          '%type_name' => $type
            ->getTranslation('label'),
        )),
      ),
      "edit any {$type_name} profile" => array(
        'title' => t('%type_name: Edit any profile', array(
          '%type_name' => $type
            ->getTranslation('label'),
        )),
      ),
      "view own {$type_name} profile" => array(
        'title' => t('%type_name: View own profile', array(
          '%type_name' => $type
            ->getTranslation('label'),
        )),
      ),
      "view any {$type_name} profile" => array(
        'title' => t('%type_name: View any profile', array(
          '%type_name' => $type
            ->getTranslation('label'),
        )),
      ),
      "delete own {$type_name} profile" => array(
        'title' => t('%type_name: Delete own profile', array(
          '%type_name' => $type
            ->getTranslation('label'),
        )),
      ),
    );
  }
  return $permissions;
}