<?php
namespace Test\Demo\XF\Entity;
use XF\Mvc\Entity\Entity;
class Post extends XFCP_Post
{
public function canView(&$error = null)
{
//get visitor
$visitor = \XF::visitor();
//get parent method
$canView = parent::canView();
if (!$canView)
{
if (!$this->Thread || !$this->Thread->canView($error))
{
return false;
}
if ($visitor->user_id == $this->Thread->user_id)
{
// view moderated posts
if ($this->message_state == 'moderated')
{
return $visitor->hasNodePermission($this->Thread->node_id, 'yourPermission');
}
// view deleted posts
if ($this->message_state == 'deleted')
{
return $visitor->hasNodePermission($this->Thread->node_id, 'yourPermission');
}
}
}
return $canView;
}