<?php
class Andy_SmilieCount_ControllerPublic_Thread extends XFCP_Andy_SmilieCount_ControllerPublic_Thread
{
public function actionAddReply()
{
$smilietext = $this->getModelFromCache('XenForo_Model_Smilie')->getSmilieText();
$maxsmiliecount = $this->getModelFromCache('XenForo_Model_Smilie')->getMaxSmilieCount();
foreach ($maxsmiliecount as $k => $v)
{
$phrase_text = $v['phrase_text'];
}
$pos1 = strpos($phrase_text, '(');
$pos2 = strpos($phrase_text, ')');
$pos_length = $pos2 - $pos1;
$pos_length = $pos_length - 1;
$pos1 = $pos1 + 1;
$max_count = substr($phrase_text, $pos1, $pos_length);
$this->_assertPostOnly();
if ($this->_input->inRequest('more_options'))
{
return $this->responseReroute(__CLASS__, 'reply');
}
$threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);
$visitor = XenForo_Visitor::getInstance();
$ftpHelper = $this->getHelper('ForumThreadPost');
$threadFetchOptions = array('readUserId' => $visitor['user_id']);
$forumFetchOptions = array('readUserId' => $visitor['user_id']);
list($thread, $forum) = $ftpHelper->assertThreadValidAndViewable($threadId, $threadFetchOptions, $forumFetchOptions);
$this->_assertCanReplyToThread($thread, $forum);
if (!XenForo_Captcha_Abstract::validateDefault($this->_input))
{
return $this->responseCaptchaFailed();
}
$input = $this->_input->filter(array(
'attachment_hash' => XenForo_Input::STRING,
'watch_thread_state' => XenForo_Input::UINT,
'watch_thread' => XenForo_Input::UINT,
'watch_thread_email' => XenForo_Input::UINT,
'_set' => array(XenForo_Input::UINT, 'array' => true),
'discussion_open' => XenForo_Input::UINT,
'sticky' => XenForo_Input::UINT,
));
$input['message'] = $this->getHelper('Editor')->getMessageText('message', $this->_input);
$input['message'] = XenForo_Helper_String::autoLinkBbCode($input['message']);
$smilie_count = 0;
foreach ($smilietext as $k => $v)
{
$smilie_count += substr_count($input['message'], $v['smilie_text']);
}
if ($smilie_count > $max_count)
{
return $this->responseError(new XenForo_Phrase('please_reduce_the_number_of_smilies_to_or_less'));
} else {
return parent::actionAddReply();
}
}
}
?>