Don't use anonymous function in MessageModel

The $this variable wasn't allowed in anonymous functions until 5.4;
Mitigate this by using a $context variable and passing it into the scope.

I looked and it seemed like this was the only occurence of the problem throughout the codebase.

Fixes #2143 from what I can see.

@myevit can you verify this fixes your issue?

Edit: Removed the anonymous function from MessageModel altogether to get 5.2 compatibility