/** * Checks whether a user has a permission or not. * * @param string|integer $Permission * You can provide a path like /some/permission, a title, or the * permission ID. * In case of ID, don't forget to provide integer (not a string * containing a number). * @param string|integer User ID of a user * * @throws exceptions\PermissionNotFoundException * @throws exceptions\UserNotProvidedException * @return boolean */ function check($Permission, $UserID = null) { if ($UserID === null) { throw new exceptions\UserNotProvidedException("\$UserID is a required argument."); } $PermissionID = $this->Permissions->returnId($Permission); // if invalid, throw exception if ($PermissionID === null) { throw new exceptions\PermissionNotFoundException("The permission '{$Permission}' not found."); } return $this->Users->check($UserID, $PermissionID); }