Issue #44 resolved
Kent-Rune Henriksen
repo owner created an issue

System for easily checking which permissions a player have, and an easy settings panel where permissions can be changed. This will be done using bitmask (Source).

<?php
define('PERMISSION_DENIED', 0);
define('PERMISSION_READ', 1);
define('PERMISSION_ADD',  2);
define('PERMISSION_UPDATE', 4);
define('PERMISSION_DELETE', 8);

?>

And a user permissions library (Source).

    public function __construct($Mask)
    {
        $this->Mask = $Mask;
    }

    public function InvokePermission($Bit)
    {
        return ($Mask & $Bit); //True / False
    }

    public function AddPermission($Bit)
    {
        $this->Mask |= $Bit; //Add the bit to the mask
    }

    public function RevokePermission()
    {
        $this->Mask &= ~ $Bit;
    }

    public GetMask()
    {
         return $this->Mask;
    }

Comments (1)

  1. Log in to comment