Marcus
Well-known member
In some occasions I want to manipulate the message state of new added discussions. In DataWriter_Discussion_Thread everything useful for that is protected. In ControllerPublic_Forum::actionAddThread, the discussion_state is set:
This works, but how could I get access to the $writer variable again?
If its not possible to get access to $writer, how could I get access to the redirecting URL?
PHP:
// discussion state changes instead of first message state
$writer->set('discussion_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState(array(), $forum));
PHP:
class Spam_ControllerPublic_Forum extends XFCP_Spam_ControllerPublic_Forum
{
public function actionAddThread()
{
$response = parent::actionAddThread();
$threadId = $writer->get['thread_id'];
$writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
$writer->setExistingData($threadId);
$writer->set('discussion_state', 'moderated');
$writer->save();
return $response;
}
}
PHP:
$return = XenForo_Link::buildPublicLink('threads', $thread);
return $this->responseRedirect(
XenForo_ControllerResponse_Redirect::SUCCESS,
$return,
new XenForo_Phrase('your_thread_has_been_posted')
);