Calc element in list view is "0"

varst

Member
Hello!

I have a Calc element and in list view the result is seen only by administrators. All other users see in the table zero. By the way access to this element is set as - Public.

Can anybody help me?
 
Maybe an element used in your calculation is not accessible?
Is accessible!

and calc elemets code is:
$db =& JFactory::getDBO();
$query = "SELECT COUNT(*) FROM `Table2` WHERE `Name` = '{Table1___id}' AND `Staatus` != 'Canceled' ";
$db->setQuery($query);
return $db->loadResult();
 
table1 is accessible for public? view list, view record, id element itself?

BTW:"& JFactory" is deprecated
 
You can install the jDump extension to debug what '{Table1___id}' is returning for admin and for public.
 
Perhaps this is a slight confusion.

As I understand it you want the actual calc value only to be visible to administrators - and you are suggesting that for non-administrators you display zero.

So it seems to me that you have two choices:

1. Make the calc element visible in the list (and forms) only to administrators using Access Levels. If you still want to display zero to other users, maybe have another calc element containing zero which is only shown to non-administrators; or

2. Add code to the calc php to check the user's admin rights and return zero if they are not administrators, and run the SQL only if they are administrators.

If it were me, I would do 1. and simply not show the calc element unless they are administrators.
 
Perhaps this is a slight confusion.

As I understand it you want the actual calc value only to be visible to administrators - and you are suggesting that for non-administrators you display zero.

So it seems to me that you have two choices:

1. Make the calc element visible in the list (and forms) only to administrators using Access Levels. If you still want to display zero to other users, maybe have another calc element containing zero which is only shown to non-administrators; or

2. Add code to the calc php to check the user's admin rights and return zero if they are not administrators, and run the SQL only if they are administrators.

If it were me, I would do 1. and simply not show the calc element unless they are administrators.

Thank you for response,

I need that all users can see the result in the list view. But now its seen only by administrators in the list view and in the record view results is seen by ALL users.
 
I am definitely confused now. AFAIK there is no reason why non-administrators would get a different result from the calc - the php code runs on the server in the same security context regardless of the Joomla View Access Levels. I could understand that non-administrators might not see the calc element at all if you had set Access / List View to something other than Public, but I cannot understand how they would see a different value.

What is the value of "Only Calc on Save"?

For this type of SQL query "Only Calc on Save" will need to be set to No to run the SQL every time you display the List - and you will need to be careful about performance because it will run that SQL individually for every row in the List that is displayed which could take some time.

(I have previously written about how to resolve these performance issues by setting Only Calc on Save = Yes and using a List PHP Event plugin and running a single Update SQL statement to update the entire table before you display the list instead of running one SQL per row.)
 
I am definitely confused now. AFAIK there is no reason why non-administrators would get a different result from the calc - the php code runs on the server in the same security context regardless of the Joomla View Access Levels. I could understand that non-administrators might not see the calc element at all if you had set Access / List View to something other than Public, but I cannot understand how they would see a different value.

What is the value of "Only Calc on Save"?

For this type of SQL query "Only Calc on Save" will need to be set to No to run the SQL every time you display the List - and you will need to be careful about performance because it will run that SQL individually for every row in the List that is displayed which could take some time.

(I have previously written about how to resolve these performance issues by setting Only Calc on Save = Yes and using a List PHP Event plugin and running a single Update SQL statement to update the entire table before you display the list instead of running one SQL per row.)

Value of "Only Calc on Save" was "No" and "Ajax calculation" - "Yes".
If I change "Only Calc on Save" to "Yes" then all users can see the values stored in the database.
 
Yes - it could be an access setting preventing the table1___id value being populated, but you also you need to make sure for table1___id that "List view settings" / "Include in list query" is set to Yes - without this, if the element is not shown in the list then the element will not be included in the Fabrik SQL statement that gets the list data and the placeholder will not be populated.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top