core_users_get_users_by_username

core_users_get_users_by_username

by john saylor -
Number of replies: 9

hi

i was just wondering why this doesn't exist within the core_ webservices. i've read some posts about writing something like this in the forum, but nothing more than that.

i guess i'm going to join those people in writing my own [extensively cribbed from core_users_get_users_by_id].

i keep feeling like i'm missing something obvious, but since i'm missing it, i don't know what it is!

Average of ratings: -
In reply to john saylor

Re: core_users_get_users_by_username

by Jérôme Mouneyrac -
Hi John,
it doesn't exist because nobody wrote this function. We were working on a solution but nobody is working on it yet: http://tracker.moodle.org/browse/MDL-29938. Note that I understand your question, me too sometimes I'm using other provider APIs.

As often similar remarks come back on the forum, I'd like to add my personal opinion in the hope to clarify some points about writing web services and the hope for a better API future:

a) often easy web services take more time that we would think. I wrote a document to help people to contribute a function to core: http://docs.moodle.org/dev/How_to_contribute_a_web_service_function_to_corehttp://docs.moodle.org/dev/How_to_contribute_a_web_service_function_to_core

b) often other apps don't need the web service we request as client. For example the iOS Moodle app doesn't need the core_users_get_users_by_username().

c) writing a third party web service function is a good and fast alternative. But at the end the question is "why developers don't contribute the function back to core ?". I think the answer often comes to:
- not sure it's secured
- not sure it's compatible with all supported dbs/browsers/webservers/PHP version/etc.
- not sure it's respecting the moodle code logic
- don't have time to make it to the Moodle standards

Don't get me wrong, as I mentioned writing third party web services are a good alternative because you are not required to be:
- compatible others than your moodle install
- 100% respecting Moodle code logic (even thought you should take care to not be too far from it, otherwise you are going to give some wrong powers to the user)
- respecting the Moodle code style
- implementing PHPunit tests
- probable other stuffs that don't come to my mind
The basic requirement for your third party web services will be to respect the permission code logic: http://docs.moodle.org/dev/How_to_contribute_a_web_service_function_to_core#Capabilities_and_context_checks

Finally at HQ we are planning to have a week or two reserved for web services and hopefully increasing the Moodle core API. With the development of the HTML5 Moodle app being active, I'm sure more functions will be integrated to core. For the last word, most (if not all) the contributions to the core web services came from not HQ devs in the last major Moodle version smile

Cheers,
Jerome
In reply to Jérôme Mouneyrac

Re: core_users_get_users_by_username

by Jason Robinson -

Hi,

Anyone know if there is a wish list of missing web services somewhere? It would be nice to see what is missing and maybe try to help.


Thanks!

In reply to Jason Robinson

Re: core_users_get_users_by_username

by Paul Charsley -

Hi Jason,

The Lightwork project is building a lot of web services for integration into Moodle. We would welcome developer assistance.

See MDL-31409 and docs.moodle.org/dev/Lightwork

Paul

In reply to Jason Robinson

Re: core_users_get_users_by_username

by Jérôme Mouneyrac -
Hi Jason,
see MDL-29934

Marked as being related is the wish list. Everytime I see a new issue suggesting a new function I add it there.

Otherwise the sub tasks are the functions that we need and are going to implement.

Cheers,
Jerome
In reply to Jérôme Mouneyrac

Re: core_users_get_users_by_username

by john saylor -

hey


thx for your thoughtful reply. i think my management is fine with having me submit the service [if i can get it to work]. so i'll take a look at those tickets, and you mention and try to give it back to the community.

really, my plan is to modify get_users_by_id as little as possible, so hopefully this will make it easier to integrate into the core.

i understand that open source projects do have any programmers on the payroll [what payroll?], so apparently simple things do not get done. i did not mean to insult or degrade you or anyone who has put effort into moodle. sorry if i sounded that way.

In reply to john saylor

Re: core_users_get_users_by_username

by Jérôme Mouneyrac -
Thanks John, we appreciate all web service contribution (follow the doc: http://docs.moodle.org/dev/How_to_contribute_a_web_service_function_to_core).

MDL-29938 is the issue you want to be resolved. Once is done get_users_by_id() is more likely going to be deprecated and get_users_by_username() rejected (MDL-28606). We try to avoid to duplicate code (so avoid maintenance nightmare). Vote for MDL-29938, ping it, it generally makes an issue move faster (not all the time but often).

Cheers,
Jerome
In reply to Jérôme Mouneyrac

Re: core_users_get_users_by_username

by john saylor -

sorry, but you seem to be saying two different things here. maybe there's something i'm not understanding

- i can contribute my webservice to core

- supporting MDL-29938 [which negates the need for the new webservice code i'd be submitting]

how long do you think it may be before MDL-29938 will be released? [maybe you are not clairvoyant ...]

In reply to john saylor

Re: core_users_get_users_by_username

by Jérôme Mouneyrac -
Hi John,
- core_user_get_users_by_username is not going to implemented because it would be good to avoid to have several get_users_by_field functions. I personally would prefer to have one get_users($field). Maintainance should be much better this way.
- sorry to not have alerted you in my first answer that there is no need to contribute core_user_get_users_by_username. I remembered about it when I searched in the tracker for the function name (MDL-28606).
- I don't know when MDL-29938 will be released. I'd like it in 2.4 but I can't promise anything.