function jquery_countdown_block_update_6100 in jQuery Countdown 6
Implement hook_update_N() Removes all block settings variables and store as array into one variable...
Parameters
$sandbox:
Return value
array
File
- jquery_countdown_block/
jquery_countdown_block.install, line 36 - Provides install, upgrade and un-install functions for jquery_countdown_block module.
Code
function jquery_countdown_block_update_6100(&$sandbox) {
$current_block_ids = variable_get('jquery_countdown_block_ids', array());
// now get for every block the settings and restore it in one variable...
foreach ($current_block_ids as $block_id) {
$block_settings = array();
$stored_vars = array(
'admin_title' => 'jquery_countdown_block_' . $block_id . '_admin_title',
'caption' => 'jquery_countdown_block_' . $block_id . '_caption',
'date' => 'jquery_countdown_block_' . $block_id . '_date',
'until' => 'jquery_countdown_block_' . $block_id . '_until',
'format' => 'jquery_countdown_block_' . $block_id . '_format',
'serversync' => 'jquery_countdown_block_' . $block_id . '_serversync',
'compact' => 'jquery_countdown_block_' . $block_id . '_compact',
);
foreach ($stored_vars as $store_key => $var) {
$var_value = variable_get($var, NULL);
// only store if we have a value...
if ($var_value) {
$block_settings[$store_key] = $var_value;
}
}
// save in new settings variable...
variable_set('jquery_countdown_block_' . $block_id . '_settings', $block_settings);
// second foreach for deleting after save... (to ensure we have all data stored)
foreach ($stored_vars as $store_key => $var) {
variable_del($var);
}
}
return array();
}