You are here

function forum_access_set_settings in Forum Access 8

Set settings for taxonomy term.

Parameters

int $tid: Taxonomy term id.

array $settings: Forum Access settings.

1 call to forum_access_set_settings()
_forum_access_form_roles_permissions_save in includes/forum_access.admin.inc
Save roles permissions.

File

./forum_access.module, line 748
Contains forum_access.module.

Code

function forum_access_set_settings($tid, array $settings) {
  \Drupal::database()
    ->delete('forum_access')
    ->condition('tid', $tid)
    ->execute();
  $insert = \Drupal::database()
    ->insert('forum_access');
  $insert
    ->fields([
    'tid',
    'rid',
    'grant_view',
    'grant_update',
    'grant_delete',
    'grant_create',
    'priority',
  ]);
  foreach ($settings['view'] as $rid => $checked) {
    $insert
      ->values([
      'tid' => $tid,
      'rid' => $rid,
      'grant_view' => (int) (!empty($checked)),
      'grant_update' => (int) (!empty($settings['update'][$rid])),
      'grant_delete' => (int) (!empty($settings['delete'][$rid])),
      'grant_create' => (int) (!empty($settings['create'][$rid])),
      'priority' => 0,
    ]);
  }
  $insert
    ->execute();
}