You are here

public function Theme::blockMeeting in BigBlueButton 8

Theme meeting details block.

Parameters

$meeting:

Return value

array

File

src/Service/Theme.php, line 121

Class

Theme
Class Theme.

Namespace

Drupal\bbb\Service

Code

public function blockMeeting($meeting) {
  $meeting = $meeting['meeting'];
  $output = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'bbb-meeting-details',
      ],
    ],
  ];
  if ($meeting->welcome) {
    $output['welcome'] = [
      '#type' => 'container',
      '#attributes' => [
        'class' => [
          'bbb-welcome',
        ],
      ],
      'message' => $meeting->welcome,
    ];
  }
  $output['status'] = [
    '#theme' => 'bbb_meeting_status',
    '#meeting' => $meeting,
  ];

  // Format links according to settings:
  $display_mode = \Drupal::config('bbb.settings')
    ->get('display_mode');

  // Block links.
  $attend = Url::fromRoute('bbb.meeting.attend', [
    'node' => $meeting->nid,
  ], [
    'absolute' => TRUE,
  ]);
  $attend_options = [];
  $moderate = Url::fromRoute('bbb.meeting.moderate', [
    'node' => $meeting->nid,
  ], [
    'absolute' => TRUE,
  ]);
  $moderate_options = [];
  $nolink = Url::fromRoute('entity.node.canonical', [
    'node' => $meeting->nid,
  ], [
    'absolute' => TRUE,
  ]);
  if ($display_mode === 'blank') {
    $attend_options = [
      'onClick' => 'window.open(\'' . $attend
        ->toString() . '\');return false',
      'html' => TRUE,
    ];
    $moderate_options = [
      'onClick' => 'window.open(\'' . $moderate
        ->toString() . '\');return false',
      'html' => TRUE,
    ];
  }
  if ($meeting->dialNumber) {
    $output = [
      '#type' => 'container',
      '#attributes' => [
        'class' => [
          'bbb-dial-number',
        ],
      ],
      'message' => $this
        ->t('Phone: @number', [
        '@number' => $meeting->dialNumber,
      ]),
    ];
  }
  $user = \Drupal::currentUser();
  if ($user
    ->hasPermission('attend meetings') || $user
    ->hasPermission('administer big blue button')) {
    $output['attend'] = [
      '#type' => 'container',
      '#attributes' => [
        'class' => [
          'bbb-meeting-attend',
        ],
      ],
      'message' => [
        '#type' => 'link',
        '#title' => $this
          ->t('Attend meeting'),
        '#url' => $display_mode == 'blank' ? $nolink : $attend,
        '#attributes' => $attend_options,
      ],
    ];
  }
  if ($user
    ->hasPermission('moderate meetings') || $user
    ->hasPermission('administer big blue button')) {
    $output['moderate'] = [
      '#type' => 'container',
      '#attributes' => [
        'class' => [
          'bbb-meeting-moderate',
        ],
      ],
      'message' => [
        '#type' => 'link',
        '#title' => $this
          ->t('Moderate meeting'),
        '#url' => $display_mode == 'blank' ? $nolink : $moderate,
        '#attributes' => $moderate_options,
      ],
    ];
  }
  if ($user
    ->hasPermission('moderate meetings') || $user
    ->hasPermission('administer big blue button')) {
    $output['moderate'] = [
      '#type' => 'container',
      '#attributes' => [
        'class' => [
          'bbb-meeting-end',
        ],
      ],
      'message' => [
        '#type' => 'link',
        '#title' => $this
          ->t('Terminate meeting'),
        '#url' => Url::fromRoute('bbb.meeting.end_meeting_confirm_form', [
          'node' => $meeting->nid,
        ]),
      ],
    ];
  }
  $output['record'] = [
    '#theme' => 'bbb_meeting_record',
    '#meeting' => $meeting,
  ];
  return $output;
}