<?php
 class vB_Api_Content_Redirect extends vB_Api_Content_Text { protected $contenttype = 'vBForum_Redirect'; protected function __construct() { parent::__construct(); $this->library = vB_Library::instance('Content_Redirect'); } public function add($data, $options = []) { if (!$this->library->validate($data, vB_Library_Content::ACTION_ADD)) { throw new vB_Exception_Api('no_create_permissions'); } $data = $this->cleanInput($data); $this->cleanOptions($options); $wysiwyg = true; if (isset($options['wysiwyg'])) { $wysiwyg = (bool) $options['wysiwyg']; } $result = $this->library->add($data, $options, $wysiwyg); return $result['nodeid']; } public function removeRedirectsFromNode($nodeid) { $nodeid = intval($nodeid); $usercontext = vB::getUserContext(); $db = vB::getDbAssertor(); if (!$usercontext->isModerator()) { throw new vB_Exception_Api('no_permission'); } $session = vB::getCurrentSession(); if (!$session->validateCpsession()) { throw new vB_Exception_Api('inlinemodauth_required'); } if (!$usercontext->getChannelPermission('moderatorpermissions', 'canmanagethreads', $nodeid)) { throw new vB_Exception_Api('no_permission'); } $redirects = $db->getColumn('vBForum:redirect', 'nodeid', ['tonodeid' => $nodeid]); foreach ($redirects AS $redirect) { $this->library->delete($redirect); } return ['success' => true]; } } 