2014-09-05 19:18:49 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru\Controllers\ViewProxies;
|
|
|
|
|
|
|
|
class UserViewProxy extends AbstractViewProxy
|
|
|
|
{
|
2014-09-06 10:00:26 +02:00
|
|
|
private $privilegeService;
|
|
|
|
|
|
|
|
public function __construct(\Szurubooru\Services\PrivilegeService $privilegeService)
|
|
|
|
{
|
|
|
|
$this->privilegeService = $privilegeService;
|
|
|
|
}
|
|
|
|
|
2014-09-05 19:18:49 +02:00
|
|
|
public function fromEntity($user)
|
|
|
|
{
|
|
|
|
$result = new \StdClass;
|
|
|
|
if ($user)
|
|
|
|
{
|
|
|
|
$result->id = $user->id;
|
|
|
|
$result->name = $user->name;
|
2014-09-06 10:00:26 +02:00
|
|
|
$result->accessRank = \Szurubooru\Helpers\EnumHelper::accessRankToString($user->accessRank);
|
|
|
|
$result->registrationTime = $user->registrationTime;
|
|
|
|
$result->lastLoginTime = $user->lastLoginTime;
|
2014-09-07 00:33:46 +02:00
|
|
|
$result->avatarStyle = $user->avatarStyle;
|
2014-09-06 10:00:26 +02:00
|
|
|
|
2014-09-07 14:50:16 +02:00
|
|
|
if ($this->privilegeService->isLoggedIn($user))
|
|
|
|
{
|
|
|
|
$result->browsingSettings = $user->browsingSettings;
|
|
|
|
}
|
|
|
|
|
2014-09-07 00:33:46 +02:00
|
|
|
if ($this->privilegeService->hasPrivilege(\Szurubooru\Privilege::VIEW_ALL_EMAIL_ADDRESSES) or
|
2014-09-06 10:00:26 +02:00
|
|
|
$this->privilegeService->isLoggedIn($user))
|
|
|
|
{
|
|
|
|
$result->email = $user->email;
|
2014-09-08 13:06:32 +02:00
|
|
|
$result->emailUnconfirmed = $user->emailUnconfirmed;
|
2014-09-06 10:00:26 +02:00
|
|
|
}
|
2014-09-10 18:06:49 +02:00
|
|
|
|
|
|
|
$result->confirmed = !$user->emailUnconfirmed;
|
2014-09-05 19:18:49 +02:00
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|