Manipulate discussion_state in new created discussions

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:
PHP:
    // discussion state changes instead of first message state
     
     $writer->set('discussion_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState(array(), $forum));
This works, but how could I get access to the $writer variable again?
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;
   }
}
If its not possible to get access to $writer, how could I get access to the redirecting URL?
PHP:
      $return = XenForo_Link::buildPublicLink('threads', $thread);

     return $this->responseRedirect(
       XenForo_ControllerResponse_Redirect::SUCCESS,
       $return,
       new XenForo_Phrase('your_thread_has_been_posted')
     );
 
you could overwrite XenForo_Model_Post::getPostInsertMessageState or the thread dw with the proxy system and change the state:)
 
Top Bottom