Code now working for other modules

The code is now working for modules other than the forum like exporting
chats, glossaries, etc. Code now according to the coding guidelines of
Moodle.