Page 1 of 1
Object Access Condition causes Internal Server Error. [500]
Posted: Sun Jan 14, 2024 5:23 am
by IzzyBok
Hi,
I'm trying to use new feature: Object Access Management with SQL Queries
viewtopic.php?p=29173&hilit=Object+Acce ... ion#p29173
object_properties.png
but this causes an Internal Server Error. [500]
error_500.png
Аny ideas on this?
Thank you in advance for the answer
Re: Object Access Condition causes Internal Server Error. [500]
Posted: Mon Jan 15, 2024 6:23 am
by IzzyBok
Hi,
This is my server log
[Mon Jan 15 15:04:52.399706 2024] [php:error] [pid 644] [client 31.200.229.186:51758] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function nuRunQueryString(), 1 passed in /var/www/html/DevDB/core/nuform.php on line 631 and exactly 2 expected in /var/www/html/DevDB/core/nudatabase.php:181\nStack trace:\n#0 /var/www/html/DevDB/core/nuform.php(631): nuRunQueryString()\n#1 /var/www/html/DevDB/core/nuform.php(611): nuGetObjectAccess()\n#2 /var/www/html/DevDB/core/nuform.php(185): nuDefaultObject()\n#3 /var/www/html/DevDB/core/nuapi.php(92): nuGetFormObject()\n#4 {main}\n thrown in /var/www/html/DevDB/core/nudatabase.php on line 181, referer:
http://1xx.x.xx.x/DevDB/index.php
My version info
Database: Ubuntu 20.04 10.3.38-MariaDB-0ubuntu0.20.04.1
PHP: 8.2.2
nuBuilder DB: V.4.5-2023.10.05.01
nuBuilder Files: V.4.5-2023.10.05.01
Thank you for any help
Re: Object Access Condition causes Internal Server Error. [500]
Posted: Tue Jan 23, 2024 5:47 pm
by kev1n
Replace the function nuGetObjectAccess() in nuform.php with this one:
Code: Select all
function nuGetObjectAccess($access, $condition) {
if ($access == 9 && !empty(trim($condition))) {
$sql = nuReplaceHashVariables($condition);
$stmt = nuRunQueryString($sql, $condition);
if (db_num_rows($stmt) == 1) {
$value = db_fetch_row($stmt)[0];
return $value;
} else {
return 0; // read/visible
}
} else {
return $access;
}
}
Re: Object Access Condition causes Internal Server Error. [500]
Posted: Fri Jan 26, 2024 10:51 am
by IzzyBok
Thanks a lot Kev1n!
Everything works fine, but if the object access condition refers to the display object, the condition is not fulfilled immediately after opening the form.
Then the page needs to be refreshed again in order for the condition to be fulfilled.
I want to hide Subform object depending on the value of the Display object on the same form.
I use the following condition in the subform object properties
SELECT IF('#sta_form_display#' = '1', 2, 0)
where 'sta_form_display' is the display object with following SQL
SELECT sta_form FROM status_contragent
WHERE status_contragent_id = '#con_status_id#'
Before I used the following JS code to hide subform object
if (nuGetValue('sta_form_display') == '1') {
nuHide('contragent_sf');
}
and no additional page refresh was required
Re: Object Access Condition causes Internal Server Error. [500]
Posted: Fri Jan 26, 2024 11:09 am
by kev1n
It could be that the display object comes later in the tab order and the value is only available after the subform has been "loaded". Theoretically, you could also enter the SQL of the display object in the condition field.
Re: Object Access Condition causes Internal Server Error. [500]
Posted: Sat Jan 27, 2024 2:32 am
by IzzyBok
Hi Kev1n, thank you so much for your reply.
I changed objects in the tab order with no result.
I entered the SQL of the display object in the condition field and problem was solved.
Thanks once more.