diff --git a/.travis.yml b/.travis.yml index ad945ca..f0fe46d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.5 - - 5.4 + - 5.6 - 5.3 before_install: - pear config-set auto_discover 1 @@ -17,4 +16,4 @@ before_script: script: - find file -type f -name '*.php' |xargs -I file php -l file - phpcs -p --extensions=php --standard="`pwd`/WCF/CodeSniff/WCF" file - - phpcpd --verbose --min-lines 10 file ; exit 0 \ No newline at end of file + - phpcpd --verbose --min-lines 10 file || true diff --git a/acptemplate/__messageLogTable.tpl b/acptemplate/__messageLogTable.tpl index 157f124..821cbb6 100644 --- a/acptemplate/__messageLogTable.tpl +++ b/acptemplate/__messageLogTable.tpl @@ -13,7 +13,7 @@ {foreach from=$messages item="message"} {$message->messageID} - {$message->time|date:"H:i:s"} + {$message->time|date:"chat.global.timeFormat"}

{@$message->getUserProfile()->getAvatar()->getImageTag(24)}

{$message->username} {@$message->getFormattedMessage("text/simplified-html")} diff --git a/acptemplate/messageLogDownload.tpl b/acptemplate/messageLogDownload.tpl index cbfa157..dd12fcc 100644 --- a/acptemplate/messageLogDownload.tpl +++ b/acptemplate/messageLogDownload.tpl @@ -1,5 +1,5 @@ {foreach from=$messages item=$rawMessage}{* *}{assign var=message value=$rawMessage->jsonify(true)}{* - *}({$message['time']|date:'H:i:s'}) {$message[username]|str_pad:15:' ':STR_PAD_LEFT}{$message[separator]} {$message[message]} + *}({$message['time']|date:'chat.global.timeFormat'}) {$message[username]|str_pad:15:' ':STR_PAD_LEFT}{$message[separator]} {$message[message]} {/foreach} diff --git a/file/lib/acp/page/MessageLogDownloadPage.class.php b/file/lib/acp/page/MessageLogDownloadPage.class.php index e96bd60..a8360c3 100644 --- a/file/lib/acp/page/MessageLogDownloadPage.class.php +++ b/file/lib/acp/page/MessageLogDownloadPage.class.php @@ -43,9 +43,9 @@ class MessageLogDownloadPage extends \wcf\page\AbstractPage { /** * given date * - * @var integer + * @var \DateTime */ - public $date = 0; + public $date = null; /** * active room @@ -69,11 +69,13 @@ class MessageLogDownloadPage extends \wcf\page\AbstractPage { public function readData() { parent::readData(); - if ($this->date > TIME_NOW) { + $now = new \DateTime('now', WCF::getUser()->getTimeZone()); + if ($this->date->getTimestamp() > $now->getTimestamp()) { throw new \wcf\system\exception\IllegalLinkException(); } - if (CHAT_LOG_ARCHIVETIME !== -1 && $this->date < strtotime('today 00:00:00 -'.ceil(CHAT_LOG_ARCHIVETIME / 1440).'day')) { + $oldest = new \DateTime('today -'.ceil(CHAT_LOG_ARCHIVETIME / 1440).'day', WCF::getUser()->getTimeZone()); + if (CHAT_LOG_ARCHIVETIME !== -1 && $this->date->getTimestamp() < $oldest->getTimestamp()) { throw new \wcf\system\exception\IllegalLinkException(); } @@ -85,7 +87,7 @@ public function readData() { $file = new \wcf\system\io\File($this->tmpFile); $file->write(WCF::getLanguage()->get('chat.acp.log.title') . ': ' . (string) $this->room . "\n"); - for ($start = $this->date, $end = $start + 86399; $start < $end; $start += 1800) { + for ($start = $this->date->getTimestamp(), $end = $this->date->add(\DateInterval::createFromDateString('1day'))->sub(\DateInterval::createFromDateString('1second'))->getTimestamp(); $start < $end; $start += 1800) { $file->write(WCF::getTpl()->fetch('messageLogDownload', 'chat', array('messages' => \chat\data\message\MessageList::getMessagesBetween($this->room, $start, $start + 1799)))); } @@ -117,8 +119,12 @@ public function readParameters() { if (isset($_REQUEST['date'])) $date = $_REQUEST['date'].' 00:00:00'; else $date = 'today 00:00:00'; - $this->date = @strtotime($date); - if ($this->date === false) throw new \wcf\system\exception\IllegalLinkException(); + try { + $this->date = new \DateTime($date, WCF::getUser()->getTimeZone()); + } + catch (\Exception $e) { + throw new \wcf\system\exception\IllegalLinkException(); + } } /** @@ -127,9 +133,7 @@ public function readParameters() { public function show() { parent::show(); - $dateTime = \wcf\util\DateUtil::getDateTimeByTimestamp($this->date); - - $fileReader = new \wcf\util\FileReader($this->tmpFile, array('mimeType' => 'text/plain', 'filename' => str_replace(' ', '-', WCF::getLanguage()->get('chat.acp.log.title') . ' ' . $this->room.'-'.\wcf\util\DateUtil::format($dateTime, 'Y-m-d').'.txt'))); + $fileReader = new \wcf\util\FileReader($this->tmpFile, array('mimeType' => 'text/plain', 'filename' => str_replace(' ', '-', WCF::getLanguage()->get('chat.acp.log.title') . ' ' . $this->room.'-'.\wcf\util\DateUtil::format($this->date, 'Y-m-d').'.txt'))); $fileReader->send(); exit; diff --git a/file/lib/data/message/Message.class.php b/file/lib/data/message/Message.class.php index f97f794..ccceb0c 100644 --- a/file/lib/data/message/Message.class.php +++ b/file/lib/data/message/Message.class.php @@ -153,10 +153,12 @@ public function jsonify($raw = false) { break; } + $time = \wcf\util\DateUtil::getDateTimeByTimestamp($this->time); + $startOfDay = new \DateTime('today', WCF::getUser()->getTimezone()); $array = array( 'formattedUsername' => $this->getUsername(true), 'formattedMessage' => $this->getFormattedMessage('text/html'), - 'formattedTime' => \wcf\util\DateUtil::format(\wcf\util\DateUtil::getDateTimeByTimestamp($this->time), 'H:i:s'), + 'formattedTime' => ($time->getTimestamp() < $startOfDay->getTimestamp() ? \wcf\util\DateUtil::format($time, 'chat.global.dateFormat').' ' : '').\wcf\util\DateUtil::format($time, 'chat.global.timeFormat'), 'separator' => $separator, 'message' => $this->getFormattedMessage('text/plain'), 'sender' => (int) $this->sender, diff --git a/file/lib/data/room/RoomAction.class.php b/file/lib/data/room/RoomAction.class.php index d89f81d..8ba22aa 100644 --- a/file/lib/data/room/RoomAction.class.php +++ b/file/lib/data/room/RoomAction.class.php @@ -69,16 +69,12 @@ public function prune() { WHERE permanent = ? AND roomID NOT IN ( - SELECT - fieldValue AS roomID - FROM - wcf".WCF_N."_user_storage - WHERE - field = ? - AND fieldValue IS NOT NULL - )"; + SELECT chatRoomID + FROM wcf".WCF_N."_user + WHERE chatRoomID IS NOT NULL + )"; $stmt = \wcf\system\WCF::getDB()->prepareStatement($sql); - $stmt->execute(array(0, 'roomID')); + $stmt->execute(array(0)); $objectIDs = array(); while ($objectID = $stmt->fetchColumn()) $objectIDs[] = $objectID; diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php index bb56a09..d42fb9a 100644 --- a/file/lib/page/ChatPage.class.php +++ b/file/lib/page/ChatPage.class.php @@ -134,7 +134,7 @@ public function readData() { } if (MODULE_ATTACHMENT) { - $this->attachmentHandler = new \wcf\system\attachment\AttachmentHandler('be.bastelstu.chat.message', 0, '', 0); + $this->attachmentHandler = new \wcf\system\attachment\AttachmentHandler('be.bastelstu.chat.message', 0, \wcf\util\StringUtil::getRandomID(), 0); } } diff --git a/file/lib/system/dashboard/box/OnlineListDashboardBox.class.php b/file/lib/system/dashboard/box/OnlineListDashboardBox.class.php index 4af020c..a7b387d 100644 --- a/file/lib/system/dashboard/box/OnlineListDashboardBox.class.php +++ b/file/lib/system/dashboard/box/OnlineListDashboardBox.class.php @@ -38,6 +38,9 @@ public function init(\wcf\data\dashboard\box\DashboardBox $box, \wcf\page\IPage * @see wcf\system\dashboard\box\AbstractContentDashboardBox::render() */ protected function render() { + if (!MODULE_CHAT) return false; + if (!\wcf\system\WCF::getUser()->userID) return false; + \wcf\system\WCF::getTPL()->assign(array( 'rooms' => $this->rooms )); diff --git a/file/lib/util/ChatUtil.class.php b/file/lib/util/ChatUtil.class.php index b9c1f2f..06c50a5 100644 --- a/file/lib/util/ChatUtil.class.php +++ b/file/lib/util/ChatUtil.class.php @@ -1,7 +1,6 @@ + + + diff --git a/language/en.xml b/language/en.xml index 6dde73c..144ffe2 100644 --- a/language/en.xml +++ b/language/en.xml @@ -198,6 +198,9 @@ Please try to reload the chat.]]> + + +