function forum_access_get_settings in Forum Access 8
Retrieve the settings for a taxonomy term.
Parameters
int $tid: (optional) Taxonomy term id.
Return value
array Settings for a taxonomy term.
2 calls to forum_access_get_settings()
- forum_access_form_taxonomy_term_forums_container_form_alter in ./
forum_access.module - Implements hook_form_FORM_ID_alter() for taxonomy_term_forums_container_form.
- forum_access_form_taxonomy_term_forums_forum_form_alter in ./
forum_access.module - Implements hook_form_FORM_ID_alter() for taxonomy_term_forums_forum_form.
File
- ./
forum_access.module, line 699 - Contains forum_access.module.
Code
function forum_access_get_settings($tid = NULL) {
$settings = [
'view' => [],
'create' => [],
'update' => [],
'delete' => [],
'priority' => 0,
];
$result = \Drupal::database()
->select('forum_access', 'a')
->fields('a', [
'tid',
'rid',
'grant_view',
'grant_update',
'grant_delete',
'grant_create',
'priority',
])
->condition('tid', $tid)
->execute();
foreach ($result as $access) {
if ($access->grant_view) {
$settings['view'][] = $access->rid;
}
if ($access->grant_update) {
$settings['update'][] = $access->rid;
}
if ($access->grant_delete) {
$settings['delete'][] = $access->rid;
}
if ($access->grant_create) {
$settings['create'][] = $access->rid;
}
if ($access->rid == AccountInterface::AUTHENTICATED_ROLE) {
// This is our reference.
$settings['priority'] = $access->priority;
}
}
return $settings;
}