Thursday, April 26, 2012

Plugin side effects

I have been trying to figure out why the role permissions were not showing up for the past few days.  I installed a this moodle plugin, Custom_SQL_queries_report, earlier in the week.  I love the idea of it, provides a window, a select only window, into the moodle db.  This allows people with a little SQL, or myself, upon request, to add queries that are easily available to a role in moodle. After installing it in the \report root, I was able to see it in the Admin | Reports block. This moodle forum helped with a couple questions I had about where to unzip and install the plugin.  The problems started when I began to try to make the plugin available to another role on our system.

My first thought was to modify the db\access.php file

After all, this is the way moodle developers add permissions to roles and capabilities when developing plugins. After repeating this process way to many times, I asked for help in the moodle forum mentioned above.  Tim Hunt, the author said, "don't mess with that file, create or set  the permissions to allow via the front end.  The front end meaning via moodle administration block.

Admin | User | Permission | Define Role - then edit the role and update the permissions that were added to the moodle environment when installing the plugin.  The permission I was after, the one I was trying to add in the access.db file was report/customsql:view.

Where are the role permissions?

When I tried editing the manager role, or any role, the role details, permissions, were not appearing.  I posted in three different forum in moodle looking for any suggestions.  After a couple days and no takers, I started to look again and think about what was different in my environment in the past few days since adding the plugin.  I checked the theme, changed it to another theme, nothing.

Finally, I decided to try moving the newly installed report\customsql folder out of  moodle.   After moving the folder outside the moodle root and clicking on the Notifications link and again checking the role details, they appeared, all the system wide permissions appeared - we just see the one below because I filtered for it. I edited the manager role, scrolled down the list until I saw the report/customsql:view rule and updated the Allow bit.

Something in the plugin is causing the role permissions to not display.

I put the block back into the moodle root and clicked notifications, but the plugin screen did not appear.  I had to increment the version.php file, as always, to trip the plugins screen to display.  I reinstalled the plugin and logged in as one of the users defined in the manager role, checked the Admin menu and this is what I saw, Ad-hoc database queries - yeah!

Moral of the story?

Be wary of unintentional side effects of installing plugins.

I will also look at the CSS and let Tim Hunt know what happened here, since I still can't edit role permissions with this plugin in place.  If I need to edit a permission of a role again, I will have to move the plugin outside moodle again.

No comments:

Post a Comment