Online Staff
Dear Larry Levesque,
I had the same requirement and I have successfully developed a piece of code for it.
please follow the below steps in order to have this feature in your system.
1. create the following table in your mysql table(with your respected table prefix)
create table ost_staff_online (staff varchar(20),isonline int default 0,logged_at datetime,logged_from varchar(50));
And then insert all your staff usernames and 0's and leave other fields blank.
e.g insert into ost_staff_online values('bonapart',0,null,null,null);
2. edit scp scp/login.php as follow
fine line "if($user=Staff:($_POST,$_POST,$errors))){
and then write this code
$user=$_POST;
$address=gethostbyaddr($_SERVER);
$update_online=mysql_query("update ost_staff_online set isonline=1,logged_at=now(),logged_from='$address' where staff='$user'");
2. create a new .php file in scp directory and call it as online_staff.php
write the following code in it:
require('staff.inc.php');
$page='online_staff.inc.php';
$nav->setTabActive('online_staff');
require(STAFFINC_DIR.'header.inc.php');
require(STAFFINC_DIR.$page);
include(STAFFINC_DIR.'footer.inc.php');
3. create new file online_staff.inc.php in include\staff directory
and write the following code.
Online Staff
The following tables show the list of staff and their status
<?php csrf_token(); ?>
<?php $staff_cnt_query=mysql_query("select count(staff) as staff_cnt from prefix_staff_online where isonline=1") or die("error while counting staff".mysql_error());
while($os=mysql_fetch_array($staff_cnt_query))
echo "Online Staff - ".$os;?>
Staff Username
Is Online
Login At
Login from
<?php
$staff_query=mysql_query("select * from ost_staff_online order by isonline") or die ("Error while retrieving list of online staff".mysql_error());
while ($row = mysql_fetch_array($staff_query)) {
?>
">
<?php
echo $row.' ';
if($row==1)
echo "";
else
echo "";
?>
<?php
$state=$row;
if($state==1)
echo "Yes";
else
echo "No";
?>
<?php echo $row;?>
<?php echo $row;?>
<?php
} //end of while.
?>
4. Edit Logout.php which resides in scp directory
write the following code after sprintf("%s logged out ",$thisstaff->getUserName(), $_SERVER));
$address=gethostbyaddr($_SERVER);
mysql_query("update ost_staff_onliine set isonline=0 where logged_from='$address'");
5. the final step is to add the menu item by editing include\class.nav.php
add the following code after $this->tabs=array('desc'=>'Knowledgebase', 'href'=>'kb.php','title'=>Knowledgebase');
$this->tabls=array('desc'=>'Online Staff','href'=>'online_staff.php','title'=>'online staff');
Enjoy.