comment_perm.admin.inc in Comment Permissions 7.2
Same filename and directory in other branches
Administration pages for Comment Permissions module.
File
comment_perm.admin.incView source
<?php
/**
* @file
* Administration pages for Comment Permissions module.
*/
/**
* Menu callback; presents the comment_perm settings page.
*/
function comment_perm_admin_settings() {
$form = array();
$form['help'] = array(
'#markup' => 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(t('administer permissions'), 'admin/user/permissions'),
)),
);
$types = array();
foreach (node_type_get_types() as $type => $content_type) {
$status = _comment_perm_admin_comment_status_info($type);
$types[$type] = $content_type->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.'),
);
return system_settings_form($form);
}
/**
* Get info about comment status for a specific node type.
*
* @param string $type
* Content type machine name.
*
* @return string
* Status message.
*/
function _comment_perm_admin_comment_status_info($type) {
switch (variable_get('comment_' . $type, COMMENT_NODE_OPEN)) {
case COMMENT_NODE_CLOSED:
$status = t('<em>(comments are currently read only)</em>');
break;
case COMMENT_NODE_OPEN:
default:
$status = '';
break;
case COMMENT_NODE_HIDDEN:
$status = t('<em>(comments are currently disabled)</em>');
break;
}
return $status;
}
Functions
Name | Description |
---|---|
comment_perm_admin_settings | Menu callback; presents the comment_perm settings page. |
_comment_perm_admin_comment_status_info | Get info about comment status for a specific node type. |