Hi,
I'm trying to use new feature: Object Access Management with SQL Queries
viewtopic.php?p=29173&hilit=Object+Acce ... ion#p29173
but this causes an Internal Server Error. [500]
Аny ideas on this?
Thank you in advance for the answer
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Object Access Condition causes Internal Server Error. [500] Topic is solved
Object Access Condition causes Internal Server Error. [500]
You do not have the required permissions to view the files attached to this post.
Re: Object Access Condition causes Internal Server Error. [500]
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
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
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Object Access Condition causes Internal Server Error. [500]
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]
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
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
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Object Access Condition causes Internal Server Error. [500]
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]
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.
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.