You are here

function simple_ldap_user_view in Simple LDAP 7.2

Implements hook_user_view()

Adds an LDAP block to the user profile page if the viewing user has sufficient permissions.

File

simple_ldap_user/simple_ldap_user.module, line 598
Main simple_ldap_user module file.

Code

function simple_ldap_user_view($account, $view_mode, $langcode) {
  global $user;
  if (user_access('administer users') || $user->uid == $account->uid && user_access('view own ldap data')) {
    $query = db_query("SELECT authname FROM {authmap} WHERE module = 'simple_ldap' AND uid = :uid", array(
      ':uid' => $account->uid,
    ));
    while ($row = $query
      ->fetchAssoc()) {
      $dn_list[] = $row['authname'];
    }
    if (!empty($dn_list)) {
      $account->content['ldap'] = array(
        '#type' => 'user_profile_category',
        '#title' => t("LDAP"),
        '#weight' => 30,
      );
      $account->content['ldap']['simple_ldap'] = array(
        '#type' => 'user_profile_item',
        '#title' => t('DNs'),
        '#markup' => theme('item_list', array(
          'items' => $dn_list,
        )),
        '#attributes' => array(
          'class' => 'simple_ldap',
        ),
      );
    }
  }
}