General developer forum

why does core webservice get_users_by_field limitation on search?

 
Picture of tim st.clair
why does core webservice get_users_by_field limitation on search?
Group Plugin developers

The web service core_user_get_users_by_field allows me to find a user on the following fields: id, idnumber, username, email. The alternate service, 'core_user_get_users' allows id, auth, firstname, lastname, email, username, idnumber. Pretty similar but obviously distinct in purpose. My point is, why is a service named core_user_get_users_by_field limited to specific fields. Why can't I, for instance, look up all users in an Institution or Department or City or Last Ip address, or any of the other useful user lookups I'd want over a web service call. I mean, I can create my own copy of the function and add the fields to the list but it seems like, with a name including "_by_field" that you'd be able to specify that field out of any in the table. Was this a conscious thing to limit the field list?

 
Average of ratings: -
Picture of Darko Miletić
Re: why does core webservice get_users_by_field limitation on search?
Group Core developersGroup Particularly helpful Moodlers

Looking at the code it is 100% conscious decision. Why? You would have to ask the implementer. Most likely security reasons.


If you have different needs just make your copy of the thing.

 
Average of ratings: -
Picture of Juho Jaakkola
Re: why does core webservice get_users_by_field limitation on search?
Group Particularly helpful MoodlersGroup Plugin developers

I'm having similar problems. My use cases are:

  • Get only the users whose profile data has changed since the last time I fetched them (the 'user' table has the 'timemodified' column, but the web services do not allow me to use it for filtering the results)
  • Get the timezone of each user (available only in some of the functions)

I already made initial patches to the latter: https://tracker.moodle.org/browse/MDL-60240

Hopefully shortcomings like this get fixed to the existing web service functions. It doesn't make sense that site owners need to reinvent the wheel for such minor differences in the requirements.

 
Average of ratings: -