You are here

function comment_perm_admin_settings in Comment Permissions 6

Same name and namespace in other branches
  1. 5 comment_perm.module \comment_perm_admin_settings()
  2. 7.2 comment_perm.admin.inc \comment_perm_admin_settings()
  3. 7 comment_perm.admin.inc \comment_perm_admin_settings()

Menu callback; presents the comment_perm settings page.

1 string reference to 'comment_perm_admin_settings'
comment_perm_menu in ./comment_perm.module
Implementation of hook_menu().

File

./comment_perm.admin.inc, line 11
Administration pages for Comment Permissions module.

Code

function comment_perm_admin_settings() {
  $form = array();
  $form['help'] = array(
    '#prefix' => '<p>',
    '#value' => t('Enable the extended comment permissions for certain content
      types here. Then go to !administer_permissions to configure which roles
      can post comments for these content types.', array(
      '!administer_permissions' => l('administer permissions', 'admin/user/permissions'),
    )),
    '#suffix' => '</p>',
  );

  // get node types
  $node_types = node_get_types();
  foreach ($node_types as $type => $obj) {
    switch (variable_get('comment_' . $type, COMMENT_NODE_READ_WRITE)) {
      case COMMENT_NODE_READ_ONLY:
        $status = '<em> (comments are currently read only)</em>';
        break;
      case COMMENT_NODE_READ_WRITE:
        $status = '';
        break;
      case COMMENT_NODE_DISABLED:
        $status = '<em>  (comments are currently disabled)</em>';
        break;
    }
    $types[$type] = $obj->name . $status;
  }
  $form['comment_perm_node_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Enable comment permissions by role for these content types'),
    '#default_value' => variable_get('comment_perm_node_types', array()),
    '#options' => $types,
  );
  $form['comment_perm_hide_comments'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hide comments entirely'),
    '#default_value' => variable_get('comment_perm_hide_comments', 0),
    '#description' => t('Comments will be hidden entirely for users without permission to post comments.  If unchecked, the messages set below will be shown instead.'),
  );
  $form['comment_perm_message_anon'] = array(
    '#type' => 'textfield',
    '#title' => t('Commenting denied message for anonymous users'),
    '#default_value' => variable_get('comment_perm_message_anon', t('Login or register to post comments!')),
    '#description' => t('Ideally commentting will be invisible to those without permission to post, but
                         just in case you can specify the message they will see.'),
  );
  $form['comment_perm_message_reg'] = array(
    '#type' => 'textfield',
    '#title' => t('Commenting denied message for registered users'),
    '#default_value' => variable_get('comment_perm_message_reg', t("We're sorry, but you can't post comments here!")),
    '#description' => t('Ideally commentting will be invisible to those without permission to post, but
                         just in case you can specify the message they will see.'),
  );
  return system_settings_form($form);
}