• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ General Support (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

Show avatars inside the chat container

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
12 posts • Page 1 of 1

Postby runebergen » Wed Sep 28, 2011 10:08 am

How can i get the usermeta of the sender ?

handleComingRequest: function( cmds )

var id = cmds[mid][0];
var date = cmds[mid][1];
var time = cmds[mid][2];
var sender = cmds[mid][3];
var recipientid = cmds[mid][4];
var cmd = cmds[mid][5];
var param = cmds[mid][6];
var fromtoday = cmds[mid][7];
var oldmsg = cmds[mid][8];


In this part I need to get the meta data of the poster (sender)
Something like this ..

var avar = this.getUserMeta(nickid, 'avatar'); // avatar

This of course dont work, as it will show YOUR avatar ... not for each sender..
Instead of nickid.. i guess I need something like sender ID ?

Could anyone please help...?

Thanks in advance
runebergen
Member
 
Posts: 30
Joined: Tue Aug 12, 2008 10:00 am
Top

Postby runebergen » Wed Sep 28, 2011 10:41 am

I guess i can send it from here...

But how..

class pfcCommand_getnewmsg extends pfcCommand
{
function run(&$xml_reponse, $p)
{
$clientid = $p["clientid"];
$param = $p["param"];
$sender = $p["sender"];
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];
runebergen
Member
 
Posts: 30
Joined: Tue Aug 12, 2008 10:00 am
Top

Postby re*s.t.a.r.s.*2 » Wed Sep 28, 2011 2:46 pm

Hi,

You need to use $params['nickmeta'] to set the avatar picture name or anything you desire!.

example

Code: Select all
$params['nickmeta']['avatar']= "<img src="./data/public/themes/default/avatars/".$dinamicAvatar."" />";

that will set the meta for that user with the img tags and the avatar's abstract URL, after that you just need to get rid of the key in the array to be shown in the whoisbox .

$params['nickmeta_key_to_hide'] = 'avatar';

Now you shouldnt be worry anymore how to loop tru the arrays since the pfcclient.js has a function thats picks up all the nickids and loops tru them to get the userMetas and show them in the whoisbox.

hope this helo you out..

regards.
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby runebergen » Wed Sep 28, 2011 2:56 pm

Thanks for the reply re*s.t.a.r.s.*2 :)

$params['nickmeta']['avatar'] = '<img...

Thats EXACTLY what i'm using :)
Each chatter has an avatar shown in the "whois" box .. I got that all working..

What I want is the users avatar to show in the chat window too (chat container)

in pfcclient.js is where i'm stuck
I can get the avatar of ME.. and show that easily in the main chat window
var avatar = this.getUserMeta(nickid, 'avatar'); // avatar

But not the avatar of OTHER users..

handleComingRequest: function( cmds )

var id = cmds[mid][0];
var date = cmds[mid][1];
var time = cmds[mid][2];
var sender = cmds[mid][3];
var recipientid = cmds[mid][4];
var cmd = cmds[mid][5];
var param = cmds[mid][6];
var fromtoday = cmds[mid][7];
var oldmsg = cmds[mid][8];

In this part i need to get the avatar of the SENDER (not me )


Any ideas?
runebergen
Member
 
Posts: 30
Joined: Tue Aug 12, 2008 10:00 am
Top

Postby re*s.t.a.r.s.*2 » Wed Sep 28, 2011 3:17 pm

hi,

What I want is the users avatar to show in the chat window too (chat container)

Ok I dont get it, you mean in the text chat area where the usernicks are shown?


explain please..
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby runebergen » Wed Sep 28, 2011 3:24 pm

Easier to explain with a photo :)
Image

So you see i need the SENDER's avatar .. and I'm stuck in how to get that data
runebergen
Member
 
Posts: 30
Joined: Tue Aug 12, 2008 10:00 am
Top

Postby runebergen » Wed Sep 28, 2011 3:28 pm

By the way, its early stage, I'm gonna make it look better when i get it working :)
(and that "send" next to avatar is just me testing output..)
runebergen
Member
 
Posts: 30
Joined: Tue Aug 12, 2008 10:00 am
Top

Postby runebergen » Wed Sep 28, 2011 3:29 pm

in pfcclient.js ...

// format and post message

var line = '';
line += '<div id="pfc_msg_'+recipientid+'_'+id+'" class="pfc_cmd_'+ cmd +' pfc_message';
line += (id % 2 == 0) ? ' pfc_evenmsg' : ' pfc_oddmsg';
if (oldmsg == 1) line += ' pfc_oldmsg';
line += '">';
line += '<span class="pfc_date';
if (fromtoday == 1) line += ' pfc_invisible';
line += '">'+ date +'</span> ';
line += '<img src="'+avatar +'" height="30" style="margin:5px; margin-left:20px" /><span class="pfc_heure">'+ time +'</span>';


This is where i need some var avatar = .... (get the senders avatar from user meta data)
Last edited by runebergen on Wed Sep 28, 2011 3:31 pm, edited 1 time in total.
runebergen
Member
 
Posts: 30
Joined: Tue Aug 12, 2008 10:00 am
Top

Postby re*s.t.a.r.s.*2 » Wed Sep 28, 2011 4:33 pm

Ok,

I would try to make an array from var avartars = this.getUserMeta(nickid, 'avatar');
that will only have the name of the pictures and then would push into the sender array

Code: Select all
// format and post message

      var line = '';
      line += '<div id="pfc_msg_'+recipientid+'_'+id+'" class="pfc_cmd_'+ cmd +' pfc_message';
      line  += (id % 2 == 0) ? ' pfc_evenmsg' : ' pfc_oddmsg';
      if (oldmsg == 1) line += ' pfc_oldmsg';
      line += '">';
      line += '<span class="pfc_date';
      if (fromtoday == 1) line += ' pfc_invisible';
      line += '">'+ date +'</span> ';
line += '<img src="'+sender[6] +'" height="30" style="margin:5px; margin-left:20px" /><span class="pfc_heure">'+ time +'</span>';

something along the lines..

thats using JS approach.

hope this gives you an Idea..

regards
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby runebergen » Wed Sep 28, 2011 5:04 pm

Hmm not sure i understand..
What i need is something that gets the ID of SENDER (chat poster), and not nickid (= YOU).

Like for example :
var avatar = pfc.getUserMeta(senderid,'avatar');

But i dont know how to get the sender ID to use instead of nickid
Last edited by runebergen on Wed Sep 28, 2011 5:04 pm, edited 1 time in total.
runebergen
Member
 
Posts: 30
Joined: Tue Aug 12, 2008 10:00 am
Top

Postby re*s.t.a.r.s.*2 » Wed Sep 28, 2011 6:51 pm

Hi,

Sorry meant to say var nickid = meta.get('users').get('nickid')[i]; that will get you all the nickids allocated in the chat, then append the nickid into cmd array ..

hope this help you..

regards.
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby runebergen » Thu Sep 29, 2011 12:00 am

Thanks for the help btw, .. but I'm no javascript coder, so i kinda gave up ..hehe
Made it happen by passing variable from getnewmsg.class.php instead..
Coding in PHP is more me ..

Code: Select all
// transform new message in html format
    $js = array();
    $data_sent = false;
    foreach ($data as $d)
    {
      $m_id          = $d["id"];
      $m_date        = date($c->date_format, $d["timestamp"] + $c->time_offset);
      $m_time        = date($c->time_format, $d["timestamp"] + $c->time_offset);
      $m_sender      = $d["sender"];
      $m_recipientid = $recipientid;
      $m_cmd         = $d["cmd"];
      $m_param       = phpFreeChat::PostFilterMsg(pfc_make_hyperlink($d["param"]));
   

    // Lets get the senders avatar from meta
     $senderID   = $container->getNickId($m_sender); //get the nickid of sender
     $senderName   = $container->getNickname($test); //get the nickid of sender
     $avatar   = $container->getUserMeta($senderID, $key = "avatar"); // avatar


 $js[] = array($m_id,
                    $m_date,
                    $m_time,
                    $m_sender,
                    $m_recipientid,
                    $m_cmd,
                    $m_param,
                    date($c->date_format, time() + $c->time_offset) == $m_date ? 1 : 0, // posted today ?
                    $oldmsg ? 1 : 0,
          $avatar

and then you can easily use that value in pfccclient.js

Code: Select all
  handleComingRequest: function( cmds )
  {
    var msg_html = $H();
    var max_msgid = $H();
   
    //alert(cmds.inspect());

    for(var mid = 0; mid < cmds.length ; mid++)
    {
      var id          = cmds[mid][0];
      var date        = cmds[mid][1];
      var time        = cmds[mid][2];
      var sender      = cmds[mid][3];
      var recipientid = cmds[mid][4];
      var cmd         = cmds[mid][5];
      var param       = cmds[mid][6];
      var fromtoday   = cmds[mid][7];
      var oldmsg      = cmds[mid][8];

    var avatar = cmds[mid][9];  // the new value from getnewmsg.class

Same procedure could easily be users for some other type of challenges i've seen on this board, such as color nick to gender in chat main area, put birthday icon .. etc etc..


Now whats left is style it to be a lot prettier ;)
With time under avatar, and the elements positioned nice etc
But at least it works now :)

Image
Last edited by runebergen on Thu Sep 29, 2011 3:23 pm, edited 1 time in total.
runebergen
Member
 
Posts: 30
Joined: Tue Aug 12, 2008 10:00 am
Top


Post a reply
12 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 13 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub