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-visibility.admin.inc, line 10 - Administrative page callbacks for the zopim module.
Code
function zopim_admin_settings_form(&$form_state) {
$settings = zopim_get_settings();
$roles = user_roles();
$role_options = array();
foreach ($roles as $rid => $name) {
$role_options[$rid] = $name;
}
$php_access = user_access('use PHP for zopim visibility');
// Initially setup mode with only 2 options, in case of no access to using PHP.
$mode_options = array(
t('Add to every page except the listed pages.'),
t('Add to the listed pages only.'),
);
$mode_description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
'%blog' => 'blog',
'%blog-wildcard' => 'blog/*',
'%front' => '<front>',
));
$form['global'] = array(
'#type' => 'fieldset',
'#title' => t('Global Visibility'),
);
$form['global']['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Global Visibility'),
'#description' => t("Turn on or off the Zopim widget's visibility globally."),
'#default_value' => $settings['visibility']['enabled'],
);
$form['role_vis_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Role Specific Visibility'),
'#collapsible' => TRUE,
);
$form['role_vis_settings']['role'] = array(
'#type' => 'checkboxes',
'#title' => t('Remove script for specific roles'),
'#default_value' => $settings['visibility']['role'],
'#options' => $role_options,
'#description' => t('Remove script only for the selected role(s). If none of the roles are selected, all roles will have the script. Otherwise, any roles selected here will NOT have the script.'),
);
// The user editing this page has no access to editing visibility with PHP and
// the visibility mode is currently set to parse PHP for visibility (2), so we
// hide all the page visibility settings from this user.
if ($settings['visibility']['page']['mode'] === 2 && !$php_access) {
$form['page'] = array(
'#tree' => TRUE,
);
$form['page']['mode'] = array(
'#type' => 'value',
'#value' => 2,
);
$form['page']['pages'] = array(
'#type' => 'value',
'#value' => $settings['visibility']['page']['pages'],
);
}
else {
$form['page'] = array(
'#type' => 'fieldset',
'#title' => t('Page Specific Visibility'),
'#collapsible' => TRUE,
'#tree' => TRUE,
);
// If user has access to use PHP then we add an addition option and
// extra description text.
if ($php_access) {
$mode_options[] = t('Add if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$mode_description .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array(
'%php' => '<?php ?>',
));
}
$form['page']['mode'] = array(
'#type' => 'radios',
'#title' => t('Add script to specific pages'),
'#options' => $mode_options,
'#default_value' => $settings['visibility']['page']['mode'],
);
$form['page']['pages'] = array(
'#type' => 'textarea',
'#title' => t('Pages'),
'#default_value' => $settings['visibility']['page']['pages'],
'#description' => $mode_description,
'#wysiwyg' => FALSE,
);
}
$form['#submit'][] = 'zopim_set_settings';
return system_settings_form($form);
}