* @package be.bastelstu.wcf.chat * @subpackage data.chat.message */ class ChatMessageEditor extends \wcf\data\DatabaseObjectEditor { /** * @see \wcf\data\DatabaseObjectDecorator::$baseClass */ protected static $baseClass = '\wcf\data\chat\message\ChatMessage'; /** * Notify the Push-Server. */ public static function create(array $parameters = array()) { try { if (\wcf\util\ChatUtil::nodePushRunning()) { $sock = stream_socket_client('unix://'.WCF_DIR.'acp/be.bastelstu.wcf.chat.nodePush/data.sock', $errno, $errstr, 1); fclose($sock); } } catch (\Exception $e) { } return parent::create($parameters); } /** * Removes old messages. * * @param integer $lifetime Delete messages older that this time. * @return integer Number of deleted messages. */ public static function prune($lifetime = CHAT_LOG_ARCHIVETIME) { $sql = "SELECT ".static::getDatabaseTableIndexName()." FROM ".static::getDatabaseTableName()." WHERE time < ?"; $stmt = \wcf\system\WCF::getDB()->prepareStatement($sql); $stmt->execute(array(TIME_NOW - $lifetime)); $objectIDs = array(); while ($objectIDs[] = $stmt->fetchColumn()); return self::deleteAll($objectIDs); } }