function homebox_merge_settings in Homebox 6.3
Same name and namespace in other branches
- 6.2 homebox.module \homebox_merge_settings()
Merge default page and user settings
Parameters
$default_blocks: A multidimensional array representing a page's default blocks
$user_blocks: A multidimensional array representing a user's default blocks for a page
Return value
A merged array, allowing user settings to override all default settings availble The array will persist all default and user settings that the other array doesn't originally have.
2 calls to homebox_merge_settings()
- homebox_prepare_block in ./
homebox.module - Prepare a block for rendering with theme('homebox_block').
- _homebox_save_user_settings in ./
homebox.module - Save the user's page settings
File
- ./
homebox.module, line 797 - Homebox main file, takes care of global functions settings constants, etc.
Code
function homebox_merge_settings($default_blocks, $user_blocks) {
// Iterate through default blocks, overriding with user settings
foreach ($default_blocks as $k => $v) {
if (!array_key_exists($k, $user_blocks)) {
continue;
}
if (is_array($v) && is_array($user_blocks[$k])) {
$default_blocks[$k] = homebox_merge_settings($v, $user_blocks[$k]);
}
else {
$default_blocks[$k] = $user_blocks[$k];
}
}
// Iterate through user blocks, carrying over any leftovers
foreach ($user_blocks as $k => $v) {
if (array_key_exists($k, $default_blocks)) {
continue;
}
if (is_array($v) && is_array($user_blocks[$k])) {
$default_blocks[$k] = homebox_merge_settings($v, $user_blocks[$k]);
}
else {
$default_blocks[$k] = $user_blocks[$k];
}
}
return $default_blocks;
}