You are here

function profile2_permission in Profile 2 7

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

Implements hook_permission().

File

./profile2.module, line 169
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.'),
    ),
  );

  // 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;
}