diff options
author | Sem <sembrestels@riseup.net> | 2011-12-09 17:58:03 +0100 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2011-12-09 17:58:03 +0100 |
commit | 0722c977bbd3a1bac5f6cb080022bca2ff5766cb (patch) | |
tree | 59acd4f6815a47b20fdfaf4130032627744cbafc /start.php | |
parent | 342ef1d2eac8914793a24ee1627eeaa8c57c9038 (diff) | |
download | elgg-0722c977bbd3a1bac5f6cb080022bca2ff5766cb.tar.gz elgg-0722c977bbd3a1bac5f6cb080022bca2ff5766cb.tar.bz2 |
Registered an event handler to notify users about friend requests.
Diffstat (limited to 'start.php')
-rw-r--r-- | start.php | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -38,7 +38,7 @@ function friendrequest_init() { //elgg_register_event_handler('create', 'friend', 'friendrequest_event_create_friend', 400); //Handle our add action event: - //elgg_register_event_handler('create', 'friendrequest', 'friendrequest_event_create_friendrequest'); + elgg_register_event_handler('create', 'friendrequest', 'friendrequest_event_create_friendrequest'); } @@ -111,7 +111,7 @@ function friendrequest_topbar_menu($hook, $entity_type, $returnvalue, $params) { return $returnvalue; } -function friendrequest_event_create_friend($event, $object_type, $object){ +function friendrequest_event_create_friend($event, $object_type, $object){var_dump($object);elgg_echo('hola'); if (($object instanceof ElggRelationship) && ($event == 'create') && ($object_type == 'friend')) { //We don't want anything happening here... (no email/etc) @@ -123,5 +123,23 @@ function friendrequest_event_create_friend($event, $object_type, $object){ } function friendrequest_event_create_friendrequest($event, $object_type, $object){ - + if (($object instanceof ElggRelationship) && ($event == 'create') && ($object_type == 'friendrequest')) { + $requester = get_entity($object->guid_one); + $requested = get_entity($object->guid_two); + + $friendrequests_url = elgg_get_site_url() . "friendrequests/"; + + // Notify target user + return notify_user( + $requested, + $requester, + elgg_echo('friendrequest:newfriend:subject', array( + $requester->name + ), $requested->language), + elgg_echo('friendrequest:newfriend:body', array( + $requester->name, + $friendrequests_url, + ), $requested->language) + ); + } } |