You are here

function constant_contact_block_form in Constant Contact 5

Same name and namespace in other branches
  1. 6 constant_contact.module \constant_contact_block_form()

Implementation of hook_form() creates the join mailing list block

1 string reference to 'constant_contact_block_form'
constant_contact_block in ./constant_contact.module
Implementation of hook_block().

File

./constant_contact.module, line 214

Code

function constant_contact_block_form($delta = 0, $op = 'list', $edit = array()) {
  global $user;
  $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;
  }
  $form = array();
  $form[] = array(
    '#value' => '<div id="' . $keyname . '" class="constant_contact_join">' . variable_get($keyname, "Join {$list} Mailing List") . '</div>',
  );

  // give anonymous users an email field
  if (empty($user->uid)) {
    $form['email'] = array(
      '#type' => 'textfield',
      '#title' => t('Email Address'),
      '#size' => 10,
    );
  }
  $form['list'] = array(
    '#type' => 'hidden',
    '#value' => $list,
  );
  $form[] = array(
    '#type' => 'submit',
    '#value' => t('Join'),
  );
  return $form;
}