Hi,

in an application I'm building here we use a person table for staff,
3rd parties as well as patients. Because of the sensitivity of the
data, I thought it makes sense to control the access rights to this
table at model level, so I wrote this:


class PersonTable extends Doctrine_Table
{

    public static function getInstance()
    {
        return Doctrine_Core::getTable('Person');
    }

    public function createQuery($alias = '')
    {

        $query = parent::createQuery($alias);

        try {
            $user = sfContext::getInstance()->getUser();
        }catch(Exception $e){
            if ($e->getMessage() == 'The "default" context does not
exist.'){  // note this ****
                return $query;
            }else{
                throw $e;
            }
        }
        if ($user->hasGroup('Peer Support Worker')){

            $user_id = $user->getGuardUser()->getStaff()->getId();
            $alias = $query->getRootAlias();
            $query->innerJoin("$alias.PeerEngagement pe")
            ->where("$alias.type='mhworker' or ($alias.type='peer' and
((pe.waiting_psw_id=$user_id and pe.assigned_psw_id is null)
                    or pe.assigned_psw_id=$user_id) or
($alias.type='staff' and $alias.id=$user_id)) ");

        }

....


But we found that dumping the fixtures would now throw an error "The
"default" context does not exist."

We couldn't come up with a way to figure out the context in this
function, so we added the try-catch block.

Any idea how this can be done better? Can we find out the context in
this function?


Kind Regards,

Jochen

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to