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