Continued work on getter/setters: post visibility

This commit is contained in:
Marcin Kurczewski 2014-05-07 18:00:05 +02:00
parent 75704ef0da
commit 8d8e92b84e
6 changed files with 12 additions and 7 deletions

View file

@ -35,7 +35,7 @@ class GetPostContentJob extends AbstractJob
$post = $this->post;
$privileges = [];
if ($post->hidden)
if ($post->isHidden())
$privileges []= new Privilege(Privilege::ViewPost, 'hidden');
$privileges []= new Privilege(Privilege::ViewPost, $post->getSafety()->toString());

View file

@ -15,7 +15,7 @@ class GetPostJob extends AbstractPostJob
$post = $this->post;
$privileges = [];
if ($post->hidden)
if ($post->isHidden())
$privileges []= new Privilege(Privilege::ViewPost, 'hidden');
$privileges []= new Privilege(Privilege::ViewPost, $post->getSafety()->toString());

View file

@ -18,7 +18,7 @@ class GetPostThumbJob extends AbstractJob
{
$post = PostModel::findByIdOrName($name);
if ($post->hidden)
if ($post->isHidden())
Access::assert(new Privilege(Privilege::ListPosts, 'hidden'));
Access::assert(new Privilege(Privilege::ListPosts, $post->getSafety()->toString()));

View file

@ -11,7 +11,7 @@ class PostEntity extends AbstractEntity implements IValidatable
public $fileSize;
public $mimeType;
protected $safety;
public $hidden;
protected $hidden;
public $uploadDate;
protected $imageWidth;
protected $imageHeight;
@ -182,6 +182,11 @@ class PostEntity extends AbstractEntity implements IValidatable
return false;
}
public function isHidden()
{
return $this->hidden;
}
public function setHidden($hidden)
{
$this->hidden = boolval($hidden);

View file

@ -26,7 +26,7 @@ class PostModel extends AbstractCrudModel
{
$post = new PostEntity;
$post->setSafety(new PostSafety(PostSafety::Safe));
$post->hidden = false;
$post->setHidden(false);
$post->uploadDate = time();
do
{
@ -52,7 +52,7 @@ class PostModel extends AbstractCrudModel
'file_size' => $post->fileSize,
'mime_type' => $post->mimeType,
'safety' => $post->getSafety()->toInteger(),
'hidden' => $post->hidden,
'hidden' => $post->isHidden(),
'upload_date' => $post->uploadDate,
'image_width' => $post->getImageWidth(),
'image_height' => $post->getImageHeight(),

View file

@ -320,7 +320,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
Privilege::HidePost,
Access::getIdentity($this->context->transport->post->getUploader()))))
{
if ($this->context->transport->post->hidden)
if ($this->context->transport->post->isHidden())
{
$options []=
[