',
)),
);
$form['path']['livechat_exclude_system_paths'] = array(
'#type' => 'checkbox',
'#title' => t('Disable LiveChat on common system paths (recommended)'),
'#description' => t('LiveChat will not trigger on the following paths: %paths', array(
'%paths' => str_replace("\n", ', ', LIVECHAT_VISIBILITY_SYSTEM_PATHS),
)),
'#default_value' => variable_get('livechat_exclude_system_paths', 1),
);
$form['livechat_group'] = array(
'#type' => 'textfield',
'#title' => 'Group Id',
'#description' => 'If you are using LiveChat on more than one website,
enter the id of the website here',
'#default_value' => variable_get('livechat_group', ''),
);
$form['livechat_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable LiveChat'),
'#description' => t('Uncheck this box to disable LiveChat.'),
'#default_value' => variable_get('livechat_enabled', TRUE),
);
return system_settings_form($form);
}
/**
* License installation form.
*/
function livechat_admin_license_form($form_state) {
$module_dir = drupal_get_path('module', 'livechat');
drupal_add_css($module_dir . '/admin/css/livechat.css');
drupal_add_js($module_dir . '/admin/js/livechat.js');
if (livechat_is_installed()) {
$form['tracking_code'] = array(
'#type' => 'item',
'#markup' => '' . t('LiveChat
is installed.') . '
',
);
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Remove'),
);
}
else {
$download_text = t('Download LiveChat for your desktop/mobile and start chatting
with your customers!');
$download_link = l(t('Download application'),
'http://www.livechatinc.com/product/', array(
'attributes' => array('external' => TRUE),
)
);
$form['download_app'] = array(
'#type' => 'item',
'#markup' => '' . $download_text . '
' . $download_link . '
',
);
// New account / Already have a license forms.
$form['choose_form'] = array(
'#type' => 'item',
'#markup' =>
'' . 'Already have a LiveChat account?
' .
'',
);
// General settings.
$form['general'] = array(
'#type' => 'fieldset',
'#collapsible' => FALSE,
'#prefix' => 'Account details
',
'#suffix' => '',
);
$form['general']['livechat_login'] = array(
'#type' => 'textfield',
'#title' => t('LiveChat login'),
'#default_value' => '',
'#size' => 30,
'#maxlength' => 100,
// Handled by JavaScript validator.
'#required' => FALSE,
);
$form['general']['license_number'] = array(
'#type' => 'hidden',
'#value' => '0',
);
$form['general']['ajax_message'] = array(
'#type' => 'item',
'#markup' => '',
);
// New account form.
$form['new_account'] = array(
'#type' => 'fieldset',
'#collapsible' => FALSE,
'#prefix' => 'Create a new LiveChat
account
',
'#suffix' => '',
);
$form['new_account']['name'] = array(
'#type' => 'textfield',
'#title' => t('Full name'),
'#size' => 30,
'#maxlength' => 60,
// Handled by JavaScript validator.
'#required' => FALSE,
);
$form['new_account']['email'] = array(
'#type' => 'textfield',
'#title' => t('E-mail'),
'#size' => 30,
'#maxlength' => 70,
// Handled by JavaScript validator.
'#required' => FALSE,
);
$form['new_account']['password'] = array(
'#type' => 'password',
'#title' => t('Password'),
'#size' => 30,
'#maxlength' => 70,
// Handled by JavaScript validator.
'#required' => FALSE,
);
$form['new_account']['password_retype'] = array(
'#type' => 'password',
'#title' => t('Retype password'),
'#size' => 30,
'#maxlength' => 70,
// Handled by JavaScript validator.
'#required' => FALSE,
);
$form['new_account']['ajax_message'] = array(
'#type' => 'item',
'#markup' => '',
);
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
}
return $form;
}
/**
* Validation callback for license installation form.
*/
function livechat_admin_license_form_validate($form, &$form_state) {
// Validate the license number.
if ($form_state['values']['op'] === t('Save')) {
if (!livechat_validate_license($form_state['input']['license_number'])) {
form_set_error('livechat_license_number', t('LiveChat license number is
incorrect.'));
}
}
}
/**
* Submit callback for license installation form.
*/
function livechat_admin_license_form_submit($form, &$form_state) {
if ($form_state['values']['op'] === t('Remove')) {
// Forget license if the "Reset" button was clicked.
variable_del('livechat_license');
}
else {
// Save the license that was returned by the admin JavaScript.
variable_set('livechat_license', $form_state['input']['license_number']);
}
}