You are here

function _mailchimp_subscribe_anon_form in Mailchimp 6.2

Same name and namespace in other branches
  1. 7 mailchimp.module \_mailchimp_subscribe_anon_form()

Helper function to return form elements for a single anon newsletter

Parameters

string $list:

string $q:

string $form:

Return value

void

2 calls to _mailchimp_subscribe_anon_form()
mailchimp_subscribe_anon_form in ./mailchimp.module
Return a form for a given MC list
mailchimp_subscribe_anon_form_all in ./mailchimp.module
Return a form for all available MC lists

File

./mailchimp.module, line 632
Mailchimp module.

Code

function _mailchimp_subscribe_anon_form($list, $q, &$form) {
  $form['list'] = array(
    '#type' => 'value',
    '#value' => $list,
  );

  // grab any default values for authenticated users
  global $user;
  $mergevalues = NULL;
  if ($user->uid) {
    $mergevalues = _mailchimp_load_user_list_mergevars($user->uid, $list->id, $q
      ->listMergeVars($list->id));
  }
  foreach ((array) $q
    ->listMergeVars($list->id) as $mergevar) {

    // set the default value for merge fields if we have it
    if ($mergevalues && $mergevalues[$mergevar['tag']]) {
      $mergevar['default'] = $mergevalues[$mergevar['tag']];
    }
    $form[$mergevar['tag']] = _mailchimp_insert_drupal_form_tag($mergevar);
  }

  // present interest groups
  if (variable_get('mailchimp_interest_groups_user_forms', FALSE)) {
    $form = array_merge($form, _mailchimp_interest_groups_element($q, $list->id, array(), TRUE));
  }
}