Restrict Messaging from Moodle Mobile

Restrict Messaging from Moodle Mobile

autor Ian Fogarty -
Počet odpovedí: 2

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

Priemer hodnotení : -
V odpovedi na Ian Fogarty

Re: Restrict Messaging from Moodle Mobile

autor Juan Leyva -
Obrázok: Core developers Obrázok: Moodle HQ Obrázok: Plugin developers Obrázok: Testers

Hello Ian,

yes, you need to edit the externallib.php file (because is the file exporting the Web Services that the mobile app uses).

If you want to see debugging in the app, you will have to setup a local environment to test the app in the browser, or debug the app via Chrome and monitor the XHR requests.

This is explained here: https://docs.moodle.org/dev/Moodle_Mobile_development_using_Chrome_or_Chromium (see screenshots)

Juan

V odpovedi na Ian Fogarty

Re: Restrict Messaging from Moodle Mobile

autor Madhu Avasarala -

Hello Ian,

Did your code hack work?

I am also interested in this feature. If you need help I will be happy to assist to the extent of my limited coding abilities. My email is madhu.avasarala@gmail.com