We continue our series of interesting support questions to help you customize your EvolutivoFW application.

Block Users from being changed

Could we create a Global Variable to block non-admin users from creating/updating other admin users? Because now we can allow non-admin users to manage other users, and if a user changes or creates an admin user, that user will have all administration privileges.

First, the application has had for many years now, checks in place to avoid non-admin users from changing the administration privilege of their user (and other users). These checks are still in place and valid now that non-administration users can manage users. This means that if a non-admin user tries to create an admin user or change the admin status of an existing user, the application will not let him. Only admin users can create/modify other admin users.

Besides that, in modules/Settings/configod.php, there is a variable

$cbodBlockedUsers = array();

If you put user names in that array, those users will be blocked from modification except for themselves and other admin users.

$cbodBlockedUsers = array('admin', 'login_user_name');

I suppose we put them in the code because a Global Variable can be modified by "anyone", and, in this case, you really don't want that to happen

GenDoc generation from the command line

I am having some problems generating a template. This particular template seems to be doing something wrong and producing invalid ODT output. I was thinking that I could try to generate it from the command line to see if I can catch some errors.

The correct way to debug a GenDoc template is to use the GenDoc direct generation page. If you open the extension URL, you will be greeted with the debug page. Just like with any other module or extension, you can navigate to index.php?module=evvtgendoc&action=index. Instead of a module list view, you will be presented with the GenDoc debug page. Here you will be able to select a record, a template, and a language to compile the template. Optionally, you can indicate if you want to see the debug output.

Once you launch the process, you will see a full trace of the work that GenDoc is doing to convert the template into a finished/merged ODT file. If there are any PHP warnings or errors, they will also appear on this page, thus making a command-line execution unnecessary.

GenDoc Debug

All that said, the answer to the question is: yes, we have a way of generating ODT files from the command line. In the build/HelperScripts directory, you will find the script dogendoc.php which can be called like this from the root of your installation.

php build/HelperScripts/dogendoc.php "recordval=74&gendoctemplate=50200&compilelang=es"

The script will execute the merge of the given template ID with the given record ID and return the file location.

GenDoc template error fix

The previous support question was a real issue in a migrated installation.

We migrated the application to another server, and the templates stopped working. The initial assumption was an error in some library that the GenDoc process uses because it was working in the original server. After some considerable debugging, we noticed that the merged template had an extra few characters at the start of the file. This made it impossible for Libre/OpenOffice to open the final document.

With some help from generative AI, we added a new (bash) script to our arsenal (build/HelperScripts), which lists all PHP files that have either an initial BOM character or some trailing whitespace.

build/HelperScripts/verifica_bom_linha_final_preciso.sh

Once we found the offending files and cleaned them, the templates started working correctly :-)

HTH!

Previous Post