I think there are many who may wants to integrate Chat option in Osclass, if not interested then just ignore this tutorial
1) First of all download friechat from
https://bitbucket.org/evnix/freichat-free-chat-script/downloads/FreiChat.V.9.6.zip2) Extract friechat folder in osclass root directory
3) Open main.php from current theme folder and place the below code between <head></head>
NOTE: DON'T FORGET TO CHANGE "YOURDOMAINNAME.COM" IN BELOW CODE <?php
if(osc_is_web_user_logged_in())
{
$ses = osc_logged_user_id() ; //tell freichat the userid of the current user
setcookie("freichat_user", "LOGGED_IN", time() 3600, "/"); // *do not change -> freichat code
}
else {
$ses = null; //tell freichat that the current user is a guest
setcookie("freichat_user", null, time() 3600, "/"); // *do not change -> freichat code
}
if(!function_exists("freichatx_get_hash")){
function freichatx_get_hash($ses){
if(is_file("/home/www/YOURDOMAINNAME.COM/freichat/hardcode.php")){
require "/home/www/YOURDOMAINNAME.COM/freichat/hardcode.php";
$temp_id = $ses . $uid;
return md5($temp_id);
}
else
{
echo "<script>alert('module freichatx says: hardcode.php file not found!');</script>";
}
return 0;
}
}
?>
<script type="text/javascript" language="javascipt" src="http://www.YOURDOMAINNAME.com/freichat/client/main.php?id=<?php echo $ses;?>&xhash=<?php echo freichatx_get_hash($ses); ?>"></script>
<link rel="stylesheet" href="http://www.YOURDOMAINNAME.com/freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css">
4) Place the below code where you want the online/offline icon to be shown, i place this inside description DIV
<div class="onlineuser">
<?php $user = User::newInstance()->findByPrimaryKey(osc_item_user_id()); ?>
<?php if(useronline_show_user_status() == 1) { ?>
<a class="chat_online_inline" id="onlineuser" href="javascript:void(0)" onClick="FreiChat.create_chat_window(<?php echo "'".$user['s_name']."'" ; ?>, <?php echo osc_item_user_id(); ?>)"></a>
<?php } else { ?>
<a class="chat_offline_inline" href="javascript:void(0)"></a>
<?php } ?>
</div>
Now its time to install friechat in order to integrate with osclass5) Open browser and install friechat by
http://YOURDOMAINNAME.COM/FRIECHAT/ and follow the instruction, You must select "
CUSTOMIZED" option from dropdown during installtion, remember you should be logged in to your site using any user before you install friechat, because friechat will search if any user is logged in to your site.
Note: you don't need to copy the code during friechat installation and paste in osclass, because we already did it in <head></head> section. If you didn't then do it before you start installation 6) Download Useronline plugin from
http://forums.osclass.org/plugins/(new-plugin)-user-online/?action=dlattach;attach=16512 install and activate it from admin panel.
7) Go to the ../oc-content/plugins/useronline foder and open index.php file
Find and replace this
function useronline_show_user_status() {
$itemUserId = osc_item_user_id();
$conn = getConnection();
$userOnline=$conn->osc_dbFetchResult("SELECT * FROM %st_useronline WHERE userid = '%s'",DB_TABLE_PREFIX, $itemUserId);
if($userOnline !=''){
echo '<img src="'.osc_base_url().'oc-content/plugins/useronline/images/online.png" />' ;
} else {
echo '<img src="'.osc_base_url().'oc-content/plugins/useronline/images/offline.png" />' ;
}
}
With This
function useronline_show_user_status() {
$itemUserId = osc_item_user_id();
$conn = getConnection();
$userOnline=$conn->osc_dbFetchResult("SELECT * FROM %st_useronline WHERE userid = '%s'",DB_TABLE_PREFIX, $itemUserId);
if($userOnline !=''){
return 1;
} else {
return 0;
}
}
8 ) Copy the oc-content/plugins/useronline/images/online.png and paste in your current theme image folder
9) Copy the oc-content/plugins/useronline/images/offline.png and paste in your current theme image folder
10) Open style.css file of your current theme and place below style code anywhere you want
.chat_online_inline{background:url(images/online.png) no-repeat;}
.chat_offline_inline{background:url(images/offline.png) no-repeat;}
.chat_online_inline,.chat_offline_inline{float:right; display: block; cursor:pointer;}
Thanks to cartagena68 for useronline plugin
any better suggestions are welcomed