I need some help in designing login and persistent user information awareness in the (Yii based) system. By "design" I mean devision to classes and relationship between them, as well as flow of code.
My application relevant characteristics:
The application holds lots of analyzed data for the users, stored in an already existing and designed (and working) database which holds both the user’s login details as well as all their stored data. This data is shown on the site in several ways - in ‘instant information’ little HTML tables on central (dynamic of course) pages. But most importantly, this information is shown in a dashboard area of the site (the dashboard implementation is another story). The information could also influence other parts of the site.
The application should work, as stated, with an already existing and designed database with many related tables. Regarding the database, lets simply assume that the central table is “users” (User Gii generated class) and all other related tables are related to this ‘users’ table and the model classes reflect those relationship.
Preliminary design thoughts
Now, I’m new to Yii (and MVC programming) and was a bit confused on how to achieve this dynamic (per user) and persistent information in Yii. I come from Drupal. There, I had to rape Drupal user management system in several locations in order to both authenticate against my DB and also inject fetched information into the globally available $user variable. The latter is similar in essence, I think, to Yii->app()->user and would love a correction if mistaken here.
In Yii, authenticating against ‘my’ DB is a breeze but I’m not sure how to inject all relevant information of the user into Yii:app()->user. I was recommended by SJFriedl on the IRC channel to do something along the lines of “extend CWebUser and keep a cache of the User model object, such that you’d say Yii::app()->user->userModel and it would only fetch it the first time you asked”.
So much for the long introduction. Now for the questions:
How do I bloody model/design this issue? Would you recommend otherwise than the suggested solution?
Regarding SJFriedl’s comment, this means to simply at the end of the login process override Yii::app()->user with an object I created, which is an extension of CWebUser, and prior to that assign to this extended CWebUser object a property of my ‘user’ model object?
Any other recommendation?
Any other enlightenment on the relevant Yii best practices will be appreciated!
EDIT: marked as ‘solved’