2012-05-19 19:25:50 +00:00
|
|
|
<?php
|
2013-01-19 19:36:40 +00:00
|
|
|
namespace chat\data\suspension;
|
2012-05-19 19:25:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Executes chat-suspension-related actions.
|
|
|
|
*
|
|
|
|
* @author Tim Düsterhus
|
2013-01-19 19:36:40 +00:00
|
|
|
* @copyright 2010-2013 Tim Düsterhus
|
2012-05-19 19:25:50 +00:00
|
|
|
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
2013-01-19 19:36:40 +00:00
|
|
|
* @package be.bastelstu.chat
|
|
|
|
* @subpackage data.suspension
|
2012-05-19 19:25:50 +00:00
|
|
|
*/
|
2013-01-19 19:36:40 +00:00
|
|
|
class SuspensionAction extends \wcf\data\AbstractDatabaseObjectAction {
|
2012-05-19 19:25:50 +00:00
|
|
|
/**
|
|
|
|
* @see \wcf\data\AbstractDatabaseObjectAction::$className
|
|
|
|
*/
|
2013-01-19 19:36:40 +00:00
|
|
|
protected $className = '\chat\data\suspension\SuspensionEditor';
|
2012-05-19 19:25:50 +00:00
|
|
|
|
|
|
|
/**
|
2013-06-22 12:40:54 +00:00
|
|
|
* Revokes expired suspensions.
|
2012-05-19 19:25:50 +00:00
|
|
|
*
|
2013-06-22 12:40:54 +00:00
|
|
|
* @return array<integer> Revoked suspensions
|
2012-05-19 19:25:50 +00:00
|
|
|
*/
|
|
|
|
public function prune() {
|
|
|
|
$sql = "SELECT
|
|
|
|
".call_user_func(array($this->className, 'getDatabaseTableIndexName'))."
|
|
|
|
FROM
|
|
|
|
".call_user_func(array($this->className, 'getDatabaseTableName'))."
|
|
|
|
WHERE
|
2013-05-23 23:21:46 +00:00
|
|
|
expires < ?";
|
2012-05-19 19:25:50 +00:00
|
|
|
$stmt = \wcf\system\WCF::getDB()->prepareStatement($sql);
|
|
|
|
$stmt->execute(array(TIME_NOW));
|
|
|
|
$objectIDs = array();
|
2013-04-23 14:16:27 +00:00
|
|
|
|
|
|
|
while ($objectID = $stmt->fetchColumn()) $objectIDs[] = $objectID;
|
2012-05-19 19:25:50 +00:00
|
|
|
|
2013-06-22 12:40:54 +00:00
|
|
|
$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();
|
2012-05-19 19:25:50 +00:00
|
|
|
}
|
|
|
|
}
|