Recently had that problem. Solved it like this:
Usually a controller is an extension of Zend_Controller_action, for example
class IndexController extends Zend_Controller_Action
What we did in our project was create an extended controller under /library/ME/Controller
class ME_Controller_Base extends Zend_Controller_Action
public function init()
{
parent::init();
}
}
Using this controller you can extend all your other controllers from it - so, the above default controller goes from
class IndexController extends Zend_Controller_Action
to
class IndexController extends ME_Controller_Base
Important, remember to always call parent::init() in the init() section of your controller (this is good practice anyway)
class IndexController extends ME_Controller_Base
{
public function init()
{
parent::init();
}
}
Now you can add any code you like to the "Base" controller. As we are using Zend_Auth with a Doctrine user object, the final "base" controller looks like this
class ME_Controller_Base extends Zend_Controller_Action
public function init()
{
parent::init();
$auth = Zend_Auth::getInstance();
$this->view->user = $auth;
$this->user = $auth;
// check auth
...
// write an update to say that this user is still alive
$this->user->getIdentity()->update();
}
}
The update() method just sets an "updated" field to the current date and flushes the user. You can then just select users who were seen within the last X minutes to show the list.