1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-23 21:50:09 +00:00
Tims-Chat/file/lib/data/chat/message/ChatMessageEditor.class.php

41 lines
1.1 KiB
PHP
Raw Normal View History

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 be.bastelstu.wcf.chat
2011-11-27 11:21:58 +00:00
* @subpackage data.chat.message
*/
class ChatMessageEditor extends \wcf\data\DatabaseObjectEditor {
/**
* @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.
*/
2012-04-15 15:32:25 +00:00
public static function prune($lifetime = CHAT_LOG_ARCHIVETIME) {
$sql = "SELECT
2012-04-15 16:00:59 +00:00
".static::getDatabaseTableIndexName()."
2011-11-27 11:21:58 +00:00
FROM
2012-04-15 16:00:59 +00:00
".static::getDatabaseTableName()."
2011-11-27 11:21:58 +00:00
WHERE
time < ?";
$stmt = \wcf\system\WCF::getDB()->prepareStatement($sql);
$stmt->execute(array(TIME_NOW - $lifetime));
2011-11-27 11:21:58 +00:00
$objectIDs = array();
while ($objectIDs[] = $stmt->fetchColumn());
return self::deleteAll($objectIDs);
2011-11-27 11:21:58 +00:00
}
}