Move security evaluations for File/Echoareas back to model

This commit is contained in:
2024-04-14 21:16:33 +10:00
parent 9c9fd84e0a
commit a2ff2df9f3
7 changed files with 42 additions and 8 deletions

View File

@@ -7,6 +7,39 @@ namespace App\Traits;
trait AreaSecurity
{
/**
* Does the security level provide read or write access
*
* @param int $sec
* @return bool
*/
public function can_access(int $sec): bool
{
return $this->can_read($sec) || $this->can_write($sec);
}
/**
* Does the security level provide read access
*
* @param int $sec
* @return bool
*/
public function can_read(int $sec): bool
{
return $this->active && (($sec >= ($x=$this->getSecReadAttribute())) && $x);
}
/**
* Does the security level provide write access
*
* @param int $sec
* @return bool
*/
public function can_write(int $sec): bool
{
return $this->active && (($sec >= ($x=$this->getSecWriteAttribute())) && $x);
}
public function getSecReadAttribute(): int
{
return ($this->security>>3) & 0x7;