block_user

Versions
4.6 – 4.7
block_user($type, $edit, &$user, $category = NULL)
5 – 6
block_user($type, $edit, &$account, $category = NULL)

Implementation of hook_user().

Allow users to decide which custom blocks to display when they visit the site.

Code

modules/block.module, line 396

<?php
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;
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.