You are here

function constant_contact_block in Constant Contact 5

Same name and namespace in other branches
  1. 6.3 constant_contact.module \constant_contact_block()
  2. 6 constant_contact.module \constant_contact_block()
  3. 6.2 constant_contact.module \constant_contact_block()

Implementation of hook_block().

File

./constant_contact.module, line 63

Code

function constant_contact_block($op = 'list', $delta = 0) {
  switch ($op) {
    case 'list':
      $blocks = array();
      $lists = constant_contact_get_lists();
      foreach ($lists as $i => $list) {
        $blocks[] = array(
          'info' => t('Constant Contact: ' . $list),
        );
      }
      return $blocks;
      break;
    case 'view':
      global $user;
      if (empty($user->uid) && !variable_get('constant_contact_allowanon', TRUE)) {
        return;
      }
      $lists = constant_contact_get_lists();
      $lists_arr = array_values($lists);
      $keyname = constant_contact_escape_listname($lists_arr[$delta]);
      $list = $lists[$keyname];
      if (constant_contact_check_user($list)) {
        return;
      }
      $block['content'] = drupal_get_form('constant_contact_block_form', $delta);
      return $block;
      break;
  }
}