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

Get list of all connected users in order to invite them

This forum is now locked as we will no longer be developing the v1.x branch

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

Topic locked
9 posts • Page 1 of 1

Postby edgar32 » Mon Feb 07, 2011 12:20 pm

Hi,

My version is 1.3.

I have added a button "Invite" in the GUI of the chat, which is supposed to open a pop up with the list of all connected nicknames, in order to allow the user to invite one of them on his current channel.

But if a user logs in the chat after the private channel was created, his nickname does not appear in the list.


Here is the code of my method supposed to return the list of all connected users :

Code: Select all
function getNicknames($nickId)
  {
     $cg =& pfcGlobalConfig::Instance();

   
   $serverid = isset($GLOBALS['serverid']) ? $GLOBALS['serverid'] : 0;
   require_once "pfcinfo.class.php";
   $info  = new pfcInfo( md5($serverid) );
   $listOnline = $info->getOnlineNick(NULL);
   
   $listNicks = Array();
   for ($i=0; $i<sizeof($listOnline); $i++) {
      if ($listOnline['nickid'][$i] != $nickId) {
          if ($listOnline['nick'][$i] != "")
             $listNicks[] = $listOnline['nick'][$i];
      }
   }

   return $listNicks;
  }

Do you see any error in it ? Do you have a more correct way to achieve this ?

Thank you for your help !

Edgar
Last edited by edgar32 on Mon Feb 07, 2011 12:21 pm, edited 1 time in total.
edgar32
New member
 
Posts: 6
Joined: Mon Feb 07, 2011 12:05 pm
Top

Postby re*s.t.a.r.s.*2 » Mon Feb 07, 2011 5:16 pm

just read this thread..

that code works for the Mysql container and file container..

http://www.phpfreechat.net/forum/viewtopic.php?id=4783
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 edgar32 » Thu Feb 10, 2011 12:00 pm

Hello re*s.t.a.r.s.*2,

Thank you for your reply.

Actually, I already have a similar methode to that explained in the message you linked to me.
The problem is the list of users that you get by calling "getOnlineNick(NULL);" is not updated with the users who logged in since you arrived yourself in the chat.

Is there a "refresh" in phpFreeChat that should be called before "getOnlineNick(NULL);" ?

Thank you,

Edgar
edgar32
New member
 
Posts: 6
Joined: Mon Feb 07, 2011 12:05 pm
Top

Postby re*s.t.a.r.s.*2 » Thu Feb 10, 2011 2:46 pm

What you need to do it do some ajax call to the file, this gets updated every few seconds depends how to set up the ajax object ...

That' s what I have done before its call the file and put it on a div in the html markup..
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 edgar32 » Wed Mar 09, 2011 6:25 pm

Hi,

I can now be more precise about my problem. Below are the steps I followed in order to get a list of users to invite on clicking on "Invite" button.


First, I slightly modified the file chat.html.tpl.php, in order to change the behaviour on clicking on invite : I called my own function "askPopupToInvite()" as you can see :

Code: Select all
<div class="pfc_btn">
        <img src="<?php echo $c->getFileUrlFromTheme('images/invite.gif'); ?>"
             alt="" title="invit someone to the current channel"
             id="pfc_invite"
             onclick="pfc.askPopupToInvite()" />
<!--             onclick="pfc.askUserToInvite()" />-->
      </div>

Secondly, I defined the function "askPopupToInvite" in a file named customize.js.php, located under chat/themes/myOwnTheme/ :

Code: Select all
pfcClient.prototype.askPopupToInvite = function()
{
   <?php $c =& pfcContainer::Instance(); ?>
   <?php $u =& pfcUserConfig::Instance(); ?>
   // Get list of nicknames to invite
   var tabNicknames = new Array;
   <?php
      $a = 0;
      foreach ($c->getNicknames($u->nickid) as $occur) {
         echo "tabNicknames[$a] ='$occur';";
         $a++;
      }
   ?>
   
   var container = document.getElementsByTagName('body')[0];
   pfc.createBGCustomizePromptBox(container);
      pfc.createCustomizePromptBox(container, tabNicknames);
}

I could detect that the code between <?php tags was executed only once, when the page was loaded, but not each time the users clicked on "Invite". As a result it was normal that the list of users to invite was incomplete.

Do you see another way to achieve this ? I would like to fill the tabNicknames var with the names of all the users connected.

Thanks,

Edgar
edgar32
New member
 
Posts: 6
Joined: Mon Feb 07, 2011 12:05 pm
Top

Postby re*s.t.a.r.s.*2 » Thu Mar 10, 2011 1:24 am

Ok,

I dont think I get complete but lets see if I understand , what you want is to have a small window that has all the users online and when you click a determined user it will select that user and invite him to the channel?

If I am right you need to call the file that has the user online with ajax and have updated certain time, then on the user list you make a link on each nick, and use the onlclick=pfc.sendRequest('/invite <?php $user."n".$defaultChannel');

Its just an Idea...
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 edgar32 » Thu Mar 10, 2011 11:58 am

Hi,

The ajax call that you talk about, in order to get the list of users, can I make it in customize.js.php ?

Concretely, can I do something like this :

Code: Select all
pfcClient.prototype.askPopupToInvite = function()
{
   // Get list of nicknames to invite
   var tabNicknames = new Array;

   // Here fill the array 'tabNicknames' with all users
 
   
}

Thanks,

Edgar
edgar32
New member
 
Posts: 6
Joined: Mon Feb 07, 2011 12:05 pm
Top

Postby edgar32 » Thu Mar 10, 2011 5:52 pm

In the end I could get closer to my objective by rewriting askPopupToInvite like this, taking some code from pfcgui.js :

Code: Select all
pfcClient.prototype.askPopupToInvite = function()
{
   var tabNicknames = new Array;
   
   var chanids = this.chanmeta.keys();
   
   chanid = chanids[0];
   var nickidlst = this.getChanMeta(chanid,'users').get('nickid');
   for (var i=0; i<nickidlst.length; i++)
   {
      var nickid = nickidlst[i];
      
      // don't add the user himself
      if(nickid != this.nickid)
      {
         var nick = this.getUserMeta(nickid, 'nick');
         tabNicknames[i] = nick;
      }
   }

       // building the window with the list and submit button .....

}

The problem that remains is that sometimes I have an 'undefined' value in tabNicknames.
This happens when a user User1 was logged in the chat, and a new user User2 arrived : User1 has then two values in 'tabNicknames' : 'User2' and 'undefined'.

Thanks for your help,

Edgar
edgar32
New member
 
Posts: 6
Joined: Mon Feb 07, 2011 12:05 pm
Top

Postby kswaby10 » Sun Apr 03, 2011 3:14 am

Thanks for your help.


driving gamesonline fishing gamesonline zombie gamesonline typing gamesonline ninja gamesamazon codesiphone casesjenn air gas grillsilly bands
kswaby10
New member
 
Posts: 1
Joined: Sun Apr 03, 2011 3:11 am
Top


Topic locked
9 posts • Page 1 of 1

Return to Feature Requests (v1.x)

Who is online

Users browsing this forum: No registered users and 1 guest

  • 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