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

File size: 935B
<?php

namespace MMO\Hide\BbCode\Tag;

class HideUsersId extends AbstractTag
{
    /**
     * @inheritDoc
     */
    public function render($content, array $tagChildren, $tagOption, array $tag, array $options)
    {
        $canView = false;
        $tagOptions = explode(',', $tagOption);
        $users = [];
        foreach ($tagOptions as $user)
        {
            $user = $this->findOne('XF:User', ['user_id', str_replace(" ", "", $user)]);
            $users[] = $user['user_id'];
        }

        if (in_array($this->visitor()->user_id, $users))
        {
            $canView = true;
        }

        $title = \XF::phrase('mh_tag_users_id_x', [
            'user_id' => implode(', ', $users)
        ]);

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