With this very small patch, notifications_lite.module became useful for me, by adding a tiny bit more flexibilty.
The patch does the following:
* Add a new, optional argument $params to notification_lite_send(). If an array is passed in, it will be stored with the other $params of the created event (only, of course, if the full notifications system is used). It's fully optional and comes last, so no existing API usage breaks. I needed this to be able to pass in some more data to access later on when sending the message (for usage with tokens).
* Allow the body/main text to unset. I'm using notifications_lite with custom messaging templates (through the action argument), and if the body is not set, I want to be able to fall back to the default message for the body (main) part.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | notifications_lite2.patch | 2.63 KB | Frando |
| notifications_lite.patch | 2.42 KB | Frando |
Comments
Comment #1
smk-ka commentedRegarding the first part, the optional $params argument, a typical use case would be a module that needs to store additional context information along with the event. For example, the privatemsg module needs to store the origin (sender) of the private message, otherwise that information would be hard to retrieve later or even completely lost. The basic idea is to allow storing the sender uid in a custom keyed variable for later retrieval. The phpdoc of $param should better reflect this pupose, otherwise +1.
For the second part, allowing body text to fall back on a default value, I do not know enough about the inner workings of this module.
Comment #2
Frando commentedRegarding the second part, without the change it is not possible to specify a default value for the body part of the message in hook_messaging, as it won't ever get used because notifications_lite sets the body content to an empty string if not present (instead of leaving it unset and therefore having notifications.module use the template).
Attached patch only extends PHPDoc for the $params array, otherwise no changes.
Comment #3
Frando commentedComment #4
jose reyero commentedCommitted to 5.x and 6.x
Thanks