Same name in other branches
- 8.x-1.x src/Plugin/QuickContent/QuickBlockContent.php \Drupal\quicktabs\Plugin\QuickContent\QuickBlockContent::accessBlock()
Checks if the current user can access a block.
1 call to QuickBlockContent::accessBlock()
- QuickBlockContent::render dans plugins/
QuickBlockContent.inc - Renders the content.
Fichier
-
plugins/
QuickBlockContent.inc, line 108
Classe
- QuickBlockContent
- Class for tab content of type "block" - this is for rendering a block as tab content.
Code
private function accessBlock($module, $delta) {
// Get current user's rids.
global $user;
$rids = array_keys($user->roles);
// Get authorized rids.
$authorized_rids = db_select('block_role', 'br')->fields('br', array(
'rid',
))
->condition('module', $module, '=')
->condition('delta', $delta, '=')
->execute()
->fetchCol('rid');
// Return whether the user can access the block:
// - Either all roles have access - no record in {block_role}
// - Or only specific roles have access - in which case rids should match.
return count($authorized_rids) == 0 || count(array_intersect($authorized_rids, $rids)) != 0;
}