You are here

function bbb_form_alter in BigBlueButton 7

Same name and namespace in other branches
  1. 6 bbb.module \bbb_form_alter()

Implements HOOK_form_alter().

File

./bbb.module, line 241
Big Blue Button - Enables universities and colleges to deliver a high-quality learning experience.

Code

function bbb_form_alter(&$form, &$form_state, $form_id) {

  // Node type settings form
  if ($form_id == 'node_type_form') {
    $form['bbb'] = array(
      '#title' => t('Big Blue Button settings'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#group' => 'additional_settings',
    );
    $form['bbb']['bbb_content_type'] = array(
      '#type' => 'checkbox',
      '#title' => t('Treat this node type as meeting'),
      '#default_value' => variable_get('bbb_content_type_' . $form['#node_type']->type, FALSE),
    );
    $form['bbb']['bbb_content_type_show_links'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show links to attend, moderate or terminate a meeting beneath the node'),
      '#default_value' => variable_get('bbb_content_type_show_links_' . $form['#node_type']->type, FALSE),
    );
    $form['bbb']['bbb_content_type_show_status'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display meeting status on node'),
      '#default_value' => variable_get('bbb_content_type_show_status_' . $form['#node_type']->type, FALSE),
    );
    $form['bbb']['bbb_content_type_moderator_required'] = array(
      '#type' => 'checkbox',
      '#title' => t('Require a moderator present to run the meeting.'),
      '#default_value' => variable_get('bbb_content_type_moderator_required_' . $form['#node_type']->type, FALSE),
    );
    $form['bbb']['bbb_content_type_welcome'] = array(
      '#title' => t('Welcome message'),
      '#type' => 'textfield',
      '#default_value' => variable_get('bbb_content_type_welcome_' . $form['#node_type']->type, ''),
      '#maxlength' => 255,
      '#description' => 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.'),
    );
    $form['bbb']['bbb_content_type_dialNumber'] = array(
      '#title' => t('Dial number'),
      '#type' => 'textfield',
      '#default_value' => variable_get('bbb_content_type_dialNumber_' . $form['#node_type']->type, ''),
      '#maxlength' => 32,
      '#description' => t('The dial access number that participants can call in using regular phone.'),
    );
    $form['bbb']['bbb_content_type_moderatorPW'] = array(
      '#title' => t('Moderator password'),
      '#type' => 'textfield',
      '#default_value' => variable_get('bbb_content_type_moderatorPW_' . $form['#node_type']->type, ''),
      '#maxlength' => 32,
      '#description' => t('The password that will be required for moderators to join the meeting or for certain administrative actions (i.e. ending a meeting).'),
    );
    $form['bbb']['bbb_content_type_attendeePW'] = array(
      '#title' => t('Attendee password'),
      '#type' => 'textfield',
      '#default_value' => variable_get('bbb_content_type_attendeePW_' . $form['#node_type']->type, ''),
      '#maxlength' => 32,
      '#description' => t('The password that will be required for attendees to join the meeting.'),
    );
    $form['bbb']['bbb_content_type_logoutURL'] = array(
      '#title' => t('Logout URL'),
      '#type' => 'textfield',
      '#default_value' => variable_get('bbb_content_type_logoutURL_' . $form['#node_type']->type, ''),
      '#maxlength' => 255,
      '#description' => 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>.'),
    );
    if (user_access('record meetings')) {
      $form['bbb']['bbb_content_type_record'] = array(
        '#title' => t('Record new meetings of this type, by default.'),
        '#type' => 'checkbox',
        '#default_value' => variable_get('bbb_content_type_record_' . $form['#node_type']->type, ''),
        '#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' => -1,
      );
    }
  }

  // Node edit form
  if (array_key_exists('#node_edit_form', $form)) {
    $node_type = $form['type']['#value'];
    if (drupal_substr($form_id, drupal_strlen($form_id) - 10, 10) == '_node_form' && bbb_is_meeting_type($node_type)) {
      if (is_numeric($form['nid']['#value'])) {
        $meeting = bbb_get_meeting($form['nid']['#value']);
      }
      if (user_access('administer big blue button')) {
        $form['bbb'] = array(
          '#title' => t('Meeting settings'),
          '#type' => 'fieldset',
          '#description' => t("The following settings may be changed until the meeting first starts."),
          '#collapsible' => TRUE,
          '#collapsed' => TRUE,
          '#tree' => TRUE,
          '#group' => 'additional_settings',
        );
        $form['bbb']['welcome'] = array(
          '#title' => t('Welcome message'),
          '#type' => 'textfield',
          '#default_value' => !empty($meeting->welcome) ? $meeting->welcome : variable_get('bbb_content_type_welcome_' . $node_type, ''),
          '#maxlength' => 255,
          '#description' => 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.'),
          '#attributes' => !empty($meeting->meetingID) ? array(
            'disabled' => 'disabled',
          ) : array(),
        );
        $form['bbb']['dialNumber'] = array(
          '#title' => t('Dial number'),
          '#type' => 'textfield',
          '#default_value' => !empty($meeting->dialNumber) ? $meeting->dialNumber : variable_get('bbb_content_type_dialNumber_' . $node_type, ''),
          '#maxlength' => 32,
          '#description' => t('The dial access number that participants can call in using regular phone.'),
          '#attributes' => !empty($meeting->meetingID) ? array(
            'disabled' => 'disabled',
          ) : array(),
        );
        $form['bbb']['moderatorPW'] = array(
          '#title' => t('Moderator password'),
          '#type' => 'textfield',
          '#default_value' => !empty($meeting->moderatorPW) ? $meeting->moderatorPW : variable_get('bbb_content_type_moderatorPW_' . $node_type, ''),
          '#maxlength' => 32,
          '#description' => t('The password that will be required for moderators to join the meeting or for certain administrative actions (i.e. ending a meeting).'),
          '#attributes' => !empty($meeting->meetingID) ? array(
            'disabled' => 'disabled',
          ) : array(),
        );
        $form['bbb']['attendeePW'] = array(
          '#title' => t('Attendee password'),
          '#type' => 'textfield',
          '#default_value' => !empty($meeting->attendeePW) ? $meeting->attendeePW : variable_get('bbb_content_type_attendeePW_' . $node_type, ''),
          '#maxlength' => 32,
          '#description' => t('The password that will be required for attendees to join the meeting.'),
          '#attributes' => !empty($meeting->meetingID) ? array(
            'disabled' => 'disabled',
          ) : array(),
        );
        $form['bbb']['logoutURL'] = array(
          '#title' => t('Logout URL'),
          '#type' => 'textfield',
          '#default_value' => !empty($meeting->logoutURL) ? $meeting->logoutURL : variable_get('bbb_content_type_logoutURL_' . $node_type, ''),
          '#maxlength' => 255,
          '#description' => 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>.'),
          '#attributes' => !empty($meeting->meetingID) ? array(
            'disabled' => 'disabled',
          ) : array(),
        );
        $form['bbb']['record'] = array(
          '#title' => t('Record meeting'),
          '#type' => 'select',
          '#default_value' => !empty($meeting->record) ? $meeting->record : variable_get('bbb_content_type_record_' . $node_type, ''),
          '#options' => array(
            0 => t('Do not record'),
            1 => t('Record'),
          ),
          '#attributes' => empty($meeting->initialized) ? array() : array(
            'disabled' => 'disabled',
          ),
          '#weight' => -1,
        );
      }
      if (user_access('record meetings') && empty($form['bbb']['record'])) {

        // this clause is for users who have the record meetings permission but no permissions to "administer BBB"
        $form['bbb'] = array(
          '#title' => t('Recording settings'),
          '#type' => 'fieldset',
          '#description' => t("The following settings may be changed until the meeting first starts."),
          '#collapsible' => TRUE,
          '#collapsed' => TRUE,
          '#tree' => TRUE,
        );
        $form['bbb']['record'] = array(
          '#title' => t('Record meeting'),
          '#type' => 'select',
          '#default_value' => !empty($meeting->record) ? $meeting->record : variable_get('bbb_content_type_record_' . $node_type, ''),
          '#options' => array(
            0 => t('Do not record'),
            1 => t('Record'),
          ),
          '#attributes' => empty($meeting->initialized) ? array() : array(
            'disabled' => 'disabled',
          ),
          '#weight' => -1,
        );
      }
    }
  }
}