1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-11-01 14:20:07 +00:00
Tims-Chat/file/lib/data/message/MessageAction.class.php

39 lines
1.1 KiB
PHP
Raw Normal View History

2011-12-13 21:35:11 +00:00
<?php
2013-01-19 19:36:40 +00:00
namespace chat\data\message;
2011-12-13 21:35:11 +00:00
/**
* Executes message related actions.
*
* @author Tim Düsterhus
2013-01-19 19:36:40 +00:00
* @copyright 2010-2013 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>
2013-01-19 19:36:40 +00:00
* @package be.bastelstu.chat
* @subpackage chat.message
2011-12-13 21:35:11 +00:00
*/
2013-01-19 19:36:40 +00:00
class MessageAction extends \wcf\data\AbstractDatabaseObjectAction {
2011-12-13 21:35:11 +00:00
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$className
2011-12-13 21:35:11 +00:00
*/
2013-01-19 19:36:40 +00:00
protected $className = '\chat\data\message\MessageEditor';
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
}