function gdpr_consent_administration in GDPR Consent 7
Module settings form.
1 string reference to 'gdpr_consent_administration'
- gdpr_consent_menu in ./
gdpr_consent.module - Implements hook_menu().
File
- ./
gdpr_consent.admin.inc, line 117 - Administration UI for the GDPR Consent module.
Code
function gdpr_consent_administration($form_state) {
$form = array();
if (module_exists('locale')) {
$languages = locale_language_list();
$language_default = language_default();
$language_code = $language_default->language;
$version_options = array(
'version' => t('All users (new version)'),
'revision' => t('Language specific users (a revision)'),
);
$version_handling = 'version';
$list = array();
foreach ($languages as $language_id => $language_name) {
$list[] = l($language_name, current_path(), array(
'query' => array(
'lang' => $language_id,
),
));
}
$form['language_links'] = array(
'#type' => 'markup',
'#markup' => '<strong>' . t('Switch language version') . '</strong>' . theme('item_list', array(
'items' => $list,
'attributes' => array(
'class' => array(
'links',
'inline',
),
),
)),
'#weight' => -999,
);
}
else {
$languages = array(
'en' => t('English'),
);
$language_code = 'en';
$version_handling = 'version';
}
if ($options = drupal_get_query_parameters()) {
$language_code = check_plain($options['lang']);
}
$conditions = gdpr_consent_get_conditions($language_code, TRUE);
$form = array_merge($form, gdpr_consent_display_fields($conditions));
$form['conditions'] = array(
'#type' => 'text_format',
'#title' => t('Consent'),
'#default_value' => $conditions['conditions'],
'#description' => t('Your GDPR consent message for users to approve.'),
'#format' => empty($conditions['format']) ? NULL : $conditions['format'],
'#required' => TRUE,
'#rows' => 20,
'#weight' => -1,
);
$form['data_details'] = array(
'#type' => 'text_format',
'#title' => t('Data details'),
'#default_value' => $conditions['data_details'],
'#description' => t("You can describe here what data you're collecting and why."),
'#format' => empty($conditions['format_details']) ? NULL : $conditions['format_details'],
'#required' => FALSE,
'#rows' => 20,
'#weight' => 0,
);
$form['gdpr_consent']['#tree'] = TRUE;
$form['gdpr_consent']['gdpr_consent_accept']['#required'] = FALSE;
if (count($languages) > 1) {
// Language and version handling options.
$form['language'] = array(
'#type' => 'fieldset',
'#title' => t('Language'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['language']['language'] = array(
'#type' => 'select',
'#title' => t('Language'),
'#options' => $languages,
'#default_value' => $language_code,
);
$form['language']['version_handling'] = array(
'#type' => 'select',
'#title' => t('Ask to re-accept'),
'#description' => t('<strong>All users</strong>: all users will be asked to accept the new version of the consent, including users who accepted a previous version. This overwrites all language versions if any exists.<br /><strong>Language specific</strong>: only new users, and users who accepted the consent in the same language as this new revision will be asked to re-accept.'),
'#options' => $version_options,
'#default_value' => $version_handling,
);
}
else {
$form['language']['language'] = array(
'#type' => 'value',
'#value' => $language_code,
);
$form['language']['version_handling'] = array(
'#type' => 'value',
'#default_value' => $version_handling,
);
}
gdpr_consent_display_form_element($form);
// Notes about changes to Consent.
$form['changes'] = array(
'#type' => 'fieldset',
'#title' => t('Explain changes'),
'#description' => t('Explain what changes were made to the data processing consent since the last version. This will only be shown to users who accepted a previous version. Each line will automatically be shown as a bullet point.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['changes']['changes'] = array(
'#type' => 'textarea',
'#title' => t('Changes'),
);
$form['#after_build'] = array(
'gdpr_consent_preview',
);
$form['preview'] = array(
'#type' => 'button',
'#value' => t('Preview'),
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
if (!empty($form['gdpr_consent']['conditions']['#markup']) || !empty($form['conditions']['#default_value'])) {
$form['language']['version_handling']['#default_value'] = 'revision';
}
return $form;
}