Version 2.19
Copyright 2012 - 2024 by Cas Nuy www.NUY.info
This plugin will enable you to define multiple queries/scripts, which can be:
- run interactively (by admin)
- scheduled, in which case results are emailed to nominated recipients
The plugin requires MantisBT version 2.0.0 or higher.
As any other plugin, place the Query directory in your plugins directory. After installing it within Mantis, click on the module to finalize the settings.
When using PHP 8.2 or later, ensure you are running at least version 2.26.
The distribution comes with 5 samples. Please use the sql found in doc\plugin_Query_samples.txt to load them using a tool like phpmyadmin.
In case the report requirements go beyond a straightforward SQL query, you can also insert a PHP script to the query engine. Your script should return the value that should be downloaded and contain no PHP tags.
A very simple script would look like:
$to_download = "Hello world";
$to_download .= "\r\n";
$to_download .= "Greetings, Cas";
return $to_download;
When adding the code to the system it will not try to trap any parsing errors so you should ensure that it does generate the required output. Finally there is the option to add a script which handles everything itself, so no emailing is done by the system.
It uses a direct mail function hence SMTP host needs to be set correctly in php.ini
Scheduling has 2 parts.
Within the plugin a set of jobs can be defined which should run as a type of batch job. For each job the following can be defined :
- Description
- Select query definition to be used
- Optionally add an additional filter for type S
- Define recipients (mantis usernames and/or normal email addresses separated by comma)
- Define frequency
There are 4 frequencies available:
- Every day
- Weekdays only (Monday till Friday)
- Weekly (Mondays)
- Monthly (First day of the month)
Finally one job needs to be scheduled on your server to run daily, shortly after midnight. This needs to be set up by your admin using either CRON or Windows Scheduled tasks. In order to run in batch mode, one needs to schedule the following job:
exec_schedule.php (https://example.com/mantisbt/plugins/Query/pages/exec_schedule.php)
Version 1.00 17-08-2012
Initial release
Version 1.01 22-08-2012
Bugfixes
Added option for users to execute query directly
- Only type Q can be run
Version 1.02 23-08-2012
Bugfixes
Added sensible samples of each type of query
Allow standard email addresses in combination with mantis usernames
Version 1.03
Bugfix Schedule
- frequency was not stored
Version 1.04
Bugfix release
Version 1.05
Allowed for additional parameters when using S(cript)
Version 1.06
Decent subject of emails
Version 1.07
Added option to define Query as User or Admin only
version 1.08
Fixed from email address, which is causing the email to be placed into the junk mailbox
Version 2.01
Mantis 2x compatible
Version 2.10 01-05-2022
Major bugfix release
Version 2.11 07-01-2024
Replaced print_successful_redirect
Version 2.13 09-05-2024
removed deprecated function
Version 2.14 14-05-2024
Lay-out corrections and added some help text
Version 2.15 14-05-2024
Bug fixes
Version 2.16 15-05-2024
Lay-out corrections and moved some help text
Moved Changelog to Readme
Made changes to lay-out (mantis standardization)
Version 2.17 15-05-2024
Removed User/Admin levels, handled via execution theshold)
Included check on query uniqueness after editing query
Version 2.18 15-05-2024
Fixed bug with non-valid query
Further beautifying
Version 2.19 16-05-2024
Added additional filter (again) for scheduled tasks
Reviewed & cleaned code
Ensured schedule name stays unique
Version 2.22 21-06-2024
Fixed 2 typos in the scripts
Adjusted soime statements cause of new php requirements