From 074dc8fda6f634cc8c024a913d8033600b336b3a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Oct 2012 09:04:43 +0000 Subject: initial commit. --- actions/get_connection.php | 21 ++++++++++++++++++ actions/get_details.php | 21 ++++++++++++++++++ actions/get_icons.php | 52 +++++++++++++++++++++++++++++++++++++++++++++ actions/get_state.php | 21 ++++++++++++++++++ actions/get_statuses.php | 41 +++++++++++++++++++++++++++++++++++ actions/join_groupchat.php | 15 +++++++++++++ actions/leave_groupchat.php | 12 +++++++++++ actions/save_state.php | 26 +++++++++++++++++++++++ 8 files changed, 209 insertions(+) create mode 100644 actions/get_connection.php create mode 100644 actions/get_details.php create mode 100644 actions/get_icons.php create mode 100644 actions/get_state.php create mode 100644 actions/get_statuses.php create mode 100644 actions/join_groupchat.php create mode 100644 actions/leave_groupchat.php create mode 100644 actions/save_state.php (limited to 'actions') diff --git a/actions/get_connection.php b/actions/get_connection.php new file mode 100644 index 000000000..a31174179 --- /dev/null +++ b/actions/get_connection.php @@ -0,0 +1,21 @@ + + * @copyright Beechannels 2007-2010 + * @link http://beechannels.com/ + */ + + header('Content-type: application/json'); + gatekeeper(); + + global $SESSION; + + if ($SESSION->offsetExists('beechat_conn')) + echo $SESSION->offsetGet('beechat_conn'); + + exit(); +?> diff --git a/actions/get_details.php b/actions/get_details.php new file mode 100644 index 000000000..4944fc4a9 --- /dev/null +++ b/actions/get_details.php @@ -0,0 +1,21 @@ + + * @copyright Beechannels 2007-2010 + * @link http://beechannels.com/ + */ + + gatekeeper(); + header('Content-type: application/json'); + $user = $_SESSION['user']; + $t = array('username' => $user->username, + 'password' => $user->password); + + echo json_encode($t); + + exit(); +?> diff --git a/actions/get_icons.php b/actions/get_icons.php new file mode 100644 index 000000000..88e7bdd3b --- /dev/null +++ b/actions/get_icons.php @@ -0,0 +1,52 @@ + + * @copyright Beechannels 2007-2010 + * @link http://beechannels.com/ + */ + + header('Content-type: application/json'); + gatekeeper(); + global $CONFIG; + + if (!empty($_POST['beechat_roster_items_usernames'])) + { + $rosterItemsUsernames = explode(',', $_POST['beechat_roster_items_usernames']); + /*foreach ($rosterItemsUsernames as $rosterItem) + { + }*/ + $userFriendsEntities = $_SESSION['user']->getFriends('', 0, 0); + + $res = array(); + foreach ($rosterItemsUsernames as $value) + { + $found = false; + $splitjid = explode('@', $value); + $jid_name = $splitjid[0]; + $jid_host = $splitjid[1]; + foreach ($userFriendsEntities as $friend) + { + if ((strtolower($friend->username) == strtolower($jid_name) && $jid_host == get_plugin_setting("domain", "beechat"))) + { + $res[$value] = array('small' => $friend->getIcon('small'), 'tiny' => $friend->getIcon('tiny')); + $found = true; + break; + } + } + if (!$found) { + $base = $CONFIG->wwwroot."mod/profile/graphics/default"; + $res[$value] = array('small' => $base."small.gif", 'tiny' => $base."tiny.gif"); + } + } + echo json_encode($res); + } + else + echo json_encode(null); + + exit(); + +?> diff --git a/actions/get_state.php b/actions/get_state.php new file mode 100644 index 000000000..6cfd2f725 --- /dev/null +++ b/actions/get_state.php @@ -0,0 +1,21 @@ + + * @copyright Beechannels 2007-2010 + * @link http://beechannels.com/ + */ + + header('Content-type: application/json'); + gatekeeper(); + + global $SESSION; + + if ($SESSION->offsetExists('beechat_state')) + echo $SESSION->offsetGet('beechat_state'); + + exit(); +?> diff --git a/actions/get_statuses.php b/actions/get_statuses.php new file mode 100644 index 000000000..c328e44b7 --- /dev/null +++ b/actions/get_statuses.php @@ -0,0 +1,41 @@ + + * @copyright Beechannels 2007-2010 + * @link http://beechannels.com/ + */ + + header('Content-type: application/json'); + gatekeeper(); + $usernames = get_input('beechat_roster_items_usernames'); + if (!empty($usernames)) + { + $iconSize = 'small'; + $rosterItemsUsernames = explode(',', $usernames); + $userFriendsEntities = $_SESSION['user']->getFriends('', count($rosterItemsUsernames), 0); + + $res = array(); + foreach ($rosterItemsUsernames as $value) + { + foreach ($userFriendsEntities as $friend) + { + if (strtolower($friend->username) == strtolower($value)) + { + $status = get_entities_from_metadata("state", "current", "object", "status", $friend->get('guid')); + $res[$value] = ($status != false) ? $status[0]->description : ''; + break; + } + } + } + echo json_encode($res); + } + else + echo json_encode(null); + + exit(); + +?> diff --git a/actions/join_groupchat.php b/actions/join_groupchat.php new file mode 100644 index 000000000..0d2d75c61 --- /dev/null +++ b/actions/join_groupchat.php @@ -0,0 +1,15 @@ +guid, 'groupchat', $group->guid)) { + error_log("joinen ok"); + add_entity_relationship($user->guid, 'groupchat', $group->guid); +} +} +echo "OK"; +error_log("join ok"); + +?> diff --git a/actions/leave_groupchat.php b/actions/leave_groupchat.php new file mode 100644 index 000000000..079ad4898 --- /dev/null +++ b/actions/leave_groupchat.php @@ -0,0 +1,12 @@ +guid, 'groupchat', $group->guid)) + remove_entity_relationship($user->guid, 'groupchat', $group->guid); +} +error_log("leave ok"); +echo "OK"; +?> diff --git a/actions/save_state.php b/actions/save_state.php new file mode 100644 index 000000000..f3a818f72 --- /dev/null +++ b/actions/save_state.php @@ -0,0 +1,26 @@ + + * @copyright Beechannels 2007-2010 + * @link http://beechannels.com/ + */ + + gatekeeper(); + + global $SESSION; + + if (!empty($_POST['beechat_state'])) + { + $SESSION->offsetSet('beechat_state', get_input('beechat_state')); + } + elseif (!empty($_POST['beechat_conn'])) + { + $SESSION->offsetSet('beechat_conn', get_input('beechat_conn')); + } + + exit(); +?> -- cgit v1.2.3