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] 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),