function _mailchimp_subscribe_anon_form in Mailchimp 7
Same name and namespace in other branches
- 6.2 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 588 - 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, $list->id);
}
foreach ((array) $q
->listMergeVars($list->id) as $mergevar) {
// set the default value for merge fields if we have it
if ($mergevalues && isset($mergevalues[$mergevar['tag']]) && $mergevalues[$mergevar['tag']]) {
$mergevar['default'] = $mergevalues[$mergevar['tag']];
}
$form[$mergevar['tag']] = _mailchimp_insert_drupal_form_tag($mergevar);
}
// present interest groups
if ($intgroup = $q
->listInterestGroups($list->id)) {
switch ($intgroup['form_field']) {
case 'radio':
$field_type = 'radios';
break;
case 'checkbox':
$field_type = 'checkboxes';
break;
default:
$field_type = $intgroup['form_field'];
}
foreach ((array) $intgroup['groups'] as $group) {
$options[$group] = $group;
}
$form['INTERESTS'] = array(
'#type' => $field_type,
'#title' => $intgroup['name'],
'#options' => $options,
);
}
}