You are here

function ed_classified_block in Classified Ads 6.2

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

Implements hook_block().

File

./ed_classified.module, line 127
Simple text-based classified ads module.

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;
  }
  elseif ($op == 'configure') {

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

    // OPTIONAL: Add code to trigger when block configuration is saved, if required.
  }
  elseif ($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;
  }
}