you want to do, you need only add it to the conditions of your find.
There's no need for it to be in the link.
Ditto for editing a record: just check the session and compare it to
the user_id in your data. If it doesn't match, throw up a flash msg
and redirect.
When in the controller, use $this->Session->read(...) and, in the
view, $session->read(...)
On Mon, Apr 27, 2009 at 1:07 PM, Teedaddy <bretteegarden@gmail.com> wrote:
>
> I basically want all my controller actions to be user specific once a
> user is logged in. I'm getting close and these suggestions have been
> very helpful.
>
> The main task would be to assure that all related records that are
> returned, found, added, etc, are tied to a specific user.id.
>
> For instance, the project I am working on is a song catalog. The
> hierarchy is UserGroups -> Users -> Catalogs -> Songs.
>
> Individual users can have many Catalogs but when the view for Songs is
> displayed or one tries to add a new song, all the records in the DB
> are displayed or all Catalogs from all Users are available in the
> Catalog dropdown form item. I only want the selection choices for
> Catalog to be those of the logged in user. Right now (with Baked views
> and controllers) every Catalog belonging to every user is displayed as
> a possible choice. I also need to make sure only related records
> (keyed by user.id) are shown in all cases.
>
> Please forgive me if I am not making this as understandable as it
> needs to be. Thanks so much for your help.
>
>
> On Apr 27, 10:17 am, brian <bally.z...@gmail.com> wrote:
>> Are you using Auth? What's the route for this URL? This should work:
>>
>> $html->link(
>> 'edit profile',
>> array(
>> 'controller' => 'users',
>> 'action' => 'edit',
>> 'user_id' => $session->read('Auth.User.id')
>> ),
>> array('title' => 'whatever')
>> )
>>
>> If you don't have a route that specifically passes user_id, you can also do:
>>
>> $html->link(
>> 'edit profile',
>> array(
>> 'controller' => 'users',
>> 'action' => 'edit',
>> $session->read('Auth.User.id')
>> ),
>> array('title' => 'whatever')
>> )
>>
>> On Mon, Apr 27, 2009 at 10:34 AM, Teedaddy <bretteegar...@gmail.com> wrote:
>>
>> > Thanks for the response, but this still doesn't answer my question of
>> > how to include this variable in a $htmlhelper link, mainly need to
>> > know the syntax. thanks so much
>>
>> > On Apr 26, 10:36 pm, NegoBlack® <paulomoacir.jun...@gmail.com> wrote:
>> >> I use to do this on my app_controller.php:
>>
>> >> public function beforeFilter(){
>>
>> >> if ($this->Auth->user()){
>> >> $this->set("userInfo", $this->Auth->user())
>> >> }
>>
>> >> }
>>
>> >> Then I can use this var on my views...
>>
>> >> On Apr 25, 7:57 pm, Teedaddy <bretteegar...@gmail.com> wrote:
>>
>> >> > Could someone be so kind to tell me the easiest way to pass the
>> >> > current logged in "Auth" user id in $htmlhelper links?
>>
>> >> > Thank you so much, just learning all this MVC method and have been
>> >> > through Auth tutorials numerous times but I am missing this somehow.
>>
>> >> > Bret
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment