function admin_set_admin_blocks in Admin 6.2
Set static cache for blocks enabled for the admin toolbar.
2 calls to admin_set_admin_blocks()
- admin_get_admin_blocks in ./
admin.module - Get wrapper around admin blocks set.
- admin_preprocess_pre_page in ./
admin.module - Preprocessor that runs *before* template_preprocess_page().
File
- ./
admin.module, line 373
Code
function admin_set_admin_blocks($reset = FALSE) {
static $blocks;
if (!isset($blocks) || $reset) {
$blocks = array();
if (user_access('use admin toolbar') && ($enabled_blocks = admin_get_settings('blocks'))) {
foreach ($enabled_blocks as $bid => $cache) {
$block = NULL;
$split = explode('-', $bid, 2);
if (count($split) === 2) {
list($module, $delta) = $split;
$block = new stdClass();
$block->module = $module;
$block->delta = $delta;
$block->cache = is_numeric($cache) ? $cache : BLOCK_NO_CACHE;
$block->region = 'admin_toolbar';
// Fake the block region.
}
if (!empty($block)) {
if ($_SERVER['REQUEST_METHOD'] == 'GET' && ($cid = admin_block_get_cache_id($block))) {
if ($cache = cache_get($cid, 'cache_block')) {
$array = $cache->data;
}
else {
$array = module_invoke($block->module, 'block', 'view', $block->delta);
cache_set($cid, $array, 'cache_block', CACHE_TEMPORARY);
}
}
else {
$array = module_invoke($block->module, 'block', 'view', $block->delta);
}
if (!empty($array['content'])) {
foreach ($array as $k => $v) {
$block->{$k} = $v;
}
if ($block->module === 'block') {
global $theme;
$block->subject = db_result(db_query("SELECT title FROM {blocks} WHERE module = 'block' AND delta = '%s'", $delta));
}
// This is here simpy to trigger any preprocess functions that may
// add javascript, etc. for this block. Note that the output is
// thrown away.
theme('block', $block);
$blocks["{$module}-{$delta}"] = $block;
}
}
}
}
}
return $blocks;
}