You are here

function comment_og_og_permission in Comment OG 7

Implements hook_og_permission().

File

./comment_og.module, line 10
Provides comment integration for Organic Groups.

Code

function comment_og_og_permission() {

  // Generate standard node permissions for all applicable node types.
  $perms = array();
  foreach (node_permissions_get_configured_types() as $type) {
    if (og_is_group_content_type('node', $type) || og_is_group_type('node', $type)) {
      $info = node_type_get_type($type);
      $type = check_plain($info->type);
      if (og_is_group_type('node', $type)) {
        $perms["post comment_node_{$type}"] = array(
          'title' => t('Post comments on %type_name', array(
            '%type_name' => $info->name,
          )),
          'description' => t('Comment on the main group node, similar to a wall post.'),
          'default role' => array(
            OG_ADMINISTRATOR_ROLE,
            OG_AUTHENTICATED_ROLE,
          ),
        );
        $perms["edit comment_node_{$type}"] = array(
          'title' => t('Edit any comment on %type_name', array(
            '%type_name' => $info->name,
          )),
          'description' => t('Member can edit any comment, including those posted by others. Edited comments are then owned by the editing member.'),
          'default role' => array(
            OG_ADMINISTRATOR_ROLE,
          ),
        );
        $perms["edit own comment_node_{$type}"] = array(
          'title' => t('Edit own comments on %type_name', array(
            '%type_name' => $info->name,
          )),
          'description' => t('Member can edit only their own comments.'),
          'default role' => array(
            OG_ADMINISTRATOR_ROLE,
          ),
        );
        $perms["delete comment_node_{$type}"] = array(
          'title' => t('Delete comments on %type_name', array(
            '%type_name' => $info->name,
          )),
          'default role' => array(
            OG_ADMINISTRATOR_ROLE,
          ),
        );
        $perms["approve comment_node_{$type}"] = array(
          'title' => t('Approve comments on %type_name', array(
            '%type_name' => $info->name,
          )),
          'default role' => array(
            OG_ADMINISTRATOR_ROLE,
          ),
        );
      }
      else {
        $perms["post comment_node_{$type}"] = array(
          'title' => t('Post comments on %type_name content', array(
            '%type_name' => $info->name,
          )),
          'default role' => array(
            OG_ADMINISTRATOR_ROLE,
            OG_AUTHENTICATED_ROLE,
          ),
        );
        $perms["edit comment_node_{$type}"] = array(
          'title' => t('Edit any comment on %type_name content', array(
            '%type_name' => $info->name,
          )),
          'description' => t('Member can edit any comment, including those posted by others. Edited comments are then owned by the editing member.'),
          'default role' => array(
            OG_ADMINISTRATOR_ROLE,
          ),
        );
        $perms["edit own comment_node_{$type}"] = array(
          'title' => t('Edit own comments on %type_name content', array(
            '%type_name' => $info->name,
          )),
          'description' => t('Member can edit only their own comments.'),
          'default role' => array(
            OG_ADMINISTRATOR_ROLE,
          ),
        );
        $perms["delete comment_node_{$type}"] = array(
          'title' => t('Delete comments on %type_name content', array(
            '%type_name' => $info->name,
          )),
          'default role' => array(
            OG_ADMINISTRATOR_ROLE,
          ),
        );
        $perms["approve comment_node_{$type}"] = array(
          'title' => t('Approve comments on %type_name content', array(
            '%type_name' => $info->name,
          )),
          'default role' => array(
            OG_ADMINISTRATOR_ROLE,
          ),
        );
      }
    }
  }
  return $perms;
}