A site I run is using ApacheSolr (working great!) and ldap for authentication. Ldap has the unfortunate side effect of making user's names quite ugly. Everywhere I can I replace the ldap username with the user's fullname. Overriding the core theme_username function takes care of most of the troubles but I need to manually override some module's output manually like with ApacheSolr.

Right now for ApaceSolr I've modified the apachesolr_search_get_username function as follows:

/**
 * Callback function for the 'Filter by name' facet block.
 */
function apachesolr_search_get_username($facet) {
  if ($facet == 0) {
    return variable_get('anonymous', t('Anonymous'));
  }
  else {
//    return db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $facet));
    // Pull the name from the user profile node
    $fullname = db_result(db_query("SELECT c.field_name_value FROM
    {content_type_uprofile} c JOIN {node} n WHERE c.nid = n.nid AND uid = %d",
    $facet));

    if (empty($fullname)) {
      $fullname = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $facet));
    }
 
   
    // Shorten the name when it is too long or it will break many tables.
    if (drupal_strlen($fullname) > 20) {
      $name = drupal_substr($fullname, 0, 20) .'...';
    }
    else {
      $name = $fullname;
    }


      return check_plain($name);

  }
}

I did notice the theme_apachesolr_facet_item which could work I suppose. It'd make it easier to override just certain blocks if the querystring was also passed in as an array something like array('facet_type' => author, 'uid' => 483)

Comments

pwolanin’s picture

Version: 6.x-1.0-beta9 » 6.x-1.x-dev
Category: support » feature
Status: Active » Needs review
StatusFileSize
new1.22 KB

this would probably help at least for your immediate need.

pwolanin’s picture

Status: Needs review » Fixed

committed to 6.x

pwolanin’s picture

Title: Allow override of facet block output. » Better theming of username in facets

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

hefox’s picture

Status: Closed (fixed) » Active
StatusFileSize
new1.17 KB

Sorry for activating this

but it'd be nice if there was an option for to use theme('username',) (w/ striptags)?

I think many use realname module or manually override user name for their user name and will have override this

ie
<?php

if (variable_get('apacheslr_username',0)) { return strip_tags(user_load($uid)); }
else ...
}

jpmckinney’s picture

Status: Active » Closed (fixed)

Just write your own theme_apachesolr_breadcrumb_uid. Setting back to closed.