Posted by kyle_mathews on May 4, 2009 at 4:33pm
| 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
this would probably help at least for your immediate need.
#2
committed to 6.x
#3
#4
Automatically closed -- issue fixed for 2 weeks with no activity.
#5
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 ...
}
#6
Just write your own theme_apachesolr_breadcrumb_uid. Setting back to closed.