UI for deleting chatrooms

This commit is contained in:
friendica 2014-05-04 20:30:52 -07:00
parent 3ae67c517e
commit 806f1f0fa1
6 changed files with 36 additions and 6 deletions

View File

@ -84,6 +84,9 @@ function chatroom_destroy($channel,$arr) {
q("delete from chatpresence where cp_room = %d", q("delete from chatpresence where cp_room = %d",
intval($r[0]['cr_id']) intval($r[0]['cr_id'])
); );
q("delete from chat where chat_room = %d",
intval($r[0]['cr_id'])
);
} }
$ret['success'] = true; $ret['success'] = true;
return $ret; return $ret;

View File

@ -49,6 +49,7 @@ function chat_post(&$a) {
if($_POST['action'] === 'drop') { if($_POST['action'] === 'drop') {
logger('delete chatroom');
chatroom_destroy($channel,array('cr_name' => $room)); chatroom_destroy($channel,array('cr_name' => $room));
goaway(z_root() . '/chat/' . $channel['channel_address']); goaway(z_root() . '/chat/' . $channel['channel_address']);
} }
@ -168,12 +169,14 @@ function chat_content(&$a) {
} }
$o = replace_macros(get_markup_template('chat.tpl'),array( $o = replace_macros(get_markup_template('chat.tpl'),array(
'$is_owner' => ((local_user() && local_user() == $x[0]['cr_uid']) ? true : false),
'$room_name' => $room_name, '$room_name' => $room_name,
'$room_id' => $room_id, '$room_id' => $room_id,
'$baseurl' => z_root(), '$baseurl' => z_root(),
'$nickname' => argv(1), '$nickname' => argv(1),
'$submit' => t('Submit'), '$submit' => t('Submit'),
'$leave' => t('Leave Room'), '$leave' => t('Leave Room'),
'$drop' => t('Delete This Room'),
'$away' => t('I am away right now'), '$away' => t('I am away right now'),
'$online' => t('I am online'), '$online' => t('I am online'),
'$bookmark_link' => $bookmark_link, '$bookmark_link' => $bookmark_link,

View File

@ -10,13 +10,20 @@
overflow-y: auto; overflow-y: auto;
} }
#chatUsers { #chatSide {
float: right; float: right;
width: 120px; width: 150px;
height: 100%; height: 100%;
border: 1px solid #000;
} }
#chatDrop {
margin-bottom: 20px;
}
#chatUsers {
border: 1px solid #000;
}
#chatBottomBar { #chatBottomBar {
position: relative; position: relative;
bottom: 0; bottom: 0;

View File

@ -167,3 +167,9 @@ li:hover .group-edit-icon {
#photo-albums-upload-link { #photo-albums-upload-link {
margin-top: 10px; margin-top: 10px;
} }
/* Chatrooms */
.chatroomlist td {
padding: 0 5px 0;
}

View File

@ -5,8 +5,19 @@
<div id="chatLineHolder"></div> <div id="chatLineHolder"></div>
</div> </div>
<div id="chatUsers"></div> <div id="chatSide">
{{if $is_owner}}
<div id="chatDrop">
<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();"/>
</form>
</div><br />
{{/if}}
<div id="chatUsers"></div><br />
</div>
<div class="clear"></div> <div class="clear"></div>
<div id="chatBottomBar"> <div id="chatBottomBar">
<div class="tip"></div> <div class="tip"></div>

View File

@ -1,7 +1,7 @@
<div class="widget"> <div class="widget">
<h3>{{$header}}</h3> <h3>{{$header}}</h3>
{{if $items}} {{if $items}}
<table> <table class="chatroomlist">
{{foreach $items as $item}} {{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> <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}} {{/foreach}}