You are here

function comment_perm_permission in Comment Permissions 7.2

Same name and namespace in other branches
  1. 7 comment_perm.module \comment_perm_permission()

Implements hook_permission().

File

./comment_perm.module, line 63
Control commenting permissions by role and by node type.

Code

function comment_perm_permission() {
  $types = variable_get('comment_perm_node_types', array());
  $perms = array();
  if (empty($types)) {
    return $perms;
  }
  foreach ($types as $type) {
    $label = ucfirst($type);
    if ($type) {
      $perms["administer comments {$type}"] = array(
        'title' => t('%type: Administer any comments and comment settings', array(
          '%type' => $label,
        )),
      );
      $perms["administer comments own {$type}"] = array(
        'title' => t('%type: Administer comments and comment settings for own content', array(
          '%type' => $label,
        )),
      );
      $perms["access comments {$type}"] = array(
        'title' => t('%type: View comments', array(
          '%type' => $label,
        )),
      );
      $perms["post comments {$type}"] = array(
        'title' => t('%type: Post comment', array(
          '%type' => $label,
        )),
      );
      $perms["skip comment approval {$type}"] = array(
        'title' => t('%type: Skip comment approval', array(
          '%type' => $label,
        )),
      );
      $perms["skip comment approval own {$type}"] = array(
        'title' => t('%type: Skip comment approval for own content', array(
          '%type' => $label,
        )),
      );
      $perms["edit own comments {$type}"] = array(
        'title' => t('%type: Edit own comments', array(
          '%type' => $label,
        )),
      );
    }
  }
  return $perms;
}