mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 00:55:19 +00:00
some work on mod chat
This commit is contained in:
parent
e4f3605054
commit
5462453bf2
13 changed files with 144 additions and 77 deletions
|
@ -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)
|
||||
);
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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) {
|
||||
|
|
52
mod/chat.php
52
mod/chat.php
|
@ -194,42 +194,38 @@ function chat_content(&$a) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
require_once('include/conversation.php');
|
||||
|
||||
$o = profile_tabs($a,((local_channel() && local_channel() == $a->profile['profile_uid']) ? true : false),$a->profile['channel_address']);
|
||||
|
||||
require_once('include/widgets.php');
|
||||
$acl = new Zotlabs\Access\AccessList($channel);
|
||||
$channel_acl = $acl->get();
|
||||
|
||||
$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');
|
||||
|
||||
$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')
|
||||
|
||||
));
|
||||
|
||||
$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;
|
||||
|
|
|
@ -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>';
|
||||
|
|
|
@ -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%;
|
||||
|
|
|
@ -15,4 +15,4 @@ $(document).ready(function() {
|
|||
$('#jot-public').show();
|
||||
}
|
||||
}).trigger('change');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
[region=aside]
|
||||
[widget=profile][/widget]
|
||||
[widget=vcard][/widget]
|
||||
[widget=chatroom_list][/widget]
|
||||
[widget=bookmarkedchats][/widget]
|
||||
[widget=suggestedchats][/widget]
|
||||
[/region]
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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}}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue