You are here

function author_pane_block in Author Pane 6

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

Implementation of hook_block().

File

./author_pane.module, line 34
Gathers information from user related contrib 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;

    // Block settings
    case 'configure':

      // Template file
      $form['author_pane_block_template'] = array(
        '#type' => 'textfield',
        '#title' => t('Template file'),
        '#description' => t('Template file to use. Do not include .tpl.php. Default is author-pane-block.'),
        '#default_value' => variable_get('author_pane_block_template', 'author-pane-block'),
      );

      // Image path
      $form['author_pane_block_image_path'] = array(
        '#type' => 'textfield',
        '#title' => t('Image path'),
        '#description' => t('Path to author pane images.  Leave blank to use default.'),
        '#default_value' => variable_get('author_pane_block_image_path', ''),
      );

      // Node types
      $types = node_get_types();
      $options = array();
      foreach ($types as $type) {
        $options[$type->type] = $type->name;
      }
      $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()),
      );

      // Imagecache preset
      if (module_exists('imagecache') && function_exists('imagecache_presets')) {
        $options = array(
          '' => '',
        );
        $presets = imagecache_presets();
        foreach ($presets as $preset) {
          $options[$preset['presetname']] = $preset['presetname'];
        }
        $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_image_path', $edit['author_pane_block_image_path']);
      variable_set('author_pane_block_template', $edit['author_pane_block_template']);
      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;
  }
}