Non-viewable elements in calc and prefilters

Status
Not open for further replies.

rackem

Well-Known Member
I have noticed that elements set to be non-viewable using access levels are not available in calc elements and prefilters.

For example, I have a list of players that I wish to prefilter based on an element called "active". The "active" element is simply a radiobutton with options yes or no.

I only wish this option to be visible and editable by Admin so that is how I set up the element. However I found the prefilter only works for non-admin if the element is visible to them.

Same for the calc element. I wanted to perform a query that did one thing if the players was active and something else if the player was inactive. However, the element value was unavailable for users not in the ACL that the "active" element was set to.

Is this a feature or a bug? I would think these operations should still be possible regardless of the ACL setting of the element. But perhaps there is a case where it isn't a good idea?
 
I can't see this behaviour:
Prefilter on an element only viewable and/or editable by "special" is working fine on my site for public users.
What are your "apply to" settings of the prefilter?
Did you check with fabrikdebug which query is created?
 
Sorry, I mis-spoke. :( You are correct, prefilters work fine, it is just the calc element. I had run across this a while back and made a note to bring it up and am just now getting to it. At the time, I was having other problems with the pre-filter.

So here is my setup.

I have a radiobutton element called "active" with options/values 1 and 0. It's edit and viewing access is set to "Admin".

My calc element contains the following:

if('{mps_players___active}' == 0) return "Inactive";

The code returns "Inactive" no matter what value "active" contains. However, if I change the viewing access of "active" to "Public", then the code provides the correct answer.
 
Does this happen regardless of the access level of the person viewing the list, or only for people who don't have view access on the calc element?

-- hugh
 
It only happens if the person viewing the list does not have view access to the element used in the calculation.

I will explain further.

List: View Access = Public
Radiobutton Element: View & Edit Access = Admin
Calc Element: View & Edit Access = Public

My Calc element uses the value of the Radiobutton element in its calculation. For Admin users the calc works fine as they have viewing access to the Radiobutton element. However, if the user does not have viewing access to the Radiobutton element, then it's value is not available to the calculation so the calculation fails.
 
Here you go Rob. My radiobutton element is "mps_players___active" so the first line is the key here.
Code:
if('{mps_players___active}' == 0) return "Inactive";
$db =&JFactory::getDBO();
$db->setQuery("SELECT COUNT(*) FROM `mps_votes` WHERE `player` = '{mps_players___id}' AND `status` = 'OK'");
$num = $db->loadResult();
if($num == 0)
return "0";
$url = JURI::base();
$url .= "index.php?option=com_fabrik&view=list&listid=16&resetfilters=1&mps_votes___player_raw={mps_players___id}";
return '<a href="'.$url.'" title="View Votes">('.$num.') View</a>';

Attached is a screenshot of my radiobutton element settings. As a workaround, I have the viewing access set to Public but I want to set the viewing ACL to be the same as editing.
 

Attachments

  • Radiobutton.jpg
    Radiobutton.jpg
    93.4 KB · Views: 201
ok looks like the encrypted values were not being sent with the ajax call and where not being added to the data that is used for the placeholder replacements.
Try updating from github I believe this is now fixed
 
Sorry for the delay Rob, I was away on vacation. I just updated from Github and found the issue remains. :(

BTW, I tried adding "_raw" to my placeholder but that had no effect.
 
did you clear your browser cache - just to make sure that the new js files are being loaded?
 
did you clear your browser cache - just to make sure that the new js files are being loaded?
Yes, both the browser and site cache were cleared after the update. I tried re-uploading Github from today and also tried it on different browsers.
 
Can you try using {mps_players___active_raw} rather than {mps_players___active}?

I'm pretty sure as part of the calc processing, we replace values with labels on the non-raw placeholders. So {mps_players___active} would be "Yes", and {mps_players___active_raw} would be "1".

I just ran some tests with a similar setup, with a radio button with write access set higher than the logged on user, and a similar calc to your that tests with _raw against the value (as opposed to the label) it all seems to work.

Note that I did just commit a couple of little changes to the calc code, to do with cleaning up the "watched" elements for the AJAX calc, but nothing which should affect what you are doing.

-- hugh
 
Can you try using {mps_players___active_raw} rather than {mps_players___active}?
Yes, I tried this earlier and again now without success.

Hmm, there must be some other setting that is different between our setups. Attached are my element settings. I just changed my calc code for troubleshooting. Note I am only displaying my calc element on the fly in the list view.
 

Attachments

  • calc.png
    calc.png
    35.8 KB · Views: 186
  • radiobutton.png
    radiobutton.png
    40.7 KB · Views: 194
What is the Access on the elements?

My Editable Access is "Registered" on the calc, and "Special" on the radio. View Access is set to Registered for both.

-- hugh
 
Ooops, just realized in your OP you specifically told me viewable was set higher than the user ... testing that now.

-- hugh
 
OK, yeah, I see the problem, but it's not a trivial one to solve.

For now, if you want to use elements in your calc which have neither view or edit access, you'll have to set your calc to "Only Calc on Save", so we use the saved value for the list display.

As things stand, elements with neither view nor edit access for the current user simply don't get included in the main data query for the list. And I'm loathe to start messing with that code right now.

-- hugh
 
OK, thanks for checking Hugh. :) That answer is fine with me.

My workaround is just to keep the element visible but not editable which is not a showstopper by any means. I just brought it up as it seemed odd and it was a nice to have.

I will close this thread. Others may stumble into it if it is an issue for them.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top