File size: 1.26Kb
<?php
namespace MMO\Hide\BbCode\Tag;
use MMO\Hide\BbCode\AbstractTag;
use XF\Entity\User;
class HideUsersId extends AbstractTag
{
/**
* @inheritDoc
*/
public function render($content, array $tagChildren, $tagOption, array $tag, array $options)
{
$canView = false;
$userIds = \array_map('trim', \explode(',', $tagOption));
$users = [];
foreach ($userIds as $userId)
{
/** @var User $user */
$user = $this->findOne(User::class, [
'user_id', str_replace(" ", "", $userId)
]);
if ($user)
{
$users[] = $user->user_id;
}
}
if (\in_array($this->visitor()->user_id, $users))
{
$canView = true;
}
$params = [
'user_id' => implode(', ', $users)
];
$title = [
'visible' => $this->getTitleVisible('mh_tag_users_id', $params),
'hidden' => $this->getTitleHidden('mh_tag_users_id', $params)
];
return $this->renderTemplate($content, $title, [
'canView' => $canView,
'options' => $options,
'tag' => $tag['tag']
]);
}
}