You are here

public function BBBNodeTypeFormController::form in BigBlueButton 8

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

modules/bbb_node/src/Form/BBBNodeTypeFormController.php, line 50

Class

BBBNodeTypeFormController
Provides an administration settings form.

Namespace

Drupal\bbb_node\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  /** @var \Drupal\bbb_node\Entity\BBBNodeTypeInterface $bbbNodeType */
  $bbbNodeType = $this->entity;
  if ($bbbNodeType
    ->isNew()) {
    $names = $this
      ->getNames();
    $options = [];
    foreach ($names as $type => $label) {
      if (!$this->nodeMeeting
        ->isTypeOf($type)) {
        $options[$type] = $label;
      }
    }
    $form['node'] = [
      '#title' => $this
        ->t('Available content types'),
      '#type' => 'fieldset',
      '#tree' => FALSE,
      '#collapsible' => FALSE,
      '#collapsed' => FALSE,
      '#weight' => 0,
    ];
    $form['node']['type'] = [
      '#title' => $this
        ->t('Content types'),
      '#type' => 'select',
      '#options' => $options,
    ];
  }
  $form['bbb'] = [
    '#title' => $this
      ->t('Big Blue Button settings'),
    '#type' => 'details',
    '#tree' => TRUE,
    '#open' => TRUE,
    '#group' => 'additional_settings',
    '#weight' => 1,
  ];
  $form['bbb']['active'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Treat this node type as meeting'),
    '#default_value' => $bbbNodeType
      ->active(),
    '#weight' => 0,
  ];
  $form['bbb']['showLinks'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show links to attend, moderate or terminate a meeting beneath the node'),
    '#default_value' => $bbbNodeType
      ->showLinks(),
    '#weight' => 1,
  ];
  $form['bbb']['showStatus'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display meeting status on node'),
    '#default_value' => $bbbNodeType
      ->showStatus(),
    '#weight' => 2,
  ];
  $form['bbb']['moderatorRequired'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Require a moderator present to run the meeting.'),
    '#default_value' => $bbbNodeType
      ->moderatorRequired(),
    '#weight' => 3,
  ];
  $form['bbb']['welcome'] = [
    '#title' => $this
      ->t('Welcome message'),
    '#type' => 'textfield',
    '#default_value' => $bbbNodeType
      ->welcome(),
    '#maxlength' => 255,
    '#description' => $this
      ->t('A welcome message that gets displayed on the chat window when the participant joins. You can include keywords (%%CONFNAME%%, %%DIALNUM%%, %%CONFNUM%%) which will be substituted automatically.'),
    '#weight' => 5,
  ];
  $form['bbb']['dialNumber'] = [
    '#title' => $this
      ->t('Dial number'),
    '#type' => 'textfield',
    '#default_value' => $bbbNodeType
      ->dialNumber(),
    '#maxlength' => 32,
    '#description' => $this
      ->t('The dial access number that participants can call in using regular phone.'),
    '#weight' => 6,
  ];
  $form['bbb']['moderatorPW'] = [
    '#title' => $this
      ->t('Moderator password'),
    '#type' => 'textfield',
    '#default_value' => $bbbNodeType
      ->moderatorPW(),
    '#maxlength' => 32,
    '#description' => $this
      ->t('The password that will be required for moderators to join the meeting or for certain administrative actions (i.e. ending a meeting).'),
    '#weight' => 7,
  ];
  $form['bbb']['attendeePW'] = [
    '#title' => $this
      ->t('Attendee password'),
    '#type' => 'textfield',
    '#default_value' => $bbbNodeType
      ->attendeePW(),
    '#maxlength' => 32,
    '#description' => $this
      ->t('The password that will be required for attendees to join the meeting.'),
    '#weight' => 8,
  ];
  $form['bbb']['logoutURL'] = [
    '#title' => $this
      ->t('Logout URL'),
    '#type' => 'textfield',
    '#default_value' => $bbbNodeType
      ->logoutURL(),
    '#maxlength' => 255,
    '#description' => $this
      ->t('The URL that the Big Blue Button client will go to after users click the OK button on the <em>You have been logged out message</em>.'),
    '#weight' => 9,
  ];
  if ($this
    ->currentUser()
    ->hasPermission('bbb_node record meetings')) {
    $form['bbb']['record'] = [
      '#title' => $this
        ->t('Record new meetings of this type, by default.'),
      '#type' => 'checkbox',
      '#default_value' => $bbbNodeType
        ->record(),
      '#description' => 'Meetings that are recorded can be viewed at <strong>http://example.com/playback/slides/playback.html?meetingId=<meetingId></strong> (The meeting ID is about 54 characters long.)',
      '#weight' => 4,
    ];
  }
  $form['#submit'][] = [
    $this,
    'saveEntity',
  ];
  return $form;
}