File tree Expand file tree Collapse file tree
wcfsetup/install/files/lib/system/session Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -745,6 +745,25 @@ public function getPermission(string $permission): mixed
745745 return $ this ->groupData [$ permission ];
746746 }
747747
748+ /**
749+ * Returns true if the active user has the given permission.
750+ * Only works for boolean permisions.
751+ *
752+ * @throws \BadMethodCallException
753+ * @since 6.3
754+ */
755+ public function hasPermission (string $ permission ): bool
756+ {
757+ $ result = $ this ->getPermission ($ permission );
758+ if ($ result === true || $ result === 1 || $ result === '1 ' ) {
759+ return true ;
760+ } else if ($ result === false || $ result === 0 || $ result === '0 ' ) {
761+ return false ;
762+ }
763+
764+ throw new \BadMethodCallException ("' {$ permission }' is not a boolean permission " );
765+ }
766+
748767 /**
749768 * Returns true if a permission was set to 'Never'. This is required to preserve
750769 * compatibility, while preventing ACLs from overruling a 'Never' setting.
You can’t perform that action at this time.
0 commit comments