I've created a sfFilter to update the current module where the user is at:
class SessionFilter extends sfFilter {
public function execute($filterChain){
if ($this->isFirstCall()){
$user = $this->getContext()->getUser()->getId();
$module = $this->getContext()->getModuleName();
Doctrine::getTable('ActiveSession')->set($user, $module);
Doctrine::getTable('ActiveSession')->refresh();
}
$filterChain->execute();
}
}
When I look up into the db I found out that the record has set the field 'module' at 'default' but when I see the log it says:
UPDATE active_session SET module = 'secretary' WHERE (sys_user_id = '2')
Does anyone know how to fix this behaviour?
EDIT: I forgot to put the set and refresh method's
class ActiveSessionTable extends Doctrine_Table
{
public function set($userId, $module){
$q = $this->createQuery()->update()
->set('module','?', $module)
->where("sys_user_id = ?", array($userId))->execute();
}
public function refresh(){
$time = time() - sfConfig::get('app_session_keep') * 60;
$this->createQuery()->delete()->where('time < ?', $time)->execute();
}
...
}
The refresh method should be used in other method but for testing I'm keeping it there.