diff options
author | root <root@migration.vz.lan> | 2012-10-23 09:04:43 +0000 |
---|---|---|
committer | root <root@migration.vz.lan> | 2012-10-23 09:04:43 +0000 |
commit | 074dc8fda6f634cc8c024a913d8033600b336b3a (patch) | |
tree | 1a9959d61e9f308b0a3443d9d67c00d26421581c /classes/BeechatSync.php | |
download | elgg-074dc8fda6f634cc8c024a913d8033600b336b3a.tar.gz elgg-074dc8fda6f634cc8c024a913d8033600b336b3a.tar.bz2 |
initial commit.
Diffstat (limited to 'classes/BeechatSync.php')
-rw-r--r-- | classes/BeechatSync.php | 37 |
1 files changed, 37 insertions, 0 deletions
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 @@ +<?php + +class BeechatSync { + static function onFriendCreate($event, $object_type, $relationship) { + if ($relationship->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); + } + + } + +} |