function ajaxblocks_update_cache in Ajax Blocks 6
Same name and namespace in other branches
- 7 ajaxblocks.module \ajaxblocks_update_cache()
Stores AJAX settings for the blocks in the system cache table.
2 calls to ajaxblocks_update_cache()
- ajaxblocks_is_ajax in ./
ajaxblocks.module - Returns TRUE if the block is configured to be loaded via AJAX. Block specific settings are also returned.
- ajaxblocks_save_settings in ./
ajaxblocks.module - Additional submit handler for block settings form. Saves AJAX settings for the block.
File
- ./
ajaxblocks.module, line 158 - Loads dynamic blocks on cached page for anonymous users by performing AJAX request.
Code
function ajaxblocks_update_cache() {
$block_roles = array();
$result = db_query('SELECT * FROM {blocks_roles}');
while ($data = db_fetch_object($result)) {
$block_id = $data->module . '-' . $data->delta;
if (!array_key_exists($block_id, $block_roles)) {
$block_roles[$block_id] = array();
}
$block_roles[$block_id][] = $data->rid;
}
$ajax_block_data = array();
$result = db_query('SELECT * FROM {ajaxblocks} WHERE is_ajax = 1');
while ($data = db_fetch_array($result)) {
$roles = trim($data['cached_roles']);
$data['cached_roles'] = explode(' ', $roles);
if ($roles == '') {
$data['cached_roles'] = array();
}
$roles = trim($data['uncached_roles']);
$data['uncached_roles'] = explode(' ', $roles);
if ($roles == '') {
$data['uncached_roles'] = array();
}
$block_id = $data['block_id'];
if (!array_key_exists($block_id, $block_roles)) {
$block_roles[$block_id] = array();
}
$data['role_permission'] = $block_roles[$block_id];
$ajax_block_data[$block_id] = $data;
}
cache_set('ajaxblocks', $ajax_block_data);
return $ajax_block_data;
}