<?php
class Andy_ChangeDate_ControllerPublic_Post extends XFCP_Andy_ChangeDate_ControllerPublic_Post
{
public function actionChangedate()
{
$post['post_id'] = $this->_input->filterSingle('post_id', XenForo_Input::UINT);
$post = $this->getModelFromCache('XenForo_Model_Post')->getPostById($post['post_id']);
$viewParams = array('post' => $post);
if (XenForo_Visitor::getInstance()->isSuperAdmin())
{
return $this->responseView('Andy_DateChange_ViewPublic_Post','andy_changedate',$viewParams);
}
}
public function actionChangedatesave()
{
$this->_assertPostOnly();
if (!XenForo_Visitor::getInstance()->isSuperAdmin())
{
return;
}
$post['post_id'] = $this->_input->filterSingle('post_id', XenForo_Input::UINT);
$newPostDate = $this->_input->filterSingle('new_post_date', XenForo_Input::STRING);
if ($newPostDate == '')
{
return $this->responseError(new XenForo_Phrase('date_missing'));
}
$newPostTime = $this->_input->filterSingle('new_post_time', XenForo_Input::STRING);
if ($newPostTime == '')
{
return $this->responseError(new XenForo_Phrase('time_missing'));
}
$date = $newPostDate . ' ' . $newPostTime;
$dateline = strtotime($date) - XenForo_Locale::getTimeZoneOffset();
if ($dateline == '')
{
return $this->responseError(new XenForo_Phrase('date_or_time_format_incorrect'));
}
$dw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');
$dw->setExistingData($post['post_id']);
$dw->set('post_date', $dateline);
$dw->save();
$threadId = $dw->get('thread_id');
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
$dw->setExistingData($threadId);
$dw->rebuildDiscussion();
$dw->save();
return $this->responseRedirect(
XenForo_ControllerResponse_Redirect::SUCCESS,
XenForo_Link::buildPublicLink('posts', $post),'Post Date Changed');
}
}
?>