public function AnonymousPublishingClAdminPrivacy::buildForm in Anonymous Publishing 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- modules/
anonymous_publishing_cl/ src/ Form/ AnonymousPublishingClAdminPrivacy.php, line 61
Class
Namespace
Drupal\anonymous_publishing_cl\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$settings = $this
->config('anonymous_publishing_cl.settings');
// Count the number of used aliases on file.
$aliases = $this
->getNumberOfVerifiedContents();
$period = [
0 => t('Delete ASAP'),
3600 => $this->dateFormatter
->formatInterval(3600),
21600 => $this->dateFormatter
->formatInterval(21600),
43200 => $this->dateFormatter
->formatInterval(43200),
86400 => $this->dateFormatter
->formatInterval(86400),
259200 => $this->dateFormatter
->formatInterval(259200),
604800 => $this->dateFormatter
->formatInterval(604800),
2592000 => $this->dateFormatter
->formatInterval(2592000),
-1 => t('Indefinitely'),
];
$form = [];
$aliasopt = $settings
->get('user_alias');
if ($aliasopt != 'anon') {
$disablep = TRUE;
$warn = '<br/><strong>' . t('Note:') . '</strong> ' . t('Purging is incompatible with having an alias (main settings). To purge, you need to turn this setting off.');
}
elseif (empty($aliases)) {
$warn = '';
$disablep = FALSE;
}
else {
$warn = '<br/>' . t('You have @count linking verification email to content. @these will be deleted when these links are purged.', [
'@count' => $this->stringTranslation
->formatPlural(count($aliases), '1 record', '@count records'),
'@these' => $this->stringTranslation
->formatPlural(count($aliases), 'This', 'These'),
]);
$disablep = FALSE;
}
$form['anonymous_publishing_privacy'] = [
'#markup' => '<p>' . t('For enhanced privacy, you can set a limited retention period for identifying information, or purge this information instantly or periodically.') . ' ' . $warn . '</p>',
];
$form['apperiod'] = [
'#type' => 'fieldset',
'#title' => t('Retention period'),
'#collapsible' => FALSE,
];
$form['apperiod']['retain_period'] = [
'#type' => 'select',
'#title' => t('Maximum period to retain records that links verification emails, ip-addresses and generated aliases to <em>specific</em> contents:'),
'#default_value' => $settings
->get('retain_period'),
'#options' => $period,
'#description' => t('Select “Indefinitely” to make the records linking verification email to content persistent. This is the <em>only</em> setting compatible with a persistent alias as byline.'),
];
$form['apperiod']['submit'] = [
'#type' => 'submit',
'#disabled' => $disablep,
'#value' => t('Save settings'),
'#name' => 'save',
];
$form['appurge'] = [
'#type' => 'fieldset',
'#title' => t('Purge'),
'#collapsible' => FALSE,
];
$form['appurge']['info'] = [
'#markup' => t('<p>Press button below to immediately purge all information linking emails, ip-addresses and generated aliases to anonymously published content. This operation can not be reversed.</p>'),
];
$form['appurge']['submit'] = [
'#type' => 'submit',
'#disabled' => $disablep,
'#value' => t('Purge now'),
'#name' => 'purge',
];
return $form;
}