1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-24 22:00:09 +00:00
Tims-Chat/file/lib/data/suspension/SuspensionAction.class.php
2013-05-24 01:21:46 +02:00

40 lines
1.1 KiB
PHP

<?php
namespace chat\data\suspension;
/**
* Executes chat-suspension-related actions.
*
* @author Tim Düsterhus
* @copyright 2010-2013 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage data.suspension
*/
class SuspensionAction extends \wcf\data\AbstractDatabaseObjectAction {
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$className
*/
protected $className = '\chat\data\suspension\SuspensionEditor';
/**
* 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
expires < ?";
$stmt = \wcf\system\WCF::getDB()->prepareStatement($sql);
$stmt->execute(array(TIME_NOW));
$objectIDs = array();
while ($objectID = $stmt->fetchColumn()) $objectIDs[] = $objectID;
return call_user_func(array($this->className, 'deleteAll'), $objectIDs);
}
}