Download & Extend

Printing avatar pic so close!!!! Help

Project:Instant messenger
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)

Issue Summary

Ok in im.module if you add the line i have identified by the "<---------??????" below you will get an avatar printing on by each user name.... But $user does not contain their correct id number it contains whomever is logged in at the time... What should I call to give me the person who wrote the messages id number ive tryed everyone i could find.... Also how do I get the pic to print to the side of the name instead of above it?

if (sizeof($msgs) > 0) {
 
    $is_user_chatroom_admin = im_is_user_chatroom_admin($msgs[0]['ruid'], $user->uid);
    foreach ($msgs as $key => $msg) {
      if ($is_user_chatroom_admin && user_access('Moderate a Chatroom', $user)) {
        $output .= l('[x]', 'im/delete_msg/' . $msg['mid']);
      }    
      $output .= '<span class="im-console-msg-name">' ;
     
      if ($user->uid == $msg['suid']) {

        $output .= t('Me') .': </span>'; 
        $output .= '<span class="im-console-my-msgtext">';
      }
      else {
        $output .= $variables['picture'] = theme('user_picture', $user);   <---------??????
      $output .= $msg['sname'] .': </span>'; 
       
        $output .= '<span class="im-console-other-msgtext">';
      }
      $output .= check_plain($msg['msg']);
      $output .= '</span><br/>';
    }
  }
  return $output;

Comments

#1

Hi,

I'm glad you're doing this. First of all, it's a good practice to override the theming function instead of editing the module file itself. To override, you can add a function in your theme's template.php file. If you are using a theme called mytheme, then you would declare the function

    function mytheme_im_msgs($msgs, $othername)

and then copy/paste from im.module code into that function and Drupal will use that instead of the function in im.module.

Anyway,

First question regarding the other persons uid. $user is you, $msg['ruid'] is the person you are talking to.

Second question re: position of picture. Sorry I don't know css enough to give you the right answer. But what you probably want to do is something like wrap the picture into a div with a class, and then style the div in your css (mytheme/style.css) using float: left or something like that.

e.g.

  $other_user = user_load(array('uid' => $msg['ruid']); 
  $output .= '<div class="im-console-picture">' . $other_user->picture . '</div>';
  $output .= $msg['sname'] .': </span>'; 
  $output .= '<span class="im-console-other-msgtext">';

If you are doing this in a chatroom, then you will do something like the above. However, this will put a load on the server because you are doing a user_load for every line of chat. If you are doing this in a 1-on-1 conversation, then the best would be to load the user once only at the top , e.g.

  if (sizeof($msgs) > 0) {
    $other_user = user_load($msgs[0]['ruid'];

Hope this at least helps. When you do manage to get this working and can send me a patch or a copy of your code, I can also add this coolness as into the module as an option. Thanks!

#2

Status:active» postponed (maintainer needs more info)

#3

Hi,

what I did for me is to show the user pic on the friend-list, since maybe sometimes you forget who is "mark093" and maybe you need to see the user profile or the user picture, so my modification provide the user picture with the username...

hope this helps..

AttachmentSize
im-friend-list.PNG 5.18 KB
im.module.patch 3.01 KB