View source
<?php
function comment_og_link_alter(&$links, $node) {
if ($node->comment) {
if (isset($node->og_groups)) {
if (!og_is_group_member(og_get_group_context())) {
unset($links['comment_add']);
}
}
}
}
function comment_og_preprocess_comment(&$variables) {
$comment = $variables['comment'];
$links = comment_links($comment, FALSE);
$group = og_get_group_context();
if ($group) {
if (!og_is_group_member($group)) {
unset($links['comment_reply']);
}
if (og_is_group_admin($group)) {
$links['comment_delete'] = array(
'title' => t('delete'),
'href' => "comment/delete/{$comment->cid}/{$group->nid}",
);
}
}
$variables['links'] = theme('links', $links);
}
function comment_og_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'comment_form' && isset($form['nid'])) {
if (!og_is_group_member(og_get_group_context())) {
$form['comment_filter']['comment'] = array(
'#type' => 'textarea',
'#title' => t('Comment'),
'#rows' => 5,
'#disabled' => TRUE,
'#description' => t('You must be a member of this group in order to post a comment.'),
);
if (isset($form['subject'])) {
unset($form['subject']);
}
if (isset($form['comment_filter']['format'])) {
unset($form['comment_filter']['format']);
}
if (isset($form['submit'])) {
unset($form['submit']);
}
if (isset($form['preview'])) {
unset($form['preview']);
}
if (isset($form['author'])) {
unset($form['author']);
}
if (isset($form['_author'])) {
unset($form['_author']);
}
}
}
}
function comment_og_menu_alter(&$items) {
$items['comment/delete'] = array(
'title' => 'Delete comment',
'page callback' => 'comment_delete',
'access callback' => 'comment_og_comment_delete',
'access arguments' => array(
3,
),
'type' => MENU_CALLBACK,
'file' => 'comment.admin.inc',
'file path' => drupal_get_path('module', 'comment'),
);
}
function comment_og_comment_delete($gid = NULL) {
if ($gid) {
$group = node_load($gid);
og_load_group($group);
return og_is_group_admin($group);
}
else {
return user_access('administer comments') && user_access('post comments');
}
}