aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-02-02 03:43:52 -0800
committerfriendica <info@friendica.com>2014-02-02 03:43:52 -0800
commite83419b53e27078867f8449f476d87b064b9d502 (patch)
treed02cdea385de99975d27c43ca555e57942ba2ee5
parent6b15e57cdbb1b525528f1e67aaa071d0ef4e6e25 (diff)
downloadvolse-hubzilla-e83419b53e27078867f8449f476d87b064b9d502.tar.gz
volse-hubzilla-e83419b53e27078867f8449f476d87b064b9d502.tar.bz2
volse-hubzilla-e83419b53e27078867f8449f476d87b064b9d502.zip
add links to change chat status and leave room
-rw-r--r--include/chat.php8
-rw-r--r--mod/chat.php10
-rw-r--r--mod/chatsvc.php32
-rw-r--r--view/tpl/chat.tpl2
4 files changed, 36 insertions, 16 deletions
diff --git a/include/chat.php b/include/chat.php
index 08fd154b5..5af3a3a9a 100644
--- a/include/chat.php
+++ b/include/chat.php
@@ -122,10 +122,10 @@ function chatroom_enter($observer_xchan,$room_id,$status,$client) {
intval($room_id)
);
if($r) {
- q("update chatpresence set cp_status = %d and cp_last = '%s' where cp_id = %d limit 1",
- dbesc($status),
+ q("update chatpresence set cp_last = '%s' where cp_id = %d and cp_client = '%s' limit 1",
dbesc(datetime_convert()),
- intval($r[0]['cp_id'])
+ intval($r[0]['cp_id']),
+ dbesc($client)
);
return true;
}
@@ -145,6 +145,7 @@ function chatroom_enter($observer_xchan,$room_id,$status,$client) {
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 and cp_client = '%s' limit 1",
dbesc($observer_xchan),
intval($room_id),
@@ -155,6 +156,7 @@ function chatroom_leave($observer_xchan,$room_id,$client) {
intval($r[0]['cp_id'])
);
}
+
return true;
}
diff --git a/mod/chat.php b/mod/chat.php
index 612878cb2..e79973aef 100644
--- a/mod/chat.php
+++ b/mod/chat.php
@@ -91,7 +91,7 @@ function chat_content(&$a) {
}
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));
}
@@ -111,7 +111,13 @@ function chat_content(&$a) {
$o = replace_macros(get_markup_template('chat.tpl'),array(
'$room_name' => $room_name,
'$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;
}
diff --git a/mod/chatsvc.php b/mod/chatsvc.php
index 0a69834f0..bbe616c48 100644
--- a/mod/chatsvc.php
+++ b/mod/chatsvc.php
@@ -29,17 +29,6 @@ function chatsvc_post(&$a) {
$room_id = $a->data['chat']['room_id'];
$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)
return;
@@ -65,6 +54,27 @@ function chatsvc_post(&$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']);
$ret = array('success' => false);
diff --git a/view/tpl/chat.tpl b/view/tpl/chat.tpl
index a0c18f8d6..dba6a777f 100644
--- a/view/tpl/chat.tpl
+++ b/view/tpl/chat.tpl
@@ -17,6 +17,8 @@
<input type="submit" name="submit" value="{{$submit}}" />
</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>