Same name and namespace in other branches
  1. 4.7.x modules/block.module \block_admin_configure()
  2. 5.x modules/block/block.module \block_admin_configure()
  3. 6.x modules/block/block.admin.inc \block_admin_configure()
  4. 7.x modules/block/block.admin.inc \block_admin_configure()

Menu callback; displays the block configuration form.

1 string reference to 'block_admin_configure'
block_menu in modules/block.module
Implementation of hook_menu().

File

modules/block.module, line 253
Controls the boxes that are displayed around the main content.

Code

function block_admin_configure($module = NULL, $delta = 0) {
  $edit = $_POST['edit'];
  $op = $_POST['op'];
  switch ($op) {
    case t('Save block'):
      if ($edit['types']) {
        $types = implode(',', $edit['types']);
      }
      else {
        $types = '';
      }
      db_query("UPDATE {blocks} SET visibility = %d, pages = '%s', custom = %d, types = '%s' WHERE module = '%s' AND delta = '%s'", $edit['visibility'], $edit['pages'], $edit['custom'], $types, $module, $delta);
      module_invoke($module, 'block', 'save', $delta, $edit);
      drupal_set_message(t('The block configuration has been saved.'));
      cache_clear_all();
      drupal_goto('admin/block');
    default:

      // Always evaluates to TRUE, but a validation step may be added later.
      if (!$edit) {
        $edit = db_fetch_array(db_query("SELECT pages, visibility, custom, types FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta));
      }

      // Module-specific block configurations.
      if ($settings = module_invoke($module, 'block', 'configure', $delta)) {
        $form = form_group(t('Block-specific settings'), $settings);
      }
      foreach (node_list() as $type) {
        $content_types[$type] = node_invoke($type, 'node_name');
      }

      // Get the block subject for the page title.
      $info = module_invoke($module, 'block', 'list');
      drupal_set_title(t("'%name' block", array(
        '%name' => $info[$delta]['info'],
      )));

      // Standard block configurations.
      $group_1 = form_radios(t('Custom visibility settings'), 'custom', $edit['custom'], array(
        t('Users cannot control whether or not they see this block.'),
        t('Show this block by default, but let individual users hide it.'),
        t('Hide this block by default but let individual users show it.'),
      ), t('Allow individual users to customize the visibility of this block in their account settings.'));
      $group_2 = form_radios(t('Show block on specific pages'), 'visibility', $edit['visibility'], array(
        t('Show on every page except the listed pages.'),
        t('Show on only the listed pages.'),
      ));
      $group_2 .= form_textarea(t('Pages'), 'pages', $edit['pages'], 40, 5, t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '<em>blog</em>' for the blog page and '<em>blog/*</em>' for every personal blog. '<em>&lt;front&gt;</em>' is the front page."));
      $group_3 = form_checkboxes(t('Restrict block to specific content types'), 'types', explode(',', $edit['types']), $content_types, t('Selecting one or more content types will cause this block to only be shown on pages of the selected types. This feature works alone or in conjunction with page specific visibility settings. For example, you can specify that a block only appear on book pages in the \'FAQ\' path.'), NULL, FALSE);
      $form .= form_group(t('User specific visibility settings'), $group_1);
      $form .= form_group(t('Page specific visibility settings'), $group_2);
      $form .= form_group(t('Content specific visibility settings'), $group_3);
      $form .= form_submit(t('Save block'));
      print theme('page', form($form));
  }
}