<?php
class DigitalPointSpy_DataWriter_DiscussionMessage_Post extends XFCP_DigitalPointSpy_DataWriter_DiscussionMessage_Post
{
public function save()
{
if ($response = parent::save())
{
if (isset($this->_existingData['xf_post']['post_id']) && isset($this->_existingData['xf_post']['thread_id']))
{
// Changing state... will be picked up by moderator log as delete/undelete, etc.
if (@$this->_existingData['xf_post']['post_id'] == @$this->_newData['xf_post']['post_id'])
{
$this->_db->insert('dp_spy', array(
'user_id' => XenForo_Visitor::getUserId(),
'thread_id' => $this->_existingData['xf_post']['thread_id'],
'post_id' => $this->_existingData['xf_post']['post_id'],
'date' => XenForo_Application::$time,
'action' => 'post_edit'
));
}
}
// New post/thread
elseif (isset($this->_newData['xf_post']['post_id']) && isset($this->_newData['xf_post']['thread_id']))
{
$this->_db->insert('dp_spy', array(
'user_id' => XenForo_Visitor::getUserId(),
'thread_id' => $this->_newData['xf_post']['thread_id'],
'post_id' => $this->_newData['xf_post']['post_id'],
'date' => XenForo_Application::$time,
'action' => ($this->_newData['xf_post']['position'] == 0 ? 'thread' : 'post') . '_create'
));
}
}
return $response;
}
}