diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-04-03 21:36:29 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-04-03 21:36:29 -0400 |
commit | 0523b4b2f1012a8b5f3bffb7f136a20dc9a4e43f (patch) | |
tree | a92197de4503ec52889dc05483493f4df1a305b8 /mod/chatsvc.php | |
parent | 99d9456b3addc651a68874ddd391d25684252c4d (diff) | |
parent | b4c1baada1fba46d4d75f40a7e78111d70d54e7a (diff) | |
download | volse-hubzilla-0523b4b2f1012a8b5f3bffb7f136a20dc9a4e43f.tar.gz volse-hubzilla-0523b4b2f1012a8b5f3bffb7f136a20dc9a4e43f.tar.bz2 volse-hubzilla-0523b4b2f1012a8b5f3bffb7f136a20dc9a4e43f.zip |
Merge branch 'master' of https://github.com/redmatrix/hubzilla into contextual-help
Diffstat (limited to 'mod/chatsvc.php')
-rw-r--r-- | mod/chatsvc.php | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/mod/chatsvc.php b/mod/chatsvc.php index 44225e6dd..4fa38e819 100644 --- a/mod/chatsvc.php +++ b/mod/chatsvc.php @@ -8,16 +8,16 @@ function chatsvc_init(&$a) { $ret = array('success' => false); - $a->data['chat']['room_id'] = intval($_REQUEST['room_id']); + App::$data['chat']['room_id'] = intval($_REQUEST['room_id']); $x = q("select cr_uid from chatroom where cr_id = %d and cr_id != 0 limit 1", - intval($a->data['chat']['room_id']) + intval(App::$data['chat']['room_id']) ); if(! $x) json_return_and_die($ret); - $a->data['chat']['uid'] = $x[0]['cr_uid']; + App::$data['chat']['uid'] = $x[0]['cr_uid']; - if(! perm_is_allowed($a->data['chat']['uid'],get_observer_hash(),'chat')) { + if(! perm_is_allowed(App::$data['chat']['uid'],get_observer_hash(),'chat')) { json_return_and_die($ret); } @@ -27,22 +27,22 @@ function chatsvc_post(&$a) { $ret = array('success' => false); - $room_id = $a->data['chat']['room_id']; + $room_id = App::$data['chat']['room_id']; $text = escape_tags($_REQUEST['chat_text']); if(! $text) return; - $sql_extra = permissions_sql($a->data['chat']['uid']); + $sql_extra = permissions_sql(App::$data['chat']['uid']); $r = q("select * from chatroom where cr_uid = %d and cr_id = %d $sql_extra", - intval($a->data['chat']['uid']), - intval($a->data['chat']['room_id']) + intval(App::$data['chat']['uid']), + intval(App::$data['chat']['room_id']) ); if(! $r) json_return_and_die($ret); $arr = array( - 'chat_room' => $a->data['chat']['room_id'], + 'chat_room' => App::$data['chat']['room_id'], 'chat_xchan' => get_observer_hash(), 'chat_text' => $text ); @@ -51,7 +51,7 @@ function chatsvc_post(&$a) { $x = q("insert into chat ( chat_room, chat_xchan, created, chat_text ) values( %d, '%s', '%s', '%s' )", - intval($a->data['chat']['room_id']), + intval(App::$data['chat']['room_id']), dbesc(get_observer_hash()), dbesc(datetime_convert()), dbesc($arr['chat_text']) @@ -64,13 +64,13 @@ function chatsvc_post(&$a) { function chatsvc_content(&$a) { $status = strip_tags($_REQUEST['status']); - $room_id = intval($a->data['chat']['room_id']); + $room_id = intval(App::$data['chat']['room_id']); $stopped = ((x($_REQUEST,'stopped') && intval($_REQUEST['stopped'])) ? true : false); if($status && $room_id) { $x = q("select channel_address from channel where channel_id = %d limit 1", - intval($a->data['chat']['uid']) + intval(App::$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'", @@ -90,11 +90,11 @@ function chatsvc_content(&$a) { $ret = array('success' => false); - $sql_extra = permissions_sql($a->data['chat']['uid']); + $sql_extra = permissions_sql(App::$data['chat']['uid']); $r = q("select * from chatroom where cr_uid = %d and cr_id = %d $sql_extra", - intval($a->data['chat']['uid']), - intval($a->data['chat']['room_id']) + intval(App::$data['chat']['uid']), + intval(App::$data['chat']['room_id']) ); if(! $r) json_return_and_die($ret); @@ -102,28 +102,30 @@ function chatsvc_content(&$a) { $inroom = array(); $r = q("select * from chatpresence left join xchan on xchan_hash = cp_xchan where cp_room = %d order by xchan_name", - intval($a->data['chat']['room_id']) + intval(App::$data['chat']['room_id']) ); if($r) { foreach($r as $rr) { switch($rr['cp_status']) { case 'away': $status = t('Away'); + $status_class = 'away'; break; case 'online': default: $status = t('Online'); + $status_class = 'online'; break; } - $inroom[] = array('img' => zid($rr['xchan_photo_m']), 'img_type' => $rr['xchan_photo_mimetype'],'name' => $rr['xchan_name'], status => $status); + $inroom[] = array('img' => zid($rr['xchan_photo_m']), 'img_type' => $rr['xchan_photo_mimetype'],'name' => $rr['xchan_name'], 'status' => $status, 'status_class' => $status_class); } } $chats = array(); $r = q("select * from chat left join xchan on chat_xchan = xchan_hash where chat_room = %d and chat_id > %d order by created", - intval($a->data['chat']['room_id']), + intval(App::$data['chat']['room_id']), intval($lastseen) ); if($r) { @@ -135,7 +137,8 @@ function chatsvc_content(&$a) { 'name' => $rr['xchan_name'], 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], 'c'), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], 'r'), - 'text' => smilies(bbcode($rr['chat_text'])) + 'text' => smilies(bbcode($rr['chat_text'])), + 'self' => ((get_observer_hash() == $rr['chat_xchan']) ? 'self' : '') ); } } @@ -143,7 +146,7 @@ function chatsvc_content(&$a) { $r = q("update chatpresence set cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s'", dbesc(datetime_convert()), - intval($a->data['chat']['room_id']), + intval(App::$data['chat']['room_id']), dbesc(get_observer_hash()), dbesc($_SERVER['REMOTE_ADDR']) ); |