more chat infrastructure

This commit is contained in:
friendica
2014-01-29 17:09:20 -08:00
parent 677f5f641e
commit b8fb6a4373
3 changed files with 89 additions and 6 deletions

View File

@@ -83,8 +83,10 @@ 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']);
@@ -94,7 +96,7 @@ function chatroom_enter($observer_xchan,$room_id,$status,$client) {
);
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 +124,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",