1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Revoking is now setting expires to TIME_NOW

This commit is contained in:
Tim Düsterhus 2013-06-22 16:17:53 +02:00
parent 4abb837878
commit a51b6ffacd
7 changed files with 9 additions and 35 deletions

View File

@ -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));

View File

@ -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');

View File

@ -16,30 +16,6 @@ class SuspensionAction extends \wcf\data\AbstractDatabaseObjectAction {
*/
protected $className = '\chat\data\suspension\SuspensionEditor';
/**
* Revokes expired suspensions.
*
* @return array<integer> 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']
)
));

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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');

View File

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