diff options
author | Michael Meer <michael@meer.name> | 2014-01-30 10:21:21 +0100 |
---|---|---|
committer | Michael Meer <michael@meer.name> | 2014-01-30 10:21:21 +0100 |
commit | e5d1e20ff50f49909e7df6fe7efe0d7488e58eaa (patch) | |
tree | a3e0b7d7e1f9a4a8a2af39d5c8fad8d62f0411a3 /include/chat.php | |
parent | ef97a454bbccbd9f7e0e63180c365ed3227fe42c (diff) | |
parent | 6c6a9b963a925d33b2cc436d877a4edc5f0d59b1 (diff) | |
download | volse-hubzilla-e5d1e20ff50f49909e7df6fe7efe0d7488e58eaa.tar.gz volse-hubzilla-e5d1e20ff50f49909e7df6fe7efe0d7488e58eaa.tar.bz2 volse-hubzilla-e5d1e20ff50f49909e7df6fe7efe0d7488e58eaa.zip |
Merge branch 'master' of https://github.com/friendica/red
to be in sync with master repro
Diffstat (limited to 'include/chat.php')
-rw-r--r-- | include/chat.php | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/include/chat.php b/include/chat.php index 6bcb003ff..b88c63fc3 100644 --- a/include/chat.php +++ b/include/chat.php @@ -20,6 +20,18 @@ function chatroom_create($channel,$arr) { return $ret; } + $r = q("select count(cr_id) as total from chatroom where cr_aid = %d", + intval($channel['channel_account_id']) + ); + if($r) + $limit = service_class_fetch($channel_id,'chatrooms'); + + if(($r) && ($limit !== false) && ($r[0]['total'] >= $limit)) { + $ret['message'] = upgrade_message(); + 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 ) @@ -83,18 +95,20 @@ function chatroom_enter($observer_xchan,$room_id,$status,$client) { $r = q("select * from chatroom where cr_id = %d limit 1", intval($room_id) ); - if(! $r) - return; + if(! $r) { + notice( t('Room not found.') . EOL); + return false; + } require_once('include/security.php'); $sql_extra = permissions_sql($r[0]['cr_uid']); - $x = q("select * from chatroom where cr_id = %d and uid = %d $sql_extra limit 1", - intval($room_id) + $x = q("select * from chatroom where cr_id = %d and cr_uid = %d $sql_extra limit 1", + intval($room_id), intval($r[0]['cr_uid']) ); if(! $x) { notice( t('Permission denied.') . EOL); - return; + return false; } $r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1", @@ -122,12 +136,13 @@ function chatroom_enter($observer_xchan,$room_id,$status,$client) { } -function chatroom_leave($observer_xchan,$room_id,$status) { +function chatroom_leave($observer_xchan,$room_id,$client) { if(! $room_id || ! $observer_xchan) return; - $r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1", + $r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d and cp_client = '%s' limit 1", dbesc($observer_xchan), - intval($room_id) + intval($room_id), + dbesc($client) ); if($r) { q("delete from chatpresence where cp_id = %d limit 1", @@ -140,7 +155,7 @@ function chatroom_leave($observer_xchan,$room_id,$status) { function chatroom_list($uid) { - $r = q("select cr_name, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d group by cp_id order by cr_name", + $r = q("select cr_name, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d group by cr_name order by cr_name", intval($uid) ); |