This class would belong more appropriately within the 'user' API
(core_user) instead of within the 'core' API, since it is
directly related to user data.
Since the class has only just been added to Moodle, now is a good
time to move it.
In all cases changes have been kept to a minimum while not making
the code completely horrible. For example, there are many instances
where it would probably be better to rewrite a query entirely, but
I have not done that (in order to reduce the risk of changes).
Added the ability for discussion IDs and from/to timestamps to be
passed in via URL (to match filters available in the summary report,
which will link to the export). Also fixed a bug where "all users"
would fail as an optional array param.