<?php

class Brivium_Credits_DataWriter_Report extends XFCP_Brivium_Credits_DataWriter_Report
{
	protected function _postSave()
	{
		if ($this->get('content_user_id') && $this->get('content_type')=='post' && $this->isInsert())
		{
			$report = $this->getMergedData();
			$creditModel = $this->_getCreditModel();
			if(!empty($report['content_user_id'])){
				$dataCredit = array(
					'extra_data' =>	array(
						'report_info'	=> $report['content_info']
					),
				);
				if($creditModel->updateUserCredit('reportPost',XenForo_Visitor::getUserId(),$dataCredit)){
					$creditModel->updateUserCredit('postReported',$report['content_user_id'],$dataCredit);
				}
			}
		}
		return parent::_postSave();
	}
	/**
	 * Gets the action model.
	 *
	 * @return Brivium_Credits_Model_Credit
	 */
	protected function _getCreditModel()
	{
		return $this->getModelFromCache('Brivium_Credits_Model_Credit');
	}
}