From 92d2be2b289a4d7dd2f529017967b2e7f1e7ebcc Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Tue, 4 Jun 2013 22:54:11 +0200 Subject: [PATCH 01/33] Add suspension list to ACP [WIP] --- acptemplate/suspensionList.tpl | 47 ++++++++++++++++ .../lib/acp/page/SuspensionListPage.class.php | 56 +++++++++++++++++++ .../data/suspension/SuspensionList.class.php | 9 +++ 3 files changed, 112 insertions(+) create mode 100644 acptemplate/suspensionList.tpl create mode 100644 file/lib/acp/page/SuspensionListPage.class.php create mode 100644 file/lib/data/suspension/SuspensionList.class.php diff --git a/acptemplate/suspensionList.tpl b/acptemplate/suspensionList.tpl new file mode 100644 index 0000000..8eaace1 --- /dev/null +++ b/acptemplate/suspensionList.tpl @@ -0,0 +1,47 @@ +{include file='header' pageTitle='chat.acp.suspension.list'} + +
+

{lang}chat.acp.suspension.list{/lang}

+
+ +{if $objects|count} +
+
+

{lang}wcf.acp.suspension.list{/lang} {#$items}

+
+ + + + + + + + + + + + + + + + + {foreach from=$objects item=$suspension} + + + + + + + + + {/foreach} + +
{lang}wcf.global.objectID{/lang}{lang}wcf.acp.chat.userID{/lang}{lang}wcf.acp.chat.username{/lang}{lang}wcf.acp.chat.roomID{/lang}{lang}wcf.acp.chat.type{/lang}{lang}wcf.acp.chat.expires{/lang}
{@$suspension->suspensionID}{@$suspension->userID}{@$suspension->username}{@$suspension->roomID}{@$suspension->type}{@$suspension->expires|date}
+ +
+{/if} + + +{include file='footer'} diff --git a/file/lib/acp/page/SuspensionListPage.class.php b/file/lib/acp/page/SuspensionListPage.class.php new file mode 100644 index 0000000..8e1f64b --- /dev/null +++ b/file/lib/acp/page/SuspensionListPage.class.php @@ -0,0 +1,56 @@ + + * @package be.bastelstu.chat + * @subpackage acp.page + */ +class SuspensionListPage extends \wcf\page\SortablePage { + /** + * @see \wcf\page\AbstractPage::$activeMenuItem + */ + public $activeMenuItem = 'chat.acp.menu.link.suspension.list'; + + /** + * @see \wcf\page\AbstractPage::$neededPermissions + */ + public $neededPermissions = array(); + + /** + * @see wcf\page\SortablePage::$defaultSortField + */ + public $defaultSortField = 'username'; + + /** + * @see wcf\page\MultipleLinkPage::$itemsPerPage + */ + public $itemsPerPage = 50; + + /** + * @see wcf\page\SortablePage::$validSortFields + */ + public $validSortFields = array('suspensionID', 'userID', 'username', 'roomID', 'type', 'expires'); + + /** + * @see wcf\page\MultipleLinkPage::$objectListClassName + */ + public $objectListClassName = 'chat\data\suspension\SuspensionList'; + + /** + * @see wcf\page\MultipleLinkPage::readObjects() + */ + protected function initObjectList() { + parent::initObjectList(); + + $this->objectList->sqlSelects .= "user.username"; + $this->objectList->sqlJoins .= "LEFT JOIN + wcf".WCF_N."_user AS user + ON suspension.userID = user.userID"; + } +} diff --git a/file/lib/data/suspension/SuspensionList.class.php b/file/lib/data/suspension/SuspensionList.class.php new file mode 100644 index 0000000..9a87032 --- /dev/null +++ b/file/lib/data/suspension/SuspensionList.class.php @@ -0,0 +1,9 @@ + Date: Tue, 4 Jun 2013 23:39:42 +0200 Subject: [PATCH 02/33] Improve template of suspensionList and add condition --- acptemplate/suspensionList.tpl | 21 +++++++------------ .../lib/acp/page/SuspensionListPage.class.php | 8 +++---- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/acptemplate/suspensionList.tpl b/acptemplate/suspensionList.tpl index 8eaace1..4732fe6 100644 --- a/acptemplate/suspensionList.tpl +++ b/acptemplate/suspensionList.tpl @@ -10,17 +10,12 @@

{lang}wcf.acp.suspension.list{/lang} {#$items}

- - - - - + + @@ -30,17 +25,17 @@ {foreach from=$objects item=$suspension} - - - - - + + + + {/foreach}
{lang}wcf.global.objectID{/lang}{lang}wcf.acp.chat.userID{/lang}{lang}wcf.acp.chat.username{/lang}{lang}wcf.acp.chat.roomID{/lang}{lang}wcf.user.username{/lang}{lang}chat.general.room{/lang} {lang}wcf.acp.chat.type{/lang} {lang}wcf.acp.chat.expires{/lang}
{@$suspension->suspensionID}{@$suspension->userID}{@$suspension->username}{@$suspension->roomID}{@$suspension->type}{@$suspension->expires|date}{$suspension->username}{if $suspension->roomID}{@$suspension->roomID}{else}{lang}chat.room.global{/lang}{/if}{lang}chat.suspension.{@$suspension->type}{/lang}{@$suspension->expires|time} ({@$suspension->expires|dateDiff})
- +{else} +

{lang}chat.acp.suspension.noItems{/lang}

{/if} diff --git a/file/lib/acp/page/SuspensionListPage.class.php b/file/lib/acp/page/SuspensionListPage.class.php index 8e1f64b..11c59d1 100644 --- a/file/lib/acp/page/SuspensionListPage.class.php +++ b/file/lib/acp/page/SuspensionListPage.class.php @@ -48,9 +48,9 @@ class SuspensionListPage extends \wcf\page\SortablePage { protected function initObjectList() { parent::initObjectList(); - $this->objectList->sqlSelects .= "user.username"; - $this->objectList->sqlJoins .= "LEFT JOIN - wcf".WCF_N."_user AS user - ON suspension.userID = user.userID"; + $this->objectList->sqlSelects .= "user_table.username"; + $this->objectList->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table + ON suspension.userID = user_table.userID"; + $this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW)); } } From c224333b10dee12e5af708fcc299f3e6643ec404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 6 Jun 2013 16:46:27 +0200 Subject: [PATCH 03/33] Add filter to suspensionList --- acptemplate/suspensionList.tpl | 18 ++--- .../lib/acp/page/SuspensionListPage.class.php | 72 ++++++++++++++++--- 2 files changed, 70 insertions(+), 20 deletions(-) diff --git a/acptemplate/suspensionList.tpl b/acptemplate/suspensionList.tpl index 4732fe6..fa559e7 100644 --- a/acptemplate/suspensionList.tpl +++ b/acptemplate/suspensionList.tpl @@ -13,11 +13,11 @@ - - - - - + + + + + @@ -25,9 +25,9 @@ {foreach from=$objects item=$suspension} - - - + + + {/foreach} @@ -35,7 +35,7 @@
{lang}wcf.global.objectID{/lang}{lang}wcf.user.username{/lang}{lang}chat.general.room{/lang}{lang}wcf.acp.chat.type{/lang}{lang}wcf.acp.chat.expires{/lang}{lang}wcf.global.objectID{/lang}{lang}wcf.user.username{/lang}{lang}chat.general.room{/lang}{lang}wcf.acp.chat.type{/lang}{lang}wcf.acp.chat.expires{/lang}
{@$suspension->suspensionID}{$suspension->username}{if $suspension->roomID}{@$suspension->roomID}{else}{lang}chat.room.global{/lang}{/if}{lang}chat.suspension.{@$suspension->type}{/lang}{$suspension->username}{if $suspension->roomID}{@$suspension->roomTitle|language}{else}{lang}chat.room.global{/lang}{/if}{lang}chat.suspension.{@$suspension->type}{/lang} {@$suspension->expires|time} ({@$suspension->expires|dateDiff})
{else} -

{lang}chat.acp.suspension.noItems{/lang}

+

{lang}chat.acp.suspension.noItems{/lang}

{/if} diff --git a/file/lib/acp/page/SuspensionListPage.class.php b/file/lib/acp/page/SuspensionListPage.class.php index 11c59d1..e00161d 100644 --- a/file/lib/acp/page/SuspensionListPage.class.php +++ b/file/lib/acp/page/SuspensionListPage.class.php @@ -6,12 +6,12 @@ * Lists chat suspensions. * * @author Maximilian Mader - * @copyright 2010-2013 Tim Düsterhus + * @copyright 2010-2013 Tim DĂĽsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package be.bastelstu.chat * @subpackage acp.page */ -class SuspensionListPage extends \wcf\page\SortablePage { +class ChatSuspensionListPage extends \wcf\page\SortablePage { /** * @see \wcf\page\AbstractPage::$activeMenuItem */ @@ -20,37 +20,87 @@ class SuspensionListPage extends \wcf\page\SortablePage { /** * @see \wcf\page\AbstractPage::$neededPermissions */ + // TODO: Permissions public $neededPermissions = array(); /** - * @see wcf\page\SortablePage::$defaultSortField + * @see \wcf\page\SortablePage::$defaultSortField */ - public $defaultSortField = 'username'; + public $defaultSortField = 'expires'; /** - * @see wcf\page\MultipleLinkPage::$itemsPerPage + * @see \wcf\page\MultipleLinkPage::$itemsPerPage */ - public $itemsPerPage = 50; + public $itemsPerPage = 30; /** - * @see wcf\page\SortablePage::$validSortFields + * @see \wcf\page\SortablePage::$validSortFields */ public $validSortFields = array('suspensionID', 'userID', 'username', 'roomID', 'type', 'expires'); /** - * @see wcf\page\MultipleLinkPage::$objectListClassName + * @see \wcf\page\MultipleLinkPage::$objectListClassName */ public $objectListClassName = 'chat\data\suspension\SuspensionList'; /** - * @see wcf\page\MultipleLinkPage::readObjects() + * type filter + * + * @var integer + */ + public $filterType = null; + + /** + * user filter + * + * @var integer + */ + public $filterUserID = null; + + /** + * room filter + * + * @var integer + */ + public $filterRoomID = null; + + /** + * @see \wcf\page\IPage::readParameters() + */ + public function readParameters() { + parent::readParameters(); + + if (isset($_REQUEST['type'])) $this->filterType = intval($_REQUEST['type']); + if (isset($_REQUEST['userID'])) $this->filterUserID = intval($_REQUEST['userID']); + if (isset($_REQUEST['roomID'])) $this->filterRoomID = intval($_REQUEST['roomID']); + } + + /** + * @see \wcf\page\MultipleLinkPage::readObjects() */ protected function initObjectList() { parent::initObjectList(); - $this->objectList->sqlSelects .= "user_table.username"; - $this->objectList->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table + $this->objectList->sqlSelects .= "user_table.username, room_table.title AS roomTitle"; + $this->objectList->sqlJoins .= " + LEFT JOIN wcf".WCF_N."_user user_table ON suspension.userID = user_table.userID"; + $conditionJoins = " LEFT JOIN chat".WCF_N."_room room_table + ON suspension.roomID = room_table.roomID"; + $this->objectList->sqlConditionJoins .= $conditionJoins; + $this->objectList->sqlJoins .= $conditionJoins; + $this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW)); + $this->objectList->getConditionBuilder()->add('room_table.permanent = ?', array(1)); + if ($this->filterType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterType)); + if ($this->filterUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.userID = ?', array($this->filterUserID)); + if ($this->filterRoomID !== null) { + if ($this->filterRoomID === 0) { + $this->objectList->getConditionBuilder()->add('suspension.roomID IS NULL', array()); + } + else { + $this->objectList->getConditionBuilder()->add('suspension.roomID = ?', array($this->filterRoomID)); + } + } } } From 2a31c615104d4c9b786c2432dced865abf3b0baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 6 Jun 2013 16:56:13 +0200 Subject: [PATCH 04/33] Fix CodeSniff complains --- ...lass.php => ChatSuspensionListPage.class.php} | 16 ++++++++-------- .../lib/data/suspension/SuspensionList.class.php | 13 +++++++++++-- 2 files changed, 19 insertions(+), 10 deletions(-) rename file/lib/acp/page/{SuspensionListPage.class.php => ChatSuspensionListPage.class.php} (92%) diff --git a/file/lib/acp/page/SuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php similarity index 92% rename from file/lib/acp/page/SuspensionListPage.class.php rename to file/lib/acp/page/ChatSuspensionListPage.class.php index e00161d..4dbe385 100644 --- a/file/lib/acp/page/SuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -24,23 +24,23 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { public $neededPermissions = array(); /** - * @see \wcf\page\SortablePage::$defaultSortField - */ + * @see \wcf\page\SortablePage::$defaultSortField + */ public $defaultSortField = 'expires'; /** - * @see \wcf\page\MultipleLinkPage::$itemsPerPage - */ + * @see \wcf\page\MultipleLinkPage::$itemsPerPage + */ public $itemsPerPage = 30; /** - * @see \wcf\page\SortablePage::$validSortFields - */ + * @see \wcf\page\SortablePage::$validSortFields + */ public $validSortFields = array('suspensionID', 'userID', 'username', 'roomID', 'type', 'expires'); /** - * @see \wcf\page\MultipleLinkPage::$objectListClassName - */ + * @see \wcf\page\MultipleLinkPage::$objectListClassName + */ public $objectListClassName = 'chat\data\suspension\SuspensionList'; /** diff --git a/file/lib/data/suspension/SuspensionList.class.php b/file/lib/data/suspension/SuspensionList.class.php index 9a87032..b08cc22 100644 --- a/file/lib/data/suspension/SuspensionList.class.php +++ b/file/lib/data/suspension/SuspensionList.class.php @@ -1,9 +1,18 @@ + * @package be.bastelstu.chat + * @subpackage data.suspension + */ class SuspensionList extends \wcf\data\DatabaseObjectList { /** - * @see wcf\data\DatabaseObjectList::$className - */ + * @see wcf\data\DatabaseObjectList::$className + */ public $className = 'chat\data\suspension\Suspension'; } \ No newline at end of file From c6ffaf4fd748375ba99c095f1a8fe21434ed9308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 6 Jun 2013 21:51:25 +0300 Subject: [PATCH 05/33] Fix selecting of global suspensions --- file/lib/acp/page/ChatSuspensionListPage.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file/lib/acp/page/ChatSuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php index 4dbe385..4c3ec47 100644 --- a/file/lib/acp/page/ChatSuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -91,7 +91,7 @@ protected function initObjectList() { $this->objectList->sqlJoins .= $conditionJoins; $this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW)); - $this->objectList->getConditionBuilder()->add('room_table.permanent = ?', array(1)); + $this->objectList->getConditionBuilder()->add('(room_table.permanent = ? OR suspension.roomID IS NULL)', array(1)); if ($this->filterType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterType)); if ($this->filterUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.userID = ?', array($this->filterUserID)); if ($this->filterRoomID !== null) { From c839d528ccba551a42a01e954cccff8c3aadb829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 8 Jun 2013 16:28:40 +0200 Subject: [PATCH 06/33] Save time and issuer of suspensions --- file/lib/system/command/commands/BanCommand.class.php | 4 +++- file/lib/system/command/commands/GbanCommand.class.php | 4 +++- file/lib/system/command/commands/GmuteCommand.class.php | 4 +++- file/lib/system/command/commands/MuteCommand.class.php | 4 +++- install.sql | 3 +++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/file/lib/system/command/commands/BanCommand.class.php b/file/lib/system/command/commands/BanCommand.class.php index 8840110..f090dfa 100644 --- a/file/lib/system/command/commands/BanCommand.class.php +++ b/file/lib/system/command/commands/BanCommand.class.php @@ -30,7 +30,9 @@ public function executeAction() { 'userID' => $this->user->userID, 'roomID' => WCF::getUser()->chatRoomID, 'type' => suspension\Suspension::TYPE_BAN, - 'expires' => $this->expires + 'expires' => $this->expires, + 'time' => TIME_NOW, + 'issuer' => WCF::getUser()->userID ) )); $this->suspensionAction->executeAction(); diff --git a/file/lib/system/command/commands/GbanCommand.class.php b/file/lib/system/command/commands/GbanCommand.class.php index 33e2fd1..9cd3593 100644 --- a/file/lib/system/command/commands/GbanCommand.class.php +++ b/file/lib/system/command/commands/GbanCommand.class.php @@ -32,7 +32,9 @@ public function executeAction() { 'userID' => $this->user->userID, 'roomID' => null, 'type' => suspension\Suspension::TYPE_BAN, - 'expires' => $this->expires + 'expires' => $this->expires, + 'time' => TIME_NOW, + 'issuer' => WCF::getUser()->userID ) )); $this->suspensionAction->executeAction(); diff --git a/file/lib/system/command/commands/GmuteCommand.class.php b/file/lib/system/command/commands/GmuteCommand.class.php index d9aa485..e54a768 100644 --- a/file/lib/system/command/commands/GmuteCommand.class.php +++ b/file/lib/system/command/commands/GmuteCommand.class.php @@ -32,7 +32,9 @@ public function executeAction() { 'userID' => $this->user->userID, 'roomID' => null, 'type' => suspension\Suspension::TYPE_MUTE, - 'expires' => $this->expires + 'expires' => $this->expires, + 'time' => TIME_NOW, + 'issuer' => WCF::getUser()->userID ) )); $this->suspensionAction->executeAction(); diff --git a/file/lib/system/command/commands/MuteCommand.class.php b/file/lib/system/command/commands/MuteCommand.class.php index f6df4be..2055fe4 100644 --- a/file/lib/system/command/commands/MuteCommand.class.php +++ b/file/lib/system/command/commands/MuteCommand.class.php @@ -62,7 +62,9 @@ public function executeAction() { 'userID' => $this->user->userID, 'roomID' => WCF::getUser()->chatRoomID, 'type' => suspension\Suspension::TYPE_MUTE, - 'expires' => $this->expires + 'expires' => $this->expires, + 'time' => TIME_NOW, + 'issuer' => WCF::getUser()->userID ) )); $this->suspensionAction->executeAction(); diff --git a/install.sql b/install.sql index 7b05374..21148c7 100644 --- a/install.sql +++ b/install.sql @@ -48,6 +48,8 @@ CREATE TABLE chat1_suspension ( roomID INT(10) DEFAULT NULL, type TINYINT(3) NOT NULL, expires INT(10) NOT NULL, + time INT(10) NOT NULL, + issuer INT(10) DEFAULT NULL, UNIQUE KEY suspension (userID, roomID, type), KEY (roomID), @@ -70,6 +72,7 @@ ALTER TABLE chat1_room ADD FOREIGN KEY (owner) REFERENCES wcf1_user (userID) ON ALTER TABLE chat1_suspension ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE CASCADE; ALTER TABLE chat1_suspension ADD FOREIGN KEY (roomID) REFERENCES chat1_room (roomID) ON DELETE CASCADE; +ALTER TABLE chat1_suspension ADD FOREIGN KEY (issuer) REFERENCES wcf1_user (userID) ON DELETE SET NULL; ALTER TABLE wcf1_user ADD FOREIGN KEY (chatRoomID) REFERENCES chat1_room (roomID) ON DELETE SET NULL; From d0ad4c9971bd3bbe025fe17561350e223f51eb37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 11 Jun 2013 01:02:08 +0200 Subject: [PATCH 07/33] Adapt to WoltLab/WCF@6e0ea1f0cd61872ecb5a2223dcc9d678fd5f3d39 --- acptemplate/suspensionList.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acptemplate/suspensionList.tpl b/acptemplate/suspensionList.tpl index fa559e7..a954cf5 100644 --- a/acptemplate/suspensionList.tpl +++ b/acptemplate/suspensionList.tpl @@ -35,7 +35,7 @@ {else} -

{lang}chat.acp.suspension.noItems{/lang}

+

{lang}wcf.global.noItems{/lang}

{/if} From 1b8801629b84a13c83f348230f8ea67c7338ceca Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Wed, 12 Jun 2013 22:49:25 +0200 Subject: [PATCH 08/33] Improve suspension list --- ...uspensionList.tpl => chatSuspensionList.tpl} | 6 +++++- .../acp/page/ChatSuspensionListPage.class.php | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) rename acptemplate/{suspensionList.tpl => chatSuspensionList.tpl} (75%) diff --git a/acptemplate/suspensionList.tpl b/acptemplate/chatSuspensionList.tpl similarity index 75% rename from acptemplate/suspensionList.tpl rename to acptemplate/chatSuspensionList.tpl index a954cf5..6b862b7 100644 --- a/acptemplate/suspensionList.tpl +++ b/acptemplate/chatSuspensionList.tpl @@ -17,7 +17,9 @@ {lang}wcf.user.username{/lang} {lang}chat.general.room{/lang} {lang}wcf.acp.chat.type{/lang} + {lang}wcf.acp.chat.time{/lang} {lang}wcf.acp.chat.expires{/lang} + {lang}wcf.acp.chat.issuer{/lang} @@ -28,7 +30,9 @@ {$suspension->username} {if $suspension->roomID}{@$suspension->roomTitle|language}{else}{lang}chat.room.global{/lang}{/if} {lang}chat.suspension.{@$suspension->type}{/lang} - {@$suspension->expires|time} ({@$suspension->expires|dateDiff}) + {@$suspension->time|plainTime} + {@$suspension->expires|plainTime} ({$suspension->expires|dateDiff}) + {$suspension->issuerUsername} {/foreach} diff --git a/file/lib/acp/page/ChatSuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php index 4c3ec47..5d5f122 100644 --- a/file/lib/acp/page/ChatSuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -36,7 +36,7 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { /** * @see \wcf\page\SortablePage::$validSortFields */ - public $validSortFields = array('suspensionID', 'userID', 'username', 'roomID', 'type', 'expires'); + public $validSortFields = array('suspensionID', 'userID', 'username', 'roomID', 'type', 'expires', 'issuer', 'time'); /** * @see \wcf\page\MultipleLinkPage::$objectListClassName @@ -57,6 +57,13 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { */ public $filterUserID = null; + /** + * issuer filter + * + * @var integer + */ + public $filterIssuerUserID = null; + /** * room filter * @@ -72,6 +79,7 @@ public function readParameters() { if (isset($_REQUEST['type'])) $this->filterType = intval($_REQUEST['type']); if (isset($_REQUEST['userID'])) $this->filterUserID = intval($_REQUEST['userID']); + if (isset($_REQUEST['issuerUserID'])) $this->filterIssuerUserID = intval($_REQUEST['issuerUserID']); if (isset($_REQUEST['roomID'])) $this->filterRoomID = intval($_REQUEST['roomID']); } @@ -81,10 +89,12 @@ public function readParameters() { protected function initObjectList() { parent::initObjectList(); - $this->objectList->sqlSelects .= "user_table.username, room_table.title AS roomTitle"; + $this->objectList->sqlSelects .= "user_table.username, user_table2.username as issuerUsername, room_table.title AS roomTitle"; $this->objectList->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table - ON suspension.userID = user_table.userID"; + ON suspension.userID = user_table.userID + LEFT JOIN wcf".WCF_N."_user user_table2 + ON suspension.issuer = user_table2.userID"; $conditionJoins = " LEFT JOIN chat".WCF_N."_room room_table ON suspension.roomID = room_table.roomID"; $this->objectList->sqlConditionJoins .= $conditionJoins; @@ -94,6 +104,7 @@ protected function initObjectList() { $this->objectList->getConditionBuilder()->add('(room_table.permanent = ? OR suspension.roomID IS NULL)', array(1)); if ($this->filterType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterType)); if ($this->filterUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.userID = ?', array($this->filterUserID)); + if ($this->filterIssuerUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.issuer = ?', array($this->filterIssuerUserID)); if ($this->filterRoomID !== null) { if ($this->filterRoomID === 0) { $this->objectList->getConditionBuilder()->add('suspension.roomID IS NULL', array()); From 7ae862c8089bda27ea2c8bc40f97093794d04402 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Wed, 12 Jun 2013 22:55:16 +0200 Subject: [PATCH 09/33] Satisfy CodeSniff --- file/lib/data/suspension/SuspensionList.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file/lib/data/suspension/SuspensionList.class.php b/file/lib/data/suspension/SuspensionList.class.php index b08cc22..ed72dd7 100644 --- a/file/lib/data/suspension/SuspensionList.class.php +++ b/file/lib/data/suspension/SuspensionList.class.php @@ -15,4 +15,4 @@ class SuspensionList extends \wcf\data\DatabaseObjectList { * @see wcf\data\DatabaseObjectList::$className */ public $className = 'chat\data\suspension\Suspension'; -} \ No newline at end of file +} From 2ec2b17a7f3b31aa456e9d1ca37a96c84a8ff393 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Sat, 15 Jun 2013 15:33:30 +0200 Subject: [PATCH 10/33] Add filter form to ChatSuspensionList --- acpMenu.xml | 7 ++ acptemplate/chatSuspensionList.tpl | 64 ++++++++++++++++++- .../acp/page/ChatSuspensionListPage.class.php | 48 ++++++++++++-- 3 files changed, 111 insertions(+), 8 deletions(-) diff --git a/acpMenu.xml b/acpMenu.xml index 7717827..4a6b342 100644 --- a/acpMenu.xml +++ b/acpMenu.xml @@ -22,5 +22,12 @@ admin.chat.canAddRoom 2 + + + + chat.acp.menu.link.chat + + 1 + diff --git a/acptemplate/chatSuspensionList.tpl b/acptemplate/chatSuspensionList.tpl index 6b862b7..8072a6c 100644 --- a/acptemplate/chatSuspensionList.tpl +++ b/acptemplate/chatSuspensionList.tpl @@ -1,9 +1,69 @@ {include file='header' pageTitle='chat.acp.suspension.list'} + +

{lang}chat.acp.suspension.list{/lang}

+
+
+
+ {lang}wcf.global.filter{/lang} + +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+
+
+ +
+ +
+
+ {if $objects|count}
@@ -16,7 +76,7 @@ {lang}wcf.global.objectID{/lang} {lang}wcf.user.username{/lang} {lang}chat.general.room{/lang} - {lang}wcf.acp.chat.type{/lang} + {lang}wcf.acp.chat.suspensionType{/lang} {lang}wcf.acp.chat.time{/lang} {lang}wcf.acp.chat.expires{/lang} {lang}wcf.acp.chat.issuer{/lang} @@ -29,7 +89,7 @@ {@$suspension->suspensionID} {$suspension->username} {if $suspension->roomID}{@$suspension->roomTitle|language}{else}{lang}chat.room.global{/lang}{/if} - {lang}chat.suspension.{@$suspension->type}{/lang} + {lang}chat.suspension.{@$suspension->type}{/lang} {@$suspension->time|plainTime} {@$suspension->expires|plainTime} ({$suspension->expires|dateDiff}) {$suspension->issuerUsername} diff --git a/file/lib/acp/page/ChatSuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php index 5d5f122..c1937e1 100644 --- a/file/lib/acp/page/ChatSuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -48,7 +48,7 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { * * @var integer */ - public $filterType = null; + public $filterSuspensionType = null; /** * user filter @@ -57,6 +57,13 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { */ public $filterUserID = null; + /* + * username + * + * @var String + */ + public $filterUsername = null; + /** * issuer filter * @@ -64,6 +71,13 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { */ public $filterIssuerUserID = null; + /* + * issuer username + * + * @var String + */ + public $filterIssuerUsername = null; + /** * room filter * @@ -77,10 +91,32 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { public function readParameters() { parent::readParameters(); - if (isset($_REQUEST['type'])) $this->filterType = intval($_REQUEST['type']); - if (isset($_REQUEST['userID'])) $this->filterUserID = intval($_REQUEST['userID']); - if (isset($_REQUEST['issuerUserID'])) $this->filterIssuerUserID = intval($_REQUEST['issuerUserID']); - if (isset($_REQUEST['roomID'])) $this->filterRoomID = intval($_REQUEST['roomID']); + if (isset($_REQUEST['username']) && !empty($_REQUEST['username'])) $this->filterUsername = \wcf\util\StringUtil::trim($_REQUEST['username']); + if (isset($_REQUEST['issuerUsername']) && !empty($_REQUEST['issuerUsername'])) $this->filterIssuerUsername = \wcf\util\StringUtil::trim($_REQUEST['issuerUsername']); + + if ($this->filterUsername != null) $this->filterUserID = \wcf\data\user\UserProfile::getUserProfileByUsername($this->filterUsername)->userID; + if ($this->filterIssuerUsername != null) $this->filterIssuerUserID = \wcf\data\user\UserProfile::getUserProfileByUsername($this->filterIssuerUsername)->userID; + + if ($this->filterUserID === null && isset($_REQUEST['userID']) && !empty($_REQUEST['userID'])) $this->filterUserID = intval($_REQUEST['userID']); + if ($this->filterIssuerUserID === null && isset($_REQUEST['issuerUserID']) && !empty($_REQUEST['issuerUserID'])) $this->filterIssuerUserID = intval($_REQUEST['issuerUserID']); + + if (isset($_REQUEST['roomID']) && $_REQUEST['roomID'] != -1) $this->filterRoomID = intval($_REQUEST['roomID']); + if (isset($_REQUEST['suspensionType']) && !empty($_REQUEST['suspensionType'])) $this->filterSuspensionType = intval($_REQUEST['suspensionType']); + } + + /** + * @see wcf\page\IPage::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign(array( + 'availableRooms' => \chat\data\room\RoomCache::getInstance()->getRooms(), + 'filterRoomID' => ($this->filterRoomID !== null) ? $this->filterRoomID : -1, + 'filterUsername' => $this->filterUsername, + 'filterIssuerUsername' => $this->filterIssuerUsername, + 'filterSuspensionType' => $this->filterSuspensionType + )); } /** @@ -102,7 +138,7 @@ protected function initObjectList() { $this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW)); $this->objectList->getConditionBuilder()->add('(room_table.permanent = ? OR suspension.roomID IS NULL)', array(1)); - if ($this->filterType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterType)); + if ($this->filterSuspensionType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterSuspensionType)); if ($this->filterUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.userID = ?', array($this->filterUserID)); if ($this->filterIssuerUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.issuer = ?', array($this->filterIssuerUserID)); if ($this->filterRoomID !== null) { From 3f26f6a263d290022835ed13b5a3682bc2ad7bff Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Sat, 15 Jun 2013 21:02:10 +0200 Subject: [PATCH 11/33] Add language variables and add username to filter form if userID/issuerUserID is supplied. --- acptemplate/chatSuspensionList.tpl | 22 +++++++++---------- .../acp/page/ChatSuspensionListPage.class.php | 10 ++++++++- language/de.xml | 10 +++++++++ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/acptemplate/chatSuspensionList.tpl b/acptemplate/chatSuspensionList.tpl index 8072a6c..77076d7 100644 --- a/acptemplate/chatSuspensionList.tpl +++ b/acptemplate/chatSuspensionList.tpl @@ -21,21 +21,21 @@
- +
-
+
- +
- @@ -47,9 +47,9 @@
-
+
- @@ -67,7 +67,7 @@ {if $objects|count}
-

{lang}wcf.acp.suspension.list{/lang} {#$items}

+

{lang}chat.acp.suspension.list{/lang} {#$items}

@@ -76,10 +76,10 @@ - - - - + + + + diff --git a/file/lib/acp/page/ChatSuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php index c1937e1..e121f77 100644 --- a/file/lib/acp/page/ChatSuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -91,15 +91,23 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { public function readParameters() { parent::readParameters(); + // get usernames if (isset($_REQUEST['username']) && !empty($_REQUEST['username'])) $this->filterUsername = \wcf\util\StringUtil::trim($_REQUEST['username']); if (isset($_REQUEST['issuerUsername']) && !empty($_REQUEST['issuerUsername'])) $this->filterIssuerUsername = \wcf\util\StringUtil::trim($_REQUEST['issuerUsername']); + // get user IDs by username if ($this->filterUsername != null) $this->filterUserID = \wcf\data\user\UserProfile::getUserProfileByUsername($this->filterUsername)->userID; if ($this->filterIssuerUsername != null) $this->filterIssuerUserID = \wcf\data\user\UserProfile::getUserProfileByUsername($this->filterIssuerUsername)->userID; - if ($this->filterUserID === null && isset($_REQUEST['userID']) && !empty($_REQUEST['userID'])) $this->filterUserID = intval($_REQUEST['userID']); + // get user IDs by request if no username was sent + if ($this->filterUserID === null && isset($_REQUEST['userID']) && !empty($_REQUEST['userID'])) $this->filterUserID = intval($_REQUEST['userID']); if ($this->filterIssuerUserID === null && isset($_REQUEST['issuerUserID']) && !empty($_REQUEST['issuerUserID'])) $this->filterIssuerUserID = intval($_REQUEST['issuerUserID']); + // get usernames by ID if no usernames were sent + if ($this->filterUsername === null) $this->filterUsername = \wcf\data\user\UserProfile::getUserProfile($this->filterUserID); + if ($this->filterIssuerUsername === null) $this->filterIssuerUsername = \wcf\data\user\UserProfile::getUserProfile($this->filterIssuerUserID); + + // get room IDs by request if (isset($_REQUEST['roomID']) && $_REQUEST['roomID'] != -1) $this->filterRoomID = intval($_REQUEST['roomID']); if (isset($_REQUEST['suspensionType']) && !empty($_REQUEST['suspensionType'])) $this->filterSuspensionType = intval($_REQUEST['suspensionType']); } diff --git a/language/de.xml b/language/de.xml index 9c20313..1467899 100644 --- a/language/de.xml +++ b/language/de.xml @@ -11,10 +11,17 @@ + + + + + + + @@ -68,6 +75,9 @@ + + + From 784047b3ed7c763a8864d57b9ea0d1e955513bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 16 Jun 2013 14:30:22 +0200 Subject: [PATCH 12/33] Fix chatSuspensionList.tpl --- acptemplate/chatSuspensionList.tpl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/acptemplate/chatSuspensionList.tpl b/acptemplate/chatSuspensionList.tpl index 77076d7..2f45676 100644 --- a/acptemplate/chatSuspensionList.tpl +++ b/acptemplate/chatSuspensionList.tpl @@ -13,7 +13,7 @@

{lang}chat.acp.suspension.list{/lang}

-
+
{lang}wcf.global.filter{/lang} @@ -35,9 +35,9 @@
- + + {foreach from=$availableRooms key=id item=room} @@ -47,10 +47,10 @@
-
+
- @@ -86,12 +86,12 @@
{foreach from=$objects item=$suspension} - + - + - - + + {/foreach} From 7aba4d17f2219a398b636671919115fb3eeba8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 16 Jun 2013 19:36:21 +0200 Subject: [PATCH 13/33] Fix ChatSuspensionList acp menu item --- acpMenu.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acpMenu.xml b/acpMenu.xml index 4a6b342..553f9e1 100644 --- a/acpMenu.xml +++ b/acpMenu.xml @@ -24,7 +24,7 @@ - + chat.acp.menu.link.chat 1 From 49ff71e8ee69f95699c7eaaf3297b6eb754fcc48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 16 Jun 2013 19:46:30 +0200 Subject: [PATCH 14/33] Hide suspension filter if no items are displayed --- acptemplate/chatSuspensionList.tpl | 102 ++++++++++++++--------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/acptemplate/chatSuspensionList.tpl b/acptemplate/chatSuspensionList.tpl index 2f45676..b478a6e 100644 --- a/acptemplate/chatSuspensionList.tpl +++ b/acptemplate/chatSuspensionList.tpl @@ -12,59 +12,59 @@

{lang}chat.acp.suspension.list{/lang}

- - -
-
- {lang}wcf.global.filter{/lang} - -
-
-
- -
-
- -
-
-
- -
-
- -
-
-
- -
-
- -
-
-
- -
-
-
-
- -
- -
- {if $objects|count} +
+
+
+ {lang}wcf.global.filter{/lang} + +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+
+
+ +
+ +
+ +

{lang}chat.acp.suspension.list{/lang} {#$items}

From 9ac860c9f1191def47868e155bfa8d37afab1378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 21 Jun 2013 19:50:55 +0300 Subject: [PATCH 15/33] Fix AwayCommand --- file/lib/system/command/commands/AwayCommand.class.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/file/lib/system/command/commands/AwayCommand.class.php b/file/lib/system/command/commands/AwayCommand.class.php index b7d0518..fb0eff0 100644 --- a/file/lib/system/command/commands/AwayCommand.class.php +++ b/file/lib/system/command/commands/AwayCommand.class.php @@ -36,11 +36,4 @@ public function getType() { public function getMessage() { return \wcf\system\bbcode\PreParser::getInstance()->parse($this->commandHandler->getParameters(), explode(',', WCF::getSession()->getPermission('user.chat.allowedBBCodes'))); } - - /** - * @see \chat\system\command\ICommand::getReceiver() - */ - public function getReceiver() { - return WCF::getUser()->userID; - } } From 7cf72a03260d85cfdbcce499c7b2b0ce735cc123 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Fri, 21 Jun 2013 20:01:44 +0300 Subject: [PATCH 16/33] Fix typo in chatSuspensionList.tpl --- acptemplate/chatSuspensionList.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acptemplate/chatSuspensionList.tpl b/acptemplate/chatSuspensionList.tpl index b478a6e..3c562b8 100644 --- a/acptemplate/chatSuspensionList.tpl +++ b/acptemplate/chatSuspensionList.tpl @@ -50,7 +50,7 @@
- +
- +
@@ -37,11 +37,11 @@
@@ -51,9 +51,9 @@
@@ -64,6 +64,10 @@
+ +
+ {pages print=true assign=pagesLinks application="chat" controller="ChatSuspensionList" link="pageNo=%d&userID=$userID&issuerUserID=$issuerUserID&roomID=$roomID&suspensionType=$suspensionType"} +
@@ -98,6 +102,10 @@
{lang}wcf.global.objectID{/lang} {lang}wcf.user.username{/lang} {lang}chat.general.room{/lang}{lang}wcf.acp.chat.suspensionType{/lang}{lang}wcf.acp.chat.time{/lang}{lang}wcf.acp.chat.expires{/lang}{lang}wcf.acp.chat.issuer{/lang}{lang}chat.acp.suspension.type{/lang}{lang}chat.general.time{/lang}{lang}chat.general.expires{/lang}{lang}chat.acp.suspension.issuer{/lang}
{@$suspension->suspensionID}{#$suspension->suspensionID} {$suspension->username}{if $suspension->roomID}{@$suspension->roomTitle|language}{else}{lang}chat.room.global{/lang}{/if}{if $suspension->roomID}{$suspension->roomTitle|language}{else}{lang}chat.room.global{/lang}{/if} {lang}chat.suspension.{@$suspension->type}{/lang}{@$suspension->time|plainTime}{@$suspension->expires|plainTime} ({$suspension->expires|dateDiff}){$suspension->time|plainTime}{$suspension->expires|plainTime} ({$suspension->expires|dateDiff}) {$suspension->issuerUsername}
+ +
+ {pages print=true assign=pagesLinks application="chat" controller="ChatSuspensionList" link="pageNo=%d&username=$username&issuerUsername=$issuerUsername&roomID=$roomID&suspensionType=$suspensionType"} +
{else}

{lang}wcf.global.noItems{/lang}

{/if} diff --git a/file/lib/acp/page/ChatSuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php index e121f77..062f8be 100644 --- a/file/lib/acp/page/ChatSuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -28,11 +28,6 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { */ public $defaultSortField = 'expires'; - /** - * @see \wcf\page\MultipleLinkPage::$itemsPerPage - */ - public $itemsPerPage = 30; - /** * @see \wcf\page\SortablePage::$validSortFields */ @@ -120,10 +115,12 @@ public function assignVariables() { WCF::getTPL()->assign(array( 'availableRooms' => \chat\data\room\RoomCache::getInstance()->getRooms(), - 'filterRoomID' => ($this->filterRoomID !== null) ? $this->filterRoomID : -1, - 'filterUsername' => $this->filterUsername, - 'filterIssuerUsername' => $this->filterIssuerUsername, - 'filterSuspensionType' => $this->filterSuspensionType + 'roomID' => ($this->filterRoomID !== null) ? $this->filterRoomID : -1, + 'username' => $this->filterUsername, + 'issuerUsername' => $this->filterIssuerUsername, + 'suspensionType' => $this->filterSuspensionType, + 'userID' => $this->filterUserID, + 'issuerUserID' => $this->filterIssuerUserID )); } From 3028edba7d0582c63d8514bc2a75c6138d74e6ce Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Sat, 22 Jun 2013 02:19:52 +0200 Subject: [PATCH 18/33] Add optional reasons to suspensions Also use $pageLinks in chatSuspension.tpl and add the missing name to testrooms name --- acptemplate/chatSuspensionList.tpl | 4 ++- .../acp/page/ChatSuspensionListPage.class.php | 2 +- .../command/commands/BanCommand.class.php | 26 +--------------- .../command/commands/GbanCommand.class.php | 30 ++----------------- .../command/commands/GmuteCommand.class.php | 9 +++--- .../command/commands/MuteCommand.class.php | 20 +++++++++---- install.sql | 3 +- 7 files changed, 29 insertions(+), 65 deletions(-) diff --git a/acptemplate/chatSuspensionList.tpl b/acptemplate/chatSuspensionList.tpl index a8b6b91..7bba8b0 100644 --- a/acptemplate/chatSuspensionList.tpl +++ b/acptemplate/chatSuspensionList.tpl @@ -84,6 +84,7 @@ {lang}chat.general.time{/lang} {lang}chat.general.expires{/lang} {lang}chat.acp.suspension.issuer{/lang} + {lang}chat.acp.suspension.reason{/lang} @@ -97,6 +98,7 @@ {$suspension->time|plainTime} {$suspension->expires|plainTime} ({$suspension->expires|dateDiff}) {$suspension->issuerUsername} + reason != $suspension->reason|truncate:30} class="jsTooltip" title="{$suspension->reason}"{/if}>{$suspension->reason|truncate:30} {/foreach} @@ -104,7 +106,7 @@
- {pages print=true assign=pagesLinks application="chat" controller="ChatSuspensionList" link="pageNo=%d&username=$username&issuerUsername=$issuerUsername&roomID=$roomID&suspensionType=$suspensionType"} + {@$pagesLinks}
{else}

{lang}wcf.global.noItems{/lang}

diff --git a/file/lib/acp/page/ChatSuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php index 062f8be..23b75c8 100644 --- a/file/lib/acp/page/ChatSuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -31,7 +31,7 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { /** * @see \wcf\page\SortablePage::$validSortFields */ - public $validSortFields = array('suspensionID', 'userID', 'username', 'roomID', 'type', 'expires', 'issuer', 'time'); + public $validSortFields = array('suspensionID', 'userID', 'username', 'roomID', 'type', 'expires', 'issuer', 'time', 'reason'); /** * @see \wcf\page\MultipleLinkPage::$objectListClassName diff --git a/file/lib/system/command/commands/BanCommand.class.php b/file/lib/system/command/commands/BanCommand.class.php index f090dfa..967e4b0 100644 --- a/file/lib/system/command/commands/BanCommand.class.php +++ b/file/lib/system/command/commands/BanCommand.class.php @@ -1,9 +1,6 @@ user, $this->room, suspension\Suspension::TYPE_BAN)) { - if ($suspension->expires > $this->expires) { - throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); - } - - $action = new suspension\SuspensionAction(array($suspension), 'delete'); - $action->executeAction(); - } - - $this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array( - 'data' => array( - 'userID' => $this->user->userID, - 'roomID' => WCF::getUser()->chatRoomID, - 'type' => suspension\Suspension::TYPE_BAN, - 'expires' => $this->expires, - 'time' => TIME_NOW, - 'issuer' => WCF::getUser()->userID - ) - )); - $this->suspensionAction->executeAction(); - } + const SUSPENSION_TYPE = suspension\Suspension::TYPE_BAN; } diff --git a/file/lib/system/command/commands/GbanCommand.class.php b/file/lib/system/command/commands/GbanCommand.class.php index 9cd3593..55c3f7e 100644 --- a/file/lib/system/command/commands/GbanCommand.class.php +++ b/file/lib/system/command/commands/GbanCommand.class.php @@ -1,9 +1,6 @@ null)); - - if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, suspension\Suspension::TYPE_BAN)) { - if ($suspension->expires > $this->expires) { - throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); - } - - $action = new suspension\SuspensionAction(array($suspension), 'delete'); - $action->executeAction(); - } - - $this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array( - 'data' => array( - 'userID' => $this->user->userID, - 'roomID' => null, - 'type' => suspension\Suspension::TYPE_BAN, - 'expires' => $this->expires, - 'time' => TIME_NOW, - 'issuer' => WCF::getUser()->userID - ) - )); - $this->suspensionAction->executeAction(); - } +class GbanCommand extends GmuteCommand { + const SUSPENSION_TYPE = suspension\Suspension::TYPE_BAN; } diff --git a/file/lib/system/command/commands/GmuteCommand.class.php b/file/lib/system/command/commands/GmuteCommand.class.php index e54a768..812012c 100644 --- a/file/lib/system/command/commands/GmuteCommand.class.php +++ b/file/lib/system/command/commands/GmuteCommand.class.php @@ -18,8 +18,8 @@ class GmuteCommand extends MuteCommand { public function executeAction() { $room = new \chat\data\room\Room(null, array('roomID' => null)); - if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, suspension\Suspension::TYPE_MUTE)) { - if ($suspension->expires > $this->expires) { + if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, static::SUSPENSION_TYPE)) { + if ($suspension->expires >= $this->expires) { throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); } @@ -31,10 +31,11 @@ public function executeAction() { 'data' => array( 'userID' => $this->user->userID, 'roomID' => null, - 'type' => suspension\Suspension::TYPE_MUTE, + 'type' => self::SUSPENSION_TYPE, 'expires' => $this->expires, 'time' => TIME_NOW, - 'issuer' => WCF::getUser()->userID + 'issuer' => WCF::getUser()->userID, + 'reason' => $this->reason ) )); $this->suspensionAction->executeAction(); diff --git a/file/lib/system/command/commands/MuteCommand.class.php b/file/lib/system/command/commands/MuteCommand.class.php index 2055fe4..59f2072 100644 --- a/file/lib/system/command/commands/MuteCommand.class.php +++ b/file/lib/system/command/commands/MuteCommand.class.php @@ -15,17 +15,25 @@ * @subpackage system.chat.command.commands */ class MuteCommand extends \chat\system\command\AbstractRestrictedCommand { + const SUSPENSION_TYPE = suspension\Suspension::TYPE_MUTE; public $user = null; public $expires = 0; public $suspensionAction = null; public $link = ''; public $room = null; + public $reason = ''; public function __construct(\chat\system\command\CommandHandler $commandHandler) { parent::__construct($commandHandler); try { - list($username, $modifier) = explode(',', $commandHandler->getParameters(), 2); + $parameters = explode(',', $commandHandler->getParameters(), 3); + list($username, $modifier) = $parameters; + + if (isset($parameters[2])) { + $this->reason = \wcf\util\StringUtil::trim($parameters[2]); + } + $modifier = ChatUtil::timeModifier(\wcf\util\StringUtil::trim($modifier)); $expires = strtotime($modifier, TIME_NOW); $this->expires = min(max(-0x80000000, $expires), 0x7FFFFFFF); @@ -48,8 +56,8 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler) } public function executeAction() { - if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\Suspension::TYPE_MUTE)) { - if ($suspension->expires > $this->expires) { + if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, static::SUSPENSION_TYPE)) { + if ($suspension->expires >= $this->expires) { throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); } @@ -64,7 +72,8 @@ public function executeAction() { 'type' => suspension\Suspension::TYPE_MUTE, 'expires' => $this->expires, 'time' => TIME_NOW, - 'issuer' => WCF::getUser()->userID + 'issuer' => WCF::getUser()->userID, + 'reason' => $this->reason ) )); $this->suspensionAction->executeAction(); @@ -95,7 +104,8 @@ public function getMessage() { return serialize(array( 'link' => $this->link, 'expires' => $this->expires, - 'type' => str_replace(array('chat\system\command\commands\\', 'command'), '', strtolower(get_class($this))) + 'type' => str_replace(array('chat\system\command\commands\\', 'command'), '', strtolower(get_class($this))), + 'message' => $this->suspensionMessage )); } } diff --git a/install.sql b/install.sql index 21148c7..b356ac2 100644 --- a/install.sql +++ b/install.sql @@ -50,6 +50,7 @@ CREATE TABLE chat1_suspension ( expires INT(10) NOT NULL, time INT(10) NOT NULL, issuer INT(10) DEFAULT NULL, + reason VARCHAR(255) NOT NULL DEFAULT '', UNIQUE KEY suspension (userID, roomID, type), KEY (roomID), @@ -78,5 +79,5 @@ ALTER TABLE wcf1_user ADD FOREIGN KEY (chatRoomID) REFERENCES chat1_room (roomID INSERT INTO chat1_room (title, topic, showOrder) VALUES ('chat.room.title1', 'chat.room.topic1', 1); INSERT INTO chat1_room (title, topic, showOrder) VALUES ('Testroom 2', 'Topic of Testroom 2', 2); -INSERT INTO chat1_room (title, topic, showOrder) VALUES ('Testroom with a very long', 'The topic of this room is rather loing as well!', 3); +INSERT INTO chat1_room (title, topic, showOrder) VALUES ('Testroom with a very long name', 'The topic of this room is rather loing as well!', 3); INSERT INTO chat1_room (title, topic, showOrder) VALUES ('Room w/o topic', '', 4); From 0e2216096cce26d67f9ba93163ab5527f8020ac6 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Sat, 22 Jun 2013 02:40:03 +0200 Subject: [PATCH 19/33] Use static:: instead of self:: --- file/lib/system/command/commands/GmuteCommand.class.php | 2 +- file/lib/system/command/commands/MuteCommand.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/file/lib/system/command/commands/GmuteCommand.class.php b/file/lib/system/command/commands/GmuteCommand.class.php index 812012c..02e76d5 100644 --- a/file/lib/system/command/commands/GmuteCommand.class.php +++ b/file/lib/system/command/commands/GmuteCommand.class.php @@ -31,7 +31,7 @@ public function executeAction() { 'data' => array( 'userID' => $this->user->userID, 'roomID' => null, - 'type' => self::SUSPENSION_TYPE, + 'type' => static::SUSPENSION_TYPE, 'expires' => $this->expires, 'time' => TIME_NOW, 'issuer' => WCF::getUser()->userID, diff --git a/file/lib/system/command/commands/MuteCommand.class.php b/file/lib/system/command/commands/MuteCommand.class.php index 59f2072..3cddd32 100644 --- a/file/lib/system/command/commands/MuteCommand.class.php +++ b/file/lib/system/command/commands/MuteCommand.class.php @@ -69,7 +69,7 @@ public function executeAction() { 'data' => array( 'userID' => $this->user->userID, 'roomID' => WCF::getUser()->chatRoomID, - 'type' => suspension\Suspension::TYPE_MUTE, + 'type' => static::SUSPENSION_TYPE, 'expires' => $this->expires, 'time' => TIME_NOW, 'issuer' => WCF::getUser()->userID, From 303eb80ee58ab1822f89de6b41fcff7f2dbd9d72 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Sat, 22 Jun 2013 14:21:15 +0200 Subject: [PATCH 20/33] Fix MuteCommand --- file/lib/system/command/commands/MuteCommand.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file/lib/system/command/commands/MuteCommand.class.php b/file/lib/system/command/commands/MuteCommand.class.php index 3cddd32..96b7b45 100644 --- a/file/lib/system/command/commands/MuteCommand.class.php +++ b/file/lib/system/command/commands/MuteCommand.class.php @@ -105,7 +105,7 @@ public function getMessage() { 'link' => $this->link, 'expires' => $this->expires, 'type' => str_replace(array('chat\system\command\commands\\', 'command'), '', strtolower(get_class($this))), - 'message' => $this->suspensionMessage + 'reason' => $this->reason )); } } From c6e146a038c5abe919b9da48354045ae0c0b31f2 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Sat, 22 Jun 2013 14:26:25 +0200 Subject: [PATCH 21/33] Display optional reasons in chat --- language/de.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/language/de.xml b/language/de.xml index 1467899..7b0c738 100644 --- a/language/de.xml +++ b/language/de.xml @@ -127,10 +127,10 @@ - - - - + + + + From 08451f44fe1ed8e2e1cea273131a9a672f092daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 22 Jun 2013 14:40:54 +0200 Subject: [PATCH 22/33] Don't delete expired suspensions --- acptemplate/chatSuspensionList.tpl | 8 ++++- .../acp/page/ChatSuspensionListPage.class.php | 18 ++++++++-- file/lib/data/suspension/Suspension.class.php | 36 ++++++++++--------- .../suspension/SuspensionAction.class.php | 26 ++++++++++++-- .../command/commands/GmuteCommand.class.php | 2 +- .../command/commands/GunbanCommand.class.php | 4 ++- .../command/commands/GunmuteCommand.class.php | 4 ++- .../command/commands/MuteCommand.class.php | 2 +- .../command/commands/UnbanCommand.class.php | 4 ++- .../command/commands/UnmuteCommand.class.php | 4 ++- install.sql | 5 ++- language/de.xml | 2 +- package.xml | 2 +- 13 files changed, 85 insertions(+), 32 deletions(-) diff --git a/acptemplate/chatSuspensionList.tpl b/acptemplate/chatSuspensionList.tpl index 7bba8b0..f87b10f 100644 --- a/acptemplate/chatSuspensionList.tpl +++ b/acptemplate/chatSuspensionList.tpl @@ -18,7 +18,13 @@
{lang}wcf.global.filter{/lang} - + +
+
+ +
+
+
diff --git a/file/lib/acp/page/ChatSuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php index 23b75c8..eadd132 100644 --- a/file/lib/acp/page/ChatSuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -80,6 +80,13 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { */ public $filterRoomID = null; + /** + * display revoked suspensions + * + * @var integer + */ + public $displayRevoked = 0; + /** * @see \wcf\page\IPage::readParameters() */ @@ -105,6 +112,9 @@ public function readParameters() { // get room IDs by request if (isset($_REQUEST['roomID']) && $_REQUEST['roomID'] != -1) $this->filterRoomID = intval($_REQUEST['roomID']); if (isset($_REQUEST['suspensionType']) && !empty($_REQUEST['suspensionType'])) $this->filterSuspensionType = intval($_REQUEST['suspensionType']); + + // display revoked + if (isset($_REQUEST['displayRevoked'])) $this->displayRevoked = intval($_REQUEST['displayRevoked']); } /** @@ -120,7 +130,8 @@ public function assignVariables() { 'issuerUsername' => $this->filterIssuerUsername, 'suspensionType' => $this->filterSuspensionType, 'userID' => $this->filterUserID, - 'issuerUserID' => $this->filterIssuerUserID + 'issuerUserID' => $this->filterIssuerUserID, + 'displayRevoked' => $this->displayRevoked )); } @@ -141,7 +152,10 @@ protected function initObjectList() { $this->objectList->sqlConditionJoins .= $conditionJoins; $this->objectList->sqlJoins .= $conditionJoins; - $this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW)); + if (!$this->displayRevoked) { + $this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW)); + $this->objectList->getConditionBuilder()->add('revoked = ?', array(0)); + } $this->objectList->getConditionBuilder()->add('(room_table.permanent = ? OR suspension.roomID IS NULL)', array(1)); if ($this->filterSuspensionType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterSuspensionType)); if ($this->filterUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.userID = ?', array($this->filterUserID)); diff --git a/file/lib/data/suspension/Suspension.class.php b/file/lib/data/suspension/Suspension.class.php index 3814807..52efac3 100644 --- a/file/lib/data/suspension/Suspension.class.php +++ b/file/lib/data/suspension/Suspension.class.php @@ -31,7 +31,7 @@ class Suspension extends \chat\data\CHATDatabaseObject { * @return boolean */ public function isValid() { - return $this->expires > TIME_NOW; + return $this->expires > TIME_NOW && !$this->revoked; } /** @@ -53,15 +53,18 @@ public static function getSuspensionsForUser(\wcf\data\user\User $user = null) { if ($suspensions === false) throw new \wcf\system\exception\SystemException(); } catch (\wcf\system\exception\SystemException $e) { + $condition = new \wcf\system\database\util\PreparedStatementConditionBuilder(); + $condition->add('userID = ?', array($user->userID)); + $condition->add('expires > ?', array(TIME_NOW)); + $condition->add('revoked = ?', array(0)); + $sql = "SELECT * FROM chat".WCF_N."_suspension - WHERE - userID = ? - AND expires > ?"; + ".$condition; $stmt = WCF::getDB()->prepareStatement($sql); - $stmt->execute(array($user->userID, TIME_NOW)); + $stmt->execute($condition->getParameters()); $suspensions = array(); while ($suspension = $stmt->fetchObject('\chat\data\suspension\Suspension')) { @@ -76,7 +79,7 @@ public static function getSuspensionsForUser(\wcf\data\user\User $user = null) { /** * Returns the appropriate suspension for user, room and type. - * Returns false if no suspension was found. + * Returns false if no active suspension was found. * * @param \wcf\data\user\User $user * @param \chat\data\room\Room $room @@ -84,23 +87,22 @@ public static function getSuspensionsForUser(\wcf\data\user\User $user = null) { * @return \chat\data\suspension\Suspension */ public static function getSuspensionByUserRoomAndType(\wcf\data\user\User $user, \chat\data\room\Room $room, $type) { + $condition = new \wcf\system\database\util\PreparedStatementConditionBuilder(); + $condition->add('userID = ?', array($user->userID)); + $condition->add('type = ?', array($type)); + $condition->add('expires > ?', array(TIME_NOW)); + $condition->add('revoked = ?', array(0)); + if ($room->roomID) $condition->add('roomID = ?', array($room->roomID)); + else $condition->add('roomID IS NULL'); + $sql = "SELECT * FROM chat".WCF_N."_suspension - WHERE - userID = ? - AND type = ?"; - - $parameter = array($user->userID, $type); - if ($room->roomID) { - $sql .= " AND roomID = ?"; - $parameter[] = $room->roomID; - } - else $sql .= " AND roomID IS NULL"; + ".$condition; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($parameter); + $statement->execute($condition->getParameters()); $row = $statement->fetchArray(); if (!$row) return false; diff --git a/file/lib/data/suspension/SuspensionAction.class.php b/file/lib/data/suspension/SuspensionAction.class.php index 669cecb..b5eae30 100644 --- a/file/lib/data/suspension/SuspensionAction.class.php +++ b/file/lib/data/suspension/SuspensionAction.class.php @@ -17,9 +17,9 @@ class SuspensionAction extends \wcf\data\AbstractDatabaseObjectAction { protected $className = '\chat\data\suspension\SuspensionEditor'; /** - * Deletes expired suspensions. + * Revokes expired suspensions. * - * @return integer Number of deleted suspensions + * @return array Revoked suspensions */ public function prune() { $sql = "SELECT @@ -34,6 +34,26 @@ public function prune() { while ($objectID = $stmt->fetchColumn()) $objectIDs[] = $objectID; - return call_user_func(array($this->className, 'deleteAll'), $objectIDs); + $suspensionAction = new self($objectIDs, 'revoke'); + $suspensionAction->executeAction(); + + return $objectIDs; + } + + /** + * Revokes suspensions. + */ + public function revoke() { + if (!isset($this->parameters['revoker'])) { + $this->parameters['revoker'] = null; + } + + $objectAction = new self($this->objectIDs, 'update', array( + 'data' => array( + 'revoked' => 1, + 'revoker' => $this->parameters['revoker'] + ) + )); + $objectAction->executeAction(); } } diff --git a/file/lib/system/command/commands/GmuteCommand.class.php b/file/lib/system/command/commands/GmuteCommand.class.php index 02e76d5..0b41c98 100644 --- a/file/lib/system/command/commands/GmuteCommand.class.php +++ b/file/lib/system/command/commands/GmuteCommand.class.php @@ -23,7 +23,7 @@ public function executeAction() { throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); } - $action = new suspension\SuspensionAction(array($suspension), 'delete'); + $action = new suspension\SuspensionAction(array($suspension), 'revoke'); $action->executeAction(); } diff --git a/file/lib/system/command/commands/GunbanCommand.class.php b/file/lib/system/command/commands/GunbanCommand.class.php index b33d6d4..04e7eb2 100644 --- a/file/lib/system/command/commands/GunbanCommand.class.php +++ b/file/lib/system/command/commands/GunbanCommand.class.php @@ -22,7 +22,9 @@ public function executeAction() { $room = new \chat\data\room\Room(null, array('roomID' => null)); if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, suspension\Suspension::TYPE_BAN)) { - $action = new suspension\SuspensionAction(array($suspension), 'delete'); + $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( + 'revoker' => WCF::getUser()->userID + )); $action->executeAction(); } else { diff --git a/file/lib/system/command/commands/GunmuteCommand.class.php b/file/lib/system/command/commands/GunmuteCommand.class.php index 3ed8125..5016716 100644 --- a/file/lib/system/command/commands/GunmuteCommand.class.php +++ b/file/lib/system/command/commands/GunmuteCommand.class.php @@ -22,7 +22,9 @@ public function executeAction() { $room = new \chat\data\room\Room(null, array('roomID' => null)); if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, suspension\Suspension::TYPE_MUTE)) { - $action = new suspension\SuspensionAction(array($suspension), 'delete'); + $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( + 'revoker' => WCF::getUser()->userID + )); $action->executeAction(); } else { diff --git a/file/lib/system/command/commands/MuteCommand.class.php b/file/lib/system/command/commands/MuteCommand.class.php index 96b7b45..4c8371d 100644 --- a/file/lib/system/command/commands/MuteCommand.class.php +++ b/file/lib/system/command/commands/MuteCommand.class.php @@ -61,7 +61,7 @@ public function executeAction() { throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); } - $action = new suspension\SuspensionAction(array($suspension), 'delete'); + $action = new suspension\SuspensionAction(array($suspension), 'revoke'); $action->executeAction(); } diff --git a/file/lib/system/command/commands/UnbanCommand.class.php b/file/lib/system/command/commands/UnbanCommand.class.php index ee4e5eb..26529ff 100644 --- a/file/lib/system/command/commands/UnbanCommand.class.php +++ b/file/lib/system/command/commands/UnbanCommand.class.php @@ -20,7 +20,9 @@ class UnbanCommand extends UnmuteCommand { */ public function executeAction() { if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\Suspension::TYPE_BAN)) { - $action = new suspension\SuspensionAction(array($suspension), 'delete'); + $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( + 'revoker' => WCF::getUser()->userID + )); $action->executeAction(); } else { diff --git a/file/lib/system/command/commands/UnmuteCommand.class.php b/file/lib/system/command/commands/UnmuteCommand.class.php index 9019a87..0ed2bf1 100644 --- a/file/lib/system/command/commands/UnmuteCommand.class.php +++ b/file/lib/system/command/commands/UnmuteCommand.class.php @@ -41,7 +41,9 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler) */ public function executeAction() { if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\Suspension::TYPE_MUTE)) { - $action = new suspension\SuspensionAction(array($suspension), 'delete'); + $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( + 'revoker' => WCF::getUser()->userID + )); $action->executeAction(); } else { diff --git a/install.sql b/install.sql index b356ac2..02defc5 100644 --- a/install.sql +++ b/install.sql @@ -51,8 +51,10 @@ CREATE TABLE chat1_suspension ( time INT(10) NOT NULL, issuer INT(10) DEFAULT NULL, reason VARCHAR(255) NOT NULL DEFAULT '', + revoked TINYINT(1) NOT NULL DEFAULT 0, + revoker INT(10) DEFAULT NULL, - UNIQUE KEY suspension (userID, roomID, type), + KEY suspension (userID, roomID, type), KEY (roomID), KEY (type), KEY (expires) @@ -74,6 +76,7 @@ ALTER TABLE chat1_room ADD FOREIGN KEY (owner) REFERENCES wcf1_user (userID) ON ALTER TABLE chat1_suspension ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE CASCADE; ALTER TABLE chat1_suspension ADD FOREIGN KEY (roomID) REFERENCES chat1_room (roomID) ON DELETE CASCADE; ALTER TABLE chat1_suspension ADD FOREIGN KEY (issuer) REFERENCES wcf1_user (userID) ON DELETE SET NULL; +ALTER TABLE chat1_suspension ADD FOREIGN KEY (revoker) REFERENCES wcf1_user (userID) ON DELETE SET NULL; ALTER TABLE wcf1_user ADD FOREIGN KEY (chatRoomID) REFERENCES chat1_room (roomID) ON DELETE SET NULL; diff --git a/language/de.xml b/language/de.xml index 7b0c738..df5d9a8 100644 --- a/language/de.xml +++ b/language/de.xml @@ -66,7 +66,7 @@ - + getCommand()}“ wurde nicht gefunden.]]> getUsername()}“ wurde nicht gefunden.]]> diff --git a/package.xml b/package.xml index 79c10d8..9417b3c 100644 --- a/package.xml +++ b/package.xml @@ -5,7 +5,7 @@ 1 - 3.0.0 Alpha 55 + 3.0.0 Alpha 59 2011-11-26 From a51b6ffacd1b05e86a67eb0ebf63a37fa4895f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 22 Jun 2013 16:17:53 +0200 Subject: [PATCH 23/33] Revoking is now setting expires to TIME_NOW --- .../acp/page/ChatSuspensionListPage.class.php | 3 +-- file/lib/data/suspension/Suspension.class.php | 4 +-- .../suspension/SuspensionAction.class.php | 26 +------------------ .../command/commands/GmuteCommand.class.php | 4 ++- .../command/commands/MuteCommand.class.php | 4 ++- .../system/cronjob/CleanupCronjob.class.php | 2 -- install.sql | 1 - 7 files changed, 9 insertions(+), 35 deletions(-) diff --git a/file/lib/acp/page/ChatSuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php index eadd132..b0870dd 100644 --- a/file/lib/acp/page/ChatSuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -153,8 +153,7 @@ protected function initObjectList() { $this->objectList->sqlJoins .= $conditionJoins; if (!$this->displayRevoked) { - $this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW)); - $this->objectList->getConditionBuilder()->add('revoked = ?', array(0)); + $this->objectList->getConditionBuilder()->add('expires > ?', array(TIME_NOW)); } $this->objectList->getConditionBuilder()->add('(room_table.permanent = ? OR suspension.roomID IS NULL)', array(1)); if ($this->filterSuspensionType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterSuspensionType)); diff --git a/file/lib/data/suspension/Suspension.class.php b/file/lib/data/suspension/Suspension.class.php index 52efac3..0fc7a16 100644 --- a/file/lib/data/suspension/Suspension.class.php +++ b/file/lib/data/suspension/Suspension.class.php @@ -31,7 +31,7 @@ class Suspension extends \chat\data\CHATDatabaseObject { * @return boolean */ public function isValid() { - return $this->expires > TIME_NOW && !$this->revoked; + return $this->expires > TIME_NOW; } /** @@ -56,7 +56,6 @@ public static function getSuspensionsForUser(\wcf\data\user\User $user = null) { $condition = new \wcf\system\database\util\PreparedStatementConditionBuilder(); $condition->add('userID = ?', array($user->userID)); $condition->add('expires > ?', array(TIME_NOW)); - $condition->add('revoked = ?', array(0)); $sql = "SELECT * @@ -91,7 +90,6 @@ public static function getSuspensionByUserRoomAndType(\wcf\data\user\User $user, $condition->add('userID = ?', array($user->userID)); $condition->add('type = ?', array($type)); $condition->add('expires > ?', array(TIME_NOW)); - $condition->add('revoked = ?', array(0)); if ($room->roomID) $condition->add('roomID = ?', array($room->roomID)); else $condition->add('roomID IS NULL'); diff --git a/file/lib/data/suspension/SuspensionAction.class.php b/file/lib/data/suspension/SuspensionAction.class.php index b5eae30..0908af1 100644 --- a/file/lib/data/suspension/SuspensionAction.class.php +++ b/file/lib/data/suspension/SuspensionAction.class.php @@ -16,30 +16,6 @@ class SuspensionAction extends \wcf\data\AbstractDatabaseObjectAction { */ protected $className = '\chat\data\suspension\SuspensionEditor'; - /** - * Revokes expired suspensions. - * - * @return array Revoked suspensions - */ - public function prune() { - $sql = "SELECT - ".call_user_func(array($this->className, 'getDatabaseTableIndexName'))." - FROM - ".call_user_func(array($this->className, 'getDatabaseTableName'))." - WHERE - expires < ?"; - $stmt = \wcf\system\WCF::getDB()->prepareStatement($sql); - $stmt->execute(array(TIME_NOW)); - $objectIDs = array(); - - while ($objectID = $stmt->fetchColumn()) $objectIDs[] = $objectID; - - $suspensionAction = new self($objectIDs, 'revoke'); - $suspensionAction->executeAction(); - - return $objectIDs; - } - /** * Revokes suspensions. */ @@ -50,7 +26,7 @@ public function revoke() { $objectAction = new self($this->objectIDs, 'update', array( 'data' => array( - 'revoked' => 1, + 'expires' => TIME_NOW 'revoker' => $this->parameters['revoker'] ) )); diff --git a/file/lib/system/command/commands/GmuteCommand.class.php b/file/lib/system/command/commands/GmuteCommand.class.php index 0b41c98..afe8bb1 100644 --- a/file/lib/system/command/commands/GmuteCommand.class.php +++ b/file/lib/system/command/commands/GmuteCommand.class.php @@ -23,7 +23,9 @@ public function executeAction() { throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); } - $action = new suspension\SuspensionAction(array($suspension), 'revoke'); + $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( + 'revoker' => WCF::getUser()->userID + )); $action->executeAction(); } diff --git a/file/lib/system/command/commands/MuteCommand.class.php b/file/lib/system/command/commands/MuteCommand.class.php index 5cb252f..d4f6c20 100644 --- a/file/lib/system/command/commands/MuteCommand.class.php +++ b/file/lib/system/command/commands/MuteCommand.class.php @@ -61,7 +61,9 @@ public function executeAction() { throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); } - $action = new suspension\SuspensionAction(array($suspension), 'revoke'); + $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( + 'revoker' => WCF::getUser()->userID + )); $action->executeAction(); } diff --git a/file/lib/system/cronjob/CleanupCronjob.class.php b/file/lib/system/cronjob/CleanupCronjob.class.php index 47e6a03..5933522 100644 --- a/file/lib/system/cronjob/CleanupCronjob.class.php +++ b/file/lib/system/cronjob/CleanupCronjob.class.php @@ -20,8 +20,6 @@ public function execute(\wcf\data\cronjob\Cronjob $cronjob) { $messageAction->executeAction(); $roomAction = new data\room\RoomAction(array(), 'prune'); $roomAction->executeAction(); - $suspensionAction = new data\suspension\SuspensionAction(array(), 'prune'); - $suspensionAction->executeAction(); // kill dead users $roomAction = new data\room\RoomAction(array(), 'removeDeadUsers'); diff --git a/install.sql b/install.sql index 02defc5..563f8a3 100644 --- a/install.sql +++ b/install.sql @@ -51,7 +51,6 @@ CREATE TABLE chat1_suspension ( time INT(10) NOT NULL, issuer INT(10) DEFAULT NULL, reason VARCHAR(255) NOT NULL DEFAULT '', - revoked TINYINT(1) NOT NULL DEFAULT 0, revoker INT(10) DEFAULT NULL, KEY suspension (userID, roomID, type), From bc56eac2e211318116448a30ef90c053cdacd2af Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Sat, 22 Jun 2013 16:31:08 +0200 Subject: [PATCH 24/33] Improve suspension list --- acptemplate/chatSuspensionList.tpl | 54 +++++++++++++------ .../acp/page/ChatSuspensionListPage.class.php | 24 +++++++-- language/de.xml | 6 ++- 3 files changed, 64 insertions(+), 20 deletions(-) diff --git a/acptemplate/chatSuspensionList.tpl b/acptemplate/chatSuspensionList.tpl index 7bba8b0..763e9a3 100644 --- a/acptemplate/chatSuspensionList.tpl +++ b/acptemplate/chatSuspensionList.tpl @@ -18,7 +18,13 @@
{lang}wcf.global.filter{/lang} - + +
+
+ +
+
+
@@ -39,7 +45,7 @@
- + + {capture assign=additionalParameters}{* + *}{if $userID}&userID={$userID}{/if}{* + *}{if $issuerUserID}&issuerUserID={$issuerUserID}{/if}{* + *}{if $roomID}&roomID={$roomID}{/if}{* + *}{if $suspensionType}&suspensionType={$suspensionType}{/if}{* + *}{if $displayRevoked}&displayRevoked={$displayRevoked}{/if}{* + *}{/capture} +
- {pages print=true assign=pagesLinks application="chat" controller="ChatSuspensionList" link="pageNo=%d&userID=$userID&issuerUserID=$issuerUserID&roomID=$roomID&suspensionType=$suspensionType"} + {pages print=true assign=pagesLinks application="chat" controller="ChatSuspensionList" link="pageNo=%d$additionalParameters"}
@@ -77,28 +91,38 @@ - - - - - - - - + + + + + + + + + + {event name='columnHeads'} {foreach from=$objects item=$suspension} - + + - + - + + {event name='columns'} {/foreach} diff --git a/file/lib/acp/page/ChatSuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php index 23b75c8..dd35f26 100644 --- a/file/lib/acp/page/ChatSuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -80,6 +80,13 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { */ public $filterRoomID = null; + /** + * display revoked suspensions + * + * @var integer + */ + public $displayRevoked = 0; + /** * @see \wcf\page\IPage::readParameters() */ @@ -105,6 +112,9 @@ public function readParameters() { // get room IDs by request if (isset($_REQUEST['roomID']) && $_REQUEST['roomID'] != -1) $this->filterRoomID = intval($_REQUEST['roomID']); if (isset($_REQUEST['suspensionType']) && !empty($_REQUEST['suspensionType'])) $this->filterSuspensionType = intval($_REQUEST['suspensionType']); + + // display revoked + if (isset($_REQUEST['displayRevoked'])) $this->displayRevoked = intval($_REQUEST['displayRevoked']); } /** @@ -120,7 +130,8 @@ public function assignVariables() { 'issuerUsername' => $this->filterIssuerUsername, 'suspensionType' => $this->filterSuspensionType, 'userID' => $this->filterUserID, - 'issuerUserID' => $this->filterIssuerUserID + 'issuerUserID' => $this->filterIssuerUserID, + 'displayRevoked' => $this->displayRevoked )); } @@ -130,18 +141,23 @@ public function assignVariables() { protected function initObjectList() { parent::initObjectList(); - $this->objectList->sqlSelects .= "user_table.username, user_table2.username as issuerUsername, room_table.title AS roomTitle"; + $this->objectList->sqlSelects .= "user_table.username, user_table2.username AS issuerUsername, user_table3.username AS revokerUsername, room_table.title AS roomTitle"; $this->objectList->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table ON suspension.userID = user_table.userID LEFT JOIN wcf".WCF_N."_user user_table2 - ON suspension.issuer = user_table2.userID"; + ON suspension.issuer = user_table2.userID + LEFT JOIN wcf".WCF_N."_user user_table3 + ON suspension.issuer = user_table3.userID"; $conditionJoins = " LEFT JOIN chat".WCF_N."_room room_table ON suspension.roomID = room_table.roomID"; $this->objectList->sqlConditionJoins .= $conditionJoins; $this->objectList->sqlJoins .= $conditionJoins; - $this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW)); + if (!$this->displayRevoked) { + $this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW)); + $this->objectList->getConditionBuilder()->add('revoked = ?', array(0)); + } $this->objectList->getConditionBuilder()->add('(room_table.permanent = ? OR suspension.roomID IS NULL)', array(1)); if ($this->filterSuspensionType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterSuspensionType)); if ($this->filterUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.userID = ?', array($this->filterUserID)); diff --git a/language/de.xml b/language/de.xml index 7b0c738..7a8f148 100644 --- a/language/de.xml +++ b/language/de.xml @@ -15,13 +15,17 @@ + + + + revokerUsername}]]> - + From f9fa3a7841a4ffe64b6831218b7bc116be00a8f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 22 Jun 2013 16:35:48 +0200 Subject: [PATCH 25/33] Fix typo in SuspensionAction --- file/lib/data/suspension/SuspensionAction.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file/lib/data/suspension/SuspensionAction.class.php b/file/lib/data/suspension/SuspensionAction.class.php index 0908af1..8b5ca77 100644 --- a/file/lib/data/suspension/SuspensionAction.class.php +++ b/file/lib/data/suspension/SuspensionAction.class.php @@ -26,7 +26,7 @@ public function revoke() { $objectAction = new self($this->objectIDs, 'update', array( 'data' => array( - 'expires' => TIME_NOW + 'expires' => TIME_NOW, 'revoker' => $this->parameters['revoker'] ) )); From 6d539e7f0a232e688a4a8f8671c75cd687874615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 22 Jun 2013 17:11:22 +0200 Subject: [PATCH 26/33] Made suspension commands more abstract --- .../AbstractSuspensionCommand.class.php | 115 ++++++++++++++++++ .../AbstractUnsuspensionCommand.class.php | 82 +++++++++++++ .../command/commands/BanCommand.class.php | 7 +- .../command/commands/GbanCommand.class.php | 7 +- .../command/commands/GmuteCommand.class.php | 38 +----- .../command/commands/GunbanCommand.class.php | 34 ------ .../command/commands/GunmuteCommand.class.php | 34 ------ .../command/commands/MuteCommand.class.php | 104 +--------------- .../command/commands/UnbanCommand.class.php | 23 +--- .../command/commands/UngbanCommand.class.php | 17 +++ .../command/commands/UngmuteCommand.class.php | 17 +++ .../command/commands/UnmuteCommand.class.php | 72 +---------- language/de.xml | 4 +- option.xml | 4 +- package.xml | 2 +- 15 files changed, 262 insertions(+), 298 deletions(-) create mode 100644 file/lib/system/command/AbstractSuspensionCommand.class.php create mode 100644 file/lib/system/command/AbstractUnsuspensionCommand.class.php delete mode 100644 file/lib/system/command/commands/GunbanCommand.class.php delete mode 100644 file/lib/system/command/commands/GunmuteCommand.class.php create mode 100644 file/lib/system/command/commands/UngbanCommand.class.php create mode 100644 file/lib/system/command/commands/UngmuteCommand.class.php diff --git a/file/lib/system/command/AbstractSuspensionCommand.class.php b/file/lib/system/command/AbstractSuspensionCommand.class.php new file mode 100644 index 0000000..93f5da2 --- /dev/null +++ b/file/lib/system/command/AbstractSuspensionCommand.class.php @@ -0,0 +1,115 @@ + + * @package be.bastelstu.chat + * @subpackage system.chat.command + */ +abstract class AbstractSuspensionCommand extends AbstractRestrictedCommand { + public $user = null; + public $expires = 0; + public $suspensionAction = null; + public $link = ''; + public $room = null; + public $reason = ''; + + public function __construct(\chat\system\command\CommandHandler $commandHandler) { + parent::__construct($commandHandler); + + try { + $parameters = explode(',', $commandHandler->getParameters(), 3); + list($username, $modifier) = $parameters; + + if (isset($parameters[2])) { + $this->reason = \wcf\util\StringUtil::trim($parameters[2]); + } + + $modifier = ChatUtil::timeModifier(\wcf\util\StringUtil::trim($modifier)); + $expires = strtotime($modifier, TIME_NOW); + $this->expires = min(max(-0x80000000, $expires), 0x7FFFFFFF); + } + catch (\wcf\system\exception\SystemException $e) { + throw new \InvalidArgumentException(); + } + + $this->user = User::getUserByUsername($username); + if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException($username); + + $profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array( + 'object' => $this->user + )); + $this->link = "[url='".$profile."']".$this->user->username.'[/url]'; + + $this->executeAction(); + + $this->didInit(); + } + + public function executeAction() { + if (static::IS_GLOBAL) $room = new \chat\data\room\Room(null, array('roomID' => null)); + else $room = $this->room; + + if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, static::SUSPENSION_TYPE)) { + if ($suspension->expires >= $this->expires) { + throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); + } + + $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( + 'revoker' => WCF::getUser()->userID + )); + $action->executeAction(); + } + + $this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array( + 'data' => array( + 'userID' => $this->user->userID, + 'roomID' => $room->roomID ?: null, + 'type' => static::SUSPENSION_TYPE, + 'expires' => $this->expires, + 'time' => TIME_NOW, + 'issuer' => WCF::getUser()->userID, + 'reason' => $this->reason + ) + )); + $this->suspensionAction->executeAction(); + } + + /** + * @see \chat\system\command\IRestrictedChatCommand::checkPermission() + */ + public function checkPermission() { + parent::checkPermission(); + + $this->room = $this->commandHandler->getRoom(); + $ph = new \chat\system\permission\PermissionHandler(); + if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(static::IDENTIFIER))) throw new \wcf\system\exception\PermissionDeniedException(); + } + + /** + * @see \chat\system\command\ICommand::getType() + */ + public function getType() { + return \chat\data\message\Message::TYPE_MODERATE; + } + + /** + * @see \chat\system\command\ICommand::getMessage() + */ + public function getMessage() { + return serialize(array( + 'link' => $this->link, + 'expires' => $this->expires, + 'type' => static::IDENTIFIER, + 'reason' => $this->reason + )); + } +} diff --git a/file/lib/system/command/AbstractUnsuspensionCommand.class.php b/file/lib/system/command/AbstractUnsuspensionCommand.class.php new file mode 100644 index 0000000..ba59fcd --- /dev/null +++ b/file/lib/system/command/AbstractUnsuspensionCommand.class.php @@ -0,0 +1,82 @@ + + * @package be.bastelstu.chat + * @subpackage system.chat.command + */ +abstract class AbstractUnsuspensionCommand extends AbstractRestrictedCommand { + public $user = null; + public $suspensionAction = null; + public $link = ''; + public $room = null; + + public function __construct(\chat\system\command\CommandHandler $commandHandler) { + parent::__construct($commandHandler); + + $username = rtrim($commandHandler->getParameters(), ','); + $this->user = User::getUserByUsername($username); + if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException($username); + + $profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array( + 'object' => $this->user + )); + $this->link = "[url='".$profile."']".$this->user->username.'[/url]'; + + $this->executeAction(); + + $this->didInit(); + } + + public function executeAction() { + if (static::IS_GLOBAL) $room = new \chat\data\room\Room(null, array('roomID' => null)); + else $room = $this->room; + + if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, static::SUSPENSION_TYPE)) { + $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( + 'revoker' => WCF::getUser()->userID + )); + $action->executeAction(); + } + else { + throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists')); + } + } + + /** + * @see \chat\system\command\IRestrictedChatCommand::checkPermission() + */ + public function checkPermission() { + parent::checkPermission(); + + $this->room = $this->commandHandler->getRoom(); + $ph = new \chat\system\permission\PermissionHandler(); + if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(static::IDENTIFIER))) throw new \wcf\system\exception\PermissionDeniedException(); + } + + /** + * @see \chat\system\command\ICommand::getType() + */ + public function getType() { + return \chat\data\message\Message::TYPE_MODERATE; + } + + /** + * @see \chat\system\command\ICommand::getMessage() + */ + public function getMessage() { + return serialize(array( + 'link' => $this->link, + 'type' => 'un'.static::IDENTIFIER + )); + } +} diff --git a/file/lib/system/command/commands/BanCommand.class.php b/file/lib/system/command/commands/BanCommand.class.php index 967e4b0..c2d7ef3 100644 --- a/file/lib/system/command/commands/BanCommand.class.php +++ b/file/lib/system/command/commands/BanCommand.class.php @@ -1,6 +1,5 @@ null)); - - if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, static::SUSPENSION_TYPE)) { - if ($suspension->expires >= $this->expires) { - throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); - } - - $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( - 'revoker' => WCF::getUser()->userID - )); - $action->executeAction(); - } - - $this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array( - 'data' => array( - 'userID' => $this->user->userID, - 'roomID' => null, - 'type' => static::SUSPENSION_TYPE, - 'expires' => $this->expires, - 'time' => TIME_NOW, - 'issuer' => WCF::getUser()->userID, - 'reason' => $this->reason - ) - )); - $this->suspensionAction->executeAction(); - } +class GmuteCommand extends \chat\system\command\AbstractSuspensionCommand { + const IDENTIFIER = 'gmute'; + const IS_GLOBAL = true; + const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE; } diff --git a/file/lib/system/command/commands/GunbanCommand.class.php b/file/lib/system/command/commands/GunbanCommand.class.php deleted file mode 100644 index 04e7eb2..0000000 --- a/file/lib/system/command/commands/GunbanCommand.class.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @package be.bastelstu.chat - * @subpackage system.chat.command.commands - */ -class GunbanCommand extends UnmuteCommand { - /** - * @see \chat\system\command\commands\UnmuteCommand::executeAction() - */ - public function executeAction() { - $room = new \chat\data\room\Room(null, array('roomID' => null)); - - if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, suspension\Suspension::TYPE_BAN)) { - $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( - 'revoker' => WCF::getUser()->userID - )); - $action->executeAction(); - } - else { - throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists')); - } - } -} diff --git a/file/lib/system/command/commands/GunmuteCommand.class.php b/file/lib/system/command/commands/GunmuteCommand.class.php deleted file mode 100644 index 5016716..0000000 --- a/file/lib/system/command/commands/GunmuteCommand.class.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @package be.bastelstu.chat - * @subpackage system.chat.command.commands - */ -class GunmuteCommand extends UnmuteCommand { - /** - * @see \chat\system\command\commands\UnmuteCommand::executeAction() - */ - public function executeAction() { - $room = new \chat\data\room\Room(null, array('roomID' => null)); - - if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $room, suspension\Suspension::TYPE_MUTE)) { - $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( - 'revoker' => WCF::getUser()->userID - )); - $action->executeAction(); - } - else { - throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists')); - } - } -} diff --git a/file/lib/system/command/commands/MuteCommand.class.php b/file/lib/system/command/commands/MuteCommand.class.php index d4f6c20..25bbd75 100644 --- a/file/lib/system/command/commands/MuteCommand.class.php +++ b/file/lib/system/command/commands/MuteCommand.class.php @@ -1,9 +1,5 @@ getParameters(), 3); - list($username, $modifier) = $parameters; - - if (isset($parameters[2])) { - $this->reason = \wcf\util\StringUtil::trim($parameters[2]); - } - - $modifier = ChatUtil::timeModifier(\wcf\util\StringUtil::trim($modifier)); - $expires = strtotime($modifier, TIME_NOW); - $this->expires = min(max(-0x80000000, $expires), 0x7FFFFFFF); - } - catch (\wcf\system\exception\SystemException $e) { - throw new \InvalidArgumentException(); - } - - $this->user = User::getUserByUsername($username); - if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException($username); - - $profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array( - 'object' => $this->user - )); - $this->link = "[url='".$profile."']".$this->user->username.'[/url]'; - - $this->executeAction(); - - $this->didInit(); - } - - public function executeAction() { - if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, static::SUSPENSION_TYPE)) { - if ($suspension->expires >= $this->expires) { - throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); - } - - $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( - 'revoker' => WCF::getUser()->userID - )); - $action->executeAction(); - } - - $this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array( - 'data' => array( - 'userID' => $this->user->userID, - 'roomID' => WCF::getUser()->chatRoomID, - 'type' => static::SUSPENSION_TYPE, - 'expires' => $this->expires, - 'time' => TIME_NOW, - 'issuer' => WCF::getUser()->userID, - 'reason' => $this->reason - ) - )); - $this->suspensionAction->executeAction(); - } - - /** - * @see \chat\system\command\IRestrictedChatCommand::checkPermission() - */ - public function checkPermission() { - parent::checkPermission(); - - $this->room = $this->commandHandler->getRoom(); - $ph = new \chat\system\permission\PermissionHandler(); - if (!$ph->getPermission($this->room, 'mod.can'.str_replace(array('chat\system\command\commands\\', 'Command'), '', get_class($this)))) throw new \wcf\system\exception\PermissionDeniedException(); - } - - /** - * @see \chat\system\command\ICommand::getType() - */ - public function getType() { - return \chat\data\message\Message::TYPE_MODERATE; - } - - /** - * @see \chat\system\command\ICommand::getMessage() - */ - public function getMessage() { - return serialize(array( - 'link' => $this->link, - 'expires' => $this->expires, - 'type' => str_replace(array('chat\system\command\commands\\', 'command'), '', strtolower(get_class($this))), - 'reason' => $this->reason - )); - } +class MuteCommand extends \chat\system\command\AbstractSuspensionCommand { + const IDENTIFIER = 'mute'; + const IS_GLOBAL = false; + const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE; } diff --git a/file/lib/system/command/commands/UnbanCommand.class.php b/file/lib/system/command/commands/UnbanCommand.class.php index 26529ff..85905b2 100644 --- a/file/lib/system/command/commands/UnbanCommand.class.php +++ b/file/lib/system/command/commands/UnbanCommand.class.php @@ -1,9 +1,5 @@ user, $this->room, suspension\Suspension::TYPE_BAN)) { - $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( - 'revoker' => WCF::getUser()->userID - )); - $action->executeAction(); - } - else { - throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists')); - } - } +class UnbanCommand extends \chat\system\command\AbstractUnsuspensionCommand { + const IDENTIFIER = 'ban'; + const IS_GLOBAL = false; + const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN; } diff --git a/file/lib/system/command/commands/UngbanCommand.class.php b/file/lib/system/command/commands/UngbanCommand.class.php new file mode 100644 index 0000000..db4a4a2 --- /dev/null +++ b/file/lib/system/command/commands/UngbanCommand.class.php @@ -0,0 +1,17 @@ + + * @package be.bastelstu.chat + * @subpackage system.chat.command.commands + */ +class GunbanCommand extends \chat\system\command\AbstractUnsuspensionCommand { + const IDENTIFIER = 'gban'; + const IS_GLOBAL = true; + const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN; +} diff --git a/file/lib/system/command/commands/UngmuteCommand.class.php b/file/lib/system/command/commands/UngmuteCommand.class.php new file mode 100644 index 0000000..c8c073d --- /dev/null +++ b/file/lib/system/command/commands/UngmuteCommand.class.php @@ -0,0 +1,17 @@ + + * @package be.bastelstu.chat + * @subpackage system.chat.command.commands + */ +class UngmuteCommand extends \chat\system\command\AbstractUnsuspensionCommand { + const IDENTIFIER = 'gmute'; + const IS_GLOBAL = true; + const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE; +} diff --git a/file/lib/system/command/commands/UnmuteCommand.class.php b/file/lib/system/command/commands/UnmuteCommand.class.php index 0ed2bf1..e7818b2 100644 --- a/file/lib/system/command/commands/UnmuteCommand.class.php +++ b/file/lib/system/command/commands/UnmuteCommand.class.php @@ -1,8 +1,5 @@ getParameters(), ','); - $this->user = User::getUserByUsername($username); - if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException($username); - - $profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array( - 'object' => $this->user - )); - $this->link = "[url='".$profile."']".$this->user->username.'[/url]'; - - $this->executeAction(); - - $this->didInit(); - } - - /** - * Removes the suspension. - */ - public function executeAction() { - if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\Suspension::TYPE_MUTE)) { - $action = new suspension\SuspensionAction(array($suspension), 'revoke', array( - 'revoker' => WCF::getUser()->userID - )); - $action->executeAction(); - } - else { - throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.notExists')); - } - } - - /** - * @see \chat\system\command\IRestrictedChatCommand::checkPermission() - */ - public function checkPermission() { - parent::checkPermission(); - - $this->room = $this->commandHandler->getRoom(); - $ph = new \chat\system\permission\PermissionHandler(); - if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(str_replace(array('chat\system\command\commands\\Un', 'Command'), '', get_class($this))))) throw new \wcf\system\exception\PermissionDeniedException(); - } - - /** - * @see \chat\system\command\ICommand::getType() - */ - public function getType() { - return \chat\data\message\Message::TYPE_MODERATE; - } - - /** - * @see \chat\system\command\ICommand::getMessage() - */ - public function getMessage() { - return serialize(array( - 'link' => $this->link, - 'type' => str_replace(array('chat\system\command\commands\\', 'command'), '', strtolower(get_class($this))) - )); - } +class UnmuteCommand extends \chat\system\command\AbstractUnsuspensionCommand { + const IDENTIFIER = 'mute'; + const IS_GLOBAL = false; + const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE; } diff --git a/language/de.xml b/language/de.xml index 34d215c..d642c7a 100644 --- a/language/de.xml +++ b/language/de.xml @@ -137,8 +137,8 @@ - - + + diff --git a/option.xml b/option.xml index bef3647..9fac9ad 100644 --- a/option.xml +++ b/option.xml @@ -49,7 +49,9 @@ textareaafk:away col:color -msg:whisper +msg:whisper +gunban:ungban +gunmute:ungmute diff --git a/package.xml b/package.xml index 961162b..1fb22be 100644 --- a/package.xml +++ b/package.xml @@ -5,7 +5,7 @@ 1 - 3.0.0 Alpha 59 + 3.0.0 Alpha 662011-11-26]]> From 0025fc63ee6f92f439ddadbae2666e142dbd413e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 22 Jun 2013 17:40:24 +0200 Subject: [PATCH 27/33] Add permissions for suspension viewing --- acpMenu.xml | 2 +- acptemplate/chatSuspensionList.tpl | 2 +- .../acp/page/ChatSuspensionListPage.class.php | 5 ++- file/lib/data/suspension/Suspension.class.php | 32 +++++++++++++++++-- .../AbstractSuspensionCommand.class.php | 4 +-- .../AbstractUnsuspensionCommand.class.php | 4 +-- .../command/commands/BanCommand.class.php | 1 - .../command/commands/GbanCommand.class.php | 1 - .../command/commands/GmuteCommand.class.php | 1 - .../command/commands/InfoCommand.class.php | 2 +- .../command/commands/MuteCommand.class.php | 1 - .../command/commands/UnbanCommand.class.php | 1 - .../command/commands/UngbanCommand.class.php | 3 +- .../command/commands/UngmuteCommand.class.php | 1 - .../command/commands/UnmuteCommand.class.php | 1 - install.sql | 2 +- language/de.xml | 4 +-- package.xml | 2 +- userGroupOption.xml | 6 ++++ 19 files changed, 50 insertions(+), 25 deletions(-) diff --git a/acpMenu.xml b/acpMenu.xml index 553f9e1..cc43cce 100644 --- a/acpMenu.xml +++ b/acpMenu.xml @@ -26,7 +26,7 @@ chat.acp.menu.link.chat - + mod.chat.canViewAllSuspensions 1 diff --git a/acptemplate/chatSuspensionList.tpl b/acptemplate/chatSuspensionList.tpl index 763e9a3..f221a30 100644 --- a/acptemplate/chatSuspensionList.tpl +++ b/acptemplate/chatSuspensionList.tpl @@ -118,7 +118,7 @@ diff --git a/file/lib/acp/page/ChatSuspensionListPage.class.php b/file/lib/acp/page/ChatSuspensionListPage.class.php index e5253a5..54f94f5 100644 --- a/file/lib/acp/page/ChatSuspensionListPage.class.php +++ b/file/lib/acp/page/ChatSuspensionListPage.class.php @@ -20,8 +20,7 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage { /** * @see \wcf\page\AbstractPage::$neededPermissions */ - // TODO: Permissions - public $neededPermissions = array(); + public $neededPermissions = array('mod.chat.canViewAllSuspensions'); /** * @see \wcf\page\SortablePage::$defaultSortField @@ -148,7 +147,7 @@ protected function initObjectList() { LEFT JOIN wcf".WCF_N."_user user_table2 ON suspension.issuer = user_table2.userID LEFT JOIN wcf".WCF_N."_user user_table3 - ON suspension.issuer = user_table3.userID"; + ON suspension.issuer = user_table3.userID"; $conditionJoins = " LEFT JOIN chat".WCF_N."_room room_table ON suspension.roomID = room_table.roomID"; $this->objectList->sqlConditionJoins .= $conditionJoins; diff --git a/file/lib/data/suspension/Suspension.class.php b/file/lib/data/suspension/Suspension.class.php index 0fc7a16..72ba521 100644 --- a/file/lib/data/suspension/Suspension.class.php +++ b/file/lib/data/suspension/Suspension.class.php @@ -22,8 +22,8 @@ class Suspension extends \chat\data\CHATDatabaseObject { */ protected static $databaseTableIndexName = 'suspensionID'; - const TYPE_MUTE = 1; - const TYPE_BAN = 2; + const TYPE_MUTE = 'mute'; + const TYPE_BAN = 'ban'; /** * Returns whether the suspension still is valid. @@ -34,6 +34,34 @@ public function isValid() { return $this->expires > TIME_NOW; } + /** + * Returns whether the given user may view this suspension. + * + * @param \wcf\data\user\User $user + * @return boolean + */ + public function isVisible($user = null) { + if ($user === null) $user = WCF::getUser(); + + $ph = new \chat\system\permission\PermissionHandler($user); + if ($ph->getPermission($this->getRoom(), 'mod.canViewAllSuspensions')) return true; + if ($ph->getPermission($this->getRoom(), 'mod.canG'.$this->type)) return true; + if (!$this->room) return false; + if ($ph->getPermission($this->getRoom(), 'mod.can'.ucfirst($this->type))) return true; + return false; + } + + /** + * Returns the room of this suspension. + * + * @return \chat\data\room\Room + */ + public function getRoom() { + if (!$this->roomID) return new \chat\data\room\Room(null, array('roomID' => null)); + + return \chat\data\room\RoomCache::getInstance()->getRoom($this->roomID); + } + /** * Returns all the suspensions for the specified user (current user if no user was specified). * diff --git a/file/lib/system/command/AbstractSuspensionCommand.class.php b/file/lib/system/command/AbstractSuspensionCommand.class.php index 93f5da2..d55df8d 100644 --- a/file/lib/system/command/AbstractSuspensionCommand.class.php +++ b/file/lib/system/command/AbstractSuspensionCommand.class.php @@ -91,7 +91,7 @@ public function checkPermission() { $this->room = $this->commandHandler->getRoom(); $ph = new \chat\system\permission\PermissionHandler(); - if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(static::IDENTIFIER))) throw new \wcf\system\exception\PermissionDeniedException(); + if (!$ph->getPermission($this->room, 'mod.can'.ucfirst((static::IS_GLOBAL ? 'g' : '').static::SUSPENSION_TYPE))) throw new \wcf\system\exception\PermissionDeniedException(); } /** @@ -108,7 +108,7 @@ public function getMessage() { return serialize(array( 'link' => $this->link, 'expires' => $this->expires, - 'type' => static::IDENTIFIER, + 'type' => (static::IS_GLOBAL ? 'g' : '').static::SUSPENSION_TYPE, 'reason' => $this->reason )); } diff --git a/file/lib/system/command/AbstractUnsuspensionCommand.class.php b/file/lib/system/command/AbstractUnsuspensionCommand.class.php index ba59fcd..4c5fecf 100644 --- a/file/lib/system/command/AbstractUnsuspensionCommand.class.php +++ b/file/lib/system/command/AbstractUnsuspensionCommand.class.php @@ -60,7 +60,7 @@ public function checkPermission() { $this->room = $this->commandHandler->getRoom(); $ph = new \chat\system\permission\PermissionHandler(); - if (!$ph->getPermission($this->room, 'mod.can'.ucfirst(static::IDENTIFIER))) throw new \wcf\system\exception\PermissionDeniedException(); + if (!$ph->getPermission($this->room, 'mod.can'.ucfirst((static::IS_GLOBAL ? 'g' : '').static::SUSPENSION_TYPE))) throw new \wcf\system\exception\PermissionDeniedException(); } /** @@ -76,7 +76,7 @@ public function getType() { public function getMessage() { return serialize(array( 'link' => $this->link, - 'type' => 'un'.static::IDENTIFIER + 'type' => 'un'.(static::IS_GLOBAL ? 'g' : '').static::SUSPENSION_TYPE, )); } } diff --git a/file/lib/system/command/commands/BanCommand.class.php b/file/lib/system/command/commands/BanCommand.class.php index c2d7ef3..c3fcf6a 100644 --- a/file/lib/system/command/commands/BanCommand.class.php +++ b/file/lib/system/command/commands/BanCommand.class.php @@ -11,7 +11,6 @@ * @subpackage system.chat.command.commands */ class BanCommand extends \chat\system\command\AbstractSuspensionCommand { - const IDENTIFIER = 'ban'; const IS_GLOBAL = false; const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN; } diff --git a/file/lib/system/command/commands/GbanCommand.class.php b/file/lib/system/command/commands/GbanCommand.class.php index dcc92f5..106bf6b 100644 --- a/file/lib/system/command/commands/GbanCommand.class.php +++ b/file/lib/system/command/commands/GbanCommand.class.php @@ -11,7 +11,6 @@ * @subpackage system.chat.command.commands */ class GbanCommand extends \chat\system\command\AbstractSuspensionCommand { - const IDENTIFIER = 'gban'; const IS_GLOBAL = true; const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN; } diff --git a/file/lib/system/command/commands/GmuteCommand.class.php b/file/lib/system/command/commands/GmuteCommand.class.php index 1f39976..c32ef0b 100644 --- a/file/lib/system/command/commands/GmuteCommand.class.php +++ b/file/lib/system/command/commands/GmuteCommand.class.php @@ -11,7 +11,6 @@ * @subpackage system.chat.command.commands */ class GmuteCommand extends \chat\system\command\AbstractSuspensionCommand { - const IDENTIFIER = 'gmute'; const IS_GLOBAL = true; const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE; } diff --git a/file/lib/system/command/commands/InfoCommand.class.php b/file/lib/system/command/commands/InfoCommand.class.php index 23c40ba..b1f81eb 100644 --- a/file/lib/system/command/commands/InfoCommand.class.php +++ b/file/lib/system/command/commands/InfoCommand.class.php @@ -45,11 +45,11 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler) } // Suspensions - // TODO: Permissions $suspensions = \chat\data\suspension\Suspension::getSuspensionsForUser($this->user); foreach ($suspensions as $roomSuspensions) { foreach ($roomSuspensions as $typeSuspension) { if (!$typeSuspension->isValid()) continue; + if (!$typeSuspension->isVisible()) continue; $dateTime = DateUtil::getDateTimeByTimestamp($typeSuspension->expires); $name = WCF::getLanguage()->getDynamicVariable('chat.general.information.suspension', array( diff --git a/file/lib/system/command/commands/MuteCommand.class.php b/file/lib/system/command/commands/MuteCommand.class.php index 25bbd75..519a58a 100644 --- a/file/lib/system/command/commands/MuteCommand.class.php +++ b/file/lib/system/command/commands/MuteCommand.class.php @@ -11,7 +11,6 @@ * @subpackage system.chat.command.commands */ class MuteCommand extends \chat\system\command\AbstractSuspensionCommand { - const IDENTIFIER = 'mute'; const IS_GLOBAL = false; const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE; } diff --git a/file/lib/system/command/commands/UnbanCommand.class.php b/file/lib/system/command/commands/UnbanCommand.class.php index 85905b2..82427f5 100644 --- a/file/lib/system/command/commands/UnbanCommand.class.php +++ b/file/lib/system/command/commands/UnbanCommand.class.php @@ -11,7 +11,6 @@ * @subpackage system.chat.command.commands */ class UnbanCommand extends \chat\system\command\AbstractUnsuspensionCommand { - const IDENTIFIER = 'ban'; const IS_GLOBAL = false; const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN; } diff --git a/file/lib/system/command/commands/UngbanCommand.class.php b/file/lib/system/command/commands/UngbanCommand.class.php index db4a4a2..a742c01 100644 --- a/file/lib/system/command/commands/UngbanCommand.class.php +++ b/file/lib/system/command/commands/UngbanCommand.class.php @@ -10,8 +10,7 @@ * @package be.bastelstu.chat * @subpackage system.chat.command.commands */ -class GunbanCommand extends \chat\system\command\AbstractUnsuspensionCommand { - const IDENTIFIER = 'gban'; +class UngbanCommand extends \chat\system\command\AbstractUnsuspensionCommand { const IS_GLOBAL = true; const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_BAN; } diff --git a/file/lib/system/command/commands/UngmuteCommand.class.php b/file/lib/system/command/commands/UngmuteCommand.class.php index c8c073d..4d912fe 100644 --- a/file/lib/system/command/commands/UngmuteCommand.class.php +++ b/file/lib/system/command/commands/UngmuteCommand.class.php @@ -11,7 +11,6 @@ * @subpackage system.chat.command.commands */ class UngmuteCommand extends \chat\system\command\AbstractUnsuspensionCommand { - const IDENTIFIER = 'gmute'; const IS_GLOBAL = true; const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE; } diff --git a/file/lib/system/command/commands/UnmuteCommand.class.php b/file/lib/system/command/commands/UnmuteCommand.class.php index e7818b2..021e6fa 100644 --- a/file/lib/system/command/commands/UnmuteCommand.class.php +++ b/file/lib/system/command/commands/UnmuteCommand.class.php @@ -11,7 +11,6 @@ * @subpackage system.chat.command.commands */ class UnmuteCommand extends \chat\system\command\AbstractUnsuspensionCommand { - const IDENTIFIER = 'mute'; const IS_GLOBAL = false; const SUSPENSION_TYPE = \chat\data\suspension\Suspension::TYPE_MUTE; } diff --git a/install.sql b/install.sql index 563f8a3..4949484 100644 --- a/install.sql +++ b/install.sql @@ -46,7 +46,7 @@ CREATE TABLE chat1_suspension ( suspensionID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, userID INT(10) NOT NULL, roomID INT(10) DEFAULT NULL, - type TINYINT(3) NOT NULL, + type VARCHAR(15) NOT NULL, expires INT(10) NOT NULL, time INT(10) NOT NULL, issuer INT(10) DEFAULT NULL, diff --git a/language/de.xml b/language/de.xml index d642c7a..594ed1c 100644 --- a/language/de.xml +++ b/language/de.xml @@ -144,8 +144,8 @@ - - + + diff --git a/package.xml b/package.xml index 1fb22be..a334d00 100644 --- a/package.xml +++ b/package.xml @@ -5,7 +5,7 @@ 1 - 3.0.0 Alpha 66 + 3.0.0 Alpha 802011-11-26]]> diff --git a/userGroupOption.xml b/userGroupOption.xml index 5c7150b..1a845fb 100644 --- a/userGroupOption.xml +++ b/userGroupOption.xml @@ -56,6 +56,12 @@ 01 + - + \ No newline at end of file From e6e4cb5225454d6ed5f4d0e7ec415599927fb40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 22 Jun 2013 18:12:05 +0200 Subject: [PATCH 31/33] Fix permission name --- userGroupOption.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/userGroupOption.xml b/userGroupOption.xml index df69eb7..b0bc315 100644 --- a/userGroupOption.xml +++ b/userGroupOption.xml @@ -104,7 +104,7 @@ 0 1 - diff --git a/file/lib/data/suspension/SuspensionAction.class.php b/file/lib/data/suspension/SuspensionAction.class.php index 8b5ca77..b0bf7e6 100644 --- a/file/lib/data/suspension/SuspensionAction.class.php +++ b/file/lib/data/suspension/SuspensionAction.class.php @@ -1,5 +1,6 @@ checkPermissions((array) 'admin.chat.canManageSuspensions'); + + $this->parameters['revoker'] = WCF::getUser()->userID; + } + /** * Revokes suspensions. */
{lang}wcf.global.objectID{/lang}{lang}wcf.user.username{/lang}{lang}chat.general.room{/lang}{lang}chat.acp.suspension.type{/lang}{lang}chat.general.time{/lang}{lang}chat.general.expires{/lang}{lang}chat.acp.suspension.issuer{/lang}{lang}chat.acp.suspension.reason{/lang}{lang}wcf.global.objectID{/lang}{lang}wcf.user.username{/lang}{lang}chat.general.room{/lang}{lang}chat.acp.suspension.type{/lang}{lang}chat.general.time{/lang}{lang}chat.general.expires{/lang}{lang}chat.acp.suspension.issuer{/lang}{lang}chat.acp.suspension.reason{/lang}
+ + {event name='rowButtons'} + {#$suspension->suspensionID} {$suspension->username} {if $suspension->roomID}{$suspension->roomTitle|language}{else}{lang}chat.room.global{/lang}{/if} {lang}chat.suspension.{@$suspension->type}{/lang} {$suspension->time|plainTime}{$suspension->expires|plainTime} ({$suspension->expires|dateDiff}) +

{$suspension->expires|plainTime}{if $suspension->expires > TIME_NOW} ({$suspension->expires|dateDiff}){/if}

+ {if $suspension->revoker}

{lang}chat.acp.suspension.revokedBy{/lang}

{/if} +
{$suspension->issuerUsername}reason != $suspension->reason|truncate:30} class="jsTooltip" title="{$suspension->reason}"{/if}>{$suspension->reason|truncate:30}reason != $suspension->reason|truncate:30} class="jsTooltip" title="{$suspension->reason}"{/if}>{$suspension->reason|truncate:30}
{$suspension->time|plainTime}

{$suspension->expires|plainTime}{if $suspension->expires > TIME_NOW} ({$suspension->expires|dateDiff}){/if}

- {if $suspension->revoker}

{lang}chat.acp.suspension.revokedBy{/lang}

{/if} + {if $suspension->revoker && $suspension->expires <= TIME_NOW}

{lang}chat.acp.suspension.revokedBy{/lang}

{/if}
{$suspension->issuerUsername} reason != $suspension->reason|truncate:30} class="jsTooltip" title="{$suspension->reason}"{/if}>{$suspension->reason|truncate:30}
- + {event name='rowButtons'} {#$suspension->suspensionID}