<?php
 class vB_Library_Content_Redirect extends vB_Library_Content_Text { protected $contenttype = 'vBForum_Redirect'; protected string|array $tablename = 'redirect'; protected $bbcode_parser = false; protected bool $canBeLastContent = false; protected bool $skipModNotification = true; protected int $inheritViewPerms = 1; protected bool $showSignature = false; protected $includeInUserPostCount = false; protected function __construct() { parent::__construct(); $this->spamType = false; } public function add($data, array $options = [], $convertWysiwygTextToBbcode = false) { $options['skipFloodCheck'] = true; $options['skipDupCheck'] = true; $options['skipNotification'] = true; $options['skipUpdateLastContent'] = true; return parent::add($data, $options, $convertWysiwygTextToBbcode); } protected function checkFloodAndThrowException(int $channelid, array $data, array $options) : void { return; } public function deleteExpiredRedirects() { $timenow = vB::getRequest()->getTimeNow(); $contenttypeid = vB_Types::instance()->getContentTypeId($this->contenttype); $assertor = vB::getDbAssertor(); $redirectids = $assertor->getColumn('vBForum:node', 'nodeid', [ vB_dB_Query::CONDITIONS_KEY=> [ ['field' => 'contenttypeid', 'value' => $contenttypeid, vB_dB_Query::OPERATOR_KEY => vB_dB_Query::OPERATOR_EQ], ['field' => 'unpublishdate', 'value' => $timenow, vB_dB_Query::OPERATOR_KEY => vB_dB_Query::OPERATOR_LTE] ], ] ); $assertor->delete('vBForum:redirect', ['nodeid' => $redirectids]); $assertor->delete('vBForum:node', ['nodeid' => $redirectids]); } public function getFullContent($nodes) { if (empty($nodes)) { return []; } $results = parent::getFullContent($nodes); foreach ($results AS $nodeid => $node) { $redirect[$node['tonodeid']] =& $results[$nodeid]; } if (!empty($redirect)) { $destiny = vB_Library::instance('node')->getFullContentForNodes(array_keys($redirect)); foreach ($destiny AS $d) { $redirect[$d['nodeid']]['toNode'] = $d; } } return $results; } protected function prepForTypeChangeOldType(array $node) : bool { return false; } protected function prepForTypeChange(array $node) : void { $this->checkContentType($node['nodeid'], $node['contenttypeid']); } } 