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
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes expired suspensions.
|
|
|
|
*
|
|
|
|
* @return integer Number of deleted suspensions
|
|
|
|
*/
|
|
|
|
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
|
|
|
|
|
|
|
return call_user_func(array($this->className, 'deleteAll'), $objectIDs);
|
|
|
|
}
|
|
|
|
}
|