You are here

function ed_classified_block in Classified Ads 5.2

Same name and namespace in other branches
  1. 5 ed_classified.module \ed_classified_block()
  2. 6.2 ed_classified.module \ed_classified_block()
  3. 7.2 ed_classified.module \ed_classified_block()

Implementation of hook_block().

File

./ed_classified.module, line 119
Simple text-based classified ads module. Michael Curry, Exodus Development, Inc. exodusdev@gmail.com for more information, please visit http://exodusdev.com/drupal/modules/classified.module Copyright (c) 2006, 2007 Exodus Development, Inc. All Rights…

Code

function ed_classified_block($op = 'list', $delta = 0, $edit = array()) {
  module_load_include('inc', 'ed_classified', 'ed_classified_utils');
  $parms = _ed_classified_displayname_parms();
  if ($op == 'list') {
    $blocks[0]['info'] = t('@name - Popular (requires access log enabled)', $parms);
    $blocks[1]['info'] = t('@name - Latest', $parms);
    $blocks[2]['info'] = t('@name - Stats', $parms);
    return $blocks;
  }
  else {
    if ($op == 'configure') {

      // OPTIONAL: Enter form elements to add to block configuration screen, if required.
    }
    else {
      if ($op == 'save') {

        // OPTIONAL: Add code to trigger when block configuration is saved, if required.
      }
      else {
        if ($op == 'view') {
          if (user_access('access content')) {
            switch ($delta) {
              case 0:
                $block['subject'] = t('Popular @name', $parms);
                $block['content'] = ed_classified_get_popular_ads_list();
                break;
              case 1:
                $block['subject'] = t('Latest @name', $parms);
                $block['content'] = ed_classified_get_latest_ads_list();
                break;
              case 2:
                $block['subject'] = t('@name Statistics', $parms);
                $block['content'] = ed_classified_get_ad_stats();
                break;
            }
          }

          // suppress empty blocks
          if (empty($block['content'])) {
            $block = array();

            // zap empty block
          }
          return $block;
        }
      }
    }
  }
}