The easiest way that comes to mine mind would be to get the ids of the
projects you are involved at first and then pass those as condition in
the before mentioned find call.

Something like...

$this->loadModel('ProjectsUser');

$ids = $this->ProjectsUser->find('list', array('conditions' =>
array('ProjectsUser.user_id => $yourId)));

$projects = $this->Project->find('all', array(
     'contain' => array(
          'Group' => array('User')
     ),
     'conditions => array('Project.id' => array_keys($ids))
));


there are probably other ways of doing this, but I would have to think
and test before I recommend them. :)


Cheers

On Jun 7, 9:03 pm, DrLaban <jbh...@gmail.com> wrote:
> Oooh! That's pretty awesome, and it seems to work like a charm,
> thanks!
>
> Just one more question on this subject. This involves a bit more
> trickery I believe;
>
> I'd also like to be able to view all the Groups/Users for all the
> projects I'm involved at. This would look something like
> [Project 1]
>   [Group 1]
>     [User 2]
>     [User 3]
>     [User 4]
>   [Group 10]
>     [User 1]
>     [User 3]
> [Project 2]
>   [Group 25]
>   [User 1]
>   [User 3]
>   [User 7]
>
> Now, the information about what projects I'm involved at is stored in
> projects_users. I guess I somehow have to use this information to be
> able to present it in the above described way? Otherwise I'm not sure
> as to how I could first filter out all the projects I'm involved with
> and then go hunt for the groups and users. Any insights on this matter
> is really appreciated.
>
> Thank you in advance!
>
> On Jun 7, 3:26 pm, vekija <vedran.konto...@gmail.com> wrote:
>
>
>
> > You can try Containable behavior.
>
> > In models put
>
> >      var $actsAs = array('Containable');
>
> > and then in the controller....
>
> >      $this->Project->find('all', array('contain' => array('Group' =>
> > array('User'))));
>
> > you can find out more about the Containable behavior in the cook 
> > bookhttp://book.cakephp.org/view/1323/Containable
>
> > On Jun 7, 2:54 pm, DrLaban <jbh...@gmail.com> wrote:
>
> > > My setup is pretty straightforward;
> > > User HABTM Group
> > > Group HABTM Project
> > > Project HABTM User
>
> > > I would like to produce a find-query that takes a single project-id
> > > and builds a hierarchic contact list, in which the users belong to
> > > their respective group(s).
>
> > > Something along these lines:
> > > [Project 1]
> > >   [Group 1]
> > >     [User 1]
> > >     [User 5]
> > >   [Group 2]
> > >     [User 1]
> > >     [User 2]
> > >     [User 3]
> > >   [Group 4]
> > >     [User 3]
> > >     [User 4]
> > > ...
>
> > > Is this possible and if so, how? All I've been able to produce is
> > > something of a flat structure where I can't match the user to a group;
> > > [Project 1]
> > >   [User 1]
> > >   [User 3]
> > >   [User 4]
> > >   [User 6]
> > >   [Group 1]
> > >   [Group 3]
> > >   [Group 4]
>
> > > This is produced when I do;
> > > $this->Project->find('all');

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to