aboutsummaryrefslogtreecommitdiff
path: root/mod/beechat/actions
diff options
context:
space:
mode:
Diffstat (limited to 'mod/beechat/actions')
-rw-r--r--mod/beechat/actions/get_connection.php21
-rw-r--r--mod/beechat/actions/get_details.php21
-rw-r--r--mod/beechat/actions/get_icons.php52
-rw-r--r--mod/beechat/actions/get_state.php21
-rw-r--r--mod/beechat/actions/get_statuses.php41
-rw-r--r--mod/beechat/actions/join_groupchat.php15
-rw-r--r--mod/beechat/actions/leave_groupchat.php12
-rw-r--r--mod/beechat/actions/save_state.php29
8 files changed, 212 insertions, 0 deletions
diff --git a/mod/beechat/actions/get_connection.php b/mod/beechat/actions/get_connection.php
new file mode 100644
index 000000000..a31174179
--- /dev/null
+++ b/mod/beechat/actions/get_connection.php
@@ -0,0 +1,21 @@
+<?php
+ /**
+ * Beechat
+ *
+ * @package beechat
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Beechannels <contact@beechannels.com>
+ * @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/mod/beechat/actions/get_details.php b/mod/beechat/actions/get_details.php
new file mode 100644
index 000000000..4944fc4a9
--- /dev/null
+++ b/mod/beechat/actions/get_details.php
@@ -0,0 +1,21 @@
+<?php
+ /**
+ * Beechat
+ *
+ * @package beechat
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Beechannels <contact@beechannels.com>
+ * @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/mod/beechat/actions/get_icons.php b/mod/beechat/actions/get_icons.php
new file mode 100644
index 000000000..33d447e2e
--- /dev/null
+++ b/mod/beechat/actions/get_icons.php
@@ -0,0 +1,52 @@
+<?php
+ /**
+ * Beechat
+ *
+ * @package beechat
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Beechannels <contact@beechannels.com>
+ * @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 == elgg_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/mod/beechat/actions/get_state.php b/mod/beechat/actions/get_state.php
new file mode 100644
index 000000000..6cfd2f725
--- /dev/null
+++ b/mod/beechat/actions/get_state.php
@@ -0,0 +1,21 @@
+<?php
+ /**
+ * Beechat
+ *
+ * @package beechat
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Beechannels <contact@beechannels.com>
+ * @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/mod/beechat/actions/get_statuses.php b/mod/beechat/actions/get_statuses.php
new file mode 100644
index 000000000..6f7620beb
--- /dev/null
+++ b/mod/beechat/actions/get_statuses.php
@@ -0,0 +1,41 @@
+<?php
+ /**
+ * Beechat
+ *
+ * @package beechat
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Beechannels <contact@beechannels.com>
+ * @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('', 1000000000, 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/mod/beechat/actions/join_groupchat.php b/mod/beechat/actions/join_groupchat.php
new file mode 100644
index 000000000..c694d7957
--- /dev/null
+++ b/mod/beechat/actions/join_groupchat.php
@@ -0,0 +1,15 @@
+<?php
+
+$user = elgg_get_logged_in_user_entity();
+$group = get_entity(get_input('group_guid'));
+
+if ($user && $group) {
+ if (!check_entity_relationship($user->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/mod/beechat/actions/leave_groupchat.php b/mod/beechat/actions/leave_groupchat.php
new file mode 100644
index 000000000..e04ab8846
--- /dev/null
+++ b/mod/beechat/actions/leave_groupchat.php
@@ -0,0 +1,12 @@
+<?php
+
+$user = elgg_get_logged_in_user_entity();
+$group = get_entity(get_input('group_guid'));
+
+if ($user && $group) {
+ if (check_entity_relationship($user->guid, 'groupchat', $group->guid))
+ remove_entity_relationship($user->guid, 'groupchat', $group->guid);
+}
+error_log("leave ok");
+echo "OK";
+?>
diff --git a/mod/beechat/actions/save_state.php b/mod/beechat/actions/save_state.php
new file mode 100644
index 000000000..f8a61c580
--- /dev/null
+++ b/mod/beechat/actions/save_state.php
@@ -0,0 +1,29 @@
+<?php
+ /**
+ * Beechat
+ *
+ * @package beechat
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Beechannels <contact@beechannels.com>
+ * @copyright Beechannels 2007-2010
+ * @link http://beechannels.com/
+ */
+
+// gatekeeper();
+
+ if (elgg_is_logged_in())
+ {
+
+ global $SESSION;
+
+ if (!empty($_POST['beechat_state']))
+ {
+ $SESSION->offsetSet('beechat_state', $_POST['beechat_state']);
+ }
+ elseif (!empty($_POST['beechat_conn']))
+ {
+ $SESSION->offsetSet('beechat_conn', get_input('beechat_conn'));
+ }
+ }
+ exit();
+?>