You are here

function _forum_access_comment_form in Forum Access 6

Same name and namespace in other branches
  1. 7 forum_access.node.inc \_forum_access_comment_form()

Remove the in-line 'Post new comment' form, if the user does not have the 'create' permission (see below). (This needs forum_access_preprocess_box() to clean up afterwards.)

Also, deny access if the user tries to enter a comment URL directly, and sanitize the Administration options for users with Edit grants.

1 call to _forum_access_comment_form()
forum_access_form_alter in ./forum_access.module
Implementation of hook_form_alter().

File

./forum_access.node.inc, line 116
forum_access.node.inc

Code

function _forum_access_comment_form(&$form, &$form_state) {
  global $user;
  if ($user->uid != 1 && isset($form['nid']['#value'])) {
    $node = node_load($form['nid']['#value']);
    if ($tid = _forum_access_get_tid($node)) {
      if (!forum_access_access($tid, 'create')) {
        switch (arg(0)) {
          case 'node':
            $form = NULL;

            // remove the in-line comment form
            break;
          case 'comment':
            drupal_access_denied();
            module_invoke_all('exit');
            exit;
        }
      }
      else {
        if (isset($form['admin']) && !empty($user->_forum_access_moderator)) {
          foreach (element_children($form['admin']) as $key) {
            if ($key != 'status') {
              $form['admin'][$key]['#access'] = FALSE;
            }
          }
        }
      }
    }
  }
}