Is there a way for Forena to restrict the debugging messages to selected roles? The Forena data source has the option of displaying the generated queries on the screen via the Debug option.

The problem here is that the messages are displayed for all users or reports while this debug option is enabled, which is undesirable as it means a developer cannot be designing new queries during normal working hours.

Is there a way to restrict the debug messages to select roles only?
1. About the debug option

The debug option for a Forena data source is one of the options you enter when defining a data source. If enabled (value = TRUE), it'll actually trigger logic as shown in this logic:

  public static function debug($short_message='', $log='') {
    if ($log) {
      watchdog('forena debug', $log, NULL);
    }
    if ($short_message) {
      drupal_set_message(check_markup($short_message));
    }
  }


2. Restrict debugging messages to selected roles.

Defining the options for a data source (such as the debug option) can be done as described in the tutorial that comes with Forena (i.e. within the Data Sources Settings):


Defined using Forena's configuration data tab (within the admin UI).
Defined within settings.php files which allows for including PHP logic.
Defined by a module using a forena_alter_repos hook.


So the actual answer to your question depends on how you define the data source, as further detailed below.

a) Using Forena's configuration data tab (within the admin UI).

Using this option there is no way to answer your question, except if you would want to hack the logic shown above (which I do not recommend).

However by using the Disable Messages module you should be able to  restrict the debug messages to select roles only (though it'd still write the watchdog messages). Refer to "Option 1" in my answer to "How to show messages starting with &quot;Debug : &quot; to an administrator only?" for more details on that (not sure if "Option 2" of that answer would make sense in this case also).

b) Using a settings.php file

Include the desired PHP logic to assign a value (TRUE or FALSE) to $conf['debug']. Have a look at the repos/sample/settings.php file that comes with Forena for an example to start from.

c) Using a custom module

Using hook forena_alter_repos (documented within Available Hooks in the Development Guide).

3. Alternative solution

From your question, it seems that your developer is designing new queries (during normal business hours) in your production environment ... There must be good reasons to do (allow) that.

However, as an alternative, you could also define an additional data source that points to the same database, and for which you enable the debug option. If you combine this with "Access [data source] Data" (as described in Forena's Permissions) you could easily limit access to this data source to developers only. And after the data blocks (SQL queries) that they created are finish (approved), just MOVE the file containing that SQL query to the regular data source.

Disclosure: I'm a co-maintainer of Forena.