If you're using CakePHP 2.0+, use AuthComponent::user() static method.

$queryData['conditions']['customer_id'] = 
AuthComponent::user('customer_id');

Em segunda-feira, 5 de novembro de 2012 22h14min48s UTC-2, Nir Regev 
escreveu:
>
> Hi all !
>
> I need to implement a little complex user permissions over data in tables :
>
> relations are similar to the following :
>
> - user belongs to a customer
> - book belongs to a customer
>
> In order to keep it DRY and "fat model / slim controller", I thought I 
> could just add something like :
>
> // Book Model
> $queryData['conditions']['customer_id']=$this->Auth->User['customer_id'];
>
> But, I don't get how to access Auth parameters from the models.
>
> The only way I found to pass this barrier is to send the user's 
> customer_id via the $_SESSION which is quite .. err .. ugly :)
>
> Any suggestions on how to pass parameters to all models ?
>
> Note that I need the customer_id available for all models, not just "Book" 
> ..
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to