Same name and namespace in other branches
- 4.7.x modules/block.module \block_user()
- 5.x modules/block/block.module \block_user()
- 6.x modules/block/block.module \block_user()
Implementation of hook_user().
Allow users to decide which custom blocks to display when they visit the site.
File
- modules/
block.module, line 396 - Controls the boxes that are displayed around the main content.
Code
function block_user($type, $edit, &$user, $category = NULL) {
switch ($type) {
case 'form':
if ($category == 'account') {
$result = db_query('SELECT * FROM {blocks} WHERE status = 1 AND custom != 0 ORDER BY weight, module, delta');
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, 'block', 'list');
if ($data[$block->delta]['info']) {
$form .= form_checkbox($data[$block->delta]['info'], 'block][' . $block->module . '][' . $block->delta, 1, isset($user->block[$block->module][$block->delta]) ? $user->block[$block->module][$block->delta] : $block->custom == 1);
}
}
if (isset($form)) {
return array(
array(
'title' => t('Block configuration'),
'data' => $form,
'weight' => 2,
),
);
}
}
break;
case 'validate':
if (!$edit['block']) {
$edit['block'] = array();
}
return $edit;
}
}