Only in realname: .tmp_realname.module.10763~
Only in realname_dev: .tmp_realname.module.37727~
Only in realname: .tmp_realname.module.45496~
Only in realname: .tmp_realname_content_profile.inc.99851~
Only in realname: .tmp_realname_theme.inc.70547~
Only in realname: .tmp_token_realname.inc.40554~
Only in realname: .tmp_token_realname.inc.5216~
Only in realname: .tmp_token_realname.inc.70043~
Only in realname_dev: .tmp_token_realname.inc.87947~
diff -urp realname_dev/realname.admin.inc realname/realname.admin.inc
--- realname_dev/realname.admin.inc	2009-07-07 16:33:44.000000000 +0200
+++ realname/realname.admin.inc	2009-09-15 23:37:13.000000000 +0200
@@ -147,6 +147,7 @@ function realname_admin_general_submit($
   variable_set('realname_max_username', $form_state['values']['realname_max_username']);
   variable_set('realname_notver', $form_state['values']['realname_notver']);
   variable_set('realname_use_title', $form_state['values']['realname_use_title']);
+  variable_set('realname_view', $form_state['values']['realname_view']);
 
   // Did the admin change the search enable or user disable settings?
   if ($form_state['values']['original_search_enable'] != $form_state['values']['realname_search_enable']
@@ -452,6 +453,51 @@ function realname_rebuild_confirm() {
 }
 
 /**
+ * Batchable function used to rebuild realnames
+ */
+function _realname_rebuild_realnames(&$context) {
+  if (empty($context['sandbox'])) {
+    // Initiate multistep processing.
+    $context['sandbox']['progress'] = 0;
+    $context['sandbox']['current_user'] = 0;
+    $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT uid) FROM {users}'));
+  }
+
+  // Process the next 20 users.
+  $limit = 20;
+  $result = db_query_range("SELECT u.uid, u.name, u.mail FROM {users} u WHERE uid > %d ORDER BY uid ASC", $context['sandbox']['current_user'], 0, $limit);
+  while ($row = db_fetch_object($result)) {
+    $realname->uid = $row->uid;
+    $realname->realname = _realname_make_name($row);
+    // Try to update, if fail - try to insert.
+    if (db_result(db_query('SELECT COUNT(uid) FROM {realname} WHERE uid=%d', $realname->uid))) {
+      drupal_write_record('realname', $realname, 'uid');
+    }
+    else {
+      drupal_write_record('realname', $realname);
+    }
+    $context['sandbox']['progress']++;
+    $context['sandbox']['current_user'] = $row->uid;
+  }
+
+  // Multistep processing : report progress.
+  if ($context['sandbox']['progress'] != ($context['sandbox']['max']) - 1) {
+    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
+  }
+}
+
+function _realname_rebuild_batch_finished($success, $results, $operations) {
+  if ($success) {
+    drupal_set_message(t('The realnames have been rebuilt.'));
+    variable_set('realname_recalculate', FALSE);
+    drupal_goto('admin/user/realname');
+  }
+  else {
+    drupal_set_message(t('The realnames have not been properly rebuilt.'), 'error');
+  }
+}
+
+/**
  * Handler for rebuild confirmation
  */
 function realname_rebuild_confirm_submit($form, &$form_state) {
@@ -460,7 +506,8 @@ function realname_rebuild_confirm_submit
     'operations' => array(
       array('_realname_rebuild_realnames', array()),
       ),
-    'finished' => '_realname_rebuild_batch_finished'
+    'file' => drupal_get_path('module', 'realname') . '/realname.admin.inc',
+    'finished' => '_realname_rebuild_batch_finished',
   );
   batch_set($batch);
 }
diff -urp realname_dev/realname.module realname/realname.module
--- realname_dev/realname.module	2009-05-13 00:29:57.000000000 +0200
+++ realname/realname.module	2009-09-16 13:07:32.000000000 +0200
@@ -144,6 +144,14 @@ function realname_menu() {
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
     );
+    
+  // Privatemsg intercept for recipient autocomplete.
+  $items['realname/privatemsg/autocomplete'] = array(
+    'title' => 'Realname Privatemsg autocomplete',
+    'access callback' => user_access('access private messages'),
+    'page callback' => 'realname_privatemsg_autocomplete',
+    'type' => MENU_CALLBACK,
+  );
  
   return $items;
 }
@@ -153,7 +161,9 @@ function realname_menu() {
  */
 function realname_menu_alter(&$callbacks) {
   $callbacks['user/%user_uid_optional']['title callback'] = 'realname_user_page_title';
-  $callbacks['user/%user_uid_optional']['page callback'] = 'realname_user_view';
+  if (!module_exists('delegator') && !module_exists('page_manager') && $callbacks['user/%user_uid_optional']['page callback'] == 'user_view') {
+    $callbacks['user/%user_uid_optional']['page callback'] = 'realname_user_view';
+  }
   $callbacks['user/%user_category/edit']['page callback'] = 'realname_user_edit';
   if (isset($callbacks['user/%user/track'])) {
     $callbacks['user/%user/track']['page callback'] = 'realname_tracker_page';
@@ -171,6 +181,26 @@ function realname_menu_alter(&$callbacks
 }
 
 /**
+* Ask Delegator to use our version of the node page view instead of
+* Drupal's when falling back.
+*/
+function realname_delegator_override($type) {
+  // Continue to support the older delegator module by passing thru
+  // to the newer function:
+  return realname_page_manager_override($type);
+}
+
+/**
+* Ask Page Manager to use our version of the node page view instead of
+* Drupal's when falling back.
+*/
+function realname_page_manager_override($type) {
+  if ($type == 'user_view') {
+    return 'realname_user_view';
+  }
+}
+
+/**
  * Correct user page breadcrumbs.
  */
 function realname_check_breadcrumbs($account) {
@@ -209,8 +239,13 @@ function realname_user_edit($account, $c
  * Intercept the user blog page.
  */
 function realname_blog_page($account) {
-  $output = blog_page_user($account);
-  drupal_set_title($title = t("@name's blog", array('@name' => $account->realname)));
+  if (module_exists('blogtitle')) {
+    $output = blogtitle_blog_page_user($account);
+  } else {
+    $output = blog_page_user($account);
+    drupal_set_title($title = t("@name's blog", array('@name' => $account->realname)));
+  }
+
   return $output;
 }
 
@@ -361,22 +396,15 @@ function realname_nodeapi(&$node, $op, $
   if (!user_access('use realname')) {
     return;
   }
-
-  // NickSI: Yes, we will have another switch later but I would like to
-  // separate table update with other processing.
-  if (variable_get('realname_profile_module', NULL) == 'content_profile'  &&
-      is_content_profile($node->type)) {
-      // Do realnames table update if content_profile has been changed.
+  
+  // NickSI: Yes, we will have another switch later but I would like to separate table update with other processing
+  // Just delete the old nickname from the table. New one is automatically generated on next request.
+  if ( variable_get('realname_profile_module', NULL) == 'content_profile' && is_content_profile($node->type)) {
     switch ($op) {
       case 'update':
       case 'insert':
       case 'delete':
-        $realname->uid = $account->uid;
-        $realname->realname = _realname_make_name($account);
-        // try to update, if fail - try to insert
-        if (!drupal_write_record('realname', $realname,  'uid')) {
-          drupal_write_record('realname', $realname);
-        }           
+        db_query('DELETE FROM {realname} WHERE uid = %d', $node->uid);
     }
   }
 
@@ -524,6 +552,10 @@ function realname_form_alter(&$form, $fo
       $form['delete']['#weight'] = 99;
       $form['#submit'][] = '_realname_role_submit';
       break;
+      
+    case 'privatemsg_new':
+      $form['privatemsg']['recipient']['#autocomplete_path'] = 'realname/privatemsg/autocomplete';
+      break;
   }
 }
 
@@ -611,6 +643,34 @@ function realname_update_index() {
   }
 }
 
+/**
+ * Intercept Privatemsg autocomplete results for usernames.
+ */
+function realname_privatemsg_autocomplete($string) {
+  $names = explode(',', $string);
+  $names = array_map('trim', $names);
+  $search = array_pop($names);
+  if ($search != '') {
+    $sql = 'SELECT u.uid, u.name, r.realname FROM {users} u INNER JOIN {realname} r USING(uid) ';
+    $sql .= ' WHERE u.status <> 0 AND LOWER(r.realname) LIKE LOWER(\'%%%s%%\') AND ';
+    $sql .= variable_get('privatemsg_default_allow', 1) ? '(u.data NOT LIKE \'%%:16:"privatemsg_allow";i:0%%\' OR u.data IS NULL)' : 'u.data LIKE \'%%:16:"privatemsg_allow";i:1%%\'';
+    $sql .= ' ORDER BY r.realname ASC';
+    $result = db_query_range($sql, $search, 0, 10);
+    $prefix = count($names) ? implode(', ', $names) .', ' : '';
+    $matches = array();
+    while ($user = db_fetch_object($result)) {
+      $account = user_load(array('uid' => $user->uid));
+      $matches[$prefix . $user->name] = $user->realname;
+      if ($user->realname != $user->name) {
+        $matches[$prefix . $user->name] .= ' ('. $user->name .')';
+      }
+    }
+    drupal_json($matches);
+  } else {
+    drupal_json(array()); // prevent Drupal autocomplete error message
+  }
+}
+
 //********************************************************************
 //* Module Functions
 //********************************************************************
@@ -712,9 +772,9 @@ function _realname_make_name(&$account) 
       ++$i;
       $private = 'private_'. $name;
       // This will let you see that a user is using Profile Privacy.
-//      if (isset($account->{$private})) {
-//        drupal_set_message("$account->name ($account->uid) has marked the $name field as private.");
-//      }
+//    if (isset($account->{$private})) {
+//      drupal_set_message("$account->name ($account->uid) has marked the $name field as private.");
+//    }
       $private_field = isset($account->{$private}) ? $account->{$private} : FALSE;
       if (isset($account->$name) && !empty($account->$name) && !$private_field) {
         if (is_array($account->$name)) {
@@ -803,46 +863,3 @@ function realname_ajax_autocomplete_user
 
   drupal_json($matches);
 }
-
-/**
- * Batchable function used to rebuild realnames
- * Batch API does not for some reason pick'em up in realname.admin.inc
- */
-function _realname_rebuild_realnames(&$context) {
-  if (empty($context['sandbox'])) {
-    // Initiate multistep processing.
-    $context['sandbox']['progress'] = 0;
-    $context['sandbox']['current_user'] = 0;
-    $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT uid) FROM {users}'));
-  }
-
-  // Process the next 20 users.
-  $limit = 20;
-  $result = db_query_range("SELECT u.uid, u.name, u.mail FROM {users} u WHERE uid >= %d ORDER BY uid ASC", $context['sandbox']['current_user'], 0, $limit);
-  while ($row = db_fetch_object($result)) {
-    $realname->uid = $row->uid;
-    $realname->realname = _realname_make_name($row);
-    // Try to update, if fail - try to insert.
-    if (!drupal_write_record('realname', $realname,  'uid')) {
-      drupal_write_record('realname', $realname);
-    }
-    $context['sandbox']['progress']++;
-    $context['sandbox']['current_user'] = $row->uid;
-  }
-
-  // Multistep processing : report progress.
-  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
-    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
-  }
-}
-
-function _realname_rebuild_batch_finished($success, $results, $operations) {
-  if ($success) {
-    drupal_set_message(t('The realnames have been rebuilt.'));
-    variable_set('realname_recalculate', FALSE);
-    drupal_goto('admin/user/realname');
-  }
-  else {
-    drupal_set_message(t('The realanmes have not been properly rebuilt.'), 'error');
-  }
-}
diff -urp realname_dev/realname_content_profile.inc realname/realname_content_profile.inc
--- realname_dev/realname_content_profile.inc	2009-07-07 16:33:44.000000000 +0200
+++ realname/realname_content_profile.inc	2009-09-16 00:25:23.000000000 +0200
@@ -14,6 +14,7 @@ function content_profile_load_profile(&$
     return;
   }
   $fields = content_fields(NULL, $type);
+  
   foreach ($fields as $field_name => $field_attributes) {
     if (isset($profile->$field_name)) {
       $values = array();
@@ -40,6 +41,8 @@ function content_profile_load_profile(&$
       }
     }
   }
+  
+  $account->title = $profile->title;
 }
 
 function realname_content_profile_get_types() {
diff -urp realname_dev/realname_handler_filter_user_name.inc realname/realname_handler_filter_user_name.inc
--- realname_dev/realname_handler_filter_user_name.inc	2009-09-16 12:43:52.000000000 +0200
+++ realname/realname_handler_filter_user_name.inc	2009-06-30 18:27:30.000000000 +0200
@@ -0,0 +1,96 @@
+<?php
+// $Id:
+
+/**
+ * Filter handler for usernames
+ */
+class realname_handler_filter_user_name extends views_handler_filter_user_name {
+  var $no_single = TRUE;
+
+  function value_form(&$form, &$form_state) {
+    $values = array();
+    if ($this->value) {
+      $result = db_query("SELECT u.*, ru.realname FROM {users} u LEFT JOIN {realname} ru ON ru.uid=u.uid WHERE u.uid IN ("  . implode(', ', $this->value) . ")");
+      while ($account = db_fetch_object($result)) {
+        if ($account->uid) {
+          $values[] = $account->realname;
+        }
+        else {
+          $values[] = 'Anonymous'; // Intentionally NOT translated.
+        }
+      }
+    }
+
+    sort($values);
+    $default_value = implode(', ', $values);
+    $form['value'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Realnames'),
+      '#description' => t('Enter a comma separated list of user real names.'),
+      '#default_value' => $default_value,
+      '#autocomplete_path' => 'admin/user/realname/ajax/autocomplete/user',
+    );
+
+    if (!empty($form_state['exposed']) && !isset($form_state['input'][$this->options['expose']['identifier']])) {
+      $form_state['input'][$this->options['expose']['identifier']] = $default_value;
+    }
+  }
+
+  /**
+   * Validate the user string. Since this can come from either the form
+   * or the exposed filter, this is abstracted out a bit so it can
+   * handle the multiple input sources.
+   */
+  function validate_user_strings(&$form, $values) {
+    $uids = array();
+    $placeholders = array();
+    $args = array();
+    $results = array();
+    foreach ($values as $value) {
+      if (strtolower($value) == 'anonymous') {
+        $uids[] = 0;
+      }
+      else {
+        $missing[strtolower($value)] = TRUE;
+        $args[] = $value;
+        $placeholders[] = "'%s'";
+      }
+    }
+
+    if (!$args) {
+      return $uids;
+    }
+
+    $result = db_query("SELECT u.*, ru.realname FROM {users} u LEFT JOIN {realname} ru ON ru.uid=u.uid WHERE ru.realname IN (" . implode(', ', $placeholders) . ")", $args);
+    while ($account = db_fetch_object($result)) {
+      unset($missing[strtolower($account->realname)]);
+      $uids[] = $account->uid;
+    }
+
+    if ($missing) {
+      form_error($form, format_plural(count($missing), 'Unable to find user: @users', 'Unable to find users: @users', array('@users' => implode(', ', array_keys($missing)))));
+    }
+
+    return $uids;
+  }
+
+  function admin_summary() {
+    // set up $this->value_options for the parent summary
+    $this->value_options = array();
+
+    if ($this->value) {
+      $result = db_query("SELECT u.*, ru.realname FROM {users} u LEFT JOIN {realname} ru ON ru.uid=u.uid WHERE u.uid IN ("  . implode(', ', $this->value) . ")");
+
+      while ($account = db_fetch_object($result)) {
+        if ($account->uid) {
+          $this->value_options[$account->uid] = $account->realname;
+        }
+        else {
+          $this->value_options[$account->uid] = 'Anonymous'; // Intentionally NOT translated.
+        }
+      }
+    }
+
+    return parent::admin_summary();
+  }
+}
diff -urp realname_dev/realname_plugin_argument_validate_user.inc realname/realname_plugin_argument_validate_user.inc
--- realname_dev/realname_plugin_argument_validate_user.inc	2009-09-16 12:43:36.000000000 +0200
+++ realname/realname_plugin_argument_validate_user.inc	2009-06-30 18:27:31.000000000 +0200
@@ -0,0 +1,16 @@
+<?php
+// $Id: realname_plugin_argument_validate_user.inc
+
+/**
+ * Override of style plugin. Replaces username with realname
+ *
+ */
+class realname_plugin_argument_validate_user extends views_plugin_argument_validate_user {
+  
+  function validate_argument($argument) {
+    $result = parent::validate_argument($argument);
+    $this->argument->validated_title = realname_make_name($account);
+    return TRUE;
+  }
+}
+
diff -urp realname_dev/realname_theme.inc realname/realname_theme.inc
--- realname_dev/realname_theme.inc	2009-03-13 15:23:01.000000000 +0100
+++ realname/realname_theme.inc	2009-09-16 13:26:10.000000000 +0200
@@ -40,7 +40,7 @@ function realname_username($object, $opt
     'not_ver' => variable_get('realname_notver', TRUE),
 //    'allowed_tags' => array('em', 'i', 'u', 'strong', 'b'),
     );
-  $options = array_merge($defaults, $options);
+  $options = array_merge($defaults, (array)$options);
 
   // If we have a user id but no realname, then make one.
   if ($object->uid && empty($object->realname) && user_access('use realname')) {
diff -urp realname_dev/token_realname.inc realname/token_realname.inc
--- realname_dev/token_realname.inc	2009-03-06 21:07:19.000000000 +0100
+++ realname/token_realname.inc	2009-09-16 14:05:56.000000000 +0200
@@ -1,44 +1,44 @@
-<?php
-// $Id: token_realname.inc,v 1.1.2.9 2009/03/06 20:07:19 nancyw Exp $ */
-/**
-* @file
-*   Token module support for the realname module.
-*/
-
-function realname_token_list($type = 'all') {
-  $tokens = array();
-  switch ($type) {
-    case 'user':
-    case 'node':
-    case 'all':
-    case 'global':
-    case 'comment':
-      $tokens[$type]['realname'] = t('The RealName for the user.');
-      $tokens[$type]['realname-link'] = t('Themed username link.');
-      $tokens[$type]['homepage'] = t('The home page for the user.');
-      return $tokens;
-  }
-}
-
-function realname_token_values($type, $object = NULL, $options = array()) {
-  global $user;
-  $tokens = array();
-  if (!$object) {
-    $object = $user;
-  }
-  switch ($type) {
-    case 'user':
-    case 'node':
-//    case 'all':
-    case 'global':
-    case 'comment':
-      if (!isset($object->uid)) {
-        return;
-      }
-      $tokens['realname'] = realname_make_name($object);
-      $tokens['realname-link'] = theme('username', $object);
-      $tokens['homepage'] = isset($object->homepage) ? $object->homepage : NULL;
-      return $tokens;
-      
-  }
-}
+<?php
+// $Id: token_realname.inc,v 1.1.2.9 2009/03/06 20:07:19 nancyw Exp $ */
+/**
+* @file
+*   Token module support for the realname module.
+*/
+
+function realname_token_list($type = 'all') {
+  $tokens = array();
+  switch ($type) {
+    case 'user':
+    case 'node':
+    case 'all':
+    case 'global':
+    case 'comment':
+      $tokens[$type]['realname'] = t('The RealName for the user.');
+      $tokens[$type]['realname-link'] = t('Themed username link.');
+      $tokens[$type]['homepage'] = t('The home page for the user.');
+      return $tokens;
+  }
+}
+
+function realname_token_values($type, $object = NULL, $options = array()) {
+  global $user;
+  $tokens = array();
+  if (!$object) {
+    $object = $user;
+  }
+  switch ($type) {
+    case 'user':
+    case 'node':
+//    case 'all':
+    case 'global':
+    case 'comment':
+      if (!isset($object->uid)) {
+        return;
+      }
+      $tokens['realname'] = realname_make_name($object);
+      $tokens['realname-link'] = theme('username', $object);
+      $tokens['homepage'] = isset($object->homepage) ? $object->homepage : NULL;
+      return $tokens;
+      
+  }
+}
