1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Manipulate discussion_state in new created discussions

Discussion in 'XenForo Development Discussions' started by Marcus, Jul 19, 2013.

  1. Marcus

    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')
         );
     
  2. xf_phantom

    xf_phantom Well-Known Member

    you could overwrite XenForo_Model_Post::getPostInsertMessageState or the thread dw with the proxy system and change the state:)
     
    Marcus likes this.
  3. xf_phantom

    xf_phantom Well-Known Member

    Marcus likes this.

Share This Page