I am need of a method that will prevent a row to be displayed anywhere in the portal when for a certain user I match a column in the database.
For example in pseudo code it would be:
when user has ‘upgraded’ never show tips for upgrading
I have ‘user’ and ‘tips’ models, and I have the mapping between them.
How can I make sure that from ‘tips’ those items are never displayed on any page in the portal. I am looking to achieve this, if possible by editing the models only, and not the controllers.
The simplest idea I could think about right now is to have a filed in the user table that would hold the ID of the tip he has completed last… in your example the user that has upgraded would hold the ID of the "Please upgrade" tip…
This way you can always show only non-completed tips…
This assumes that tips are serial… ie. you need to complete them all one by one and in order…
if you would like the user to choose what tip to complete… than a 3rd table is needed where you would hold user_id and tip_id…
You got it wrong. I know how to represent this in the database.
My question was how to code this on an abstracted level (possibly in the model) that find() and search() never return anything that is not relevant. I need a way to restrict some table-records per-user to never ever show up in the system.
I do not want to change all the pages that make use of the model, I even don’t know how many are, and there is team-work so it might break in future, if other programmers don’t follow the protocol.
So for this situation is not viable doing like you just posted, because that time I have to alter all of the existing code where these items are displayed.
I want to run something for each access, that means I want to run a filter on the model before running any operation.
Something like beforeFind, but this should be globally and abstracted on the model class.