From d3e8cba1327983d4e17ff414f2d7e5726d8a77b0 Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Mon, 25 Nov 2013 18:02:31 +1030 Subject: [PATCH] Basic PermissionsAPI template for others to improve. --- src/API/PermissionsAPI.php | 97 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/API/PermissionsAPI.php diff --git a/src/API/PermissionsAPI.php b/src/API/PermissionsAPI.php new file mode 100644 index 000000000..cad35a393 --- /dev/null +++ b/src/API/PermissionsAPI.php @@ -0,0 +1,97 @@ +The whole point of this permissions API is to provide developers with an expendable API + * that allows fine tuning of each and every specific part of PocketMine. + * + * Thus, it should be as abstract as possible. + * + * Roles and levels - Administrator / Moderator etc will be handled by plugins. + * Permissions loading and file formats etc will be handled by separate plugins. + * + * Permission checking on events will be handled by this API + * Add enable-op argument to allow disabling OP systems. OP system should override this permission system, and this API + * Will determine whether that option is set or not.

+ */ +class PermissionsAPI +{ + function __construct() + { + + } + + function __destruct() + { + + } + + public function init() + { + + } + + /** + * @param string $username Username of the user to check permissions + * @param integer $permission Permission to check the user for. + * + * @return boolean Whether the person has permissions or not. + */ + public static function isPermissionGranted($username, $permission) + { + + } + + /** + * @param Player $player Username of the user to check permissions + * @param integer $permission Permission to check the user for. + * + * @return boolean True ons set. False on failure. + */ + public static function setPermission($player, $permission) + { + if(!isset($player->permissions) or !($player->permissions instanceof stdClass)) + { + $player->permission = new stdClass(); + }//Check if the permission variable is set, and initialise it if not. + + + } +} + +/** + * Class Permission + * + * Each Permission object will be given a level in integer, and it will be this permission object that will be assigned to players. + * Not just an integer variable. + * + * Plugins can extend this to have their own Permissions assigned to players. + */ +abstract class Permission +{ + private $permissionLevel; + + public abstract function getPermissionLevel(); +} \ No newline at end of file