You are here

function forum_access_get_acl in Forum Access 8

Returns the ACL ID of the forum.

3 calls to forum_access_get_acl()
ForumAccess::import in forum_access_migrate/src/Plugin/migrate/destination/ForumAccess.php
forum_access_node_insert in ./forum_access.module
Implements hook_ENTITY_TYPE_insert() for node entities.
_forum_access_forum_moderators_form in includes/forum_access.admin.inc
Create moderators list of users.

File

includes/forum_access.acl.inc, line 13
Integration with ACL.

Code

function forum_access_get_acl($tid, $name) {
  $acl_id = acl_get_id_by_name('forum_access', $name, $tid);

  // Create acl if doesn't exists.
  if (!$acl_id) {
    $acl_id = acl_create_acl('forum_access', $name, $tid);

    // Update all nodes which are related to this term with term's ACL.
    $connection = Database::getConnection();
    $subselect = $connection
      ->select('taxonomy_index', 'n');
    $subselect
      ->fields('n', [
      'nid',
    ])
      ->condition('n.tid', $tid);
    acl_add_nodes($subselect, $acl_id, 1, 1, 1);
  }
  return $acl_id;
}