1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Add option to force a room selection

This commit is contained in:
Tim Düsterhus 2014-02-13 16:39:16 +01:00
parent 4d208f8893
commit 1c1f695ecd
4 changed files with 197 additions and 151 deletions

View File

@ -173,16 +173,21 @@ public function readRoom() {
if ($this->roomID === 0) { if ($this->roomID === 0) {
// no room given // no room given
$room = reset($this->rooms); if (CHAT_FORCE_ROOM_SELECT) {
if ($room === null) { return;
// no valid room found }
throw new exception\IllegalLinkException(); else {
$room = reset($this->rooms);
if ($room === null) {
// no valid room found
throw new exception\IllegalLinkException();
}
// redirect to first chat-room
\wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
'object' => $room
)));
exit;
} }
// redirect to first chat-room
\wcf\util\HeaderUtil::redirect(\wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
'object' => $room
)));
exit;
} }
if (!isset($this->rooms[$this->roomID])) throw new exception\IllegalLinkException(); if (!isset($this->rooms[$this->roomID])) throw new exception\IllegalLinkException();

View File

@ -44,6 +44,8 @@ public function isVisible() {
* @see \wcf\system\menu\page\PageMenuItemProvider::getLink() * @see \wcf\system\menu\page\PageMenuItemProvider::getLink()
*/ */
public function getLink() { public function getLink() {
if (CHAT_FORCE_ROOM_SELECT) return parent::getLink();
return \wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array( return \wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
'application' => 'chat', 'application' => 'chat',
'object' => $this->room, 'object' => $this->room,

View File

@ -18,6 +18,11 @@
<optiontype>boolean</optiontype> <optiontype>boolean</optiontype>
<defaultvalue>1</defaultvalue> <defaultvalue>1</defaultvalue>
</option> </option>
<option name="chat_force_room_select">
<categoryname>chat.general</categoryname>
<optiontype>boolean</optiontype>
<defaultvalue>0</defaultvalue>
</option>
<option name="chat_reloadtime"> <option name="chat_reloadtime">
<categoryname>chat.general</categoryname> <categoryname>chat.general</categoryname>
<optiontype>integer</optiontype> <optiontype>integer</optiontype>

View File

@ -1,157 +1,191 @@
{include file='documentHeader'} {include file='documentHeader'}
<head> <head>
<title>{$room} - {lang}chat.general.title{/lang} - {PAGE_TITLE|language}</title> <title>{if $room}{$room} - {/if}{lang}chat.general.title{/lang} - {PAGE_TITLE|language}</title>
{include file='headInclude' sandbox=false} {include file='headInclude' sandbox=false}
{include file='javascriptInclude' application='chat'} {if $room}
<script data-relocate="true"> {include file='javascriptInclude' application='chat'}
//<![CDATA[ <script data-relocate="true">
(function ($, window) { //<![CDATA[
$(function(){ (function ($, window) {
WCF.Language.addObject({ $(function(){
'chat.general.query': '{lang}chat.general.query{/lang}', WCF.Language.addObject({
'chat.general.kick': '{lang}chat.general.kick{/lang}', 'chat.general.query': '{lang}chat.general.query{/lang}',
'chat.general.ban': '{lang}chat.general.ban{/lang}', 'chat.general.kick': '{lang}chat.general.kick{/lang}',
'chat.general.profile': '{lang}chat.general.profile{/lang}', 'chat.general.ban': '{lang}chat.general.ban{/lang}',
'chat.general.notify.title': '{lang}chat.general.notify.title{/lang}', 'chat.general.profile': '{lang}chat.general.profile{/lang}',
'chat.general.privateChannelTopic': '{lang}chat.general.privateChannelTopic{/lang}', 'chat.general.notify.title': '{lang}chat.general.notify.title{/lang}',
'chat.general.closePrivateChannel': '{lang}chat.general.closePrivateChannel{/lang}', 'chat.general.privateChannelTopic': '{lang}chat.general.privateChannelTopic{/lang}',
'chat.general.closeTopic': '{lang}chat.general.closeTopic{/lang}', 'chat.general.closePrivateChannel': '{lang}chat.general.closePrivateChannel{/lang}',
'chat.error.onMessageLoad': '{@"chat.error.onMessageLoad"|language|encodeJS}', 'chat.general.closeTopic': '{lang}chat.general.closeTopic{/lang}',
'chat.error.duplicateTab': '{lang}chat.error.duplicateTab{/lang}', 'chat.error.onMessageLoad': '{@"chat.error.onMessageLoad"|language|encodeJS}',
'chat.error.join': '{lang}chat.error.join{/lang}', 'chat.error.duplicateTab': '{lang}chat.error.duplicateTab{/lang}',
'chat.error.reload': '{lang}chat.error.reload{/lang}', 'chat.error.join': '{lang}chat.error.join{/lang}',
'wcf.attachment.upload.error.invalidExtension': '{lang}wcf.attachment.upload.error.invalidExtension{/lang}', 'chat.error.reload': '{lang}chat.error.reload{/lang}',
'wcf.attachment.upload.error.tooLarge': '{lang}wcf.attachment.upload.error.tooLarge{/lang}', 'wcf.attachment.upload.error.invalidExtension': '{lang}wcf.attachment.upload.error.invalidExtension{/lang}',
'wcf.attachment.upload.error.reachedLimit': '{lang}wcf.attachment.upload.error.reachedLimit{/lang}', 'wcf.attachment.upload.error.tooLarge': '{lang}wcf.attachment.upload.error.tooLarge{/lang}',
'wcf.attachment.upload.error.reachedRemainingLimit': '{lang}wcf.attachment.upload.error.reachedRemainingLimit{/lang}', 'wcf.attachment.upload.error.reachedLimit': '{lang}wcf.attachment.upload.error.reachedLimit{/lang}',
'wcf.attachment.upload.error.uploadFailed': '{lang}wcf.attachment.upload.error.uploadFailed{/lang}', 'wcf.attachment.upload.error.reachedRemainingLimit': '{lang}wcf.attachment.upload.error.reachedRemainingLimit{/lang}',
'wcf.global.button.upload': '{lang}wcf.global.button.upload{/lang}', 'wcf.attachment.upload.error.uploadFailed': '{lang}wcf.attachment.upload.error.uploadFailed{/lang}',
'wcf.attachment.insert': '{lang}wcf.attachment.insert{/lang}', 'wcf.global.button.upload': '{lang}wcf.global.button.upload{/lang}',
'wcf.attachment.delete.sure': '{lang}wcf.attachment.delete.sure{/lang}', 'wcf.attachment.insert': '{lang}wcf.attachment.insert{/lang}',
'chat.message.{$messageTypes[TYPE_ATTACHMENT]}': '{lang}chat.message.{$messageTypes[TYPE_ATTACHMENT]}{/lang}' 'wcf.attachment.delete.sure': '{lang}wcf.attachment.delete.sure{/lang}',
}); 'chat.message.{$messageTypes[TYPE_ATTACHMENT]}': '{lang}chat.message.{$messageTypes[TYPE_ATTACHMENT]}{/lang}'
});
// Boot the chat // Boot the chat
{if MODULE_SMILEY}WCF.TabMenu.init();{/if} {if MODULE_SMILEY}WCF.TabMenu.init();{/if}
{if MODULE_ATTACHMENT && $__wcf->session->getPermission('user.chat.canUploadAttachment')} {if MODULE_ATTACHMENT && $__wcf->session->getPermission('user.chat.canUploadAttachment')}
new be.bastelstu.Chat.Attachment(); new be.bastelstu.Chat.Attachment();
new be.bastelstu.Chat.Action.Delete('wcf\\data\\attachment\\AttachmentAction', '#timsChatUploadDropdownMenu > li'); new be.bastelstu.Chat.Action.Delete('wcf\\data\\attachment\\AttachmentAction', '#timsChatUploadDropdownMenu > li');
{/if} {/if}
new WCF.Message.Smilies(); new WCF.Message.Smilies();
{capture assign='messageTemplate'}{include application='chat' file='message'}{/capture} {capture assign='messageTemplate'}{include application='chat' file='message'}{/capture}
{capture assign='userTemplate'}{include application='chat' file='userListUser'}{/capture} {capture assign='userTemplate'}{include application='chat' file='userListUser'}{/capture}
var config = { var config = {
reloadTime: {@CHAT_RELOADTIME}, reloadTime: {@CHAT_RELOADTIME},
messageURL: '{link application="chat" controller="NewMessages"}{/link}', messageURL: '{link application="chat" controller="NewMessages"}{/link}',
installedCommands: [ {implode from=$commands item='command'}'{$command|encodeJS}'{/implode} ], installedCommands: [ {implode from=$commands item='command'}'{$command|encodeJS}'{/implode} ],
messageTypes: { {implode from=$messageTypes key='name' item='messageType'}'{$name|substr:5|encodeJS}': '{$messageType|encodeJS}'{/implode} } messageTypes: { {implode from=$messageTypes key='name' item='messageType'}'{$name|substr:5|encodeJS}': '{$messageType|encodeJS}'{/implode} }
}; };
{event name='beforeInit'} {event name='beforeInit'}
be.bastelstu.Chat.init( be.bastelstu.Chat.init(
{$roomID}, {$roomID},
config, config,
new WCF.Template('{literal}{if $newMessageCount}({#$newMessageCount}) {/if}{$title} - {/literal}{"chat.general.title"|language|encodeJS} - {PAGE_TITLE|language|encodeJS}'), new WCF.Template('{literal}{if $newMessageCount}({#$newMessageCount}) {/if}{$title} - {/literal}{"chat.general.title"|language|encodeJS} - {PAGE_TITLE|language|encodeJS}'),
new WCF.Template('{@$messageTemplate|encodeJS}'), new WCF.Template('{@$messageTemplate|encodeJS}'),
new WCF.Template('{@$userTemplate|encodeJS}') new WCF.Template('{@$userTemplate|encodeJS}')
); );
{event name='afterInit'} {event name='afterInit'}
$('#timsChatCopyright').click(function (event) { $('#timsChatCopyright').click(function (event) {
event.preventDefault(); event.preventDefault();
if (!$.wcfIsset('timsChatCopyrightDialog')) $('<div id="timsChatCopyrightDialog"></div>').appendTo('body'); if (!$.wcfIsset('timsChatCopyrightDialog')) $('<div id="timsChatCopyrightDialog"></div>').appendTo('body');
$('#timsChatCopyrightDialog').load('{link application="chat" controller="Copyright"}{/link}').wcfDialog({ $('#timsChatCopyrightDialog').load('{link application="chat" controller="Copyright"}{/link}').wcfDialog({
title: '<img width="246" height="90" alt="" src="{$__wcf->getPath("chat")|encodeJS}images/chatLogo.png"> {if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}' title: '<img width="246" height="90" alt="" src="{$__wcf->getPath("chat")|encodeJS}images/chatLogo.png"> {if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}'
});
}); });
}); });
}); })(jQuery, this);
})(jQuery, this); //]]>
//]]> </script>
</script> {/if}
</head> </head>
<body id="tpl{$templateName|ucfirst}"> <body id="tpl{$templateName|ucfirst}">
{capture assign='sidebar'}{include application='chat' file='sidebar'}{/capture} {if $room}
{include file='header' sandbox=false sidebarOrientation='right'} {capture assign='sidebar'}{include application='chat' file='sidebar'}{/capture}
{include file='header' sandbox=false sidebarOrientation='right'}
<div id="timsChatTopic" class="marginTop container{if $room->topic|language === ''} empty{/if}"> <div id="timsChatTopic" class="marginTop container{if $room->topic|language === ''} empty{/if}">
<span class="icon icon16 icon-remove jsTopicCloser jsTooltip" title="{lang}chat.general.closeTopic{/lang}"></span> <span class="icon icon16 icon-remove jsTopicCloser jsTooltip" title="{lang}chat.general.closeTopic{/lang}"></span>
<span class="topic">{$room->topic|language}</span> <span class="topic">{$room->topic|language}</span>
</div> </div>
<div id="privateChannelsMenu"> <div id="privateChannelsMenu">
<ul> <ul>
<li id="privateChannel0" class="privateChannel active" data-private-channel-id="0"> <li id="privateChannel0" class="privateChannel active" data-private-channel-id="0">
<span class="userAvatar framed small"> <span class="userAvatar framed small">
<span class="icon icon16 icon-comment-alt jsTooltip" title="{lang}chat.general.room{/lang}"></span> <span class="icon icon16 icon-comment-alt jsTooltip" title="{lang}chat.general.room{/lang}"></span>
</span> </span>
<span class="userAvatar framed large"> <span class="userAvatar framed large">
<span class="icon icon32 icon-comment-alt jsTooltip" title="{lang}chat.general.room{/lang}"></span> <span class="icon icon32 icon-comment-alt jsTooltip" title="{lang}chat.general.room{/lang}"></span>
</span> </span>
</li> </li>
</ul> </ul>
</div> </div>
<div id="timsChatMessageContainer0" class="timsChatMessageContainer marginTop container active" data-user-id="0"> <div id="timsChatMessageContainer0" class="timsChatMessageContainer marginTop container active" data-user-id="0">
<p class="error noJsOnly" style="display: none;">{lang}chat.general.noJs{/lang}</p> <p class="error noJsOnly" style="display: none;">{lang}chat.general.noJs{/lang}</p>
<ul> <ul>
</ul> </ul>
</div> </div>
<form id="timsChatForm" action="{link application='chat' controller='Chat' action='Send'}{/link}" method="post"> <form id="timsChatForm" action="{link application='chat' controller='Chat' action='Send'}{/link}" method="post">
<fieldset> <fieldset>
<dl class="wide" id="timsChatInputContainer"> <dl class="wide" id="timsChatInputContainer">
<dt> <dt>
{lang}chat.general.message{/lang} {lang}chat.general.message{/lang}
</dt> </dt>
<dd> <dd>
<input id="timsChatInput" accesskey="w" type="text" class="inputText long" name="text" autocomplete="off" maxlength="{@CHAT_MAX_LENGTH}" disabled="disabled" placeholder="{lang}chat.general.submit.default{/lang}" /> <input id="timsChatInput" accesskey="w" type="text" class="inputText long" name="text" autocomplete="off" maxlength="{@CHAT_MAX_LENGTH}" disabled="disabled" placeholder="{lang}chat.general.submit.default{/lang}" />
<small class="innerError" style="display: none;">Lorem ipsum dolor sit amet.</small> <small class="innerError" style="display: none;">Lorem ipsum dolor sit amet.</small>
</dd> </dd>
</dl> </dl>
</fieldset> </fieldset>
<button type="submit" class="invisible" accesskey="s"></button> <button type="submit" class="invisible" accesskey="s"></button>
</form> </form>
{if MODULE_SMILEY && $smileyCategories|count} {if MODULE_SMILEY && $smileyCategories|count}
{include file='messageFormSmilies' wysiwygSelector=''} {include file='messageFormSmilies' wysiwygSelector=''}
{/if} {/if}
<nav id="timsChatOptions" class="marginTop jsMobileNavigation buttonGroupNavigation"> <nav id="timsChatOptions" class="marginTop jsMobileNavigation buttonGroupNavigation">
<span class="invisible">{lang}chat.general.controls{/lang}</span> <span class="invisible">{lang}chat.general.controls{/lang}</span>
<ul class="smallButtons buttonGroup"> <ul class="smallButtons buttonGroup">
<li><a id="timsChatAutoscroll" accesskey="d" class="button active timsChatToggle jsTooltip" title="{lang}chat.general.scroll{/lang}" data-status="1"><span class="icon icon16 icon-arrow-down"></span><span class="invisible">{lang}chat.general.scroll{/lang}</span></a></li>{* <li><a id="timsChatAutoscroll" accesskey="d" class="button active timsChatToggle jsTooltip" title="{lang}chat.general.scroll{/lang}" data-status="1"><span class="icon icon16 icon-arrow-down"></span><span class="invisible">{lang}chat.general.scroll{/lang}</span></a></li>{*
*}<li><a id="timsChatFullscreen" accesskey="f" class="button timsChatToggle jsTooltip" title="{lang}chat.general.fullscreen{/lang}" data-status="0"><span class="icon icon16 icon-fullscreen"></span><span class="invisible">{lang}chat.general.fullscreen{/lang}</span></a></li>{* *}<li><a id="timsChatFullscreen" accesskey="f" class="button timsChatToggle jsTooltip" title="{lang}chat.general.fullscreen{/lang}" data-status="0"><span class="icon icon16 icon-fullscreen"></span><span class="invisible">{lang}chat.general.fullscreen{/lang}</span></a></li>{*
*}<li><a id="timsChatNotify" accesskey="n" class="button timsChatToggle jsTooltip" title="{lang}chat.general.notify{/lang}" data-status="0"><span class="icon icon16 icon-bell-alt"></span><span class="invisible">{lang}chat.general.notify{/lang}</span></a></li>{* *}<li><a id="timsChatNotify" accesskey="n" class="button timsChatToggle jsTooltip" title="{lang}chat.general.notify{/lang}" data-status="0"><span class="icon icon16 icon-bell-alt"></span><span class="invisible">{lang}chat.general.notify{/lang}</span></a></li>{*
*}<li{if !MODULE_SMILEY || !$smileyCategories|count} style="display: none;"{/if}><a id="timsChatSmilies" accesskey="e" class="button{if ENABLE_SMILIES_DEFAULT_VALUE} active{/if} timsChatToggle jsTooltip" title="{lang}chat.general.smilies{/lang}" data-status="{@ENABLE_SMILIES_DEFAULT_VALUE}"><span class="icon icon16 icon-smile"></span><span class="invisible">{lang}chat.general.smilies{/lang}</span></a></li>{* *}<li{if !MODULE_SMILEY || !$smileyCategories|count} style="display: none;"{/if}><a id="timsChatSmilies" accesskey="e" class="button{if ENABLE_SMILIES_DEFAULT_VALUE} active{/if} timsChatToggle jsTooltip" title="{lang}chat.general.smilies{/lang}" data-status="{@ENABLE_SMILIES_DEFAULT_VALUE}"><span class="icon icon16 icon-smile"></span><span class="invisible">{lang}chat.general.smilies{/lang}</span></a></li>{*
*}{if MODULE_ATTACHMENT && $__wcf->session->getPermission('user.chat.canUploadAttachment')}{* *}{if MODULE_ATTACHMENT && $__wcf->session->getPermission('user.chat.canUploadAttachment')}{*
*}<li id="timsChatUploadContainer" class="dropdown" data-max-size="{$attachmentHandler->getMaxSize()}"> *}<li id="timsChatUploadContainer" class="dropdown" data-max-size="{$attachmentHandler->getMaxSize()}">
<a id="timsChatUpload" class="dropdownToggle button jsTooltip" title="{lang}wcf.attachment.attachments{/lang}" data-toggle="timsChatUploadContainer"> <a id="timsChatUpload" class="dropdownToggle button jsTooltip" title="{lang}wcf.attachment.attachments{/lang}" data-toggle="timsChatUploadContainer">
<span class="icon icon16 icon-paper-clip"></span> <span class="icon icon16 icon-paper-clip"></span>
<span class="invisible">{lang}wcf.attachment.attachments{/lang}</span> <span class="invisible">{lang}wcf.attachment.attachments{/lang}</span>
</a> </a>
<ul id="timsChatUploadDropdownMenu" class="dropdownMenu"> <ul id="timsChatUploadDropdownMenu" class="dropdownMenu">
<li class="uploadButton" style="margin-top: 0;"> <li class="uploadButton" style="margin-top: 0;">
<span><label for="timsChatUploadInput">{lang}wcf.global.button.upload{/lang}</label></span> <span><label for="timsChatUploadInput">{lang}wcf.global.button.upload{/lang}</label></span>
</li>
</ul>
</li>{/if}{*
*}<li><a id="timsChatClear" class="button jsTooltip" title="{lang}chat.general.clear{/lang}"><span class="icon icon16 icon-remove"></span><span class="invisible">{lang}chat.general.clear{/lang}</span></a></li>{*
*}<li><a id="timsChatMark" class="button timsChatToggle jsTooltip" title="{lang}chat.general.mark{/lang}" data-status="0"><span class="icon icon16 icon-check"></span><span class="invisible">{lang}chat.general.mark{/lang}</span></a></li>
</ul>
</nav>
{else}
{include file='header' sandbox=false}
<header class="boxHeadline">
<h1>{lang}chat.general.title{/lang}</h1>
</header>
<div class="container marginTop">
<ul class="containerList">
{foreach from=$rooms item='room'}
{assign var='users' value=$room->getUsers()}
<li>
<div>
<div>
<div class="containerHeadline">
<h3><a href="{link application='chat' controller='Chat' object=$room}{/link}">{$room}</a> <span class="badge">{#$users|count}</span></h3>
<p>{$room->topic|language}</p>
</div>
<ul class="dataList">
{foreach from=$users item='user'}
<li><a href="{link controller='User' object=$user}{/link}" class="userLink" data-user-id="{$user->userID}">{$user}</a></li>
{/foreach}
</ul>
</div>
</div>
</li> </li>
</ul> {/foreach}
</li>{/if}{* </ul>
</div>
*}<li><a id="timsChatClear" class="button jsTooltip" title="{lang}chat.general.clear{/lang}"><span class="icon icon16 icon-remove"></span><span class="invisible">{lang}chat.general.clear{/lang}</span></a></li>{* {/if}
*}<li><a id="timsChatMark" class="button timsChatToggle jsTooltip" title="{lang}chat.general.mark{/lang}" data-status="0"><span class="icon icon16 icon-check"></span><span class="invisible">{lang}chat.general.mark{/lang}</span></a></li>
</ul>
</nav>
{include file='footer' sandbox=false} {include file='footer' sandbox=false}
</body> </body>