I was always missing 'Who is online' feature... so I made it by myself ;)
Notice: For keeping online time im using column 'lastlogin' in table ost_staff.
The idea is simple: Make an update of online time every person who refreshes one of the admin pages.
For this I needed to make two modifications:
One is in header.inc.php in the staff directory:
Beginning of the file:
<? if(!defined('OSTSCPINC') || !is_object($thisuser) || !$thisuser->isStaff() || !is_object($nav)) die('Access Denied'); ?>
//INSERT CODE HERE
<html>
<head>
Replace text //INSERT CODE HERE with:
<?
if(is_object($thisuser) && $thisuser->isStaff())
{
//@Modification: Online List
$staffid=$thisuser->getId();
$qry = mysql_query("UPDATE ost_staff SET `lastlogin` = NOW() WHERE staff_id = '$staffid'");
}
?>
Voila. We have automatically updated OnlineList in the database as lastlogin
Now lets present results:
We need to make some changes in the tickets.inc.php file
Search for:
if($canDelete) {?>
<input class="button" type="submit" name="delete" value="Delete"
onClick=' return confirm("JesteĀ¶ pewien, że chcesz SKASOWAĆ wybrane zgłoszenia?");'>
<?}?>
</td></tr>
<? }
} ?>
</form>
//INSERT CODE HERE
Replace the dummy line with:
@Modification OnlineList
<? if ($thisuser->isadmin()) { ?>
<tr><td></td></tr>
<tr><th align="left">Last active (15 mins)</th></tr>
<tr><td colspan="8">
<?
$qry = mysql_query("SELECT staff_id,firstname,lastlogin FROM ost_staff ORDER BY lastlogin DESC");
while($row = mysql_fetch_array($qry)) {
$staff=$row;
$staffid=$row;
$activity=strtotime($row);
$currently=time();
if ($currently - $activity < 900) {
echo '<a href="admin.php?t=staff&id='.$row.'"><span title="'.$row.'">'.$staff.'</span></a>, ';
}
}
}?>
Bingo ;)
Such made OnlineList will be visible on the bottom of the ticket list page.
Every nickname is clickable leading to the staff profile.
Important: I`ve made this list only visible for admins.
If you want to show it to all staff you need to remove one condition.
So paste this code instead of the upper one
@Modification OnlineList
<tr><td></td></tr>
<tr><th align="left">Last active (15 mins)</th></tr>
<tr><td colspan="8">
<?
$qry = mysql_query("SELECT staff_id,firstname,lastlogin FROM ost_staff ORDER BY lastlogin DESC");
while($row = mysql_fetch_array($qry)) {
$staff=$row;
$staffid=$row;
$activity=strtotime($row);
$currently=time();
if ($currently - $activity < 900) {
echo '<a href="admin.php?t=staff&id='.$row.'"><span title="'.$row.'">'.$staff.'</span></a>, ';
}
} ?>
Hint: If you want to have different time span change the value in line:
if ($currently - $activity < 900) {
from 900 to any other (counting in seconds)
Have fun ;)
Greets.