aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/get_connection.php21
-rw-r--r--actions/get_details.php21
-rw-r--r--actions/get_icons.php52
-rw-r--r--actions/get_state.php21
-rw-r--r--actions/get_statuses.php41
-rw-r--r--actions/join_groupchat.php15
-rw-r--r--actions/leave_groupchat.php12
-rw-r--r--actions/save_state.php26
8 files changed, 209 insertions, 0 deletions
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 @@
+<?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/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 @@
+<?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/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 @@
+<?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 == 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 @@
+<?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/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 @@
+<?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('', 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 @@
+<?php
+
+$user = get_loggedin_user();
+$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/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 @@
+<?php
+
+$user = get_loggedin_user();
+$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/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 @@
+<?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();
+
+ 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();
+?>