Pointers required fairly urgently - wanting to hook into core messaging system

Pointers required fairly urgently - wanting to hook into core messaging system

by Just H -
Number of replies: 5
Hi folks

We're on a bit of a tight deadline with a project and was hoping someone could point us in the right direction.

Background

We're about to run a major table top exercise with multiple geographical locations involved. This exercise will involve "moving" hundreds of resources between these geographical locations in "real time".

We are going to use the database module to track these resources.

The majority of resources will be moved from either of two locations to any one of four locations. A person will be logged in at these six locations for the duration of the exercise.

The operators at the two initial locations will upgrade the database entry with the location the resource is en route to and the estimated time of arrival of the resource at the new location. He or she will then hit a button on the database update (edit) screen to email the specific location the resource is heading to.

The operator at the location the resource is headed to, on receipt of this email, needs to then collect relevant data on this resource from the database module, transfer to a fridge magnet and put this magnet on a board at the location at the time the resource would arrive if moving for real.

At times, due to "traffic congestion" etc. that the exercise control people will through into the mix, some of these resources will have to be rerouted and therefore, the initial location needs to be notified the resource is no longer headed their way and the new location will need to be notified the resource is headed their way.

Due to the amount of resources, all such notifications (en route and rerouted) need to be acknowledged by the operator at the relevant location to ensure nothing slips through the cracks and if it does, track where the systems fails (as in the system the exercise is designed to test, not computer system).

Again, due to the amount of resources, the operators at the four destination locations are going to be under pressure and won't have time to sit there hitting "refresh" in their browsers to see if they have another one heading their way, which is why we decided to email them.

What we've done so far

We've added a button to email the notification from the database module.

This is sent to a given email address based on a field in the database (i.e. an "en route to" field). The email includes a link to the relevant database entry which is tracked in the background when the operator clicks it.

Once the initial notification email has been sent, this button changes to a "reroute" button which if hit then sends two emails (one to the original notifying resource is no longer on it's way there and another to the new destination location telling the operator the resource is en route)

Issues

We have no control over firewalls and available email accounts at the destination locations therefore, tried setting up email accounts for the various locations with the intention of using Thunderbird portable as the email client at the locations (as it has a new email notification similar to Outlook) - gets blocked by firewall at our location, likely to at others.

Tested it using Yahoo email accounts - not much point as there is no automatic new email notification so might as well hit refresh in the browser on the database screen.

When the operator at the receiving location clicks the link in the email to acknowledge receipt, it opens another window containing the relevant database entry (could end up with 200-300 screens opening!).

**** Help required (point of this post) ****

Probably due to not having the message block showing in the course we are running this exercise from, we seem to have overlooked the obvious - the inbuilt messaging system!

Hooking into the inbuilt messaging system would be the ideal solution.

What we're thinking now is the "notification email" button that we've already added to the database module should in fact send an internal message to the relevant operator rather than an email to an external email address. This would then give us the popup box at the destination location ensuring the operator gets a notification message we can track.

So what we'd like is:
  • hit the "notification button" on the database entry edit screen
  • a template message (either resource en route or the rerouted emails as mentioned above) is then sent to the relevant operator (i.e. "student")
  • message pops up at relevant location

We are just about to start looking at the messaging code to see if we can achieve this. We are not Moodle developers and not experts in PHP/MySQL either.

So the question is, is there anything in particular we should be looking at (existing functions, classes, libraries etc.) within the existing message/Moodle code that we can hook into?

-------

Sorry about the long post but I thought some background knowledge would help you help us smile

Any pointers and insights into the code that would help us achieve our aims would be much appreciated.

Regards
Harry




Average of ratings: -
In reply to Just H

Re: Pointers required fairly urgently - wanting to hook into core messaging system

by Matt Campbell -
Looks like Petr Skoda has done the most recent work with Messaging, so he may be your best bet on this.

I've done some mangling with the code for the Message Access Restriction hack, and you might want to look at /message/lib.php, in function message_post_message. Looks like you may be able to use that and have it do most of the work for you.

Then, if you look at /message/send.php, just after message_post_message is called, you'll see where the message is formatted and sent, via either the messaging system or by email (as set by the user). You may actually be able to take most of /message/send.php and use most of it for this part of what you want to do.

Hope this helps,
Matt
In reply to Matt Campbell

Re: Pointers required fairly urgently - wanting to hook into core messaging system

by Just H -
Hi Matt

Thanks for the reply, much appreciated, we'll have a look Monday and see what we can come up with.

Regards
H
In reply to Matt Campbell

Re: Pointers required fairly urgently - wanting to hook into core messaging system

by Just H -
Thanks again for the pointer Matt, based on the info you supplied my colleague knocked something up and it worked a treat for a demo we did yesterday big grin just a shame overnight the automatic popup stopped "popping up" sad

Gotta love these "little challenges"!

Regards
H
In reply to Just H

Re: Pointers required fairly urgently - wanting to hook into core messaging system

by Matt Campbell -
Glad I was able to point you in the right direction...and tell your colleague to quit installing every popup blocker he finds! smile

Thanks,
Matt
In reply to Matt Campbell

Re: Pointers required fairly urgently - wanting to hook into core messaging system

by Just H -
If only it was that simple ... although I must admit it wasn't the first thing we checked smile

Ever get one of those "simple" projects that blow up into an epic. Started as a simple database for one mob now we're looking at various groups, groupings (that don't seem to be working either), info to be shown/hidden depending on the user, messaging hacks, role overrides, external pages pulling overview data out of a couple of databases, "press" releases for some of the players . . . and surprise surprise, deadlines are not negotiable (two working days and counting down)! On the plus side, having to get our heads around some functionality we haven't played with to date so all good.

This install of Moodle is not really an educational install, using more as a collaborative portal for various emergency services agencies therefore, all up it's fun, but not something we can afford to fail with. With hindsight we shouldn't have done the first part so well or quickly for them . . . might have kept the project creep out of the equation smile

H