diff options
author | Cash Costello <cash.costello@gmail.com> | 2011-06-26 08:38:28 -0400 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2011-06-26 08:38:28 -0400 |
commit | f3240e1da73d4a89e379c0c34f8ce86f460e18dc (patch) | |
tree | 66fef49336480d2f2a1395417c099e20176a05e0 | |
parent | 32387e6db0c56935e93314217b52eab4d9dca016 (diff) | |
download | elgg-f3240e1da73d4a89e379c0c34f8ce86f460e18dc.tar.gz elgg-f3240e1da73d4a89e379c0c34f8ce86f460e18dc.tar.bz2 |
Fixes #3585 do not need to check parameters because was registered for only one event
-rw-r--r-- | engine/lib/relationships.php | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index 5224efaf1..9d5fd39b6 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -593,38 +593,31 @@ function export_relationship_plugin_hook($hook, $entity_type, $returnvalue, $par } /** - * An event listener which will notify users based on certain events. + * Notify user that someone has friended them * - * @param string $event Event name - * @param string $object_type Object type - * @param mixed $object Object + * @param string $event Event name + * @param string $type Object type + * @param mixed $object Object * * @return bool */ -function relationship_notification_hook($event, $object_type, $object) { - global $CONFIG; +function relationship_notification_hook($event, $type, $object) { - if ( - ($object instanceof ElggRelationship) && - ($event == 'create') && - ($object_type == 'friend') - ) { - $user_one = get_entity($object->guid_one); - $user_two = get_entity($object->guid_two); + $user_one = get_entity($object->guid_one); + $user_two = get_entity($object->guid_two); - // Notify target user - return notify_user($object->guid_two, $object->guid_one, + return notify_user($object->guid_two, + $object->guid_one, elgg_echo('friend:newfriend:subject', array($user_one->name)), elgg_echo("friend:newfriend:body", array($user_one->name, $user_one->getURL())) - ); - } + ); } -/** Register the import hook */ +// Register the import hook elgg_register_plugin_hook_handler("import", "all", "import_relationship_plugin_hook", 3); -/** Register the hook, ensuring entities are serialised first */ +// Register the hook, ensuring entities are serialised first elgg_register_plugin_hook_handler("export", "all", "export_relationship_plugin_hook", 3); -/** Register event to listen to some events **/ +// Register event to listen to some events elgg_register_event_handler('create', 'friend', 'relationship_notification_hook'); |