I'm trying to create a script then trigger it from time to time to check "who" is logged in in admin (users), so I created this:
$adminUser = Mage::getModel('admin/user');
$users = $adminUser->getCollection()->load();
echo '<pre>';
foreach($users as $user){
$name = $user->getUsername();
Mage::getSingleton('core/session', array('name'=>$name));
if(Mage::getSingleton('admin/session')->isLoggedIn()){
echo $name.' is logged in<br/>';
}else{
echo " go away bad boy<br/>";
}
}
echo '</pre>';
?>
Simplified code .... still no positive results ....
controller_action_predispatch
that would be like the most classy event to watch out for (but be aware it is used in frontend and backend)Mage::getSingleton('admin/session')->getUser()
which gives you the current user. You should make sure however, that all your logging is happening if it is an adminhtml interaction and only then check for the current user. About your other approach, yes that can work out as well, you'd just need to figure first of all, what you actually want to know and track from your admins ([possibly] active session/login, actual interaction, idle state, ...)