• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Different WHERE for database join for front-end/admin?

chris.paschen

Chris Paschen
We've got a database join element on a form.

We have a joins where of:

WHERE {thistable}.user_id = {$my->id} AND {thistable}.state = 1

This works perfectly in the front-end. The users can only select options from the lookup table that matches their user id.

However, we need to have administrators access the same form on the admin-side but they should not have that filter applied.

We've tried to use the Apply Where To (user access level); however, the administrators are members of the front-end group (authors) that needs to access this with the filter, so it is being applied to administrators as well.

Is there any way to apply the filter on the front-end only, no mater what the level of user?

Would there be a way to do that with an Eval option code?
 
FYI ... I did manage to get this to work by using an Eval option code snippet that uses
$user->authorise
to check to see if the current user is an admin and then manually filter the list there and only return the appropriate ones.
 
Just curious ... would the way you add the functionality (at the element level) be at all faster (less processing time) than me doing it with an Eval bit of code?
If there's no specific reason to change it (other than ease), it might be better if I just add a sample of my code to the wiki (it took me quite a bit of 'testing' to get my code right, and might help save others time).
 
Well, yes it would be faster, in that it's always faster to hand off filtering to MySQL, so you then only post-process what you need, and don't waste time loading rows you don't need and doing your own filtering at the application level. But "faster" is relative. In this case, probably measured in milliseconds.

-- hugh
 
OK ... we can live with miliseconds for now; however, at some point this database join might involve lots of records (potentially thousands), but we'll revisit this when that time comes. The Eval should be fine for now.
Thanks.
 
Well yes, if thousands of rows are involved, then milliseconds can indeed add up into seconds.

-- hugh
--
"I was told there wouldn't be math"
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top