I want to get & list all the users that belongs to the same idempresa that the user logged in has. idempresa is related to users in a sf_guard_profile table and yes I have the relation declared on schema.yml file. I think in write a method in sfGuardUserTable.class.php but I'm not so sure it will works in others words I don't know where to touch or what to handle this. Can any point me in the right direction on this? This is the method (unfinished):
public function getUsersByCompany() {
$user = sfContext::getInstance()->getUser()->getProfile()->getIdEmpresa();
$q = $this->createQuery('g');
return $q;
}
Any advice?
It's generally not good practice to use sfContext::getInstance(). Read this post http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/.
How about adding a static method to your
sfGuardUserTable.class.php, e.gThen calling it in your controller or from where you need, e.g