mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Revoking is now setting expires to TIME_NOW
This commit is contained in:
parent
4abb837878
commit
a51b6ffacd
@ -153,8 +153,7 @@ protected function initObjectList() {
|
|||||||
$this->objectList->sqlJoins .= $conditionJoins;
|
$this->objectList->sqlJoins .= $conditionJoins;
|
||||||
|
|
||||||
if (!$this->displayRevoked) {
|
if (!$this->displayRevoked) {
|
||||||
$this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW));
|
$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));
|
$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->filterSuspensionType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterSuspensionType));
|
||||||
|
@ -31,7 +31,7 @@ class Suspension extends \chat\data\CHATDatabaseObject {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isValid() {
|
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 = new \wcf\system\database\util\PreparedStatementConditionBuilder();
|
||||||
$condition->add('userID = ?', array($user->userID));
|
$condition->add('userID = ?', array($user->userID));
|
||||||
$condition->add('expires > ?', array(TIME_NOW));
|
$condition->add('expires > ?', array(TIME_NOW));
|
||||||
$condition->add('revoked = ?', array(0));
|
|
||||||
|
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
*
|
*
|
||||||
@ -91,7 +90,6 @@ public static function getSuspensionByUserRoomAndType(\wcf\data\user\User $user,
|
|||||||
$condition->add('userID = ?', array($user->userID));
|
$condition->add('userID = ?', array($user->userID));
|
||||||
$condition->add('type = ?', array($type));
|
$condition->add('type = ?', array($type));
|
||||||
$condition->add('expires > ?', array(TIME_NOW));
|
$condition->add('expires > ?', array(TIME_NOW));
|
||||||
$condition->add('revoked = ?', array(0));
|
|
||||||
if ($room->roomID) $condition->add('roomID = ?', array($room->roomID));
|
if ($room->roomID) $condition->add('roomID = ?', array($room->roomID));
|
||||||
else $condition->add('roomID IS NULL');
|
else $condition->add('roomID IS NULL');
|
||||||
|
|
||||||
|
@ -16,30 +16,6 @@ class SuspensionAction extends \wcf\data\AbstractDatabaseObjectAction {
|
|||||||
*/
|
*/
|
||||||
protected $className = '\chat\data\suspension\SuspensionEditor';
|
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.
|
* Revokes suspensions.
|
||||||
*/
|
*/
|
||||||
@ -50,7 +26,7 @@ public function revoke() {
|
|||||||
|
|
||||||
$objectAction = new self($this->objectIDs, 'update', array(
|
$objectAction = new self($this->objectIDs, 'update', array(
|
||||||
'data' => array(
|
'data' => array(
|
||||||
'revoked' => 1,
|
'expires' => TIME_NOW
|
||||||
'revoker' => $this->parameters['revoker']
|
'revoker' => $this->parameters['revoker']
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
@ -23,7 +23,9 @@ public function executeAction() {
|
|||||||
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists'));
|
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();
|
$action->executeAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,9 @@ public function executeAction() {
|
|||||||
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists'));
|
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();
|
$action->executeAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,6 @@ public function execute(\wcf\data\cronjob\Cronjob $cronjob) {
|
|||||||
$messageAction->executeAction();
|
$messageAction->executeAction();
|
||||||
$roomAction = new data\room\RoomAction(array(), 'prune');
|
$roomAction = new data\room\RoomAction(array(), 'prune');
|
||||||
$roomAction->executeAction();
|
$roomAction->executeAction();
|
||||||
$suspensionAction = new data\suspension\SuspensionAction(array(), 'prune');
|
|
||||||
$suspensionAction->executeAction();
|
|
||||||
|
|
||||||
// kill dead users
|
// kill dead users
|
||||||
$roomAction = new data\room\RoomAction(array(), 'removeDeadUsers');
|
$roomAction = new data\room\RoomAction(array(), 'removeDeadUsers');
|
||||||
|
@ -51,7 +51,6 @@ CREATE TABLE chat1_suspension (
|
|||||||
time INT(10) NOT NULL,
|
time INT(10) NOT NULL,
|
||||||
issuer INT(10) DEFAULT NULL,
|
issuer INT(10) DEFAULT NULL,
|
||||||
reason VARCHAR(255) NOT NULL DEFAULT '',
|
reason VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
revoked TINYINT(1) NOT NULL DEFAULT 0,
|
|
||||||
revoker INT(10) DEFAULT NULL,
|
revoker INT(10) DEFAULT NULL,
|
||||||
|
|
||||||
KEY suspension (userID, roomID, type),
|
KEY suspension (userID, roomID, type),
|
||||||
|
Loading…
Reference in New Issue
Block a user