Continued work on getter/setters: post visibility
This commit is contained in:
parent
75704ef0da
commit
8d8e92b84e
6 changed files with 12 additions and 7 deletions
|
@ -35,7 +35,7 @@ class GetPostContentJob extends AbstractJob
|
||||||
$post = $this->post;
|
$post = $this->post;
|
||||||
$privileges = [];
|
$privileges = [];
|
||||||
|
|
||||||
if ($post->hidden)
|
if ($post->isHidden())
|
||||||
$privileges []= new Privilege(Privilege::ViewPost, 'hidden');
|
$privileges []= new Privilege(Privilege::ViewPost, 'hidden');
|
||||||
|
|
||||||
$privileges []= new Privilege(Privilege::ViewPost, $post->getSafety()->toString());
|
$privileges []= new Privilege(Privilege::ViewPost, $post->getSafety()->toString());
|
||||||
|
|
|
@ -15,7 +15,7 @@ class GetPostJob extends AbstractPostJob
|
||||||
$post = $this->post;
|
$post = $this->post;
|
||||||
$privileges = [];
|
$privileges = [];
|
||||||
|
|
||||||
if ($post->hidden)
|
if ($post->isHidden())
|
||||||
$privileges []= new Privilege(Privilege::ViewPost, 'hidden');
|
$privileges []= new Privilege(Privilege::ViewPost, 'hidden');
|
||||||
|
|
||||||
$privileges []= new Privilege(Privilege::ViewPost, $post->getSafety()->toString());
|
$privileges []= new Privilege(Privilege::ViewPost, $post->getSafety()->toString());
|
||||||
|
|
|
@ -18,7 +18,7 @@ class GetPostThumbJob extends AbstractJob
|
||||||
{
|
{
|
||||||
$post = PostModel::findByIdOrName($name);
|
$post = PostModel::findByIdOrName($name);
|
||||||
|
|
||||||
if ($post->hidden)
|
if ($post->isHidden())
|
||||||
Access::assert(new Privilege(Privilege::ListPosts, 'hidden'));
|
Access::assert(new Privilege(Privilege::ListPosts, 'hidden'));
|
||||||
Access::assert(new Privilege(Privilege::ListPosts, $post->getSafety()->toString()));
|
Access::assert(new Privilege(Privilege::ListPosts, $post->getSafety()->toString()));
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class PostEntity extends AbstractEntity implements IValidatable
|
||||||
public $fileSize;
|
public $fileSize;
|
||||||
public $mimeType;
|
public $mimeType;
|
||||||
protected $safety;
|
protected $safety;
|
||||||
public $hidden;
|
protected $hidden;
|
||||||
public $uploadDate;
|
public $uploadDate;
|
||||||
protected $imageWidth;
|
protected $imageWidth;
|
||||||
protected $imageHeight;
|
protected $imageHeight;
|
||||||
|
@ -182,6 +182,11 @@ class PostEntity extends AbstractEntity implements IValidatable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isHidden()
|
||||||
|
{
|
||||||
|
return $this->hidden;
|
||||||
|
}
|
||||||
|
|
||||||
public function setHidden($hidden)
|
public function setHidden($hidden)
|
||||||
{
|
{
|
||||||
$this->hidden = boolval($hidden);
|
$this->hidden = boolval($hidden);
|
||||||
|
|
|
@ -26,7 +26,7 @@ class PostModel extends AbstractCrudModel
|
||||||
{
|
{
|
||||||
$post = new PostEntity;
|
$post = new PostEntity;
|
||||||
$post->setSafety(new PostSafety(PostSafety::Safe));
|
$post->setSafety(new PostSafety(PostSafety::Safe));
|
||||||
$post->hidden = false;
|
$post->setHidden(false);
|
||||||
$post->uploadDate = time();
|
$post->uploadDate = time();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ class PostModel extends AbstractCrudModel
|
||||||
'file_size' => $post->fileSize,
|
'file_size' => $post->fileSize,
|
||||||
'mime_type' => $post->mimeType,
|
'mime_type' => $post->mimeType,
|
||||||
'safety' => $post->getSafety()->toInteger(),
|
'safety' => $post->getSafety()->toInteger(),
|
||||||
'hidden' => $post->hidden,
|
'hidden' => $post->isHidden(),
|
||||||
'upload_date' => $post->uploadDate,
|
'upload_date' => $post->uploadDate,
|
||||||
'image_width' => $post->getImageWidth(),
|
'image_width' => $post->getImageWidth(),
|
||||||
'image_height' => $post->getImageHeight(),
|
'image_height' => $post->getImageHeight(),
|
||||||
|
|
|
@ -320,7 +320,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
||||||
Privilege::HidePost,
|
Privilege::HidePost,
|
||||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||||
{
|
{
|
||||||
if ($this->context->transport->post->hidden)
|
if ($this->context->transport->post->isHidden())
|
||||||
{
|
{
|
||||||
$options []=
|
$options []=
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in a new issue