diff options
author | Mario Vavti <mario@mariovavti.com> | 2016-03-30 14:31:55 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2016-03-30 14:31:55 +0200 |
commit | 5462453bf2bde50166c68f90b08d24826dd07ba8 (patch) | |
tree | 8951f8c1f38cb9847419fce8874a89325da6fe54 | |
parent | e4f360505466d4701ea4ac8f8bec18fac5b4c3ec (diff) | |
download | volse-hubzilla-5462453bf2bde50166c68f90b08d24826dd07ba8.tar.gz volse-hubzilla-5462453bf2bde50166c68f90b08d24826dd07ba8.tar.bz2 volse-hubzilla-5462453bf2bde50166c68f90b08d24826dd07ba8.zip |
some work on mod chat
-rw-r--r-- | include/chat.php | 2 | ||||
-rw-r--r-- | include/nav.php | 4 | ||||
-rw-r--r-- | include/widgets.php | 15 | ||||
-rw-r--r-- | mod/chat.php | 48 | ||||
-rw-r--r-- | mod/lockview.php | 30 | ||||
-rw-r--r-- | view/css/mod_chat.css | 23 | ||||
-rw-r--r-- | view/js/mod_chat.js | 2 | ||||
-rw-r--r-- | view/pdl/mod_chat.pdl | 3 | ||||
-rw-r--r-- | view/theme/redbasic/css/style.css | 1 | ||||
-rw-r--r-- | view/tpl/chat.tpl | 2 | ||||
-rw-r--r-- | view/tpl/chatroom_new.tpl | 24 | ||||
-rw-r--r-- | view/tpl/chatroomlist.tpl | 16 | ||||
-rw-r--r-- | 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 '<li>' . t('Remote privacy information not available.') . '</li>'; 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 @@ <form id="chat-destroy" method="post" action="chat"> <input type="hidden" name="room_name" value="{{$room_name}}" /> <input type="hidden" name="action" value="drop" /> - <input type="submit" name="submit" value="{{$drop}}" onclick="return confirmDelete();"/> + <input type="submit" name="submit" value="{{$drop}}" onclick="return confirmDelete();"/> </form> </div> {{/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 @@ -<div class="generic-content-wrapper-styled"> -<h1>{{$header}}</h1> - -<form action="chat" method="post" > -{{include file="field_input.tpl" field=$name}} -{{include file="field_input.tpl" field=$chat_expire}} -<button id="dbtn-acl" class="btn btn-default" data-toggle="modal" data-target="#aclModal" onclick="return false;" >{{$permissions}}</button> -{{$acl}} -<div class="clear"></div> -<br /> -<br /> -<input id="dbtn-submit" type="submit" name="submit" value="{{$submit}}" /> -</form> +<div id="chatroom-new" class="section-content-tools-wrapper"> + <form action="chat" method="post" > + {{include file="field_input.tpl" field=$name}} + {{include file="field_input.tpl" field=$chat_expire}} + {{$acl}} + <div class="btn-group pull-right"> + <button id="dbtn-acl" class="btn btn-default" data-toggle="modal" data-target="#aclModal" title="{{$permissions}}" onclick="return false;" ><i id="jot-perms-icon" class="icon-{{$lockstate}}"></i></button> + <button id="dbtn-submit" class="btn btn-primary" type="submit" name="submit" value="{{$submit}}">{{$submit}}</button> + </div> + <div class="clear"></div> + </form> </div> 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 @@ <div class="widget"> -<h3>{{$header}}</h3> -{{if $items}} -<table class="chatroomlist"> -{{foreach $items as $item}} -<tr><td align="left"><a href="{{$baseurl}}/chat/{{$nickname}}/{{$item.cr_id}}">{{$item.cr_name}}</a></td><td align="right">{{$item.cr_inroom}}</td></tr> -{{/foreach}} -</table> -{{/if}} + <h3>{{$header}}</h3> + {{if $items}} + <ul class="nav nav-pills nav-stacked"> + {{foreach $items as $item}} + <li><a href="{{$baseurl}}/chat/{{$nickname}}/{{$item.cr_id}}"><span class="badge pull-right">{{$item.cr_inroom}}</span>{{$item.cr_name}}</a></li> + {{/foreach}} + </ul> + {{/if}} </div> 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 @@ -<div class="generic-content-wrapper-styled"> -<h2>{{$header}}</h2> - -{{if $is_owner}} -<p> -<span class="btn btn-default"><a href="{{$baseurl}}/chat/{{$nickname}}/new">{{$newroom}}</a></span> -</p> -{{/if}} - -{{$rooms}} +<div class="generic-content-wrapper"> + <div class="section-title-wrapper"> + {{if $is_owner}} + <button type="button" class="btn btn-success btn-xs pull-right" onclick="openClose('chatroom-new');"><i class="icon-plus-sign"></i> {{$newroom}}</button> + {{/if}} + <h2>{{$header}}</h2> + </div> + {{if $is_owner}} + {{$chatroom_new}} + {{/if}} + {{if $rooms}} + <div class="section-content-wrapper-np"> + <table id="chatrooms-index"> + <tr> + <th width="98%">name</th> + <th width="1%" class="chatrooms-index-tool"></th> + <th width="1%"></th> + </tr> + {{foreach $rooms as $room}} + <tr class="chatroom-index-row"> + <td><a href="{{$baseurl}}/chat/{{$nickname}}/{{$room.cr_id}}">{{$room.cr_name}}</a></td> + <td class="chatrooms-index-tool dropdown"> + {{if $room.allow_cid || $room.allow_gid || $room.deny_cid || $room.deny_gid}} + <i class="icon-lock lockview dropdown-toggle" data-toggle="dropdown" onclick="lockview('chatroom',{{$room.cr_id}});"></i> + <ul id="panel-{{$room.cr_id}}" class="lockview-panel dropdown-menu"></ul> + {{/if}} + </td> + <td><span class="badge">{{$room.cr_inroom}}</span></td> + </tr> + {{/foreach}} + </table> + </div> + {{else}} + <div class="section-content-wrapper"> + {{$norooms}} + </div> + {{/if}} </div> |