block_admin_configure

Versions
4.6 – 5
block_admin_configure($module = NULL, $delta = 0)
6
block_admin_configure(&$form_state, $module = NULL, $delta = 0)
7
block_admin_configure($form, &$form_state, $block)

Menu callback; displays the block configuration form.

Code

modules/block.module, line 253

<?php
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));
  }
}
?>
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.