You are here

function _forum_access_forum_interference_form in Forum Access 7

1 call to _forum_access_forum_interference_form()
_forum_access_forum_form in ./forum_access.admin.inc
Rewrite the forum administration page with our new access rules.

File

./forum_access.admin.inc, line 371
forum_access.admin.inc

Code

function _forum_access_forum_interference_form($is_container, $na_modules, $fa_priority) {
  $tr = 't';
  $l = 'l';
  $form = array();
  if (count($na_modules) && !$is_container) {
    $form = array(
      '#type' => 'fieldset',
      '#title' => t('Module interference'),
      '#collapsible' => TRUE,
    );
    $variables = array(
      '%content_type' => node_type_get_name('forum'),
      '!Forum_Access' => 'Forum Access',
      '!Content_Access' => $l('Content Access', 'http://drupal.org/project/content_access'),
      '@Content_Access' => 'Content Access',
      '!ACL' => 'ACL',
      '!module_list' => '<ul><li>' . implode($na_modules, '</li><li>') . '</li></ul>',
    );
    $description = t('Forums can contain other content types besides %content_type; !Forum_Access will contribute the grants defined above to every node in this forum, but other node access control modules may also contribute their grants, especially to nodes of types other than %content_type.', $variables);
    $form[] = array(
      '#type' => 'item',
      '#markup' => '<p>' . t("Besides !Forum_Access (and !ACL) you have installed the following node access module(s): !module_list   The grants of every module are combined for each node. Access can only be granted, not removed &mdash; if a certain module grants a permission, the other(s) cannot deny it.", $variables) . '</p>',
      '#description' => filter_xss($description),
    );
    if (module_exists('content_access')) {
      foreach (array(
        'view',
        'update',
        'delete',
        'per_node',
      ) as $type) {
        $value = content_access_get_settings($type, 'forum');
        if (!empty($value)) {
          $ca_interferes = TRUE;
        }
      }
      $ca_priority = content_access_get_settings('priority', 'forum');
      $is_conflict = $ca_priority >= $fa_priority && !empty($ca_interferes) || $ca_priority > $fa_priority;
      $variables += array(
        '!link' => l(t('@Content_Access configuration for the %content_type type', $variables), 'admin/structure/types/manage/forum/access', array(
          'html' => TRUE,
        )),
        '%Advanced' => $tr('Advanced'),
      );
      $specifically = $ca_priority == $fa_priority ? t('Specifically, any grants given by !Content_Access cannot be taken back by !Forum_Access.', $variables) : '';
      if ($is_conflict) {
        $form['by_content_access'] = array(
          '#type' => 'fieldset',
          '#title' => 'Content Access',
          '#collapsible' => FALSE,
          '#attributes' => array(
            'class' => array(
              'error',
            ),
          ),
        );
        $form['by_content_access'][] = array(
          '#markup' => '<div>' . t('You have set the !Content_Access module to control access to content of type %content_type&mdash;this can interfere with proper operation of !Forum_Access!', $variables) . " {$specifically}</div>",
        );
        if ($ca_priority == $fa_priority) {
          $form['by_content_access'][] = array(
            '#markup' => '<div>' . t("Unless you really know what you're doing, we recommend that you go to the !link page and clear all checkboxes. This will instruct @Content_Access to leave the %content_type nodes alone. However, if you put nodes of other content types into forums as well, then these content types will continue to have this problem.", $variables) . '</div>',
          );
        }
        else {
          $variables += array(
            '%ca_priority' => $ca_priority,
            '%fa_priority' => $fa_priority,
          );
          $form['by_content_access'][] = array(
            '#markup' => '<div>' . t("The priority of @Content_Access (%ca_priority) is higher than the priority of !Forum_Access (%fa_priority), which means the latter is <strong>completely disabled</strong> for the %content_type type! Unless you really know what you're doing, we recommend that you go to the !link page, change the priority (under %Advanced) to 0, and clear all checkboxes.", $variables) . '</div>',
          );
        }
        $form['by_content_access'][] = array(
          '#markup' => '<div>' . t("Alternatively, you can give !Forum_Access priority over @Content_Access by either raising the priority of !Forum_Access in every forum above the priority of @Content_Access, or by lowering the priority of @Content_Access for the content types in question below the priority of !Forum_Access.", $variables) . '</div>',
        );
      }
      else {
        $form[] = array(
          '#markup' => '<p>' . t('Note: You have installed the !Content_Access module, which has the capability to grant access to content that would otherwise be protected by !Forum_Access. Be careful when configuring @Content_Access!', $variables) . '</p>',
        );
      }
    }
    $form['advanced'] = array(
      '#type' => 'fieldset',
      '#title' => t('Advanced'),
      '#collapsible' => TRUE,
      '#collapsed' => !($fa_priority != 0),
    );
    $description = t("If you have no other node access control modules installed, you should leave this at the default 0. <br /> Otherwise you can raise or lower the priority of !Forum_Access' grants. Out of all the grants contributed to a node, only those with the highest priority are used, and all others are discarded.", $variables);
    $form['advanced']['priority'] = array(
      '#type' => 'weight',
      '#title' => check_plain(t('Priority of !Forum_Access node grants in this forum', $variables)),
      '#default_value' => $fa_priority,
      '#description' => filter_xss($description, array(
        'br',
      )),
    );
  }
  return $form;
}