Quantcast

modified_by , created_by ...

Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

modified_by , created_by ...

spark-3

 Hi,

 Every model in my project does have a 'created_by' and 'modified_by'
field, storing some user ID.
 Currently, I'm using a controller beforeFilter to populate a
temporary Model with the $this->Auth->user() , only if $this->data is
full of something, and a beforeSave in the Model, to associate that
temporary fields to the model being saved.
 Actually, I don't quite like this approach, but couldn't think of
something better, since a Model can't access the Auth component. Or
could it ?
 Is there a better way to write it ?

  thanks
  Spark

--
[livesets] http://djspark.com.br/
[web] http://sydi.net
[filmes] http://melhoresfilmes.com.br

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: modified_by , created_by ...

rtconner

This blog post might be worth your time.
http://www.ad7six.com/MiBlog/TrackWhoMakesDBChanges

On Jan 15, 12:21 pm, "DJ Spark" <[hidden email]> wrote:

>  Hi,
>
>  Every model in my project does have a 'created_by' and 'modified_by'
> field, storing some user ID.
>  Currently, I'm using a controller beforeFilter to populate a
> temporary Model with the $this->Auth->user() , only if $this->data is
> full of something, and a beforeSave in the Model, to associate that
> temporary fields to the model being saved.
>  Actually, I don't quite like this approach, but couldn't think of
> something better, since a Model can't access the Auth component. Or
> could it ?
>  Is there a better way to write it ?
>
>   thanks
>   Spark
>
> --
> [livesets]http://djspark.com.br/
> [web]http://sydi.net
> [filmes]http://melhoresfilmes.com.br
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: modified_by , created_by ...

spark-3

 Thanks !
 The link gives a nice pragmatic solution (although not fully MVC-compliant:)

  So, there's no way to access a controller in the model, right ?

  Spark

On Jan 15, 2008 4:36 PM, rtconner <[hidden email]> wrote:

>
> This blog post might be worth your time.
> http://www.ad7six.com/MiBlog/TrackWhoMakesDBChanges
>
>
> On Jan 15, 12:21 pm, "DJ Spark" <[hidden email]> wrote:
> >  Hi,
> >
> >  Every model in my project does have a 'created_by' and 'modified_by'
> > field, storing some user ID.
> >  Currently, I'm using a controller beforeFilter to populate a
> > temporary Model with the $this->Auth->user() , only if $this->data is
> > full of something, and a beforeSave in the Model, to associate that
> > temporary fields to the model being saved.
> >  Actually, I don't quite like this approach, but couldn't think of
> > something better, since a Model can't access the Auth component. Or
> > could it ?
> >  Is there a better way to write it ?
> >
> >   thanks
> >   Spark
> >
> > --
> > [livesets]http://djspark.com.br/
> > [web]http://sydi.net
> > [filmes]http://melhoresfilmes.com.br
> >
>



--
[livesets] http://djspark.com.br/
[web] http://sydi.net
[filmes] http://melhoresfilmes.com.br

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: modified_by , created_by ...

rtconner

No "Cake Approved" method at least.

I have my own solution to this, I made the my auth component a global
and have a function to access the current logged in user data from
anywhere (view, helper, or model). I know many would frown on this,
but it has made developement very easy for me. I care about that more
than MVC compliance. It is still PHP we are using so I'll use it's
constructs when they best suite me.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: modified_by , created_by ...

kat nattras
This post has NOT been accepted by the mailing list yet.
In reply to this post by spark-3
I was having same issue and this article solved my problem

http://codingsips.alampk.com/cakephp-automatic-created-by-modified-by/
Loading...