<?php
 abstract class vB_Systemevent_Item_ChannelTask extends vB_Systemevent_Item { protected vB_Entity_Channeltask $entity; protected array $serializefields = ['entity']; private static int $lookbackDays = 30; public static function createTaskFromEntity(vB_Entity_Channeltask $entity) : self { $class = 'vB_Systemevent_Item_ChannelTask_' . ucfirst($entity->task); $item = new $class(); $item->entity = $entity; return $item; } protected function getTopics() { $db = vB::getDbAssertor(); $timenow = vB::getRequest()->getTimeNow(); $cutoff = $timenow - $this->entity->maxageseconds; $max_cutoff = $cutoff - (self::$lookbackDays * 86400); if ($this->entity->maxagefrom == 'created') { $query = 'vBForum:fetchHardAutoExpireTopicsForChannel'; } else { $query = 'vBForum:fetchSoftAutoExpireTopicsForChannel'; } return $db->getColumn($query, 'nodeid', [ 'cutoff' => $cutoff, 'lookback_cutoff' => $max_cutoff, 'parentid' => $this->entity->nodeid, ]); } public function jsonSerialize() : mixed { return $this->entity; } protected function fromData(mixed $item) : void { $this->entity = vB_Entity_Channeltask::createFromArray($item); } } 