Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-07-2007, 02:46 PM
Casual Pligger
 
Join Date: Mar 2007
Posts: 48
Thanks: 0
Thanked 13 Times in 6 Posts
Instructions - Integration of phpFreeChat to Pligg

Ok, this took a couple of days, but I accomplished what I wanted. My requirements were as follows:
- Allow logged in user to chat live about a story
- Use the user's Pligg login as their chat name
- Use the story's name as the room name
- Do not require login to chat
- Disallow user creation of chat rooms
- Make chat UI appear in separate window
- Ajax and PHP constructed
- Allow multiple chat windows for multiple stories at once

After spending days scouring through SourceForge, this forum, the web, etc., I decide on phpFreeChat.

The integrations steps are as follows:

1 - Install phpFreeChat. I put mine into a subdirectory "chat" in htdocs. NOTE: The default download had some problems, so use SVN to get the latest from sourceforge.
2 - Modify phpFreeChat functionality to conform to the above requirements:
a - Remove the minimize button. Standard configuration has a minimize button to minimize the chat area if you embed the chat inline. Since each chat is opened in a separate window, this functionality was redundant and useless. Unfortunately, there is no configuration option to get rid of this, so this is a hack. First remove the first line from <yourchatdirectory>/themes/default/chat.html.tpl.php:
Code:
Remove this line:
               <img id="pfc_minmax" onclick="pfc.swap_minimize_maximize()" src="<?php echo $c->getFileUrlFromTheme('images/'.($start_minimized?'maximize':'minimize').'.gif'); ?>" alt=""/>
Second, edit the file <yourchatdirectory>/data/public/js/pfcclient.js and stub out the function swap_minimize_maximize and refresh_minimize_maximize:
Code:
  /**
   * Minimize/Maximized the chat zone
   */
  swap_minimize_maximize: function()
  {
    // CCC - We don't need this anymore as we have removed the image.  Stub out this function to avoid problems.
    // if (this.minmax_status) {
    //   this.minmax_status = false;
    // } else {
    //   this.minmax_status = true;
    // }
    // setCookie('pfc_minmax_status', this.minmax_status);
    // this.refresh_minimize_maximize();
  },
  refresh_minimize_maximize: function()
  {
    // CCC - We don't need this anymore as we have removed the image.  Stub out this function to avoid problems.
    // var content = $('pfc_content_expandable');
    // var btn     = $('pfc_minmax');
    // if (this.minmax_status)
    // {
    //   btn.src = this.res.getFileUrl('images/maximize.gif');
    //   btn.alt = this.res.getLabel('Magnify');
    //   btn.title = btn.alt;
    //   content.style.display = 'none';
    // }
    // else
    // {
    //   btn.src = this.res.getFileUrl('images/minimize.gif');
    //   btn.alt = this.res.getLabel('Cut down');
    //   btn.title = btn.alt;
    //   content.style.display = 'block';
    // }
  },
b - Modify the channels functionality. Make only one "room" or channel tab show up. Edit the file <yourchatdirectory>/data/public/js/pfcclient.js and stub out the following section in the code that processes the "nick" command around line 291:
Code:
        // now join channels comming from sessions
        // REMOVE - CCC - To only show the channel passed on the paramater list for multi window support
	  //for (var i=0; i<pfc_userchan.length; i++)
        //{
        //  if (i<pfc_userchan.length-1)
        //    cmd = '/join2';
        //  else
        //    cmd = '/join';
        //  cmd += ' "'+pfc_userchan[i]+'"'; 
        //  this.sendRequest(cmd);
        //}
c - Modify the global config settings. Edit the file <yourchatdirectory>/src/pfcglobalconfig.class.php. Change the following settings:
Code:
  var $max_nick_len        = 45;  // To ensure the logins passed from Pligg aren't too long.
  var $theme               = "blune";  //  I used this theme as it was the cleanest
NOTE: phpFreeChat caches these config settings. So, to get them to show up immediately, delete the cache files located in <yourchatdirectory>/data/private/cache.
3 - Create a file called start.php. Put it in your installed chat directory and insert the following code. You're Pligg interface will pass the username and roomname to this file to open the room, set the nickname of the user and connect in a new window. You can change the window size and titles.
Code:
<?php

require_once "src/phpfreechat.class.php"; // adjust to your own path
$params["serverid"] = md5(__FILE__); // used to identify the chat
$params = array("title" => "ActtUp Chat", 
	"max_msg" => 21, 
	"clock" => false, 
	"showwhosonline" => false, 
	"channels" => array ($_GET['roomname']),
	"nick" => $_GET['nickname'],
	"showsmileys" => false, 
	"height" => "270px", 
	"width" => "300px", 
	"serverid" => md5(__FILE__), 
	"theme" => "blune", ); 

$chat = new phpFreeChat($params);
$title = $_GET['roomname'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>ActtUp Chat - <?php echo $title; ?></title>
    <script type="text/javascript">window.resizeTo (860,640);</script>
    <?php $chat->printJavascript(); ?>
    <?php $chat->printStyle(); ?>
  </head>
  <body>
    <?php $chat->printChat(); ?>
  </body>
</html>
4 - Create a callout to start your chat. I am using a derivative of the Paul01 template, so I'm not to certain how this might differ in the other templates. I will use Paul01 in this example. Edit the file templates/Paul01/link_summary.tpl and insert this code after the last span. First look for:
Code:
			{if $Enable_Recommend eq 1}
				{if $Recommend_Type eq 1}
					<span id="emailto-{$link_shakebox_index}" style="display:none"></span>
				{/if}
			{/if}
and insert this after it:
Code:
		{if $user_logged_in ne ''}
			<span id="ls_category-{$link_shakebox_index}">| <a href="chat/start.php?roomname={$title_short}&nickname={$user_logged_in}" target="_blank">Chat</a> </span>
  		{/if}
This will insert a link only accessible when the user is logged in to launch phpFreeChat.

I hope you find this useful. If someone tries this and I've missed something, please let me know.

You can see this functioning at http://www.acttup.com. Of course you must register and login to see it. Please be kind and don't spam it up. It's very new and untested. Thanks.

Last edited by TrailofDead; 03-08-2007 at 09:49 AM.. Reason: Changed Title to not look like question
Reply With Quote
The Following 4 Users Say Thank You to TrailofDead For This Useful Post:
  #2 (permalink)  
Old 03-07-2007, 04:26 PM
kbeeveer46's Avatar
Pligg Developer/Admin
Pligg Version: 0
Pligg Template: none
 
Join Date: Jun 2006
Location: Muncie, Indiana
Posts: 3,547
Thanks: 254
Thanked 649 Times in 513 Posts
Very cool. Too bad it has to bring you to a new page to chat :P
__________________
I accept donations for my time helping users like you on the forum and IRC.
Reply With Quote
  #3 (permalink)  
Old 03-07-2007, 05:53 PM
Casual Pligger
 
Join Date: Mar 2007
Posts: 48
Thanks: 0
Thanked 13 Times in 6 Posts
it doesn't, you get easily embed it if you'd like. Just take the code from start.php and embed the appropriate section. In fact, that's the way the phpFreeChat guys expected it to be done.

However, I wanted the user to be able to chat and still browse the web site.
Reply With Quote
  #4 (permalink)  
Old 03-07-2007, 05:54 PM
kbeeveer46's Avatar
Pligg Developer/Admin
Pligg Version: 0
Pligg Template: none
 
Join Date: Jun 2006
Location: Muncie, Indiana
Posts: 3,547
Thanks: 254
Thanked 649 Times in 513 Posts
I see. Sounds cool.
__________________
I accept donations for my time helping users like you on the forum and IRC.
Reply With Quote
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
Pligg Integration with IPB iMMENSE Customization Assistance 10 03-05-2008 08:02 AM


Search Engine Friendly URLs by vBSEO 3.2.0