Export to pdf only for specific table or user

Matthijs

Member
Hi, in my config file, I have set: $export_to_pdf_feature = 0;

My question: is it possible to show the pdf button only for a specific table or user?

thanks!

Your current DaDaBIK version​


You are using DaDaBIK version 11.10-Elba monthly, installed on 13-07-2023 (installation code: 18828644e443ac0e33), the latest version of DaDaBIK is 11.11-Elba released on 27-09-2023

You are not running the last release of DaDaBIK, the release you are running might have bugs and security holes, see the official change log for further information. You can upgrade DaDaBIK here.

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enterprise to Platinum) please contact us.


System info​


PHP Version: 8.1.22


mysql version: 10.6.14-MariaDB


Web server: Apache/2


Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0
 

deep64blue

DaDaBIK Guru
@Matthijs for a specific user you could try something like this in your config_custom.php:-

PHP:
if ('matthijs'==$current_user) {
    $export_to_pdf_feature = 1;
} else {
    $export_to_pdf_feature = 0;
}

If multiple people need access then set up a group and check for group membership instead.
 

eugenio

Administrator
Staff member
The logic is correct but $current_user is not set yet in config_custom.php so it wouldn't work.

I suggest to move that code to the startup function and to use $_SESSION['logged_user_infos_ar']['username_user'] instead of $current_user. You should also add:

PHP:
global $export_to_pdf_feature;

at the beginning of the startup function.

I haven't tested it but it should work.

Best,
 

Matthijs

Member
Hi Eugenio, I added this in custom_functions.php:

$custom_startup_function = 'dadabik_startup';
function dadabik_startup ()
{
global $show_logout_account_admin_box;

if ($_SESSION['logged_user_infos_ar']["username_user"] == 'Admin')
{
$show_logout_account_admin_box = 1;
} else {
$show_logout_account_admin_box = 0;
}
}

But then I get this error:
AH01071: Got error 'PHP message: PHP Warning: Undefined array key "logged_user_infos_ar" in /home/mslboot/domains/mslb.nl/public_html/dadabik/include/custom_functions.php on line 26PHP message: PHP Warning: Trying to access array offset on value of type null in /home/mslboot/domains/mslb.nl/public_html/dadabik/include/custom_functions.php on line 26'
 

eugenio

Administrator
Staff member
If you are not logged in yet, it's undefined.
PHP:
if (isset($_SESSION['logged_user_infos_ar']['username_user']) && $_SESSION['logged_user_infos_ar']["username_user"] == 'Admin')
 

eugenio

Administrator
Staff member
Hi Eugenio, also when logged in, it does not work ...
Please be more specific. Errors? Unexpected behaviours?
Also, you started the thread discussing $export_to_pdf_feature and now it seems you are working on $show_logout_account_admin_box.
 

Matthijs

Member
Hi sorry for the confusion. I tested again, both with $export_to_pdf_feature as well as $show_logout_account_admin_box;

For $export_to_pdf_feature it works fine.
For $show_logout_account_admin_box, the first time dadabik is displayed, the login box is not displayed. But if I select then one of the options in the left menu, the login box is there. For me that is OK. With these settings I can, as admin, edit the dadabik app without having to update config_custom.php everytime.

So for me, all ok!

This is the code I use in custom_functions.php:

$custom_startup_function = 'dadabik_startup';
function dadabik_startup ()
{
global $show_logout_account_admin_box;
global $export_to_pdf_feature;

if (isset($_SESSION['logged_user_infos_ar']['username_user']) && $_SESSION['logged_user_infos_ar']["username_user"] == 'Admin')
{
$show_logout_account_admin_box = 1;
$export_to_pdf_feature = 1;
} else {
$show_logout_account_admin_box = 0;
$export_to_pdf_feature = 0;
}
}
 
Top