function zopim_admin_settings_form in Zopim Live Chat 6.2
Same name in this branch
- 6.2 includes/zopim-account.admin.inc \zopim_admin_settings_form()
- 6.2 includes/zopim-customize.admin.inc \zopim_admin_settings_form()
- 6.2 includes/zopim-visibility.admin.inc \zopim_admin_settings_form()
Same name and namespace in other branches
- 6 zopim.admin.inc \zopim_admin_settings_form()
- 7 zopim.admin.inc \zopim_admin_settings_form()
Implementation of hook_admin_settings().
1 string reference to 'zopim_admin_settings_form'
- zopim_menu in ./
zopim.module
File
- includes/
zopim-account.admin.inc, line 11 - Administrative page callbacks for the zopim module.
Code
function zopim_admin_settings_form(&$form_state) {
$settings = zopim_get_settings();
$account_details = zopim_get_account_details();
// Add ctools dependent js.
$form['js']['#after_build'] = array(
'zopim_admin_settings_form_load_js',
);
if ($account_details->error == 'Invalid Salt') {
drupal_set_message(t('We could not verify your Zopim account. You may need to reset your Zopim credentials below.'), 'error');
}
if (is_object($account_details)) {
if ($account_details->package_id == "trial") {
$account_details->package_id = t('Free Lite Package + 14 Days Full-features');
}
else {
$account_details->package_id = t('%s Package', array(
'%s' => ucfirst($account_details->package_id),
));
}
}
$form['general'] = array(
'#type' => 'fieldset',
'#title' => t('General Settings'),
'#collapsible' => FALSE,
'#tree' => TRUE,
);
// array of translatable tokens used in agreement text.
$agreement_tokens = array(
'%s' => 'Zopim',
'!tos' => l(t('Terms of Service'), 'http://www.zopim.com/termsnconditions'),
'!pol' => l(t('Privacy Policy'), 'http://www.zopim.com/privacypolicy'),
);
$form['general']['agreement'] = array(
'#title' => $settings['general']['agreement'] === 1 ? t("You have already accepted %s's !tos and !pol", $agreement_tokens) : t("I agree to %s's !tos and !pol", $agreement_tokens),
'#type' => 'checkbox',
'#required' => TRUE,
'#description' => t("You must agree to Zopim's terms in order to use this module."),
'#disabled' => $settings['general']['agreement'] === 1,
'#default_value' => $settings['general']['agreement'],
);
$form['general']['use_ssl'] = array(
'#type' => 'checkbox',
'#title' => t('Use SSL Connection for Account Authorization'),
'#description' => t('Uncheck this if you are unable to login or register.'),
'#default_value' => $settings['general']['use_ssl'],
);
$form['account_setup'] = array(
'#type' => 'fieldset',
'#title' => !$settings['general']['username'] && !$settings['general']['password'] ? t('Account Setup') : t('Account Settings'),
'#collapsible' => FALSE,
'#tree' => TRUE,
);
// If no username/password set then allow setting up new account.
if (!$settings['general']['username'] && !$settings['general']['password']) {
$form['account_setup']['account'] = array(
'#type' => 'radios',
'#title' => t('Select whether you have an existing account or not'),
'#required' => TRUE,
'#options' => array(
0 => t('Give me a new account - %s', array(
'%s' => 'absolutely free!',
)),
1 => t('I already have a %s account', array(
'%s' => 'Zopim',
)),
),
'#default_value' => $settings['general']['account'],
);
$form['account_setup']['existing_account'] = array(
'#type' => 'fieldset',
'#title' => t('Existing Account Settings'),
'#collapsible' => FALSE,
'#process' => array(
'ctools_dependent_process',
),
'#dependency' => array(
'radio:account_setup[account]' => array(
'1',
),
),
'#input' => TRUE,
'#id' => 'existing-account',
'#prefix' => '<div id="existing-account-wrapper">',
'#suffix' => '</div>',
'#tree' => TRUE,
);
$form['account_setup']['existing_account']['username'] = array(
'#type' => 'textfield',
'#title' => t('Zopim Username (E-mail)'),
'#size' => 32,
);
$form['account_setup']['existing_account']['password'] = array(
'#type' => 'password',
'#title' => t('Zopim Password'),
'#size' => 32,
);
$form['account_setup']['new_account'] = array(
'#type' => 'fieldset',
'#title' => t('Create a New Account'),
'#collapsible' => FALSE,
'#process' => array(
'ctools_dependent_process',
),
'#dependency' => array(
'radio:account_setup[account]' => array(
'0',
),
),
'#input' => TRUE,
'#id' => 'new-account',
'#prefix' => '<div id="new-account-wrapper">',
'#suffix' => '</div>',
);
$form['account_setup']['new_account']['first_name'] = array(
'#type' => 'textfield',
'#title' => t('First Name'),
'#size' => 32,
);
$form['account_setup']['new_account']['last_name'] = array(
'#type' => 'textfield',
'#title' => t('Last Name'),
'#size' => 32,
);
$form['account_setup']['new_account']['email'] = array(
'#type' => 'textfield',
'#title' => t('E-mail'),
'#size' => 32,
);
// Had to http, instead of https for the scripts here, the https won't load
// due to invalid certificate from recaptcha.
$recaptcha = <<<EOC
<script type="text/javascript" src="http://api-secure.recaptcha.net/challenge?k=6Lfr8AQAAAAAAC7MpRXM2hgLfyss_KKjvcJ_JFIk"></script>
<noscript>
<iframe src="http://api-secure.recaptcha.net/noscript?k=6Lfr8AQAAAAAAC7MpRXM2hgLfyss_KKjvcJ_JFIk" height="300" width="500" frameborder="0"></iframe><br />
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge">
</noscript>
EOC;
$form['account_setup']['new_account']['verification'] = array(
'#title' => t('Verification'),
'#type' => 'markup',
'#value' => $recaptcha,
);
}
else {
$form['account_setup']['username'] = array(
'#value' => '<div class="form-item form-item-labeled"><label>' . t('Zopim Username (E-mail)') . '</label><div>' . $settings['general']['username'] . '</div></div>',
);
$form['account_setup']['package'] = array(
'#value' => '<div class="form-item form-item-labeled"><label>' . t('Package') . '</label><div><i>' . $account_details->package_id . '</i></div></div>',
);
$form['account_setup']['existing_account']['reset'] = array(
'#type' => 'checkbox',
'#title' => t('Reset Zopim Credentials'),
'#description' => t('This will reset your Zopim Username and Password that are stored in Drupal, allowing you to reinput them.'),
'#default_value' => 0,
);
}
$form['#submit'][] = 'zopim_set_settings';
return system_settings_form($form);
}