2011-12-13 21:35:11 +00:00
|
|
|
<?php
|
|
|
|
namespace wcf\data\chat\message;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Executes message related actions.
|
|
|
|
*
|
|
|
|
* @author Tim Düsterhus
|
2012-01-28 16:50:33 +00:00
|
|
|
* @copyright 2010-2012 Tim Düsterhus
|
2011-12-13 21:35:11 +00:00
|
|
|
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
2012-03-12 16:18:15 +00:00
|
|
|
* @package be.bastelstu.wcf.chat
|
2011-12-13 21:35:11 +00:00
|
|
|
* @subpackage data.chat.message
|
|
|
|
*/
|
|
|
|
class ChatMessageAction extends \wcf\data\AbstractDatabaseObjectAction {
|
|
|
|
/**
|
2012-02-26 16:55:44 +00:00
|
|
|
* @see \wcf\data\AbstractDatabaseObjectAction::$className
|
2011-12-13 21:35:11 +00:00
|
|
|
*/
|
|
|
|
protected $className = '\wcf\data\chat\message\ChatMessageEditor';
|
2012-05-19 18:33:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes old messages.
|
|
|
|
*
|
|
|
|
* @return integer Number of deleted messages.
|
|
|
|
*/
|
|
|
|
public function prune() {
|
|
|
|
$sql = "SELECT
|
|
|
|
".call_user_func(array($this->className, 'getDatabaseTableIndexName'))."
|
|
|
|
FROM
|
|
|
|
".call_user_func(array($this->className, 'getDatabaseTableName'))."
|
|
|
|
WHERE
|
|
|
|
time < ?";
|
|
|
|
$stmt = \wcf\system\WCF::getDB()->prepareStatement($sql);
|
|
|
|
$stmt->execute(array(TIME_NOW - CHAT_LOG_ARCHIVETIME));
|
|
|
|
$objectIDs = array();
|
|
|
|
while ($objectIDs[] = $stmt->fetchColumn());
|
|
|
|
|
|
|
|
return call_user_func(array($this->className, 'deleteAll'), $objectIDs);
|
|
|
|
}
|
2011-12-13 21:35:11 +00:00
|
|
|
}
|