In the mean time (waiting for v2)
- Copy the function buildQueryWhere() from your model
- paste the the original buildQueryWhere statement under the original in your model
- rename the function to where author
Add the standard joomla db check
Add the standard joomla get user
Function buildQueryWhereAuthor()
{
$db=JFactory::getDBO();
$user =JFactory::getUser();
[ original code goes here]
and Change the where
$where[] = 'a.id = '.(int) $this->_id;
to
$where[] = 'a.author = '.(int) $user->id;
}
in the
administrator/classes/jmodel.item.php
Copy the buildQueryWhere()
buildQueryWhere()
{
.........
}
Paste and rename
To buildQueryWhereAuthor()
Then where ever the you need to filter on author for that given model (or what ever value you decided to give the $where[] = 'a.id = '.(int) $user->id;)
Just change the
. $this-> buildQueryWhere() in your SQL statements
To
. $this-> buildQueryWhereAuthor()
With out fear of of losing any existing where functionality such as access filtering
it should be noted that this will only work for the specific model... you will need to do this for each model where you need to filter on a specific field
i know had to do this outside the cook environment on many many tables... would be nice to see the addWhere() and buildQuerywhere[something]() auto generated in item class and all models
And yes the addWhere in model.item class is also handy for adding additional filtering on a specific item
To admin -> can we get this added to the class and models in the mean time whilst waiting for v2 Please...
???
But im not complaining cook has saved me many many hours so far (THANKS ADMIN) so and to hand code this for the moment there is no argument from me
and as always there coud be a simpler way such as a switch statement based on the current view but i will leave that up to you to explore..