You are here

function author_pane_block in Author Pane 6.2

Same name and namespace in other branches
  1. 5 author_pane.module \author_pane_block()
  2. 6 author_pane.module \author_pane_block()

Implementation of hook_block().

1 string reference to 'author_pane_block'
author_pane_get_block in ./author_pane.module
Creates the contents of the block. Called from author_pane_block().

File

./author_pane.module, line 42
Gathers information from user related modules into one template.

Code

function author_pane_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $blocks[0]['info'] = t('Author Pane');

      // We don't want the block to cache since what is displayed depends on
      // both the user viewing and the user being viewed.
      $blocks[0]['cache'] = BLOCK_NO_CACHE;
      return $blocks;
    case 'configure':

      // Get a list of all node types.
      $types = node_get_types();
      $options = array();
      foreach ($types as $type) {
        $options[$type->type] = $type->name;
      }

      // Allow user to choose which node types will display the block.
      $form['author_pane_block_display_types'] = array(
        '#type' => 'checkboxes',
        '#title' => t('Node types to display on'),
        '#options' => $options,
        '#default_value' => variable_get('author_pane_block_display_types', array()),
      );
      if (module_exists('imagecache') && function_exists('imagecache_presets')) {

        // Get all the imagecache presets on the site.
        $options = array(
          '' => '',
        );
        $presets = imagecache_presets();
        foreach ($presets as $preset) {
          $options[$preset['presetname']] = $preset['presetname'];
        }

        // Allow the user to choose a preset to use.
        $form['author_pane_block_user_picture_preset'] = array(
          '#type' => 'select',
          '#title' => t('User picture preset'),
          '#options' => $options,
          '#description' => t('Imagecache preset to use for the user picture on this block. Leave blank to not use this feature.'),
          '#default_value' => variable_get('author_pane_block_user_picture_preset', ''),
        );
      }
      return $form;
    case 'save':
      variable_set('author_pane_block_display_types', $edit['author_pane_block_display_types']);
      variable_set('author_pane_block_user_picture_preset', $edit['author_pane_block_user_picture_preset']);
      return;
    case 'view':
      $block = array();
      $block['subject'] = t('Author Information');
      $block['content'] = author_pane_get_block();
      return $block;
  }
}