? drupal-6.x-dev-theme_username-0.2.patch
? theme_username.patch
? sites/default/files
? sites/default/settings.php
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.417
diff -u -p -r1.417 theme.inc
--- includes/theme.inc	20 Feb 2008 13:39:29 -0000	1.417
+++ includes/theme.inc	21 Feb 2008 15:42:09 -0000
@@ -1536,22 +1536,33 @@ function theme_blocks($region) {
  *
  * @param $object
  *   The user object to format, usually returned from user_load().
+ * @param $options
+ *   An associative array of additional options, with the following keys:
+ *     'plain' (default FALSE)
+ *       Whether to force the output as plain text format. Useful for
+ *       centralize username style handling.
  * @return
  *   A string containing an HTML link to the user's page if the passed object
  *   suggests that this is a site user. Otherwise, only the username is returned.
  */
-function theme_username($object) {
+function theme_username($object, $options = array()) {
+  // Merge in defaults.
+  $options += array(
+    'plain' => FALSE,
+  );
 
   if ($object->uid && $object->name) {
+    $name = $object->name;
+
     // Shorten the name when it is too long or it will break many tables.
-    if (drupal_strlen($object->name) > 20) {
-      $name = drupal_substr($object->name, 0, 15) .'...';
+    if (drupal_strlen($name) > 20) {
+      $name = drupal_substr($name, 0, 15) .'...';
     }
     else {
-      $name = $object->name;
+      $name = $name;
     }
 
-    if (user_access('access user profiles')) {
+    if (user_access('access user profiles') && !$options['plain']) {
       $output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
     }
     else {
@@ -1559,15 +1570,17 @@ function theme_username($object) {
     }
   }
   else if ($object->name) {
+    $name = $object->name;
+
     // Sometimes modules display content composed by people who are
     // not registered members of the site (e.g. mailing list or news
     // aggregator modules). This clause enables modules to display
     // the true author of the content.
-    if (!empty($object->homepage)) {
-      $output = l($object->name, $object->homepage, array('rel' => 'nofollow'));
+    if (!empty($object->homepage) && !$options['plain']) {
+      $output = l($name, $object->homepage, array('rel' => 'nofollow'));
     }
     else {
-      $output = check_plain($object->name);
+      $output = check_plain($name);
     }
 
     $output .= ' ('. t('not verified') .')';
Index: modules/blog/blog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v
retrieving revision 1.299
diff -u -p -r1.299 blog.module
--- modules/blog/blog.module	20 Feb 2008 13:46:38 -0000	1.299
+++ modules/blog/blog.module	21 Feb 2008 15:42:10 -0000
@@ -105,7 +105,7 @@ function blog_form(&$node) {
 function blog_view($node, $teaser = FALSE, $page = FALSE) {
   if ($page) {
     // Breadcrumb navigation
-    drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("@name's blog", array('@name' => $node->name)), 'blog/'. $node->uid)));
+    drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("@name's blog", array('@name' => theme('username', $node, array('plain' => TRUE)))), 'blog/'. $node->uid)));
   }
   return node_prepare($node, $teaser);
 }
@@ -119,9 +119,9 @@ function blog_link($type, $node = NULL, 
   if ($type == 'node' && $node->type == 'blog') {
     if (arg(0) != 'blog' || arg(1) != $node->uid) {
       $links['blog_usernames_blog'] = array(
-        'title' => t("@username's blog", array('@username' => $node->name)),
+        'title' => t("@username's blog", array('@username' => theme('username', $node, array('plain' => TRUE)))),
         'href' => "blog/$node->uid",
-        'attributes' => array('title' => t("Read @username's latest blog entries.", array('@username' => $node->name)))
+        'attributes' => array('title' => t("Read @username's latest blog entries.", array('@username' => theme('username', $node, array('plain' => TRUE)))))
       );
     }
   }
Index: modules/blog/blog.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.pages.inc,v
retrieving revision 1.7
diff -u -p -r1.7 blog.pages.inc
--- modules/blog/blog.pages.inc	10 Feb 2008 18:58:28 -0000	1.7
+++ modules/blog/blog.pages.inc	21 Feb 2008 15:42:10 -0000
@@ -12,7 +12,7 @@
 function blog_page_user($account) {
   global $user;
 
-  drupal_set_title($title = t("@name's blog", array('@name' => $account->name)));
+  drupal_set_title($title = t("@name's blog", array('@name' => theme('username', $account, array('plain' => TRUE)))));
 
   $items = array();
 
@@ -88,7 +88,7 @@ function blog_page_last() {
  */
 function blog_feed_user($account) {
   $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n  WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $account->uid, 0, variable_get('feed_default_items', 10));
-  $channel['title'] = $account->name ."'s blog";
+  $channel['title'] = t("@name's blog", array('@name' => theme('username', $account, array('plain' => TRUE))));
   $channel['link'] = url('blog/'. $account->uid, array('absolute' => TRUE));
 
   $items = array();
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.619
diff -u -p -r1.619 comment.module
--- modules/comment/comment.module	20 Feb 2008 13:46:39 -0000	1.619
+++ modules/comment/comment.module	21 Feb 2008 15:42:16 -0000
@@ -1450,7 +1450,7 @@ function comment_form_add_preview($form,
     }
     if (!empty($account)) {
       $comment->uid = $account->uid;
-      $comment->name = check_plain($account->name);
+      $comment->name = theme('username', $account, array('plain' => TRUE));
     }
     elseif (empty($comment->name)) {
       $comment->name = variable_get('anonymous', t('Anonymous'));
Index: modules/contact/contact.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.pages.inc,v
retrieving revision 1.7
diff -u -p -r1.7 contact.pages.inc
--- modules/contact/contact.pages.inc	17 Feb 2008 19:29:07 -0000	1.7
+++ modules/contact/contact.pages.inc	21 Feb 2008 15:42:16 -0000
@@ -42,7 +42,7 @@ function contact_mail_page() {
     $form['name'] = array('#type' => 'textfield',
       '#title' => t('Your name'),
       '#maxlength' => 255,
-      '#default_value' => $user->uid ? $user->name : '',
+      '#default_value' => $user->uid ? theme('username', $user, array('plain' => TRUE)) : '',
       '#required' => TRUE,
     );
     $form['mail'] = array('#type' => 'textfield',
@@ -164,7 +164,7 @@ function contact_user_page($account) {
     $output = t('You cannot contact more than %number users per hour. Please try again later.', array('%number' => variable_get('contact_hourly_threshold', 3)));
   }
   else {
-    drupal_set_title(check_plain($account->name));
+    drupal_set_title(theme('username', $account, array('plain' => TRUE)));
     $output = drupal_get_form('contact_mail_user', $account);
   }
 
@@ -177,11 +177,11 @@ function contact_mail_user(&$form_state,
   $form['recipient'] = array('#type' => 'value', '#value' => $recipient);
   $form['from'] = array('#type' => 'item',
     '#title' => t('From'),
-    '#value' => check_plain($user->name) .' &lt;'. check_plain($user->mail) .'&gt;',
+    '#value' => theme('username', $user, array('plain' => TRUE)) .' &lt;'. check_plain($user->mail) .'&gt;',
   );
   $form['to'] = array('#type' => 'item',
     '#title' => t('To'),
-    '#value' => check_plain($recipient->name),
+    '#value' => theme('username', $recipient, array('plain' => TRUE)),
   );
   $form['subject'] = array('#type' => 'textfield',
     '#title' => t('Subject'),
Index: modules/openid/openid.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/openid/openid.pages.inc,v
retrieving revision 1.5
diff -u -p -r1.5 openid.pages.inc
--- modules/openid/openid.pages.inc	30 Jan 2008 22:11:22 -0000	1.5
+++ modules/openid/openid.pages.inc	21 Feb 2008 15:42:17 -0000
@@ -28,7 +28,7 @@ function openid_authentication_page() {
  * Menu callback; Manage OpenID identities for the specified user.
  */
 function openid_user_identities($account) {
-  drupal_set_title(check_plain($account->name));
+  drupal_set_title(theme('username', $account, array('plain' => TRUE)));
   drupal_add_css(drupal_get_path('module', 'openid') .'/openid.css', 'module');
 
   // Check to see if we got a response
Index: modules/statistics/statistics.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.pages.inc,v
retrieving revision 1.2
diff -u -p -r1.2 statistics.pages.inc
--- modules/statistics/statistics.pages.inc	20 Oct 2007 21:57:50 -0000	1.2
+++ modules/statistics/statistics.pages.inc	21 Feb 2008 15:42:17 -0000
@@ -60,7 +60,7 @@ function statistics_user_tracker() {
       $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 3));
     }
 
-    drupal_set_title(check_plain($account->name));
+    drupal_set_title(theme('username', $account, array('plain' => TRUE)));
     $output = theme('table', $header, $rows);
     $output .= theme('pager', NULL, 30, 0);
     return $output;
Index: modules/tracker/tracker.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/tracker/tracker.pages.inc,v
retrieving revision 1.5
diff -u -p -r1.5 tracker.pages.inc
--- modules/tracker/tracker.pages.inc	28 Nov 2007 10:29:20 -0000	1.5
+++ modules/tracker/tracker.pages.inc	21 Feb 2008 15:42:17 -0000
@@ -19,7 +19,7 @@ function tracker_page($account = NULL, $
       // When viewed from user/%user/track, display the name of the user
       // as page title -- the tab title remains Track so this needs to be done
       // here and not in the menu definiton.
-      drupal_set_title(check_plain($account->name));
+      drupal_set_title(theme('username', $account, array('plain' => TRUE)));
     }
   // TODO: These queries are very expensive, see http://drupal.org/node/105639
     $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_updated DESC';
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.896
diff -u -p -r1.896 user.module
--- modules/user/user.module	20 Feb 2008 13:46:43 -0000	1.896
+++ modules/user/user.module	21 Feb 2008 15:42:20 -0000
@@ -529,13 +529,13 @@ function user_search($op = 'search', $ke
           // Administrators can also search in the otherwise private email field.
           $result = pager_query("SELECT name, uid, mail FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%') OR LOWER(mail) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys, $keys);
           while ($account = db_fetch_object($result)) {
-            $find[] = array('title' => $account->name .' ('. $account->mail .')', 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
+            $find[] = array('title' => theme('username', $account, array('plain' => TRUE)) .' ('. $account->mail .')', 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
           }
         }
         else {
           $result = pager_query("SELECT name, uid FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys);
           while ($account = db_fetch_object($result)) {
-            $find[] = array('title' => $account->name, 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
+            $find[] = array('title' => theme('username', $account, array('plain' => TRUE)), 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
           }
         }
         return $find;
@@ -687,7 +687,7 @@ function user_block($op = 'list', $delta
 
       case 1:
         if ($menu = menu_tree()) {
-          $block['subject'] = $user->uid ? check_plain($user->name) : t('Navigation');
+          $block['subject'] = $user->uid ? theme('username', $user, array('plain' => TRUE)) : t('Navigation');
           $block['content'] = $menu;
         }
         return $block;
@@ -2187,7 +2187,7 @@ function user_block_user_action(&$object
   }
   db_query("UPDATE {users} SET status = 0 WHERE uid = %d", $uid);
   sess_destroy_uid($uid);
-  watchdog('action', 'Blocked user %name.', array('%name' => check_plain($user->name)));
+  watchdog('action', 'Blocked user %name.', array('%name' => theme('username', $user, array('plain' => TRUE))));
 }
 
 /**
Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.12
diff -u -p -r1.12 user.pages.inc
--- modules/user/user.pages.inc	18 Feb 2008 16:53:37 -0000	1.12
+++ modules/user/user.pages.inc	21 Feb 2008 15:42:20 -0000
@@ -12,9 +12,9 @@
 function user_autocomplete($string = '') {
   $matches = array();
   if ($string) {
-    $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%s%%')", $string, 0, 10);
+    $result = db_query_range("SELECT uid, name FROM {users} WHERE LOWER(name) LIKE LOWER('%s%%')", $string, 0, 10);
     while ($user = db_fetch_object($result)) {
-      $matches[$user->name] = check_plain($user->name);
+      $matches[$user->name] = theme('username', $user, array('plain' => TRUE));
     }
   }
 
@@ -147,7 +147,7 @@ function user_logout() {
  * Menu callback; Displays a user or user profile page.
  */
 function user_view($account) {
-  drupal_set_title(check_plain($account->name));
+  drupal_set_title(theme('username', $account, array('plain' => TRUE)));
   // Retrieve all profile fields and attach to $account->content.
   user_build_content($account);
 
@@ -218,7 +218,7 @@ function template_preprocess_user_profil
  * @see user_edit_submit()
  */
 function user_edit($account, $category = 'account') {
-  drupal_set_title(check_plain($account->name));
+  drupal_set_title(theme('username', $account, array('plain' => TRUE)));
   return drupal_get_form('user_profile_form', $account, $category);
 }
 
