Hi
We have recently enabled messaging to the site and to avoid abuse we have implemented the code tweak here Messaging: Method to restrict student messages to teachers only so messages are only sent to or from teachers. The students can not send messages to each other.
This code has worked great in normal browser sessions but obviously does not work in the mobile app. The app allows anybody to anybody messaging. After looking through code i think the file in <moodle>\message\externallib.php handles the code and i have tried putting in an if statment around line 130
if(!user_has_role_assignment($tousers[$message['touserid']],3)) {
$success = false;
$errormessage = "invalid message recipient";
}
At the moment I just have a text string for the error rather than loading from the language file as I am not sure if i am looking in the correct place. I dont expect anyone to do the work for me but i was wondering if anyone knew if i am on the right track or if I am wasting my time.
In the past when adjusting code, i have always done temporary print statments to the browser to make sure variables are what I am expecting etc but I am assuming i can't do with this the mobile app - is there any equivalent i could use as I feel i am coding in the dark with this?
Hope this makes sense
Ian