Hi,
I'm using Notifications http://drupal.org/project/notifications on my site to alert members of Organic Groups when nodes are posted or changed.
This is working fine, but I have some custom content types, for example "milestone" and "todo" which I would like to create my own events for. These content types use a CCK "user reference" field to identify the person responsible for a task, and I'd like to setup an event to notify users when they are assigned.
Having read through http://drupal.org/node/253102 and http://drupal.org/node/293299 several times, I'm still at a loss, and wondered if anyone could help?
As far as I can tell, I just need to implement hook_notifications(), and call notifications_event() at the appropriate time, however I'm getting an error:
warning: array_merge() [function.array-merge]: Argument #1 is not an array in .../sites/all/modules/notifications/notifications.module on line 408.
The code i have is as follows:
function kairn_notifications($op, &$arg0 = NULL, $arg1 = NULL, $arg2 = NULL) {
if ($op = 'event types') {
$types[] = array(
'type' => 'node',
'action' => 'reassigned',
'name' => t('[type-name]: [title]'),
'line' => t('The [type-name] has been reassigned'),
'digest' => array('node', 'nid'),
'description' => t('Node reassigned'),
);
return $types;
}
}
and the following is called from my drupal action (which works fine in itself):
function kairn_mail_action(&$object, $context = array()) {
$event = array(
'module' => 'kairn',
'uid' => $object->uid,
'oid' => $object->nid,
'type' => 'assignment',
'action' => 'reassigned',
'node' => $object,
'params' => array('nid' => $object->nid),
);
notifications_event($event);
}
Apologies if I'm missing something completely obvious. I've looked in the notifications_content.module and can't work out what I'm doing wrong.
Thanks in advance,
Pete
Comments
anyone?
I've still had no luck with this. Is there anyone familiar with the notifications framework who could help?
'twould be much appreciated :)
Thanks,
Peter
I came across you post (while
I came across you post (while look for notifications info as well), and noticed a small error in your code...
...I think you meant to use
==instead of=. It may be the completely obvious something that your looking for.Willing to share your code?
Hey Pete,
Did you get this working? If so, any chance you'd be willing to share your code? I for one would be quite interested in some kind of integration between Notifications and CCK User Reference fields :)
Jeff
_________
http://marmaladesoul.com
That's probably it!
Hey pathfinder, that's probably it!
I actually ended up using the Messaging Framework directly to send my messages, because when I thought about it, nobody needed to subscribe to the particular event as such. A message only needed to go to the assignee of a task (basically, "someone has assigned a task to you").
I was a bit confused as to how the Messaging Framework and Notifications actually tied together when I posted this, but the documentation was updated afterwards and made things a lot clearer!
Jeff, as I haven't implemented Notifications as such, I'm not sure if my code does exactly what you're after, but I do act upon changes to a CCK User Reference field and send a message to the user that's selected.
That's was just a case of implementing
hook_nodeapifor the "update" operation and checking the node object to see if the field has been changed.Here are some code snippets:
actually, just realised, that
actually,
just realised, that example doesn't use a CCK field, but that'd just be a case of checking
$node->field_<yourfieldname>[0][uid]instead of$node->assignee.Cheers,
Pete
Wonderful!
Wonderful! Thank you very much for sharing :) I will definitely give this a go.
Jeff
_________
http://marmaladesoul.com