Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

89 lines (77 sloc) 3.237 kB
<?php
/**
* @file
* Administrative page callbacks for the snapengage module.
*/
/**
* Implementation of hook_admin_settings() for configuring the module
*/
function snapengage_admin_settings_form(&$form_state) {
$form['account'] = array(
'#type' => 'fieldset',
'#title' => t('General settings'),
'#collapsible' => FALSE,
);
$form['account']['snapengage_widget_id'] = array(
'#type' => 'textfield',
'#title' => t('Widget ID'),
'#default_value' => variable_get('snapengage_widget_id', ''),
'#required' => TRUE,
'#description' => t(''),
);
// Render the role overview.
$form['role_vis_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Role specific visibility settings'),
'#collapsible' => TRUE,
);
$roles = user_roles();
$role_options = array();
foreach ($roles as $rid => $name) {
$role_options[$rid] = $name;
}
$form['role_vis_settings']['snapengage_roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Role specific visibility'),
'#default_value' => variable_get('snapengage_roles', array()),
'#options' => $role_options,
'#description' => t('Show widget only for the selected role(s). If none of the roles are selected, the widget will be shown for all roles. If a user has any of the roles checked, the widget will be shown for the user.'),
);
// Page specific visibility configurations.
$form['page_vis_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Page specific visibility settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$access = user_access('use PHP for tracking visibility');
$visibility = variable_get('snapengage_visibility', 0);
$pages = variable_get('snapengage_pages', '');
if ($visibility == 2 && !$access) {
$form['page_vis_settings'] = array();
$form['page_vis_settings']['visibility'] = array('#type' => 'value', '#value' => 2);
$form['page_vis_settings']['pages'] = array('#type' => 'value', '#value' => $pages);
}
else {
$options = array(t('Add to every page except the listed pages.'), t('Add to the listed pages only.'));
$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>'));
if ($access) {
$options[] = t('Add if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$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_vis_settings']['snapengage_visibility'] = array(
'#type' => 'radios',
'#title' => t('Add widget to specific pages'),
'#options' => $options,
'#default_value' => $visibility,
);
$form['page_vis_settings']['snapengage_pages'] = array(
'#type' => 'textarea',
'#title' => t('Pages'),
'#default_value' => $pages,
'#description' => $description,
'#wysiwyg' => FALSE,
);
}
return system_settings_form($form);
}
Jump to Line
Something went wrong with that request. Please try again.