diff options
author | Michael Meer <michael@meer.name> | 2014-01-29 14:07:25 +0100 |
---|---|---|
committer | Michael Meer <michael@meer.name> | 2014-01-29 14:07:25 +0100 |
commit | ac8d481a3223335050a7f8dfe1c893a0b301ae7b (patch) | |
tree | c5461820ba181db4258bcf524c42f3fac982e454 /include | |
parent | aa285b83c1c8f674be8f200d4feae6299eafc436 (diff) | |
parent | a1e7c65d51a6472cf7fe95686883f77953d7dfd7 (diff) | |
download | volse-hubzilla-ac8d481a3223335050a7f8dfe1c893a0b301ae7b.tar.gz volse-hubzilla-ac8d481a3223335050a7f8dfe1c893a0b301ae7b.tar.bz2 volse-hubzilla-ac8d481a3223335050a7f8dfe1c893a0b301ae7b.zip |
Merge branch 'master' of https://github.com/friendica/red
to be in sync with main repro
Diffstat (limited to 'include')
-rw-r--r-- | include/bbcode.php | 8 | ||||
-rw-r--r-- | include/chat.php | 148 | ||||
-rw-r--r-- | include/identity.php | 50 | ||||
-rwxr-xr-x | include/text.php | 2 | ||||
-rw-r--r-- | include/widgets.php | 9 |
5 files changed, 208 insertions, 9 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index 084c02125..fec8750e9 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -442,14 +442,6 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // Check for list text $Text = str_replace("[*]", "<li>", $Text); - // Check for style sheet commands - if (strpos($Text,'[/style]') !== false) { - $Text = preg_replace("(\[style=(.*?)\](.*?)\[\/style\])ism","<span style=\"$1;\">$2</span>",$Text); - } - // Check for CSS classes - if (strpos($Text,'[/class]') !== false) { - $Text = preg_replace("(\[class=(.*?)\](.*?)\[\/class\])ism","<span class=\"$1\">$2</span>",$Text); - } // handle nested lists $endlessloop = 0; diff --git a/include/chat.php b/include/chat.php new file mode 100644 index 000000000..6bcb003ff --- /dev/null +++ b/include/chat.php @@ -0,0 +1,148 @@ +<?php /** @file */ + + +function chatroom_create($channel,$arr) { + + $ret = array('success' => false); + + $name = trim($arr['name']); + if(! $name) { + $ret['message'] = t('Missing room name'); + return $ret; + } + + $r = q("select cr_id from chatroom where cr_uid = %d and cr_name = '%s' limit 1", + intval($channel['channel_id']), + dbesc($name) + ); + if($r) { + $ret['message'] = t('Duplicate room name'); + 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 ) + values ( %d, %d , '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", + intval($channel['channel_account_id']), + intval($channel['channel_id']), + dbesc($name), + dbesc($created), + dbesc($created), + dbesc($arr['allow_cid']), + dbesc($arr['allow_gid']), + dbesc($arr['deny_cid']), + dbesc($arr['deny_gid']) + ); + + if($x) + $ret['success'] = true; + + return $ret; +} + + +function chatroom_destroy($channel,$arr) { + + $ret = array('success' => false); + if(intval($arr['cr_id'])) + $sql_extra = " and cr_id = " . intval($arr['cr_id']) . " "; + elseif(trim($arr['cr_name'])) + $sql_extra = " and cr_name = '" . protect_sprintf(dbesc(trim($arr['cr_name']))) . "' "; + else { + $ret['message'] = t('Invalid room specifier.'); + return $ret; + } + + $r = q("select * from chatroom where cr_uid = %d $sql_extra limit 1", + intval($channel['channel_id']) + ); + if(! $r) { + $ret['message'] = t('Invalid room specifier.'); + return $ret; + } + + q("delete from chatroom where cr_id = %d limit 1", + intval($r[0]['cr_id']) + ); + if($r[0]['cr_id']) { + q("delete from chatpresence where cp_room = %d", + intval($r[0]['cr_id']) + ); + } + $ret['success'] = true; + return $ret; +} + + +function chatroom_enter($observer_xchan,$room_id,$status,$client) { + + if(! $room_id || ! $observer_xchan) + return; + + $r = q("select * from chatroom where cr_id = %d limit 1", + intval($room_id) + ); + if(! $r) + return; + 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) + intval($r[0]['cr_uid']) + ); + if(! $x) { + notice( t('Permission denied.') . EOL); + return; + } + + $r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1", + dbesc($observer_xchan), + intval($room_id) + ); + if($r) { + q("update chatpresence set cp_status = %d and cp_last = '%s' where cp_id = %d limit 1", + dbesc($status), + dbesc(datetime_convert()), + intval($r[0]['cp_id']) + ); + return true; + } + + $r = q("insert into chatpresence ( cp_room, cp_xchan, cp_last, cp_status, cp_client ) + values ( %d, '%s', '%s', '%s', '%s' )", + intval($room_id), + dbesc($observer_xchan), + dbesc(datetime_convert()), + dbesc($status), + dbesc($client) + ); + return $r; +} + + +function chatroom_leave($observer_xchan,$room_id,$status) { + if(! $room_id || ! $observer_xchan) + return; + $r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1", + dbesc($observer_xchan), + intval($room_id) + ); + if($r) { + q("delete from chatpresence where cp_id = %d limit 1", + intval($r[0]['cp_id']) + ); + } + return true; +} + + +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", + intval($uid) + ); + + return $r; +}
\ No newline at end of file diff --git a/include/identity.php b/include/identity.php index a99474d42..2db5d8ece 100644 --- a/include/identity.php +++ b/include/identity.php @@ -544,6 +544,9 @@ function profile_load(&$a, $nickname, $profile = '') { } $a->profile = $r[0]; + $online = get_online_status($nickname); + $a->profile['online_status'] = $online['result']; + $a->profile_uid = $r[0]['profile_uid']; $a->page['title'] = $a->profile['channel_name'] . " - " . $a->profile['channel_address'] . "@" . $a->get_hostname(); @@ -678,13 +681,15 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) { $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False); $marital = ((x($profile,'marital') == 1) ? t('Status:') : False); $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False); + $profile['online'] = (($profile['online_status'] === 'online') ? t('Online Now') : False); +logger('online: ' . $profile['online']); if(! perm_is_allowed($profile['uid'],((is_array($observer)) ? $observer['xchan_hash'] : ''),'view_profile')) { $block = true; } if(($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) { - $location = $pdesc = $gender = $marital = $homepage = False; + $location = $pdesc = $gender = $marital = $homepage = $online = False; } $firstname = ((strpos($profile['name'],' ')) @@ -1144,3 +1149,46 @@ function is_foreigner($s) { function is_member($s) { return((is_foreigner($s)) ? false : true); } + +function get_online_status($nick) { + + $ret = array('result' => false); + + $r = q("select channel_id, channel_hash from channel where channel_address = '%s' limit 1", + dbesc(argv(1)) + ); + if($r) { + $hide = get_pconfig($r[0]['channel_id'],'system','hide_online_status'); + if($hide) + return $ret; + $x = q("select cp_status from chatpresence where cp_xchan = '%s' and cp_room = 0 limit 1", + dbesc($r[0]['channel_hash']) + ); + if($x) + $ret['result'] = $x[0]['cp_status']; + } + + return $ret; +} + + +function remote_online_status($webbie) { + + $result = false; + $r = q("select * from hubloc where hubloc_addr = '%s' limit 1", + dbesc($webbie) + ); + if(! $r) + return $result; + + $url = $r[0]['hubloc_url'] . '/online/' . substr($webbie,0,strpos($webbie,'@')); + + $x = z_fetch_url($url); + if($x['success']) { + $j = json_decode($x['body'],true); + if($j) + $result = (($j['result']) ? $j['result'] : false); + } + return $result; + +} diff --git a/include/text.php b/include/text.php index f5c440e4a..a459296cb 100755 --- a/include/text.php +++ b/include/text.php @@ -891,6 +891,7 @@ function smilies($s, $sample = false) { $s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism','smile_encode',$s); $s = preg_replace_callback('/<code>(.*?)<\/code>/ism','smile_encode',$s); +// $s = preg_replace_callback('/<(.*?)>/ism','smile_encode',$s); $texts = array( '<3', @@ -983,6 +984,7 @@ function smilies($s, $sample = false) { $s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism','smile_decode',$s); $s = preg_replace_callback('/<code>(.*?)<\/code>/ism','smile_decode',$s); +// $s = preg_replace_callback('/<(.*?)>/s','smile_decode',$s); return $s; diff --git a/include/widgets.php b/include/widgets.php index efa350785..8b22515b1 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -576,3 +576,12 @@ function widget_menu_preview($arr) { require_once('include/menu.php'); return menu_render(get_app()->data['menu_item']); } + +function widget_chatroom_list($arr) { + require_once("include/chat.php"); + $r = chatroom_list(local_user()); + return replace_macros(get_markup_template('chatroomlist.tpl'),array( + '$header' => t('Chat Rooms'), + '$items' => $r, + )); +}
\ No newline at end of file |