<?php
class Brivium_Credits_DataWriter_DiscussionMessage_ProfilePost extends XFCP_Brivium_Credits_DataWriter_DiscussionMessage_ProfilePost
{
	
	protected function _messagePostSave()
	{
		
		if ($this->isStatus() && $this->isChanged('message'))
		{
			$this->_getCreditModel()->updateUserCredit('updateStatus',$this->get('user_id'));
		}
		if ($this->isInsert() && !$this->isStatus())
		{
			$dataCredit = array(
				'extraData' 		=>	array('user_id'=>$this->get('profile_user_id'))
			);
			$this->_getCreditModel()->updateUserCredit('profilePost',$this->get('user_id'),$dataCredit);
			$dataCredit = array(
				'user_action_id' 	=>	$this->get('user_id'),
				'content_id' 		=>	$this->get('profile_post_id'),
				'content_type'		=>	'profile_post',
				'extraData' 		=>	array('user_id'=>$this->get('user_id'))
			);
			$this->_getCreditModel()->updateUserCredit('getProfilePost',$this->get('profile_user_id'),$dataCredit);
		}
		return parent::_messagePostSave();
	}
	/**
	 * Gets the action model.
	 *
	 * @return Brivium_Credits_Model_Credit
	 */
	protected function _getCreditModel()
	{
		return $this->getModelFromCache('Brivium_Credits_Model_Credit');
	}
}