Move security evaluations for File/Echoareas back to model
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user