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
{if MODULE_SMILEY}WCF.TabMenu.init();{/if} // Boot the chat
{if MODULE_ATTACHMENT && $__wcf->session->getPermission('user.chat.canUploadAttachment')} {if MODULE_SMILEY}WCF.TabMenu.init();{/if}
new be.bastelstu.Chat.Attachment(); {if MODULE_ATTACHMENT && $__wcf->session->getPermission('user.chat.canUploadAttachment')}
new be.bastelstu.Chat.Action.Delete('wcf\\data\\attachment\\AttachmentAction', '#timsChatUploadDropdownMenu > li'); new be.bastelstu.Chat.Attachment();
{/if} new be.bastelstu.Chat.Action.Delete('wcf\\data\\attachment\\AttachmentAction', '#timsChatUploadDropdownMenu > li');
new WCF.Message.Smilies(); {/if}
new WCF.Message.Smilies();
{capture assign='messageTemplate'}{include application='chat' file='message'}{/capture}
{capture assign='userTemplate'}{include application='chat' file='userListUser'}{/capture} {capture assign='messageTemplate'}{include application='chat' file='message'}{/capture}
{capture assign='userTemplate'}{include application='chat' file='userListUser'}{/capture}
var config = {
reloadTime: {@CHAT_RELOADTIME}, var config = {
messageURL: '{link application="chat" controller="NewMessages"}{/link}', reloadTime: {@CHAT_RELOADTIME},
installedCommands: [ {implode from=$commands item='command'}'{$command|encodeJS}'{/implode} ], messageURL: '{link application="chat" controller="NewMessages"}{/link}',
messageTypes: { {implode from=$messageTypes key='name' item='messageType'}'{$name|substr:5|encodeJS}': '{$messageType|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} }
};
{event name='beforeInit'}
{event name='beforeInit'}
be.bastelstu.Chat.init(
{$roomID}, be.bastelstu.Chat.init(
config, {$roomID},
new WCF.Template('{literal}{if $newMessageCount}({#$newMessageCount}) {/if}{$title} - {/literal}{"chat.general.title"|language|encodeJS} - {PAGE_TITLE|language|encodeJS}'), config,
new WCF.Template('{@$messageTemplate|encodeJS}'), new WCF.Template('{literal}{if $newMessageCount}({#$newMessageCount}) {/if}{$title} - {/literal}{"chat.general.title"|language|encodeJS} - {PAGE_TITLE|language|encodeJS}'),
new WCF.Template('{@$userTemplate|encodeJS}') new WCF.Template('{@$messageTemplate|encodeJS}'),
); new WCF.Template('{@$userTemplate|encodeJS}')
);
{event name='afterInit'}
{event name='afterInit'}
$('#timsChatCopyright').click(function (event) {
event.preventDefault(); $('#timsChatCopyright').click(function (event) {
if (!$.wcfIsset('timsChatCopyrightDialog')) $('<div id="timsChatCopyrightDialog"></div>').appendTo('body'); event.preventDefault();
$('#timsChatCopyrightDialog').load('{link application="chat" controller="Copyright"}{/link}').wcfDialog({ if (!$.wcfIsset('timsChatCopyrightDialog')) $('<div id="timsChatCopyrightDialog"></div>').appendTo('body');
title: '<img width="246" height="90" alt="" src="{$__wcf->getPath("chat")|encodeJS}images/chatLogo.png"> {if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}' $('#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}'
});
}); });
}); });
}); })(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}">
<span class="icon icon16 icon-remove jsTopicCloser jsTooltip" title="{lang}chat.general.closeTopic{/lang}"></span>
<span class="topic">{$room->topic|language}</span>
</div>
<div id="privateChannelsMenu">
<ul>
<li id="privateChannel0" class="privateChannel active" data-private-channel-id="0">
<span class="userAvatar framed small">
<span class="icon icon16 icon-comment-alt jsTooltip" title="{lang}chat.general.room{/lang}"></span>
</span>
<span class="userAvatar framed large">
<span class="icon icon32 icon-comment-alt jsTooltip" title="{lang}chat.general.room{/lang}"></span>
</span>
</li>
</ul>
</div>
<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>
<ul>
</ul>
</div>
<form id="timsChatForm" action="{link application='chat' controller='Chat' action='Send'}{/link}" method="post">
<fieldset>
<dl class="wide" id="timsChatInputContainer">
<dt>
{lang}chat.general.message{/lang}
</dt>
<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}" />
<small class="innerError" style="display: none;">Lorem ipsum dolor sit amet.</small>
</dd>
</dl>
</fieldset>
<button type="submit" class="invisible" accesskey="s"></button>
</form>
<div id="timsChatTopic" class="marginTop container{if $room->topic|language === ''} empty{/if}"> {if MODULE_SMILEY && $smileyCategories|count}
<span class="icon icon16 icon-remove jsTopicCloser jsTooltip" title="{lang}chat.general.closeTopic{/lang}"></span> {include file='messageFormSmilies' wysiwygSelector=''}
<span class="topic">{$room->topic|language}</span> {/if}
</div>
<nav id="timsChatOptions" class="marginTop jsMobileNavigation buttonGroupNavigation">
<div id="privateChannelsMenu"> <span class="invisible">{lang}chat.general.controls{/lang}</span>
<ul> <ul class="smallButtons buttonGroup">
<li id="privateChannel0" class="privateChannel active" data-private-channel-id="0"> <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>{*
<span class="userAvatar framed small">
<span class="icon icon16 icon-comment-alt jsTooltip" title="{lang}chat.general.room{/lang}"></span> *}<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>{*
</span>
<span class="userAvatar framed large"> *}<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>{*
<span class="icon icon32 icon-comment-alt jsTooltip" title="{lang}chat.general.room{/lang}"></span>
</span> *}<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>
</ul> *}{if MODULE_ATTACHMENT && $__wcf->session->getPermission('user.chat.canUploadAttachment')}{*
</div> *}<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">
<div id="timsChatMessageContainer0" class="timsChatMessageContainer marginTop container active" data-user-id="0"> <span class="icon icon16 icon-paper-clip"></span>
<p class="error noJsOnly" style="display: none;">{lang}chat.general.noJs{/lang}</p> <span class="invisible">{lang}wcf.attachment.attachments{/lang}</span>
<ul> </a>
</ul> <ul id="timsChatUploadDropdownMenu" class="dropdownMenu">
</div> <li class="uploadButton" style="margin-top: 0;">
<span><label for="timsChatUploadInput">{lang}wcf.global.button.upload{/lang}</label></span>
<form id="timsChatForm" action="{link application='chat' controller='Chat' action='Send'}{/link}" method="post"> </li>
<fieldset> </ul>
<dl class="wide" id="timsChatInputContainer"> </li>{/if}{*
<dt>
{lang}chat.general.message{/lang} *}<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>{*
</dt>
<dd> *}<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>
<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}" /> </ul>
<small class="innerError" style="display: none;">Lorem ipsum dolor sit amet.</small> </nav>
</dd> {else}
</dl> {include file='header' sandbox=false}
</fieldset> <header class="boxHeadline">
<button type="submit" class="invisible" accesskey="s"></button> <h1>{lang}chat.general.title{/lang}</h1>
</form> </header>
{if MODULE_SMILEY && $smileyCategories|count} <div class="container marginTop">
{include file='messageFormSmilies' wysiwygSelector=''} <ul class="containerList">
{/if} {foreach from=$rooms item='room'}
{assign var='users' value=$room->getUsers()}
<nav id="timsChatOptions" class="marginTop jsMobileNavigation buttonGroupNavigation">
<span class="invisible">{lang}chat.general.controls{/lang}</span> <li>
<ul class="smallButtons buttonGroup"> <div>
<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>{* <div>
<div class="containerHeadline">
*}<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>{* <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>
*}<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>{* </div>
*}<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>{* <ul class="dataList">
{foreach from=$users item='user'}
*}{if MODULE_ATTACHMENT && $__wcf->session->getPermission('user.chat.canUploadAttachment')}{* <li><a href="{link controller='User' object=$user}{/link}" class="userLink" data-user-id="{$user->userID}">{$user}</a></li>
*}<li id="timsChatUploadContainer" class="dropdown" data-max-size="{$attachmentHandler->getMaxSize()}"> {/foreach}
<a id="timsChatUpload" class="dropdownToggle button jsTooltip" title="{lang}wcf.attachment.attachments{/lang}" data-toggle="timsChatUploadContainer"> </ul>
<span class="icon icon16 icon-paper-clip"></span> </div>
<span class="invisible">{lang}wcf.attachment.attachments{/lang}</span> </div>
</a>
<ul id="timsChatUploadDropdownMenu" class="dropdownMenu">
<li class="uploadButton" style="margin-top: 0;">
<span><label for="timsChatUploadInput">{lang}wcf.global.button.upload{/lang}</label></span>
</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>