2011-11-27 11:21:58 +00:00
|
|
|
<?php
|
|
|
|
namespace wcf\data\chat\message;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides functions to edit chat messages.
|
|
|
|
*
|
|
|
|
* @author Tim Düsterhus
|
2012-01-28 16:50:33 +00:00
|
|
|
* @copyright 2010-2012 Tim Düsterhus
|
2011-11-27 11:21:58 +00:00
|
|
|
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
|
|
|
* @package timwolla.wcf.chat
|
|
|
|
* @subpackage data.chat.message
|
|
|
|
*/
|
|
|
|
class ChatMessageEditor extends \wcf\data\DatabaseObjectEditor {
|
|
|
|
/**
|
2012-02-26 16:55:44 +00:00
|
|
|
* @see \wcf\data\DatabaseObjectDecorator::$baseClass
|
2011-11-27 11:21:58 +00:00
|
|
|
*/
|
|
|
|
protected static $baseClass = '\wcf\data\chat\message\ChatMessage';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes old messages.
|
|
|
|
*
|
|
|
|
* @param integer $lifetime Delete messages older that this time.
|
|
|
|
* @return integer Number of deleted messages.
|
|
|
|
*/
|
|
|
|
public static function cleanup($lifetime = CHAT_ARCHIVETIME) {
|
2011-12-10 16:20:57 +00:00
|
|
|
$sql = "SELECT
|
2011-11-27 11:21:58 +00:00
|
|
|
".static::getDatabaseIndexName()."
|
|
|
|
FROM
|
|
|
|
".static::getDatabaseTableName()."
|
|
|
|
WHERE
|
|
|
|
time < ?";
|
|
|
|
$statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
|
|
|
|
$statement->execute(TIME_NOW - $lifetime);
|
|
|
|
$objectIDs = array();
|
2011-12-10 16:20:57 +00:00
|
|
|
while ($objectIDs[] = $statement->fetchColumn());
|
2011-11-27 11:21:58 +00:00
|
|
|
return static::deleteAll($objectIDs);
|
|
|
|
}
|
|
|
|
}
|