From 6d452e7aed99e961445f31124341ca4426524f2f Mon Sep 17 00:00:00 2001 From: Shawn Kwang Date: Tue, 28 Feb 2017 13:01:09 -0600 Subject: [PATCH] Drupal: Use boinc username in Solr searches. Changed bundle name from "Profile" to "User". Boinc username is used in Solr index (replaces drupal username). Search template updated to use bundle name "User" and to use boinc username. https://dev.gridrepublic.org/browse/DBOINCP-357 --- .../boinc/modules/boincuser/boincuser.module | 17 +++++++++++++++++ .../boinc/templates/search-result.tpl.php | 6 ++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drupal/sites/default/boinc/modules/boincuser/boincuser.module b/drupal/sites/default/boinc/modules/boincuser/boincuser.module index 769e2f71bf..c35bf6f065 100644 --- a/drupal/sites/default/boinc/modules/boincuser/boincuser.module +++ b/drupal/sites/default/boinc/modules/boincuser/boincuser.module @@ -1815,6 +1815,23 @@ function boincuser_apachesolr_index_documents_alter(array &$documents, $entity, $node = node_load($nid); $account = user_load($node->uid); + // Use boincuser name and not drupal user name + $document->label = apachesolr_clean_text($account->boincuser_name); + // Author information + if ($node->uid == 0 || strlen($node->name) == 0) { + // @see user_validate_name(). !'0' === TRUE. + $document->ss_name = '0'; + } + else { + $document->ss_name = $account->boincuser_name; + // We want the name to be searchable for keywords. + $document->tos_name = $account->boincuser_name; + } + + // Rename "Profle" to "User" + $document->bundle = "User"; + $document->bundle_name = "User"; + // Replace the Solr document's created field with the date the user // account was created. This replaces the node creation date typically // used for indexing nodes. diff --git a/drupal/sites/default/boinc/themes/boinc/templates/search-result.tpl.php b/drupal/sites/default/boinc/themes/boinc/templates/search-result.tpl.php index 829b7983b7..870b7badf1 100644 --- a/drupal/sites/default/boinc/themes/boinc/templates/search-result.tpl.php +++ b/drupal/sites/default/boinc/themes/boinc/templates/search-result.tpl.php @@ -53,14 +53,16 @@ uid); if (isset($account)) { - $user_image = boincuser_get_user_profile_image($account->uid, FALSE); + $user_image = boincuser_get_user_profile_image($account->uid); $url = "{$base_path}account/{$account->uid}"; if (empty($title)) { - $title = $account->name; + $title = $account->boincuser_name; } } ?>