You are here

function comment_og_comment_edit in Comment OG 6

Returns comment form if the option is enabled and the acting user is a group admin Otherwise, revert to the default behavior

1 string reference to 'comment_og_comment_edit'
comment_og_menu in ./comment_og.module
Implementation of hook_menu().

File

./comment_og.module, line 251

Code

function comment_og_comment_edit($cid = NULL, $gid = NULL) {
  $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $cid));
  $comment = drupal_unpack($comment);
  $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
  $admins_can_edit = variable_get('comment_og_admin_edit', 1);
  $group = $gid ? node_load($gid) : NULL;
  if ($group) {
    og_load_group($group);

    // if the user would normally be able to edit the comment, use the default form
    if (comment_access('edit', $comment)) {
      return comment_form_box((array) $comment);
    }
    elseif ($admins_can_edit && og_is_group_admin($group)) {
      return comment_og_form_box((array) $comment, $group);
    }
  }
  else {
    drupal_access_denied();
  }
}