<?php if (!defined('VB_ENTRY')) die('Access denied.'); class vB_Api_Vb4_newreply extends vB_Api { public function postreply($threadid, $message, $posthash = null, $subject = null) { $cleaner = vB::getCleaner(); $threadid = $cleaner->clean($threadid, vB_Cleaner::TYPE_UINT); $message = $cleaner->clean($message, vB_Cleaner::TYPE_STR); $subject = $cleaner->clean($subject, vB_Cleaner::TYPE_STR); $posthash = $cleaner->clean($posthash, vB_Cleaner::TYPE_STR); if (empty($threadid) || empty($message)) { return array("response" => array("errormessage" => array("invalidid"))); } $data = array( 'parentid' => $threadid, 'title' => !empty($subject) ? $subject : '(Untitled)', 'rawtext' => $message, 'created' => vB::getRequest()->getTimeNow(), ); $result = vB_Api::instance('content_text')->add($data, array('wysiwyg' => false)); if (empty($result) || !empty($result['errors'])) { return vB_Library::instance('vb4_functions')->getErrorResponse($result); } vB_Library::instance('vb4_posthash')->appendAttachments($result, $posthash); return array('response' => array( 'errormessage' => 'redirect_postthanks', 'show' => array( 'threadid' => $result, 'postid' => $result, ), )); } public function newreply($threadid, $disablesmilies = false) { $cleaner = vB::getCleaner(); $threadid = $cleaner->clean($threadid, vB_Cleaner::TYPE_UINT); $thread = vB_Api::instance('node')->getFullContentforNodes(array($threadid)); if(empty($thread)) { return array("response" => array("errormessage" => array("invalidid"))); } $thread = $thread[0]; $prefixes = vB_Library::instance('vb4_functions')->getPrefixes($threadid); $options = vB::getDatastore()->getValue('options'); $postattachment = $thread['content']['createpermissions']['vbforum_attach']; $postattachment = empty($postattachment) ? 0 : intval($postattachment); $checked = array( 'parseurl' => 1, 'signature' => "", "subscribe" => $thread['content']['subscribed'], ); $userContext = vB::getUserContext(); $currentUserId = $userContext->fetchUserId(); $signature = vB_Api::instanceInternal('user')->fetchSignature($currentUserId); if (!empty($signature)) { $checked['signature'] = 1; } $textDataArray = vB_Api::instanceInternal('content_text')->getDataForParse(array($threadid)); $channelAllowsSmilies = $textDataArray[$threadid]['bbcodeoptions']['allowsmilies']; if ($channelAllowsSmilies) { if (!empty($disablesmilies)) { $checked['disablesmilies'] = 1; } else { $checked['disablesmilies'] = ""; } $show['smiliebox'] = 1; } else { $show['smiliebox'] = 0; } $out = array( 'show' => array( 'tag_option' => 1, 'smiliebox' => $show['smiliebox'], ), 'vboptions' => array( 'postminchars' => $options['postminchars'], 'titlemaxchars' => $options['titlemaxchars'], ), 'response' => array( 'title' => '', 'forumrules' => array( 'can' => array( 'postattachment' => $postattachment, ), ), 'prefix_options' => $prefixes, 'poststarttime' => 0, 'posthash' => vB_Library::instance('vb4_posthash')->getNewPosthash(), ), 'checked' => $checked, ); return $out; } } 