You are here

public function DisclaimerEmailBlock::blockForm in Disclaimer 8

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/DisclaimerEmailBlock.php, line 119

Class

DisclaimerEmailBlock
Provides a 'DisclaimerEmailBlock' block.

Namespace

Drupal\disclaimer\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form['redirect'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Redirect'),
    '#description' => $this
      ->t('The URL a rejected user is sent to. eg. /content-for-unconfirmed-users. (relative, absolute, <front>)'),
    '#default_value' => $this->configuration['redirect'],
    '#maxlength' => 256,
    '#size' => 64,
    '#required' => TRUE,
    '#weight' => 10,
  ];
  $form['max_age'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Max-age'),
    '#description' => $this
      ->t('The time in seconds the user is confirmed. Set to 0 for no expiry. (86400 seconds = 24 hours)'),
    '#default_value' => $this->configuration['max_age'],
    '#maxlength' => 64,
    '#size' => 64,
    '#required' => TRUE,
    '#weight' => 20,
  ];
  $form['challenge'] = [
    '#type' => 'text_format',
    '#format' => $this->configuration['challenge']['format'],
    '#title' => $this
      ->t('Challenge'),
    '#description' => $this
      ->t('The question the user must confirm by entering an e-mail address. "Do you agree?" type of question. <em>Continue</em> = User stays on requested page. <em>Disagree</em> = User is redirected to <em>Redirect</em> url specified below.'),
    '#default_value' => $this->configuration['challenge']['value'],
    '#required' => TRUE,
    '#weight' => 30,
  ];
  $form['allowed_emails'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Allowed e-mails'),
    '#description' => $this
      ->t('List of allowed e-mails. One rule per line. Supports <em>*</em> wildcard. For example: <em>*@example.com</em>'),
    '#default_value' => $this->configuration['allowed_emails'],
    '#weight' => 60,
    '#required' => TRUE,
  ];
  $form['email_validation_fail'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('E-mail rejected message'),
    '#description' => $this
      ->t("Error message displayed when form is submitted and user's e-mail is rejected."),
    '#default_value' => $this->configuration['email_validation_fail'],
    '#maxlength' => 512,
    '#size' => 512,
    '#required' => TRUE,
    '#weight' => 70,
  ];
  $form['disclaimer'] = [
    '#type' => 'text_format',
    '#format' => $this->configuration['disclaimer']['format'],
    '#title' => $this
      ->t('Disclaimer'),
    '#description' => $this
      ->t('The text displayed to the user on a protected page when the user has JS turned off. (No popup with challenge is available.)'),
    '#default_value' => $this->configuration['disclaimer']['value'],
    '#weight' => 80,
    '#required' => FALSE,
  ];
  return $form;
}