<?php
namespace SV\AttachmentImprovements\XF\Attachment;
class Post extends XFCP_Post
{
public function getConstraints(array $context)
{
$constraints = parent::getConstraints($context);
$thread = null;
$nodeId = null;
$em = \XF::app()->em();
if (!empty($extraContext['node_id']))
{
$nodeId = $extraContext['node_id'];
}
else if (!empty($extraContext['thread_id']))
{
/** @var \XF\Entity\Thread $thread */
$thread = $em->find('XF:Thread', $extraContext['thread_id']);
if ($thread)
{
$nodeId = $thread->node_id;
}
}
else if (!empty($extraContext['post_id']))
{
/** @var \XF\Entity\Post $post */
$post = $em->find('XF:Post', $extraContext['post_id']);
if ($post)
{
/** @var \XF\Entity\Thread $thread */
$thread = $em->find('XF:Thread', $post->thread_id);
if ($thread)
{
$nodeId = $thread->node_id;
}
}
}
if ($nodeId)
{
$constraints = $this->svUpdateConstraints($constraints, $nodeId, $thread);
}
return $constraints;
}
...