function _homebox_check_views_block_access in Homebox 6
Same name and namespace in other branches
- 6.2 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())
2 calls to _homebox_check_views_block_access()
- homebox_list_available_blocks in ./
homebox.module - List available blocks to let user show/hide blocks
- homebox_load_blocks_in_regions in ./
homebox.module - Loads available blocks for user
File
- ./
homebox.module, line 451 - Home box 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;
}