SiT! Bugs - SiT!
View Issue Details
0000395SiT!otherpublic2009-01-11 16:382009-08-16 14:38
paulh 
ivan 
normalfeatureN/A
closedfixed 
 
3.503.50 
0000395: Variable for last seen
We should have a global variable similar to $now for last seen calculation as its hard coded in a number of places and would be difficult to change if necessary (it also means there could be differences throughout SiT in its calculation)
No tags attached.
Issue History
2009-01-11 16:38paulhNew Issue
2009-01-11 16:43ivanNote Added: 0000473
2009-01-11 16:43ivanStatusnew => feedback
2009-01-11 18:03paulhNote Added: 0000475
2009-03-04 18:17ivanNote Added: 0000707
2009-03-04 18:17ivanAssigned To => ivan
2009-03-04 18:17ivanStatusfeedback => assigned
2009-03-04 18:17ivanTarget Version => 3.50
2009-04-23 10:13DimKirNote Added: 0000969
2009-04-23 10:20ivanNote Added: 0000970
2009-04-23 10:40DimKirNote Added: 0000971
2009-04-23 11:37ivanNote Added: 0000972
2009-04-23 12:11ivanNote Added: 0000973
2009-04-23 12:11ivanStatusassigned => resolved
2009-04-23 12:11ivanResolutionopen => fixed
2009-04-23 12:11ivanFixed in Version => Current SVN
2009-08-16 13:17ivanFixed in VersionCurrent SVN => 3.50
2009-08-16 14:38ivanNote Added: 0001610
2009-08-16 14:38ivanStatusresolved => closed

Notes
(0000473)
ivan   
2009-01-11 16:43   
Theres the function user_online()

Is this not good enough?
(0000475)
paulh   
2009-01-11 18:03   
Not really as a group_selector has a "All Online" option and this a number of places have SQL hardcoded for calculating last see e.g. users.php:



if ($onlineonly === 'true' OR $filtergroup === 'allonline' )
{
    $sql .= "AND lastseen > NOW() - (60 * 30) ";
}
(0000707)
ivan   
2009-03-04 18:17   
I think it's ok to have that in several places but the 30 shouldn't be hardcoded it should use the session length variable
(0000969)
DimKir   
2009-04-23 10:13   
version 3.45.
MySQL error (column 'lastseen').

I changed user_add.php (lines 237-243):
        $sql = "INSERT INTO `{$dbUsers}` (username, password, realname, roleid,
                groupid, title, email, phone, mobile, fax, status, var_style,
                holiday_entitlement, user_startdate, lastseen) ";
        $sql .= "VALUES ('$username', '$password', '$realname', '$roleid',
                '$groupid', '$jobtitle', '$email', '$phone', '$mobile', '$fax',
                1, '{$CONFIG['default_interface_style']}',
                '$holiday_entitlement', '$startdate',NOW())";
(0000970)
ivan   
2009-04-23 10:20   
Thanks DimKir, but is that what we want do you think? That will make it look as if newly added users are online right now?
(0000971)
DimKir   
2009-04-23 10:40   
Sorry for wrong code, I had to quickly correct the problem with MySQL error :-)

Now I change the code back and reproduced the problem:
Application Error [256]
MySQL Query Error Field 'lastseen' doesn't have a default value in user_add.php @ line 245 trigger_error()
(0000972)
ivan   
2009-04-23 11:37   
Ah I didn't see that error. I've gone with your suggestion and changed it to use NOW() it's better than an error message at least and it probably doesn't matter that the user shows online for a short time after user creation.
(0000973)
ivan   
2009-04-23 12:11   
Added a new variable $startofsession which is the current time less the length of user sessions. If lastseen is greater than this time we can assume the user is online.

trunk svn r5346
(0001610)
ivan   
2009-08-16 14:38   
Released in 3.50rc1