You are here

public function MiniorangeOAuthClientCustomerSetup::buildForm in Drupal OAuth & OpenID Connect Login - OAuth2 Client SSO Login 8

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

File

src/Form/MiniorangeOAuthClientCustomerSetup.php, line 23
Contains \Drupal\miniorange_oauth_client\Form\MiniorangeOAuthClientCustomerSetup.

Class

MiniorangeOAuthClientCustomerSetup

Namespace

Drupal\miniorange_oauth_client\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  global $base_url;
  $current_status = \Drupal::config('miniorange_oauth_client.settings')
    ->get('miniorange_oauth_client_status');
  $form['markup_library'] = array(
    '#attached' => array(
      'library' => array(
        "miniorange_oauth_client/miniorange_oauth_client.admin",
        "miniorange_oauth_client/miniorange_oauth_client.style_settings",
        "miniorange_oauth_client/miniorange_oauth_client.module",
        "miniorange_oauth_client/miniorange_oauth_client.slide_support_button",
      ),
    ),
  );
  if ($current_status == 'VALIDATE_OTP') {
    $form['header_top_style_1'] = array(
      '#markup' => '<div class="mo_oauth_table_layout_1">',
    );
    $form['markup_top'] = array(
      '#markup' => '<div class="mo_oauth_table_layout mo_oauth_container">',
    );
    $admin_mail = \Drupal::config('miniorange_oauth_client.settings')
      ->get('miniorange_oauth_client_customer_admin_email');
    $form['markup_top_vt_start'] = array(
      '#type' => 'fieldset',
      '#title' => t('OTP VALIDATION'),
      '#attributes' => array(
        'style' => 'padding:2% 2% 5%; margin-bottom:2%',
      ),
      '#markup' => '<br><hr><br>',
    );
    $form['markup_top_vt_start']['mo_user_profile'] = array(
      '#markup' => '<h3>Please enter the OTP sent to <i>' . $admin_mail . '</i>: </h3><br>',
    );
    $form['markup_top_vt_start']['miniorange_oauth_client_customer_otp_token'] = array(
      '#type' => 'textfield',
      '#title' => t('OTP'),
      '#attributes' => array(
        'style' => 'width:30%;',
        'placeholder' => 'Enter OTP',
      ),
    );
    $form['markup_top_vt_start']['mo_btn_brk'] = array(
      '#markup' => '<br><br>',
    );
    $form['markup_top_vt_start']['miniorange_oauth_client_customer_validate_otp_button'] = array(
      '#type' => 'submit',
      '#value' => t('Validate OTP'),
      '#submit' => array(
        '::miniorange_oauth_client_validate_otp_submit',
      ),
    );
    $form['markup_top_vt_start']['miniorange_oauth_client_customer_setup_resendotp'] = array(
      '#type' => 'submit',
      '#value' => t('Resend OTP'),
      '#submit' => array(
        '::miniorange_oauth_client_resend_otp',
      ),
    );
    $form['markup_top_vt_start']['miniorange_oauth_client_customer_setup_back'] = array(
      '#type' => 'submit',
      '#value' => t('Back'),
      '#submit' => array(
        '::miniorange_oauth_client_back',
      ),
    );
    Utilities::nofeaturelisted($form, $form_state);
    $form['markup_top_vt_start']['header_top_div_end'] = array(
      '#markup' => '</div>',
    );
    Utilities::AddSupportButton($form, $form_state);
    return $form;
  }
  elseif ($current_status == 'PLUGIN_CONFIGURATION') {
    $form['header_top_style_1'] = array(
      '#markup' => '<div class="mo_oauth_table_layout_1">',
    );
    $form['markup_top'] = array(
      '#markup' => '<div class="mo_oauth_table_layout mo_oauth_container">',
    );
    $form['markup_top_vt_start'] = array(
      '#type' => 'fieldset',
      '#title' => t('PROFILE'),
      '#attributes' => array(
        'style' => 'padding:2% 2% 5%; margin-bottom:2%',
      ),
      '#markup' => '<br><hr><br>',
    );
    $form['markup_top_vt_start']['mo_message_wlcm'] = array(
      '#markup' => '<div class="mo_oauth_client_welcome_message">Thank you for registering with miniOrange',
    );
    $form['markup_top_vt_start']['mo_user_profile'] = array(
      '#markup' => '</div><br><br><h4>Your Profile: </h4>',
    );
    $header = array(
      'email' => array(
        'data' => t('Customer Email'),
      ),
      'customerid' => array(
        'data' => t('Customer ID'),
      ),
      'token' => array(
        'data' => t('Token Key'),
      ),
      'apikey' => array(
        'data' => t('API Key'),
      ),
    );
    $options = [];
    $options[0] = array(
      'email' => \Drupal::config('miniorange_oauth_client.settings')
        ->get('miniorange_oauth_client_customer_admin_email'),
      'customerid' => \Drupal::config('miniorange_oauth_client.settings')
        ->get('miniorange_oauth_client_customer_id'),
      'token' => \Drupal::config('miniorange_oauth_client.settings')
        ->get('miniorange_oauth_client_customer_admin_token'),
      'apikey' => \Drupal::config('miniorange_oauth_client.settings')
        ->get('miniorange_oauth_client_customer_api_key'),
    );
    $form['markup_top_vt_start']['fieldset']['customerinfo'] = array(
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $options,
    );
    $form['markup_top_vt_start']['miniorange_oauth_client_support_div_cust'] = array(
      '#markup' => '<br><br><br><br></div>',
    );
    Utilities::nofeaturelisted($form, $form_state);
    $form['mo_markup_div_end2'] = array(
      '#markup' => '</div>',
    );
    Utilities::AddSupportButton($form, $form_state);
    return $form;
  }
  $form['header_top_style_1'] = array(
    '#markup' => '<div class="mo_oauth_table_layout_1">',
  );
  $form['markup_top'] = array(
    '#markup' => '<div class="mo_oauth_table_layout mo_oauth_container">',
  );
  $form['markup_top_vt_start'] = array(
    '#type' => 'fieldset',
    '#title' => t('REGISTER/LOGIN WITH MINIORANGE'),
    '#attributes' => array(
      'style' => 'padding:2% 2% 5%; margin-bottom:2%',
    ),
    '#markup' => '<br><hr><br>',
  );
  $form['markup_top_vt_start']['markup_2'] = array(
    '#markup' => '<div class="mo_oauth_highlight_background_note_export"><p><h3>Why Should I register?</h3></p>
            <b> You will be needing a miniOrange account to upgrade to the Standard, Premium or Enterprise versions of the modules.</b>
             If you face any problem during registration, you can create an account by clicking <a href="https://www.miniorange.com/businessfreetrial" target="_blank">here.</a><br>
             We do not store any information except the email that you will use to register with us.<br></div><br>',
  );
  $form['markup_top_vt_start']['miniorange_oauth_client_customer_setup_username'] = array(
    '#type' => 'email',
    '#title' => t('Email'),
    '#attributes' => array(
      'style' => 'width:50%;',
      'placeholder' => 'Enter your email',
    ),
    '#required' => TRUE,
  );
  $form['markup_top_vt_start']['miniorange_oauth_client_customer_setup_phone'] = array(
    '#type' => 'textfield',
    '#title' => t('Phone'),
    '#attributes' => array(
      'style' => 'width:50%;',
    ),
    '#description' => '<b>NOTE:</b> We will only call if you need support.',
  );
  $form['markup_top_vt_start']['miniorange_oauth_client_customer_setup_password'] = array(
    '#type' => 'password_confirm',
    '#required' => TRUE,
  );
  $form['markup_top_vt_start']['miniorange_oauth_client_customer_setup_button'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#prefix' => '<br>',
  );
  $form['markup_top_vt_start']['markup_divEnd'] = array(
    '#markup' => '</div>',
  );
  Utilities::nofeaturelisted($form, $form_state);
  $form['mo_markup_div_end2'] = array(
    '#markup' => '</div>',
  );
  Utilities::AddSupportButton($form, $form_state);
  return $form;
}