You are here

function _cookie_content_blocker_cookie_aware_form in Cookie Content Blocker 7

Add cookie awareness settings to the form.

Parameters

array $form: The structure of the form.

Return value

array The configuration form.

1 call to _cookie_content_blocker_cookie_aware_form()
cookie_content_blocker_settings_form in ./cookie_content_blocker.admin.inc
Form callback for the admin settings form.

File

./cookie_content_blocker.admin.inc, line 68
Admin functionality for Cookie content blocker.

Code

function _cookie_content_blocker_cookie_aware_form(array $form) {
  $consent_settings = variable_get('cookie_content_blocker_consent_awareness', _cookie_consent_blocker_consent_awareness_defaults());
  $consent_settings = array_replace_recursive(_cookie_consent_blocker_consent_awareness_defaults(), $consent_settings);
  $form['cookie_content_blocker_consent_awareness'] = array(
    '#type' => 'fieldset',
    '#tree' => TRUE,
    '#title' => t('Consent awareness'),
    '#description' => t('Manage how Cookie content blocker knows about cookie consent and how it can change the consent. Note: only one cookie category is supported.'),
    '#collapsible' => TRUE,
    'accepted' => array(
      '#type' => 'fieldset',
      '#title' => t('Consent given'),
      '#description' => t('Define the event that is triggered when a visitor actively gives consent and the cookies to determine if consent already has been given earlier.'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    ),
    'declined' => array(
      '#type' => 'fieldset',
      '#title' => t('Consent refused'),
      '#description' => t('Define the event that is triggered when a visitor actively declines consent and the cookies to determine if consent already has been declined earlier.'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    ),
    'change' => array(
      '#type' => 'fieldset',
      '#title' => t('Change consent'),
      '#description' => t('Define the event that has to be triggered when the button or blocked content placeholder is clicked.'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    ),
  );
  foreach ($consent_settings as $type => $type_settings) {
    $form['cookie_content_blocker_consent_awareness'][$type]['event'] = _cookie_content_blocker_event_form($type_settings['event']);
    if ($type === 'change') {
      continue;
    }
    $form['cookie_content_blocker_consent_awareness'][$type]['cookie']['operator'] = array(
      '#type' => 'select',
      '#title' => t('Cookie comparison operator'),
      '#default_value' => $type_settings['cookie']['operator'],
      '#empty_option' => t('- Select -'),
      '#options' => _cookie_content_blocker_cookie_value_operator_options(),
      '#element_validate' => array(
        '_cookie_content_blocker_element_validate_cleanup_value',
      ),
    );
    $form['cookie_content_blocker_consent_awareness'][$type]['cookie']['name'] = array(
      '#type' => 'textfield',
      '#title' => t('Cookie name'),
      '#default_value' => $type_settings['cookie']['name'],
      '#element_validate' => array(
        '_cookie_content_blocker_element_validate_cleanup_value',
      ),
    );
    $form['cookie_content_blocker_consent_awareness'][$type]['cookie']['value'] = array(
      '#type' => 'textfield',
      '#title' => t('Cookie value'),
      '#default_value' => $type_settings['cookie']['value'],
      '#element_validate' => array(
        '_cookie_content_blocker_element_validate_cleanup_value',
      ),
    );
  }
  return $form;
}