function campaignmonitor_general_form in Campaign Monitor 5.2
Same name and namespace in other branches
- 5 campaignmonitor.module \campaignmonitor_general_form()
- 6 campaignmonitor.module \campaignmonitor_general_form()
- 6.2 campaignmonitor.module \campaignmonitor_general_form()
1 string reference to 'campaignmonitor_general_form'
File
- ./
campaignmonitor.module, line 292
Code
function campaignmonitor_general_form() {
global $user;
$name = '';
$email = '';
$default = FALSE;
// Check if the profile module is installed. If it is, use the name element of the profile
if (module_exists("profile")) {
profile_load_profile($user);
$name = $user->profile_name;
}
if ($user->uid != 0) {
$email = $user->mail;
if (_campaignmonitor_is_subscribed(variable_get('campaignmonitor_api_key', ''), variable_get('campaignmonitor_list_id', ''), $email)) {
$default = TRUE;
// Also if subscribed get name
$subscriber = _campaignmonitor_get_subscriber(variable_get('campaignmonitor_api_key', ''), variable_get('campaignmonitor_list_id', ''), $email);
$name = $subscriber['name'];
}
else {
$default = FALSE;
}
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 20,
'#maxlength' => 50,
'#required' => TRUE,
'#default_value' => $name,
);
$form['email'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#size' => 20,
'#maxlength' => 100,
'#required' => TRUE,
'#default_value' => $email,
);
$form['unsubscribe_newsletter'] = array(
'#type' => 'checkbox',
'#title' => t('Unsubscribe'),
'#default_value' => $default,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}