View file upload/src/addons/MMO/Hide/BbCode/Tag/HideReplyReacts.php

File size: 0.99Kb
<?php

namespace MMO\Hide\BbCode\Tag;

class HideReplyReacts extends AbstractTag
{
    /**
     * @inheritDoc
     */
    public function render($content, array $tagChildren, $tagOption, array $tag, array $options)
    {
        $canView = false;
        $tagOptions = explode(',', $tagOption);
        $reactedUsers = $options['entity']['reaction_users'];

        foreach ($reactedUsers AS $reactedUser)
        {
            if ($reactedUser['user_id'] != $this->visitor()->user_id || !in_array($reactedUser['reaction_id'], $tagOptions) || $this->canReplyView($options))
            {
                continue;
            }

            $canView = true;
        }

        $title = $this->templater->renderTemplate('public:mh_tag_react', [
            'reactions' => $tagOptions
        ]);

        return $this->renderTemplate($content, $title, [
            'canView' => $canView,
            'options' => $options,
            'tag' => $tag['tag']
        ]);
    }
}