You are here

public static function Utilities::show_attr_list_from_idp in OAuth2 Login 8

2 calls to Utilities::show_attr_list_from_idp()
MiniorangeMapping::buildForm in src/Form/MiniorangeMapping.php
Form constructor.
MiniorangeMapping::clear_attr_list in src/Form/MiniorangeMapping.php

File

src/Utilities.php, line 338

Class

Utilities

Namespace

Drupal\oauth2_login

Code

public static function show_attr_list_from_idp(&$form, $form_state) {
  global $base_url;
  $server_attrs = \Drupal::config('oauth2_login.settings')
    ->get('miniorange_oauth_client_attr_list_from_server');
  if (empty($server_attrs)) {
    Utilities::spConfigGuide($form, $form_state);
    return;
  }
  $form['miniorange_idp_guide_link'] = array(
    '#markup' => '<div class="mo_saml_table_layout mo_saml_container_2" id="mo_oauth_guide_vt">',
  );
  $form['miniorange_saml_attr_header'] = array(
    '#markup' => '<div class="mo_attr_table">Attributes received from the OAuth Server:</div><br>',
  );
  $icnt = count($server_attrs);
  if ($icnt >= 8) {
    $scrollkit = 'scrollit';
  }
  else {
    $scrollkit = '';
  }
  $form['mo_saml_attrs_list_idp'] = array(
    '#markup' => '<div class="table-responsive mo_guide_text-center" style="font-family: sans-serif;font-size: 12px;"><div class=' . $scrollkit . '>
                <table class="mo_guide_table mo_guide_table-striped mo_guide_table-bordered" style="border: 1px solid #ddd;max-width: 100%;border-collapse: collapse;">
                    <thead>
                        <tr>
                            <th class="mo_guide_text-center mo_td_values">ATTRIBUTE NAME</th>
                            <th class="mo_guide_text-center mo_td_values">ATTRIBUTE VALUE</th>
                        </tr>
                    </thead>',
  );
  $someattrs = '';
  $attrroles = '';
  if (isset($server_attrs) && !empty($server_attrs)) {
    foreach ($server_attrs as $attr_name => $attr_values) {
      if (is_array($attr_values) || is_object($attr_values)) {
        foreach ($attr_values as $key1 => $val) {
          $someattrs .= '<tr><td>' . $attr_name . '.' . $key1 . '</td><td>';
          $someattrs .= $val . '</td></tr>';
        }
      }
      else {
        $someattrs .= '<tr><td>' . $attr_name . '</td><td>';
        $someattrs .= $attr_values . '</td></tr>';
      }
      if ($attr_name == 'roles' && is_array($server_attrs['roles'])) {
        foreach ($attr_values as $attr_roles => $role) {
          $attrroles .= $role . ' | ';
        }
        $someattrs .= $attrroles . '</td></tr>';
      }
    }
  }
  $form['miniorange_saml_guide_table_list'] = array(
    '#markup' => '<tbody style="font-weight:bold;font-size: 12px;color:gray;">' . $someattrs . '</tbody></table></div>',
  );
  $form['miniorange_break'] = array(
    '#markup' => '<br>',
  );
  $form['miniorange_saml_clear_attr_list'] = array(
    '#type' => 'submit',
    '#value' => t('Clear Attribute List'),
    '#submit' => array(
      '::clear_attr_list',
    ),
    '#id' => 'button_config_center',
    '#limit_validation_errors' => array(),
  );
  $form['miniorange_saml_guide_clear_list_note'] = array(
    '#markup' => '<br><div style="font-size: 13px;"><b>NOTE : </b>Please clear this list after configuring the module to hide your confidential attributes.<br>
                            Click on <b>Test configuration</b> in <b>CONFIGURE OAUTH</b> tab to populate the list again.</div>',
  );
  $form['miniorange_saml_guide_table_end'] = array(
    '#markup' => '</div>',
  );
}