View source
<?php
require_once 'constant_contact.config.php';
function constant_contact_check_details() {
$username = variable_get('constant_contact_username', '');
$password = variable_get('constant_contact_password', '');
$api_key = variable_get('constant_contact_api_key', '');
if ($username && $password && $api_key) {
return true;
}
return false;
}
function constant_contact_requirements($phase) {
$requirements = array();
@ini_get('allow_url_fopen', 1);
if ($phase == 'runtime') {
$details = constant_contact_check_details();
if ($details) {
$requirements['constant_contact'] = array(
'value' => t('Configured'),
'severity' => REQUIREMENT_OK,
'description' => t('The Constant Contact account settings have been configured'),
);
}
else {
$requirements['constant_contact'] = array(
'value' => t('Not configured'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The Constant Contact account settings have not been configured, <a href="@settings">configure now</a>', array(
'@settings' => url('admin/constant_contact/settings'),
)),
);
}
$requirements['constant_contact']['title'] = t('Constant Contact');
}
else {
if (!extension_loaded('xml')) {
$requirements['xml'] = array(
'value' => t('XML extension Not installed'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The XML extension for PHP is missing or outdated. Please check the PHP XML documentation for information on how to correct this.'),
);
$requirements['xml']['title'] = t('Constant Contact');
}
if (!extension_loaded('openssl')) {
$requirements['openssl'] = array(
'value' => t('openssl extension Not installed'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The openssl extension for PHP is missing or outdated. Please check the PHP openssl documentation for information on how to correct this.'),
);
$requirements['openssl']['title'] = t('Constant Contact');
}
if (!ini_get('allow_url_fopen')) {
$requirements['allow_url_fopen'] = array(
'value' => t('allow_url_fopen setting Not enabled'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The allow_url_fopen setting is not enabled in your php.ini config file'),
);
$requirements['allow_url_fopen']['title'] = t('Constant Contact');
}
}
return $requirements;
}
function constant_contact_install() {
variable_set('constant_contact_username', '');
variable_set('constant_contact_password', '');
variable_set('constant_contact_api_key', '');
variable_set('constant_contact_custom_fields', CONSTANT_CONTACT_CUSTOM_FIELDS);
variable_set('constant_contact_show_on_register', CONSTANT_CONTACT_SHOW_ON_REGISTER);
variable_set('constant_contact_show_list_selection', CONSTANT_CONTACT_SHOW_LIST_SELECTION);
variable_set('constant_contact_signup_lists_description', CONSTANT_CONTACT_SIGNUP_LISTS_DESCRIPTION);
variable_set('constant_contact_signup_title', CONSTANT_CONTACT_SIGNUP_TITLE);
variable_set('constant_contact_signup_description', CONSTANT_CONTACT_SIGNUP_DESCRIPTION);
variable_set('constant_contact_show_firstname', CONSTANT_CONTACT_SHOW_FIRSTNAME);
variable_set('constant_contact_show_lastname', CONSTANT_CONTACT_SHOW_LASTNAME);
variable_set('constant_contact_show_job_title', CONSTANT_CONTACT_SHOW_JOB_TITLE);
variable_set('constant_contact_show_company_name', CONSTANT_CONTACT_SHOW_COMPANY_NAME);
}
function constant_contact_uninstall() {
variable_del('constant_contact_username');
variable_del('constant_contact_password');
variable_del('constant_contact_api_key');
variable_del('constant_contact_custom_fields');
variable_del('constant_contact_show_on_register');
variable_del('constant_contact_show_list_selection');
variable_del('constant_contact_signup_lists_description');
variable_del('constant_contact_signup_title');
variable_del('constant_contact_signup_description');
variable_del('constant_contact_show_firstname');
variable_del('constant_contact_show_lastname');
variable_del('constant_contact_show_job_title');
variable_del('constant_contact_show_company_name');
variable_del('constant_contact_lists');
cache_clear_all('variables', 'cache');
}
function constant_contact_disable() {
drupal_set_message(t('The Constant Contact module has been disabled, to upgrade please uninstall.'));
}
function constant_contact_enable() {
drupal_set_message(t('The Constant Contact module has been enabled, please visit the settings page to configure your account details.'));
}