2

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

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 "Debug : " 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.

| improve this answer | |
  • I already tried the 3rd solution but it failed to work. I copied and pasted the exact details from the working version into the new one for debugging and for some reason it fails to connect. If I check it again and it doesn't work I will submit a bug for it. I will try the same method with a new database user and see it that will work. In he meantime I will try the Disable Messages module. Thanks – vfclists Jun 27 '16 at 22:34
  • Using a copy of the existing data source worked. I forgot to enter the password to the copy. – vfclists Jun 28 '16 at 5:24
  • With Disable Messages I tried SQL* as the text to check for but that doesn't seem to work, so for now I am disabling the permission to see status messages for the relevant roles. – vfclists Jun 28 '16 at 5:26
  • @vfclists Merci for the update, and the accept! Personally I'd go for the alternative solution (with an extra data source), though I plan to do some more checking about using Disable Messages for that "SQL*". – Pierre.Vriens Jun 28 '16 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.