mirror of
https://github.com/friendica/friendica
synced 2024-11-18 16:23:41 +00:00
Move to PermissionSet::isPublic()
This commit is contained in:
parent
caa977c24e
commit
bf224b58f8
2 changed files with 18 additions and 12 deletions
|
@ -86,16 +86,6 @@ class PermissionSet extends BaseDepository
|
||||||
return new Collection\PermissionSets(parent::_select($condition, $params)->getArrayCopy());
|
return new Collection\PermissionSets(parent::_select($condition, $params)->getArrayCopy());
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkPublic(Entity\PermissionSet $permissionSet): bool
|
|
||||||
{
|
|
||||||
return (($permissionSet->id === self::PUBLIC) ||
|
|
||||||
(is_null($permissionSet->id) &&
|
|
||||||
empty($permissionSet->allow_cid) &&
|
|
||||||
empty($permissionSet->allow_gid) &&
|
|
||||||
empty($permissionSet->deny_cid) &&
|
|
||||||
empty($permissionSet->deny_gid)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a given PermissionSet into a DB compatible row array
|
* Converts a given PermissionSet into a DB compatible row array
|
||||||
*
|
*
|
||||||
|
@ -221,7 +211,7 @@ class PermissionSet extends BaseDepository
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't select/update Public permission sets
|
// Don't select/update Public permission sets
|
||||||
if ($this->checkPublic($permissionSet)) {
|
if ($permissionSet->isPublic()) {
|
||||||
return $this->selectPublicForUser($permissionSet->uid);
|
return $this->selectPublicForUser($permissionSet->uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +231,7 @@ class PermissionSet extends BaseDepository
|
||||||
public function save(Entity\PermissionSet $permissionSet): Entity\PermissionSet
|
public function save(Entity\PermissionSet $permissionSet): Entity\PermissionSet
|
||||||
{
|
{
|
||||||
// Don't save/update the common public PermissionSet
|
// Don't save/update the common public PermissionSet
|
||||||
if ($this->checkPublic($permissionSet)) {
|
if ($permissionSet->isPublic()) {
|
||||||
return $this->selectPublicForUser($permissionSet->uid);
|
return $this->selectPublicForUser($permissionSet->uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Friendica\Security\PermissionSet\Entity;
|
namespace Friendica\Security\PermissionSet\Entity;
|
||||||
|
|
||||||
use Friendica\BaseEntity;
|
use Friendica\BaseEntity;
|
||||||
|
use Friendica\Security\PermissionSet\Depository\PermissionSet as PermissionSetDepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property-read int|null $id
|
* @property-read int|null $id
|
||||||
|
@ -47,6 +48,21 @@ class PermissionSet extends BaseEntity
|
||||||
$this->deny_gid = $deny_gid;
|
$this->deny_gid = $deny_gid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks, if the current PermissionSet is a/the public PermissionSet
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isPublic(): bool
|
||||||
|
{
|
||||||
|
return (($this->id === PermissionSetDepository::PUBLIC) ||
|
||||||
|
(is_null($this->id) &&
|
||||||
|
empty($this->allow_cid) &&
|
||||||
|
empty($this->allow_gid) &&
|
||||||
|
empty($this->deny_cid) &&
|
||||||
|
empty($this->deny_gid)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Entity with a new allowed_cid list (wipes the id because it isn't the same entity anymore)
|
* Creates a new Entity with a new allowed_cid list (wipes the id because it isn't the same entity anymore)
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue