From 074dc8fda6f634cc8c024a913d8033600b336b3a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Oct 2012 09:04:43 +0000 Subject: initial commit. --- classes/BeechatSync.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 classes/BeechatSync.php (limited to 'classes/BeechatSync.php') diff --git a/classes/BeechatSync.php b/classes/BeechatSync.php new file mode 100644 index 000000000..e0a2f90b8 --- /dev/null +++ b/classes/BeechatSync.php @@ -0,0 +1,37 @@ +relationship == 'friendrequest') { + elgg_load_library('elgg:beechat'); + $friend = get_entity($relationship->guid_two); + // create friend request + ejabberd_friend_request(elgg_get_logged_in_user_entity(), $friend); + } + } + static function onFriendDelete($event, $object_type, $relationship) { + if ($relationship->relationship == 'friendrequest') { + elgg_load_library('elgg:beechat'); + $subject = get_entity($relationship->guid_two); + // here friend is guid_one because is the one initiating + $friend = get_entity($relationship->guid_one); + $friends = $friend->isFriendsWith($subject->guid); + if ($friends) { + // accept friend request + ejabberd_friend_accept(elgg_get_logged_in_user_entity(), $friend); + } else { + // decline friend request + ejabberd_friend_deny(elgg_get_logged_in_user_entity(), $friend); + } + } + elseif ($relationship->relationship == 'friend') { + elgg_load_library('elgg:beechat'); + $subject = get_entity($relationship->guid_one); + $friend = get_entity($relationship->guid_two); + // delete friendship + ejabberd_friend_remove(elgg_get_logged_in_user_entity(), $friend); + } + + } + +} -- cgit v1.2.3