2018-08-16 22:30:59 +00:00
|
|
|
|
<?php
|
|
|
|
|
/*
|
2021-02-04 22:04:35 +00:00
|
|
|
|
* Copyright (c) 2010-2021 Tim Düsterhus.
|
2018-08-16 22:30:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Use of this software is governed by the Business Source License
|
|
|
|
|
* included in the LICENSE file.
|
|
|
|
|
*
|
2021-03-05 16:19:27 +00:00
|
|
|
|
* Change Date: 2025-03-05
|
2018-08-16 22:30:59 +00:00
|
|
|
|
*
|
|
|
|
|
* On the date above, in accordance with the Business Source
|
|
|
|
|
* License, use of this software will be governed by version 3
|
|
|
|
|
* or later of the General Public License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace chat\data\suspension;
|
|
|
|
|
|
|
|
|
|
use \wcf\system\WCF;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Executes suspension-related actions.
|
|
|
|
|
*/
|
|
|
|
|
class SuspensionAction extends \wcf\data\AbstractDatabaseObjectAction {
|
|
|
|
|
/**
|
|
|
|
|
* @inheritDoc
|
|
|
|
|
*/
|
|
|
|
|
protected $requireACP = [ 'revoke' ];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Validates parameters and permissions.
|
|
|
|
|
*/
|
|
|
|
|
public function validateRevoke() {
|
|
|
|
|
if (empty($this->objects)) {
|
|
|
|
|
$this->readObjects();
|
|
|
|
|
|
|
|
|
|
if (empty($this->objects)) {
|
|
|
|
|
throw new UserInputException('objectIDs');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unset($this->parameters['revoker']);
|
|
|
|
|
|
|
|
|
|
WCF::getSession()->checkPermissions([ 'admin.chat.canManageSuspensions' ]);
|
|
|
|
|
|
|
|
|
|
foreach ($this->getObjects() as $object) {
|
|
|
|
|
if (!$object->isActive()) throw new UserInputException('objectIDs', 'nonActive');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Revokes the suspensions
|
|
|
|
|
*/
|
|
|
|
|
public function revoke() {
|
|
|
|
|
if (empty($this->objects)) {
|
|
|
|
|
$this->readObjects();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// User cannot be set during an AJAX request, but may be set by Tim’s Chat itself.
|
|
|
|
|
if (!isset($this->parameters['revoker'])) $this->parameters['revoker'] = WCF::getUser();
|
|
|
|
|
|
|
|
|
|
$data = [ 'revoked' => TIME_NOW
|
|
|
|
|
, 'revokerID' => $this->parameters['revoker']->userID
|
|
|
|
|
, 'revoker' => $this->parameters['revoker']->username
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$objectAction = new static($this->getObjects(), 'update', [ 'data' => $data ]);
|
|
|
|
|
$objectAction->executeAction();
|
|
|
|
|
}
|
|
|
|
|
}
|