diff options
-rw-r--r-- | languages/en.php | 8 | ||||
-rw-r--r-- | start.php | 24 |
2 files changed, 29 insertions, 3 deletions
diff --git a/languages/en.php b/languages/en.php index 821278c1a..9b34a6030 100644 --- a/languages/en.php +++ b/languages/en.php @@ -17,6 +17,14 @@ $english = array( 'friendrequest:remove:check' => 'Are you sure you want to decline the friend request?', 'friendrequest:none' => 'No pending friend requests.', + 'friendrequest:new:subject' => '%s want to be your friend', + 'friendrequest:new:body' => '%s want to be your friend. She is waiting that you aprovate her petition. Do not her wait! + +You can see your pending friend requests following this link (remember you have to be logged in to see it): + + %s + +(Do not try to reply this mail, because is a machine who is sending it)', ); @@ -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) + ); + } } |