3 namespace wcf\data\modification\log
;
5 use wcf\system\cache\runtime\UserProfileRuntimeCache
;
6 use wcf\system\log\modification\ConversationModificationLogHandler
;
10 * Represents a list of modification logs for conversation log page.
12 * @author Alexander Ebert
13 * @copyright 2001-2019 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @method ViewableConversationModificationLog current()
17 * @method ViewableConversationModificationLog[] getObjects()
18 * @method ViewableConversationModificationLog|null getSingleObject()
19 * @method ViewableConversationModificationLog|null search($objectID)
20 * @property ViewableConversationModificationLog[] $objects
22 class ConversationLogModificationLogList
extends ModificationLogList
27 public function __construct($conversationID)
29 parent
::__construct();
32 $this->getConditionBuilder()->add(
33 'modification_log.objectTypeID = ?',
34 [ConversationModificationLogHandler
::getInstance()->getObjectType('com.woltlab.wcf.conversation.conversation')->objectTypeID
]
36 $this->getConditionBuilder()->add(
37 'modification_log.objectID = ?',
45 public function readObjects()
47 $sql = "SELECT modification_log.*
48 FROM wcf" . WCF_N
. "_modification_log modification_log
49 " . $this->getConditionBuilder() . "
50 " . (!empty($this->sqlOrderBy
) ?
"ORDER BY " . $this->sqlOrderBy
: '');
51 $statement = WCF
::getDB()->prepareStatement($sql, $this->sqlLimit
, $this->sqlOffset
);
52 $statement->execute($this->getConditionBuilder()->getParameters());
53 $this->objects
= $statement->fetchObjects(($this->objectClassName ?
: $this->className
));
55 // use table index as array index
56 $objects = $userIDs = [];
57 foreach ($this->objects
as $object) {
58 $objectID = $object->{$this->getDatabaseTableIndexName()};
59 $objects[$objectID] = $object;
61 $this->indexToObject
[] = $objectID;
63 if ($object->userID
) {
64 $userIDs[] = $object->userID
;
67 $this->objectIDs
= $this->indexToObject
;
68 $this->objects
= $objects;
70 if (!empty($userIDs)) {
71 UserProfileRuntimeCache
::getInstance()->cacheObjectIDs($userIDs);
74 foreach ($this->objects
as &$object) {
75 $object = new ViewableConversationModificationLog($object);
81 * Returns all log entries created before given point of time. Applicable entries
82 * will be returned and removed from collection.
85 * @return ViewableConversationModificationLog[]
87 public function getEntriesUntil($time)
90 foreach ($this->objects
as $index => $entry) {
91 if ($entry->time
< $time) {
93 unset($this->objects
[$index]);
97 if (!empty($entries)) {
98 $this->indexToObject
= \array_keys
($this->objects
);