Project:Apache Solr Search Integration
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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:

<?php
/**
* 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

<?php
array('facet_type' => author, 'uid' => 483)
?>

Comments

#1

Version:6.x-1.0-beta9» 6.x-1.x-dev
Category:support request» feature request
Status:active» needs review

this would probably help at least for your immediate need.

AttachmentSizeStatusTest resultOperations
username-override-453310-1.patch1.22 KBIgnored: Check issue status.NoneNone

#2

Status:needs review» fixed

committed to 6.x

#3

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

#4

Status:fixed» closed (fixed)

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

#5

Status:closed (fixed)» active

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 ...
}

AttachmentSizeStatusTest resultOperations
apacheslr_theme_username.patch1.17 KBIgnored: Check issue status.NoneNone

#6

Status:active» closed (fixed)

Just write your own theme_apachesolr_breadcrumb_uid. Setting back to closed.