You are here

class User_pruneSettingsForm in User Prune 8

Configure Userprune settings for this site.

Hierarchy

Expanded class hierarchy of User_pruneSettingsForm

File

src/Form/User_pruneSettingsForm.php, line 14
Contains \Drupal\user_prune\Form

Namespace

Drupal\User_prune\Form
View source
class User_pruneSettingsForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'Userprune_admin_settings';
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'Userprune.settings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['year_select'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Select Year'),
      '#default_value' => \Drupal::state()
        ->get('year_select'),
      '#options' => [
        '0' => $this
          ->t('0 Years'),
        '31556926' => $this
          ->t('1 Year'),
        '63113852' => $this
          ->t('2 Years'),
        '94670778' => $this
          ->t('3 Years'),
        '126227704' => $this
          ->t('4 Years'),
        '157784630' => $this
          ->t('5 Years'),
        '189341556' => $this
          ->t('6 Years'),
        '220898482' => $this
          ->t('7 Years'),
        '252455408' => $this
          ->t('8 Years'),
        '284012334' => $this
          ->t('9 Years'),
        '315569260' => $this
          ->t('10 Years'),
      ],
    ];
    $form['month_select'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Select Month'),
      '#default_value' => \Drupal::state()
        ->get('month_select'),
      '#options' => [
        '0' => $this
          ->t('0 Months'),
        '2629743' => $this
          ->t('1 Month'),
        '5259486' => $this
          ->t('2 Months'),
        '7889229' => $this
          ->t('3 Months'),
        '10518972' => $this
          ->t('4 Months'),
        '13148715' => $this
          ->t('5 Months'),
        '15778458' => $this
          ->t('6 Months'),
        '18408201' => $this
          ->t('7 Months'),
        '21037944' => $this
          ->t('8 Months'),
        '23667687' => $this
          ->t('9 Months'),
        '26297430' => $this
          ->t('10 Months'),
        '28927173' => $this
          ->t('11 Months'),
        '31556916' => $this
          ->t('12 Months'),
      ],
    ];
    $form['day_select'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Day Year'),
      '#default_value' => \Drupal::state()
        ->get('day_select'),
      '#options' => [
        '0' => $this
          ->t('0 Days'),
        '86400' => $this
          ->t('1 Day'),
        '172800' => $this
          ->t('2 Days'),
        '259200' => $this
          ->t('3 Days'),
        '345600' => $this
          ->t('4 Days'),
        '432000' => $this
          ->t('5 Days'),
        '518400' => $this
          ->t('6 Days'),
        '604800' => $this
          ->t('7 Days'),
        '691200' => $this
          ->t('8 Days'),
        '777600' => $this
          ->t('9 Days'),
        '864000' => $this
          ->t('10 Days'),
        '950400' => $this
          ->t('11 Days'),
        '1036800' => $this
          ->t('12 Days'),
        '1123200' => $this
          ->t('13 Days'),
        '1209600' => $this
          ->t('14 Days'),
        '1296000' => $this
          ->t('15 Days'),
        '1382400' => $this
          ->t('16 Days'),
        '1468800' => $this
          ->t('17 Days'),
        '1555200' => $this
          ->t('18 Days'),
        '1641600' => $this
          ->t('19 Days'),
        '1728000' => $this
          ->t('20 Days'),
        '1814400' => $this
          ->t('21 Days'),
        '1900800' => $this
          ->t('22 Days'),
        '1987200' => $this
          ->t('23 Days'),
        '2073600' => $this
          ->t('24 Days'),
        '2160000' => $this
          ->t('25 Days'),
        '2246400' => $this
          ->t('26 Days'),
        '2332800' => $this
          ->t('27 Days'),
        '2419200' => $this
          ->t('28 Days'),
        '2505600' => $this
          ->t('29 Days'),
        '2592000' => $this
          ->t('30 Days'),
        '2678400' => $this
          ->t('31 Days'),
      ],
    ];
    $form['user_number_select'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Select the number of user to delete on cronrun'),
      '#default_value' => \Drupal::state()
        ->get('user_number_select'),
      '#options' => [
        '10' => $this
          ->t('10'),
        '25' => $this
          ->t('25'),
        '50' => $this
          ->t('50'),
        '75' => $this
          ->t('75'),
        '100' => $this
          ->t('100'),
        '200' => $this
          ->t('200'),
        '500' => $this
          ->t('500'),
      ],
    ];
    $form['user_status'] = array(
      '#type' => 'radios',
      '#title' => $this
        ->t('User status'),
      '#default_value' => \Drupal::state()
        ->get('user_status'),
      '#options' => array(
        'all' => $this
          ->t('All users'),
        'blocked' => $this
          ->t('Just the blocked users'),
        'active' => $this
          ->t('Just the active users'),
      ),
    );

    // User never logged in.
    $form['user_never_logged_in_label'] = array(
      '#markup' => "<label for='logged-in'>" . t('Never logged in users') . "</div>",
    );
    $form['user_never_logged_in'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Delete only users who never logged in.'),
      '#default_value' => \Drupal::state()
        ->get('user_never_logged_in'),
    );

    /*$form['title'] = array(
          '#type' => 'item',
          '#title' => $this->t('Do not delete users with roles:'),
        );

        $system_roles = user_roles(true);
        foreach($system_roles as $system_role){
          $role_id = $system_role->id();
          if($role_id != 'authenticated'){
            $form['roles'][$system_role->id()] = array(
              '#type' => 'checkbox',
              '#title' => t($system_role->id()),
              '#default_value' => \Drupal::state()->get($system_role->id()),
            );
          }
        }*/
    $form['delete_users_on_cron_lable'] = array(
      '#markup' => "<label for='logged-in'>" . t('On Cron') . "</div>",
    );
    $form['delete_users_on_cron'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Delete users on each cron run.'),
      '#default_value' => \Drupal::state()
        ->get('delete_users_on_cron'),
    );
    $form['preview_button'] = array(
      '#type' => 'submit',
      '#value' => 'Preview',
      '#submit' => array(
        'preview_button_action',
      ),
    );
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    foreach ($form_state
      ->getValues() as $key => $value) {
      \Drupal::state()
        ->set($key, $value);
    }
    foreach ($form_state
      ->getValues() as $key => $value) {
      drupal_set_message($key . ': ' . $value);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBase::create public static function Instantiates a new instance of this class. Overrides FormBase::create 13
ConfigFormBase::__construct public function Constructs a \Drupal\system\ConfigFormBase object. 11
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 62
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.
User_pruneSettingsForm::buildForm public function Form constructor. Overrides ConfigFormBase::buildForm
User_pruneSettingsForm::getEditableConfigNames protected function Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait::getEditableConfigNames
User_pruneSettingsForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
User_pruneSettingsForm::submitForm public function Form submission handler. Overrides ConfigFormBase::submitForm