mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Made rooms sortable
This commit is contained in:
parent
b68f4087eb
commit
86544d5ae8
@ -1,18 +1,19 @@
|
|||||||
{include file='header'}
|
{include file='header'}
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
//<![CDATA[
|
||||||
|
$(function() {
|
||||||
|
new WCF.Action.Delete('\\wcf\\data\\chat\\room\\ChatRoomAction', $('.chatRoomRow'));
|
||||||
|
new WCF.Sortable.List('chatRoomList', '\\wcf\\data\\chat\\room\\ChatRoomAction');
|
||||||
|
});
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
<header class="wcf-mainHeading wcf-container">
|
<header class="wcf-mainHeading wcf-container">
|
||||||
<img src="{@$__wcf->getPath('wcf')}icon/chat1.svg" alt="" class="wcf-containerIcon" />
|
<img src="{@$__wcf->getPath('wcf')}icon/chat1.svg" alt="" class="wcf-containerIcon" />
|
||||||
<hgroup class="wcf-containerContent">
|
<hgroup class="wcf-containerContent">
|
||||||
<h1>{lang}wcf.acp.chat.room.list{/lang}</h1>
|
<h1>{lang}wcf.acp.chat.room.list{/lang}</h1>
|
||||||
</hgroup>
|
</hgroup>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
//<![CDATA[
|
|
||||||
$(function() {
|
|
||||||
new WCF.Action.Delete('wcf\\data\\chat\\room\\ChatRoomAction', $('.chatRoomRow'), $('.wcf-content .wcf-badge'));
|
|
||||||
});
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="wcf-contentHeader">
|
<div class="wcf-contentHeader">
|
||||||
@ -27,69 +28,31 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{hascontent}
|
<section id="chatRoomList" class="wcf-border wcf-sortableListContainer">
|
||||||
<div class="wcf-border wcf-boxTitle">
|
{hascontent}
|
||||||
<hgroup>
|
<ol class="wcf-sortableList" data-object-id="0">
|
||||||
<h1>{lang}wcf.acp.chat.room.list{/lang} <span class="wcf-badge" title="{lang}wcf.acp.chat.room.list.count{/lang}">{#$items}</span></h1>
|
{content}
|
||||||
</hgroup>
|
{foreach from=$objects item=chatRoom}
|
||||||
|
<li class="wcf-sortableNode chatRoomRow" data-object-id="{@$chatRoom->roomID}">
|
||||||
|
<span class="wcf-sortableNodeLabel">
|
||||||
|
<a href="{link controller='ChatRoomEdit' id=$chatRoom->roomID}{/link}">{$chatRoom->title|language}</a>
|
||||||
|
|
||||||
<table>
|
<span class="wcf-sortableButtonContainer">
|
||||||
<thead>
|
{if $__wcf->session->getPermission('admin.content.chat.canEditRoom')}
|
||||||
<tr>
|
<a href="{link controller='ChatRoomEdit' id=$chatRoom->roomID}{/link}"><img src="{@$__wcf->getPath('wcf')}icon/edit1.svg" alt="" title="{lang}wcf.global.button.edit{/lang}" class="balloonTooltip" /></a>
|
||||||
<th class="columnID columnChatRoomID" colspan="2">{lang}wcf.global.objectID{/lang}</th>
|
{/if}
|
||||||
<th class="columnTitle columnChatRoomTitle">{lang}wcf.acp.chat.room.title{/lang}</th>
|
{if $__wcf->session->getPermission('admin.content.chat.canDeleteRoom')}
|
||||||
|
<img src="{@$__wcf->getPath('wcf')}icon/delete1.svg" alt="" title="{lang}wcf.global.button.delete{/lang}" class="jsDeleteButton jsTooltip" data-object-id="{@$chatRoom->roomID}" data-confirm-message="{lang}wcf.acp.bbcode.delete.sure{/lang}" />
|
||||||
{event name='headColumns'}
|
{/if}
|
||||||
</tr>
|
</span>
|
||||||
</thead>
|
</span>
|
||||||
|
</li>
|
||||||
<tbody>
|
{/foreach}
|
||||||
{content}
|
{/content}
|
||||||
{foreach from=$objects item=chatRoom}
|
</ol>
|
||||||
<tr class="chatRoomRow">
|
{hascontentelse}
|
||||||
<td class="columnIcon">
|
<p class="wcf-warning">{lang}wcf.acp.chat.room.noneAvailable{/lang}</p>
|
||||||
{if $__wcf->session->getPermission('admin.content.chat.canEditRoom')}
|
{/hascontent}
|
||||||
<a href="{link controller='ChatRoomEdit' id=$chatRoom->roomID}{/link}"><img src="{@$__wcf->getPath('wcf')}icon/edit1.svg" alt="" title="{lang}wcf.global.button.edit{/lang}" class="balloonTooltip" /></a>
|
</section>
|
||||||
{else}
|
|
||||||
<img src="{@$__wcf->getPath('wcf')}icon/edit1D.svg" alt="" title="{lang}wcf.global.button.edit{/lang}" />
|
|
||||||
{/if}
|
|
||||||
{if $__wcf->session->getPermission('admin.content.chat.canDeleteRoom')}
|
|
||||||
<img src="{@$__wcf->getPath('wcf')}icon/delete1.svg" alt="" title="{lang}wcf.global.button.delete{/lang}" class="deleteButton balloonTooltip" data-object-id="{@$chatRoom->roomID}" data-confirm-message="{lang}wcf.acp.bbcode.delete.sure{/lang}" />
|
|
||||||
{else}
|
|
||||||
<img src="{@$__wcf->getPath('wcf')}icon/delete1D.svg" alt="" title="{lang}wcf.global.button.delete{/lang}" />
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{event name='buttons'}
|
|
||||||
</td>
|
|
||||||
<td class="columnID"><p>{@$chatRoom->roomID}</p></td>
|
|
||||||
<td class="columnTitle columnChatRoomTitle"><p>{if $__wcf->session->getPermission('admin.content.chat.canEditRoom')}<a href="{link controller='ChatRoomEdit' id=$chatRoom->roomID}{/link}">{$chatRoom->title|language}</a>{else}{$chatRoom->title|language}{/if}</p></td>
|
|
||||||
|
|
||||||
{event name='columns'}
|
|
||||||
</tr>
|
|
||||||
{/foreach}
|
|
||||||
{/content}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="wcf-contentFooter">
|
|
||||||
{@$pagesLinks}
|
|
||||||
|
|
||||||
{if $__wcf->session->getPermission('admin.content.chat.canAddRoom')}
|
|
||||||
<nav>
|
|
||||||
<ul class="wcf-largeButtons">
|
|
||||||
<li><a href="{link controller='ChatRoomAdd'}{/link}" title="{lang}wcf.acp.chat.room.add{/lang}" class="wcf-button"><img src="{@$__wcf->getPath('wcf')}icon/add1.svg" alt="" /> <span>{lang}wcf.acp.chat.room.add{/lang}</span></a></li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{hascontentelse}
|
|
||||||
<div class="wcf-border wcf-content">
|
|
||||||
<div>
|
|
||||||
<p class="wcf-warning">{lang}wcf.acp.chat.room.noneAvailable{/lang}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/hascontent}
|
|
||||||
|
|
||||||
{include file='footer'}
|
{include file='footer'}
|
@ -117,7 +117,7 @@ public function save() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
\wcf\system\acl\ACLHandler::getInstance()->save($roomID, $this->objectTypeID);
|
\wcf\system\acl\ACLHandler::getInstance()->save($roomID, $this->objectTypeID);
|
||||||
\wcf\system\chat\permissions\ChatPermissionHandler::clearCache();
|
\wcf\system\chat\permission\ChatPermissionHandler::clearCache();
|
||||||
|
|
||||||
$this->saved();
|
$this->saved();
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace wcf\data\chat\room;
|
namespace wcf\data\chat\room;
|
||||||
|
use \wcf\system\WCF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes chatroom-related actions.
|
* Executes chatroom-related actions.
|
||||||
@ -25,4 +26,67 @@ class ChatRoomAction extends \wcf\data\AbstractDatabaseObjectAction {
|
|||||||
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
|
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
|
||||||
*/
|
*/
|
||||||
protected $permissionsUpdate = array('admin.content.chat.canEditRoom');
|
protected $permissionsUpdate = array('admin.content.chat.canEditRoom');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixes create to append new boards.
|
||||||
|
*/
|
||||||
|
public function create() {
|
||||||
|
$room = parent::create();
|
||||||
|
|
||||||
|
WCF::getDB()->beginTransaction();
|
||||||
|
$sql = "SELECT max(position) as max
|
||||||
|
FROM wcf".WCF_N."_chat_room";
|
||||||
|
$stmt = WCF::getDB()->prepareStatement($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$row = $stmt->fetchArray();
|
||||||
|
|
||||||
|
$sql = "UPDATE wcf".WCF_N."_chat_room
|
||||||
|
SET position = ".($row['max'] + 1)."
|
||||||
|
WHERE roomID = ?";
|
||||||
|
$stmt = WCF::getDB()->prepareStatement($sql);
|
||||||
|
$stmt->execute(array($room->roomID));
|
||||||
|
WCF::getDB()->commitTransaction();
|
||||||
|
|
||||||
|
return $room;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates parameters to update sorting.
|
||||||
|
*/
|
||||||
|
public function validateUpdatePosition() {
|
||||||
|
// validate permissions
|
||||||
|
if (is_array($this->permissionsUpdate) && count($this->permissionsUpdate)) {
|
||||||
|
try {
|
||||||
|
WCF::getSession()->checkPermissions($this->permissionsUpdate);
|
||||||
|
}
|
||||||
|
catch (\wcf\system\exception\PermissionDeniedException $e) {
|
||||||
|
throw new ValidateActionException('Insufficient permissions');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new ValidateActionException('Insufficient permissions');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($this->parameters['data']['structure'])) {
|
||||||
|
throw new ValidateActionException('Missing parameter structure');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates sorting.
|
||||||
|
*/
|
||||||
|
public function updatePosition() {
|
||||||
|
$roomList = new \wcf\data\chat\room\ChatRoomList();
|
||||||
|
$roomList->sqlOrderBy = "chat_room.position";
|
||||||
|
$roomList->sqlLimit = 0;
|
||||||
|
$roomList->readObjects();
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
WCF::getDB()->beginTransaction();
|
||||||
|
foreach ($this->parameters['data']['structure'][0] as $roomID) {
|
||||||
|
$editor = new ChatRoomEditor($roomList->search($roomID));
|
||||||
|
$editor->update(array('position' => $i++));
|
||||||
|
}
|
||||||
|
WCF::getDB()->commitTransaction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user