From 5462453bf2bde50166c68f90b08d24826dd07ba8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 Mar 2016 14:31:55 +0200 Subject: some work on mod chat --- include/chat.php | 2 +- include/nav.php | 4 +--- include/widgets.php | 15 +++++++----- mod/chat.php | 48 ++++++++++++++++++--------------------- mod/lockview.php | 30 ++++++++++++++++++++---- view/css/mod_chat.css | 23 +++++++++++++++++++ view/js/mod_chat.js | 2 +- view/pdl/mod_chat.pdl | 3 ++- view/theme/redbasic/css/style.css | 1 + view/tpl/chat.tpl | 2 +- view/tpl/chatroom_new.tpl | 24 +++++++++----------- view/tpl/chatroomlist.tpl | 16 ++++++------- view/tpl/chatrooms.tpl | 47 ++++++++++++++++++++++++++++++-------- 13 files changed, 142 insertions(+), 75 deletions(-) diff --git a/include/chat.php b/include/chat.php index 81c5c5d62..8a5970cca 100644 --- a/include/chat.php +++ b/include/chat.php @@ -202,7 +202,7 @@ function chatroom_list($uid) { require_once('include/security.php'); $sql_extra = permissions_sql($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 $sql_extra group by cr_name, cr_id order by cr_name", + $r = q("select allow_cid, allow_gid, deny_cid, deny_gid, cr_name, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d $sql_extra group by cr_name, cr_id order by cr_name", intval($uid) ); diff --git a/include/nav.php b/include/nav.php index 5f630745c..4e9a8ab19 100644 --- a/include/nav.php +++ b/include/nav.php @@ -92,10 +92,8 @@ EOT; $nav['usermenu'][] = Array('photos/' . $channel['channel_address'], t('Photos'), "", t('Your photos'),'photos_nav_btn'); $nav['usermenu'][] = Array('cloud/' . $channel['channel_address'],t('Files'),"",t('Your files'),'cloud_nav_btn'); - require_once('include/chat.php'); - $has_chats = chatroom_list_count(local_channel()); if(! UNO) - $nav['usermenu'][] = Array('chat/' . $channel['channel_address'] . (($has_chats) ? '' : '/new'), t('Chat'),"",t('Your chatrooms'),'chat_nav_btn'); + $nav['usermenu'][] = Array('chat/' . $channel['channel_address'], t('Chat'),"",t('Your chatrooms'),'chat_nav_btn'); require_once('include/menu.php'); diff --git a/include/widgets.php b/include/widgets.php index ac0b6a84f..2aa3dccf1 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -797,12 +797,15 @@ function widget_chatroom_list($arr) { require_once("include/chat.php"); $r = chatroom_list($a->profile['profile_uid']); - return replace_macros(get_markup_template('chatroomlist.tpl'), array( - '$header' => t('Chat Rooms'), - '$baseurl' => z_root(), - '$nickname' => $a->profile['channel_address'], - '$items' => $r, - )); + + if($r) { + return replace_macros(get_markup_template('chatroomlist.tpl'), array( + '$header' => t('Chat Rooms'), + '$baseurl' => z_root(), + '$nickname' => $a->profile['channel_address'], + '$items' => $r, + )); + } } function widget_bookmarkedchats($arr) { diff --git a/mod/chat.php b/mod/chat.php index f219bde73..6c0a61880 100644 --- a/mod/chat.php +++ b/mod/chat.php @@ -194,42 +194,38 @@ function chat_content(&$a) { } + require_once('include/conversation.php'); + $o = profile_tabs($a,((local_channel() && local_channel() == $a->profile['profile_uid']) ? true : false),$a->profile['channel_address']); + $acl = new Zotlabs\Access\AccessList($channel); + $channel_acl = $acl->get(); - if(local_channel() && argc() > 2 && argv(2) === 'new') { - - $acl = new Zotlabs\Access\AccessList($channel); - $channel_acl = $acl->get(); - - require_once('include/acl_selectors.php'); - - $o = replace_macros(get_markup_template('chatroom_new.tpl'),array( - '$header' => t('New Chatroom'), - '$name' => array('room_name',t('Chatroom Name'),'', ''), - '$chat_expire' => array('chat_expire',t('Expiration of chats (minutes)'),120,''), - '$permissions' => t('Permissions'), - '$acl' => populate_acl($channel_acl,false), - '$submit' => t('Submit') - )); - return $o; - } - - + $lockstate = (($channel_acl['allow_cid'] || $channel_acl['allow_gid'] || $channel_acl['deny_cid'] || $channel_acl['deny_gid']) ? 'lock' : 'unlock'); + require_once('include/acl_selectors.php'); - require_once('include/conversation.php'); + $chatroom_new = replace_macros(get_markup_template('chatroom_new.tpl'),array( + '$header' => t('New Chatroom'), + '$name' => array('room_name',t('Chatroom name'),'', ''), + '$chat_expire' => array('chat_expire',t('Expiration of chats (minutes)'),120,''), + '$permissions' => t('Permissions'), + '$acl' => populate_acl($channel_acl,false), + '$lockstate' => $lockstate, + '$submit' => t('Submit') - $o = profile_tabs($a,((local_channel() && local_channel() == $a->profile['profile_uid']) ? true : false),$a->profile['channel_address']); + )); - require_once('include/widgets.php'); + $rooms = chatroom_list($a->profile['profile_uid']); $o .= replace_macros(get_markup_template('chatrooms.tpl'), array( '$header' => sprintf( t('%1$s\'s Chatrooms'), $a->profile['name']), '$baseurl' => z_root(), - '$nickname' => $channel['channel_address'], - '$rooms' => widget_chatroom_list(array()), - '$newroom' => t('New Chatroom'), - '$is_owner' => ((local_channel() && local_channel() == $a->profile['profile_uid']) ? 1 : 0) + '$nickname' => $a->profile['channel_address'], + '$rooms' => $rooms, + '$norooms' => t('No chatrooms available'), + '$newroom' => t('Create New'), + '$is_owner' => ((local_channel() && local_channel() == $a->profile['profile_uid']) ? 1 : 0), + '$chatroom_new' => $chatroom_new )); return $o; diff --git a/mod/lockview.php b/mod/lockview.php index 84c16f658..d4a626a11 100644 --- a/mod/lockview.php +++ b/mod/lockview.php @@ -14,11 +14,21 @@ function lockview_content(&$a) { if(! $item_id) killme(); - if (!in_array($type, array('item','photo','event', 'menu_item'))) + if (!in_array($type, array('item','photo','event', 'menu_item', 'chatroom'))) killme(); - //we have different naming in in menu_item table - $id = (($type == 'menu_item') ? 'mitem_id' : 'id'); + //we have different naming in in menu_item table and chatroom table + switch($type) { + case 'menu_item': + $id = 'mitem_id'; + break; + case 'chatroom': + $id = 'cr_id'; + break; + default: + $id = 'id'; + break; + } $r = q("SELECT * FROM %s WHERE $id = %d LIMIT 1", dbesc($type), @@ -30,8 +40,18 @@ function lockview_content(&$a) { $item = $r[0]; - //we have different naming in in menu_item table - $uid = (($type == 'menu_item') ? $item['mitem_channel_id'] : $item['uid']); + //we have different naming in in menu_item table and chatroom table + switch($type) { + case 'menu_item': + $uid = $item['mitem_channel_id']; + break; + case 'chatroom': + $uid = $item['cr_uid']; + break; + default: + $uid = $item['uid']; + break; + } if($uid != local_channel()) { echo '
  • ' . t('Remote privacy information not available.') . '
  • '; diff --git a/view/css/mod_chat.css b/view/css/mod_chat.css index ded4b0ceb..c59d8d459 100644 --- a/view/css/mod_chat.css +++ b/view/css/mod_chat.css @@ -1,3 +1,26 @@ +#chatroom-new { + display: none; +} + +#chatrooms-index { + width: 100%; +} + +#chatrooms-index th:nth-child(1), +#chatrooms-index td:nth-child(1){ + padding: 7px 3px 7px 10px; +} + +#chatrooms-index th:nth-child(3), +#chatrooms-index td:nth-child(3){ + padding: 7px 10px 7px 7px; +} + +.chatrooms-index-tool { + padding: 7px 10px; +} + + #chatContainer { height: 100%; width: 100%; diff --git a/view/js/mod_chat.js b/view/js/mod_chat.js index 6c432742f..0d47e3e77 100644 --- a/view/js/mod_chat.js +++ b/view/js/mod_chat.js @@ -15,4 +15,4 @@ $(document).ready(function() { $('#jot-public').show(); } }).trigger('change'); -}); \ No newline at end of file +}); diff --git a/view/pdl/mod_chat.pdl b/view/pdl/mod_chat.pdl index cdc66dd3d..564199bed 100644 --- a/view/pdl/mod_chat.pdl +++ b/view/pdl/mod_chat.pdl @@ -1,5 +1,6 @@ [region=aside] -[widget=profile][/widget] +[widget=vcard][/widget] +[widget=chatroom_list][/widget] [widget=bookmarkedchats][/widget] [widget=suggestedchats][/widget] [/region] diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 424055fbf..b92fe5afe 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -1510,6 +1510,7 @@ nav .dropdown-menu { word-wrap: break-word; } +.chatroom-index-row:hover td, .locs-index-row:hover td, [id^="cloud-index-"]:hover td, .cloud-index-active { diff --git a/view/tpl/chat.tpl b/view/tpl/chat.tpl index 18576fd56..5ea1ae22e 100644 --- a/view/tpl/chat.tpl +++ b/view/tpl/chat.tpl @@ -5,7 +5,7 @@
    - +
    {{/if}} diff --git a/view/tpl/chatroom_new.tpl b/view/tpl/chatroom_new.tpl index c64f21c97..8acff2ff5 100644 --- a/view/tpl/chatroom_new.tpl +++ b/view/tpl/chatroom_new.tpl @@ -1,14 +1,12 @@ -
    -

    {{$header}}

    - -
    -{{include file="field_input.tpl" field=$name}} -{{include file="field_input.tpl" field=$chat_expire}} - -{{$acl}} -
    -
    -
    - -
    +
    +
    + {{include file="field_input.tpl" field=$name}} + {{include file="field_input.tpl" field=$chat_expire}} + {{$acl}} +
    + + +
    +
    +
    diff --git a/view/tpl/chatroomlist.tpl b/view/tpl/chatroomlist.tpl index 71fec8200..ac0f7cf9b 100644 --- a/view/tpl/chatroomlist.tpl +++ b/view/tpl/chatroomlist.tpl @@ -1,11 +1,11 @@
    -

    {{$header}}

    -{{if $items}} - -{{foreach $items as $item}} - -{{/foreach}} -
    {{$item.cr_name}}{{$item.cr_inroom}}
    -{{/if}} +

    {{$header}}

    + {{if $items}} + + {{/if}}
    diff --git a/view/tpl/chatrooms.tpl b/view/tpl/chatrooms.tpl index 570aef1c7..c7333efcf 100644 --- a/view/tpl/chatrooms.tpl +++ b/view/tpl/chatrooms.tpl @@ -1,12 +1,39 @@ -
    -

    {{$header}}

    - -{{if $is_owner}} -

    -{{$newroom}} -

    -{{/if}} - -{{$rooms}} +
    +
    + {{if $is_owner}} + + {{/if}} +

    {{$header}}

    +
    + {{if $is_owner}} + {{$chatroom_new}} + {{/if}} + {{if $rooms}} +
    + + + + + + + {{foreach $rooms as $room}} + + + + + + {{/foreach}} +
    name
    {{$room.cr_name}}{{$room.cr_inroom}}
    +
    + {{else}} +
    + {{$norooms}} +
    + {{/if}}
    -- cgit v1.2.3