I have a yii app that is user-centric. By that, I mean that I have one application, but all of the data used pertains to the currently logged in user. Just like many web sites. Nothing new.
Well, as I’m building the app, I’m changing LOTS of code to make data retrieval/writing user-specific. Lots of
’ AND user_id = ’ . Yii->app()User->id
I’ve had some lengthy discussions about why this id specification should exist in the controllers. The main argument being that maybe some of the data is NOT user centric. However, for this application it certainly is. There should be NO model instances that don’t belong to a user thats currently logged in.
So that made me think; “Why don’t I just put something in the MODEL that filters the data by user_id.” Small code change, and semantically correct. Again, EVERY model (here) should be tied to a user.
What do you think of this, and how would you go about doing it?
If you have experience with giix models I’d like to know if theres facility for that there.