aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-01-29 00:08:29 -0800
committerfriendica <info@friendica.com>2014-01-29 00:08:29 -0800
commit9261a170eb45f0b189afb4c1a30603d0cbb8f31c (patch)
tree76ce693c986042d0d1109d19814174c0f66cca75
parent0013e59086080963737d6c864eca7ff852a1e9da (diff)
downloadvolse-hubzilla-9261a170eb45f0b189afb4c1a30603d0cbb8f31c.tar.gz
volse-hubzilla-9261a170eb45f0b189afb4c1a30603d0cbb8f31c.tar.bz2
volse-hubzilla-9261a170eb45f0b189afb4c1a30603d0cbb8f31c.zip
basic chatroom management backend
-rw-r--r--include/chat.php117
-rwxr-xr-xinstall/htconfig.sample.php2
-rw-r--r--version.inc2
3 files changed, 119 insertions, 2 deletions
diff --git a/include/chat.php b/include/chat.php
new file mode 100644
index 000000000..4df419294
--- /dev/null
+++ b/include/chat.php
@@ -0,0 +1,117 @@
+<?php /** @file */
+
+
+function chatroom_create($channel,$arr) {
+
+ $ret = array('success' => false);
+
+ $name = trim($arr['name']);
+ if(! $name) {
+ $ret['message'] = t('Missing room name');
+ return $ret;
+ }
+
+ $r = q("select cr_id from chatroom where cr_uid = %d and cr_name = '%s' limit 1",
+ intval($channel['channel_id']),
+ dbesc($name)
+ );
+ if($r) {
+ $ret['message'] = t('Duplicate room name');
+ return $ret;
+ }
+
+ $created = datetime_convert();
+
+ $x = q("insert into chatroom ( cr_aid, cr_uid, cr_name, cr_created, cr_edited, allow_cid, allow_gid, deny_cid, deny_gid )
+ values ( %d, %d , '%s' '%s', '%s', '%s', '%s', '%s', '%s' ) ",
+ intval($channel['account_id']),
+ intval($channel['channel_id']),
+ dbesc($name),
+ dbesc($created),
+ dbesc($created),
+ dbesc($arr['allow_cid']),
+ dbesc($arr['allow_gid']),
+ dbesc($arr['deny_cid']),
+ dbesc($arr['deny_gid'])
+ );
+ if($x)
+ $ret['success'] = true;
+
+ return $ret;
+}
+
+
+function chatroom_destroy($channel,$arr) {
+
+ $ret = array('success' => false);
+ if(intval($arr['cr_id']))
+ $sql_extra = " and cr_id = " . intval($arr['cr_id']) . " ";
+ elseif(trim($arr['cr_name']))
+ $sql_extra = " and cr_name = '" . protect_sprintf(dbesc(trim($arr['cr_name']))) . "' ";
+ else {
+ $ret['message'] = t('Invalid room specifier.');
+ return $ret;
+ }
+
+ $r = q("select * from chatroom where cr_uid = %d $sql_extra limit 1",
+ intval($channel['channel_id'])
+ );
+ if(! $r) {
+ $ret['message'] = t('Invalid room specifier.');
+ return $ret;
+ }
+
+ q("delete from chatroom where cr_id = %d limit 1",
+ intval($r[0]['cr_id'])
+ );
+ if($r[0]['cr_id']) {
+ q("delete from chatpresence where cp_room = %d",
+ intval($r[0]['cr_id'])
+ );
+ }
+ $ret['success'] = true;
+ return $ret;
+}
+
+
+function chatroom_enter($observer_xchan,$room_id,$status) {
+ if(! $room_id || ! $observer)
+ return;
+ $r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1",
+ dbesc($observer_xchan),
+ intval($room_id)
+ );
+ if($r) {
+ q("update chatpresence set cp_status = %d and cp_last = '%s' where cp_id = %d limit 1",
+ dbesc($status),
+ dbesc(datetime_convert()),
+ intval($r[0]['cp_id'])
+ );
+ return true;
+ }
+
+ $r = q("insert into chatpresence ( cp_room, cp_xchan, cp_last, cp_status )
+ values ( %d, '%s', '%s', '%s' )",
+ intval($room_id),
+ dbesc($observer_xchan),
+ dbesc(datetime_convert()),
+ dbesc($status)
+ );
+ return $r;
+}
+
+
+function chatroom_leave($observer_xchan,$room_id,$status) {
+ if(! $room_id || ! $observer)
+ return;
+ $r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1",
+ dbesc($observer_xchan),
+ intval($room_id)
+ );
+ if($r) {
+ q("delete from chatpresence where cp_id = %d limit 1",
+ intval($r[0]['cp_id'])
+ );
+ }
+ return true;
+} \ No newline at end of file
diff --git a/install/htconfig.sample.php b/install/htconfig.sample.php
index 33258cf41..b23dfe3b6 100755
--- a/install/htconfig.sample.php
+++ b/install/htconfig.sample.php
@@ -3,7 +3,7 @@
// If automatic system installation fails:
// Copy or rename this file to .htconfig.php in the top level
-// Friendica directory
+// Red Matrix directory
// Why .htconfig.php? Because it contains sensitive information which could
// give somebody complete control of your database. Apache's default
diff --git a/version.inc b/version.inc
index 3c79f0c43..36c8c7342 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2014-01-28.571
+2014-01-29.572