You are here

public function LearningPathAdminSettingsForm::buildForm in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/Form/LearningPathAdminSettingsForm.php \Drupal\opigno_learning_path\Form\LearningPathAdminSettingsForm::buildForm()

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 ConfigFormBase::buildForm

File

src/Form/LearningPathAdminSettingsForm.php, line 32

Class

LearningPathAdminSettingsForm
Class LearningPathAdminSettingsForm.

Namespace

Drupal\opigno_learning_path\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $tokens_description = [
    '#type' => 'container',
    [
      '#type' => 'html_tag',
      '#tag' => 'div',
      '#value' => t('Group tokens:'),
    ],
    [
      '#theme' => 'item_list',
      '#list_type' => 'ul',
      '#items' => [
        '[group] - ' . $this
          ->t('group name'),
        '[link] - ' . $this
          ->t('link to group'),
        '[user] - ' . $this
          ->t('user account name'),
        '[user-role] - ' . $this
          ->t('user role in group'),
        '[user-status] - ' . $this
          ->t('user current status'),
      ],
    ],
  ];
  $config = $this
    ->config('opigno_learning_path.learning_path_settings');
  $form['opigno_learning_path_mail'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('E-mail notifications settings'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_admin'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Notify administrators'),
    '#description' => $this
      ->t('If checked administrators will be notified on trainings updates.'),
    '#default_value' => $config
      ->get('opigno_learning_path_notify_admin'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_admin_mails'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Administrators email list.'),
    '#default_value' => $config
      ->get('opigno_learning_path_notify_admin_mails'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_admin_user_subscribed'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message to admins when user subscribed/updated/removed'),
    '#default_value' => $config
      ->get('opigno_learning_path_notify_admin_user_subscribed'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_admin_user_approval'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message to admins when user awaiting approval'),
    '#default_value' => $config
      ->get('opigno_learning_path_notify_admin_user_approval'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_admin_user_blocked'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message to admins when user blocked'),
    '#default_value' => $config
      ->get('opigno_learning_path_notify_admin_user_blocked'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_group_tokens_1'] = $tokens_description;
  if (\Drupal::moduleHandler()
    ->moduleExists('token')) {
    $form['opigno_learning_path_mail']['token_tree_1'] = [
      '#theme' => 'token_tree_link',
      '#show_restricted' => TRUE,
    ];
  }
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_users'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Notify users'),
    '#description' => $this
      ->t('If checked users will be notified on training updates.'),
    '#default_value' => $config
      ->get('opigno_learning_path_notify_users'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_user_user_subscribed'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message to user when he subscribed/updated/removed'),
    '#default_value' => $config
      ->get('opigno_learning_path_notify_user_user_subscribed'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_user_user_approval'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message to user when he awaiting approval'),
    '#default_value' => $config
      ->get('opigno_learning_path_notify_user_user_approval'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_user_user_blocked'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message to user when he blocked'),
    '#default_value' => $config
      ->get('opigno_learning_path_notify_user_user_blocked'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_group_tokens_2'] = $tokens_description;
  if (\Drupal::moduleHandler()
    ->moduleExists('token')) {
    $form['opigno_learning_path_mail']['token_tree_2'] = [
      '#theme' => 'token_tree_link',
      '#show_restricted' => TRUE,
    ];
  }
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_user_user_certificate_expired'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message to user when a training certificate has expired'),
    '#default_value' => $config
      ->get('opigno_learning_path_notify_user_user_certificate_expired'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_notify_group_tokens_3'] = [
    '#type' => 'container',
    [
      '#type' => 'html_tag',
      '#tag' => 'div',
      '#value' => t('Group tokens:'),
    ],
    [
      '#theme' => 'item_list',
      '#list_type' => 'ul',
      '#items' => [
        '[group:title] - ' . $this
          ->t('group name'),
        '[group:url] - ' . $this
          ->t('link to group'),
        '[group:expiration_date] - ' . $this
          ->t('certificate expiration date'),
      ],
    ],
  ];
  if (\Drupal::moduleHandler()
    ->moduleExists('token')) {
    $form['opigno_learning_path_mail']['token_tree_3'] = [
      '#theme' => 'token_tree_link',
      '#token_types' => [
        'group',
      ],
      '#show_restricted' => TRUE,
    ];
  }
  $form['opigno_learning_path_mail']['opigno_learning_path_student_does_activity_notify'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Notify manager'),
    '#description' => $this
      ->t('If checked a manager will be notified when student does an activity.'),
    '#default_value' => $config
      ->get('opigno_learning_path_student_does_activity_notify'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_student_does_activity'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message to a manager when student does an activity.'),
    '#default_value' => $config
      ->get('opigno_learning_path_student_does_activity'),
  ];
  $form['opigno_learning_path_mail']['student_does_activity_tokens'] = [
    '#type' => 'container',
    [
      '#type' => 'html_tag',
      '#tag' => 'div',
      '#value' => t('Tokens:'),
    ],
    [
      '#theme' => 'item_list',
      '#list_type' => 'ul',
      '#items' => [
        '[module] - ' . $this
          ->t('module name'),
        '[link] - ' . $this
          ->t('link to evaluate'),
        '[manager] - ' . $this
          ->t('manager name'),
        '[user] - ' . $this
          ->t('user name'),
        '[sitename] - ' . $this
          ->t('site name'),
      ],
    ],
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_students_answer_is_reviewed_notify'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Notify student'),
    '#description' => $this
      ->t('If checked a student will be notified when student does an activity.'),
    '#default_value' => $config
      ->get('opigno_learning_path_students_answer_is_reviewed_notify'),
  ];
  $form['opigno_learning_path_mail']['opigno_learning_path_students_answer_is_reviewed'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message to a student when his answer has been reviewed.'),
    '#default_value' => $config
      ->get('opigno_learning_path_students_answer_is_reviewed'),
  ];
  $form['opigno_learning_path_mail']['students_answer_is_reviewed_tokens'] = [
    '#type' => 'container',
    [
      '#type' => 'html_tag',
      '#tag' => 'div',
      '#value' => t('Tokens:'),
    ],
    [
      '#theme' => 'item_list',
      '#list_type' => 'ul',
      '#items' => [
        '[module] - ' . $this
          ->t('module name'),
        '[manager] - ' . $this
          ->t('manager name'),
        '[user] - ' . $this
          ->t('user name'),
        '[sitename] - ' . $this
          ->t('site name'),
      ],
    ],
  ];
  return parent::buildForm($form, $form_state);
}