function _homebox_check_views_block_access in Homebox 6.2
Same name and namespace in other branches
- 6 homebox.module \_homebox_check_views_block_access()
Helper function to properly check access to blocks generated by the Views module Coda taken from : function views_block($op = 'view', $delta = 0, $edit = array())
Parameters
$block: A block object
Return value
Boolean value of user access to the View
1 call to _homebox_check_views_block_access()
- _homebox_can_view_block in ./
homebox.module - Determine if user has access to view a block
File
- ./
homebox.module, line 1155 - Homebox main file, takes care of global functions settings constants, etc.
Code
function _homebox_check_views_block_access($block) {
$delta = $block->delta;
// if this is 32, this should be an md5 hash.
if (drupal_strlen($delta) == 32) {
$hashes = variable_get('views_block_hashes', array());
if (!empty($hashes[$delta])) {
$delta = $hashes[$delta];
}
}
// This indicates it's a special one.
if (drupal_substr($delta, 0, 1) == '-') {
list($nothing, $type, $name, $display_id) = explode('-', $delta);
if ($view = views_get_view($name)) {
if ($view
->access($display_id)) {
$view
->destroy();
return TRUE;
}
$view
->destroy();
}
}
list($name, $display_id) = explode('-', $delta);
// Load the view
if ($view = views_get_view($name)) {
if ($view
->access($display_id)) {
$view
->destroy();
return TRUE;
}
$view
->destroy();
}
return FALSE;
}