add links to change chat status and leave room
This commit is contained in:
parent
6b15e57cdb
commit
e83419b53e
@ -122,10 +122,10 @@ function chatroom_enter($observer_xchan,$room_id,$status,$client) {
|
|||||||
intval($room_id)
|
intval($room_id)
|
||||||
);
|
);
|
||||||
if($r) {
|
if($r) {
|
||||||
q("update chatpresence set cp_status = %d and cp_last = '%s' where cp_id = %d limit 1",
|
q("update chatpresence set cp_last = '%s' where cp_id = %d and cp_client = '%s' limit 1",
|
||||||
dbesc($status),
|
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($r[0]['cp_id'])
|
intval($r[0]['cp_id']),
|
||||||
|
dbesc($client)
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -145,6 +145,7 @@ function chatroom_enter($observer_xchan,$room_id,$status,$client) {
|
|||||||
function chatroom_leave($observer_xchan,$room_id,$client) {
|
function chatroom_leave($observer_xchan,$room_id,$client) {
|
||||||
if(! $room_id || ! $observer_xchan)
|
if(! $room_id || ! $observer_xchan)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d and cp_client = '%s' limit 1",
|
$r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d and cp_client = '%s' limit 1",
|
||||||
dbesc($observer_xchan),
|
dbesc($observer_xchan),
|
||||||
intval($room_id),
|
intval($room_id),
|
||||||
@ -155,6 +156,7 @@ function chatroom_leave($observer_xchan,$room_id,$client) {
|
|||||||
intval($r[0]['cp_id'])
|
intval($r[0]['cp_id'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
mod/chat.php
10
mod/chat.php
@ -91,7 +91,7 @@ function chat_content(&$a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if((argc() > 3) && intval(argv(2)) && (argv(3) === 'leave')) {
|
if((argc() > 3) && intval(argv(2)) && (argv(3) === 'leave')) {
|
||||||
chatroom_leave($observer,$room_id,$_SERVER['REMOTE_ADDR']);
|
chatroom_leave($observer,argv(2),$_SERVER['REMOTE_ADDR']);
|
||||||
goaway(z_root() . '/channel/' . argv(1));
|
goaway(z_root() . '/channel/' . argv(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,13 @@ function chat_content(&$a) {
|
|||||||
$o = replace_macros(get_markup_template('chat.tpl'),array(
|
$o = replace_macros(get_markup_template('chat.tpl'),array(
|
||||||
'$room_name' => $room_name,
|
'$room_name' => $room_name,
|
||||||
'$room_id' => $room_id,
|
'$room_id' => $room_id,
|
||||||
'$submit' => t('Submit')
|
'$baseurl' => z_root(),
|
||||||
|
'$nickname' => argv(1),
|
||||||
|
'$submit' => t('Submit'),
|
||||||
|
'$leave' => t('Leave Room'),
|
||||||
|
'$away' => t('I am away right now'),
|
||||||
|
'$online' => t('I am online')
|
||||||
|
|
||||||
));
|
));
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
@ -29,17 +29,6 @@ function chatsvc_post(&$a) {
|
|||||||
|
|
||||||
$room_id = $a->data['chat']['room_id'];
|
$room_id = $a->data['chat']['room_id'];
|
||||||
$text = escape_tags($_REQUEST['chat_text']);
|
$text = escape_tags($_REQUEST['chat_text']);
|
||||||
$status = strip_tags($_REQUEST['status']);
|
|
||||||
|
|
||||||
if($status && $room_id) {
|
|
||||||
$r = q("update chatpresence set cp_status = '%s', cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s' limit 1",
|
|
||||||
dbesc($status),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($room_id),
|
|
||||||
dbesc(get_observer_hash()),
|
|
||||||
dbesc($_SERVER['REMOTE_ADDR'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if(! $text)
|
if(! $text)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -65,6 +54,27 @@ function chatsvc_post(&$a) {
|
|||||||
|
|
||||||
function chatsvc_content(&$a) {
|
function chatsvc_content(&$a) {
|
||||||
|
|
||||||
|
$status = strip_tags($_REQUEST['status']);
|
||||||
|
$room_id = intval($a->data['chat']['room_id']);
|
||||||
|
|
||||||
|
if($status && $room_id) {
|
||||||
|
|
||||||
|
$x = q("select channel_address from channel where channel_id = %d limit 1",
|
||||||
|
intval($a->data['chat']['uid'])
|
||||||
|
);
|
||||||
|
|
||||||
|
$r = q("update chatpresence set cp_status = '%s', cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s' limit 1",
|
||||||
|
dbesc($status),
|
||||||
|
dbesc(datetime_convert()),
|
||||||
|
intval($room_id),
|
||||||
|
dbesc(get_observer_hash()),
|
||||||
|
dbesc($_SERVER['REMOTE_ADDR'])
|
||||||
|
);
|
||||||
|
|
||||||
|
goaway(z_root() . '/chat/' . $x[0]['channel_address'] . '/' . $room_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$lastseen = intval($_REQUEST['last']);
|
$lastseen = intval($_REQUEST['last']);
|
||||||
|
|
||||||
$ret = array('success' => false);
|
$ret = array('success' => false);
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
<input type="submit" name="submit" value="{{$submit}}" />
|
<input type="submit" name="submit" value="{{$submit}}" />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<a href="{{$baseurl}}/chat/{{$nickname}}/{{$room_id}}/leave">{{$leave}}</a> | <a href="{{$baseurl}}/chatsvc?f=&room_id={{$room_id}}&status=away">{{$away}}</a> | <a href="{{$baseurl}}/chatsvc?f=&room_id={{$room_id}}&status=online">{{$online}}</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user