1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.
    Dismiss Notice

Use viewlevel or user_id to filter view for a list

Discussion in 'Community' started by paulsteigel, Jul 24, 2018.

  1. paulsteigel

    paulsteigel Member

    Level: Standard
    Dear All,
    I would like to have your advice with following case:
    I have a table named product(Id, name, descriptio,user_id).
    Requirements: I would like the list to view all records of that user (edit/deleting allowed) and also records created by other users of the same access level/ view level (edit but not delete).
    Please show me whether I am right or wrong with filed settings in table products? Whether it can be done with just Pre-filter options?
    I am newbie to fabrikar but having great interest in fabrik
    THank you very much for tour attention.
    Yours very faithfully
    Dang DInh Ngoc
  2. danielbidala

    danielbidala Member

    Level: Community
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    What do you mean by "the same access level / view level"?

    For example, if I belong to "Registered" and "Office Staff" ... should I see all records by anyone in both Registered and Office Staff?

    Or do you have a single, specific Access Level you want to restrict the test to?

    -- hugh
    paulsteigel likes this.
  4. paulsteigel

    paulsteigel Member

    Level: Standard
    Hi Cheesgrit
    Thank you very much for your post.
    I have been guided by Hugh by giving a prefilter for user_id Or 1=1. This has somewhat solved my requirement but not for all the cases.
    Given an Example that
    I am belong to a group name FoodSafety Authority (A) and I myselft under the Board of Director(B) Of higher level than Food Safety Authority
    There are also user those are producer of food(C).
    So I would like: When A access they can see all things proposed by C but not B, When B log in they can see all A and C posted while C can only see what he posted.
    THis is a bit complicated as I am helping farmer to register their food chain with agriculture management authority. And still stuck in this circumstances.
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Trying to use view levels in a query is problematic, because for reasons I don't quite understand, J! decided to use a flat, JSON structure for the group / access level relationship. So instead of having a (say) #__viewlevel_group_map table, with entries like ...

    level_id, group_id

    ... they have a single #__viewlevels table with the group ids as a JSON array

    id, title, ordering, rules
    2,Registered, 1,[6,2,8]

    ... so the group ids are in the [6,2,8]. WHICH makes it pretty much impossible to do any direct querying of the sort you need, where you would need to join the user table, the user_usergroup_map table to the groups in a viewlevel.

    So you'd probably have to do this with a PHP prefilter (type 'eval'), which returns a set of user ID's.

    I have a feeling I provided someone else with a similar solution in the last year or so. Try searching the forums for getAuthorisedViewLevels, see if you come up with anything.

    -- hugh
    paulsteigel likes this.

Share This Page