public function hasPermission($sSearch, $mUser = null)
    {
        //  Fetch the correct ACL
        if (is_numeric($mUser)) {

            $oUser = $this->getById($mUser);

            if (isset($oUser->acl)) {
                $aAcl = $oUser->acl;
                unset($oUser);
            } else {
                return false;
            }

        } elseif (isset($mUser->acl)) {
            $aAcl = $mUser->acl;
        } else {
            $aAcl = (array) $this->activeUser('acl');
        }

        // --------------------------------------------------------------------------

        // Super users or CLI users can do anything their heart desires
        $oInput = Factory::service('Input');
        if (in_array('admin:superuser', $aAcl) || $oInput::isCli()) {
            return true;
        }

        // --------------------------------------------------------------------------

        /**
         * Test the ACL
         * We're going to use regular expressions here so we can allow for some
         * flexibility in the search, i.e admin:* would return true if the user has
         * access to any of admin.
         */

        $bHasPermission = false;

        /**
         * Replace :* with :.* - this is a common mistake when using the permission
         * system (i.e., assuming that star on it's own will match)
         */

        $sSearch = strtolower(preg_replace('/:\*/', ':.*', $sSearch));

        foreach ($aAcl as $sPermission) {

            $sPattern = '/^' . $sSearch . '$/';
            $bMatch   = preg_match($sPattern, $sPermission);

            if ($bMatch) {
                $bHasPermission = true;
                break;
            }
        }

        return $bHasPermission;
    }
public function hasPermission($sSearch, $mUser = null)
    {
        //  Fetch the correct ACL
        if (is_numeric($mUser)) {

            $oUser = $this->getById($mUser);

            if (isset($oUser->acl)) {
                $aAcl = $oUser->acl;
                unset($oUser);
            } else {
                return false;
            }

        } elseif (isset($mUser->acl)) {
            $aAcl = $mUser->acl;
        } else {
            $aAcl = (array) $this->activeUser('acl');
        }

        // --------------------------------------------------------------------------

        // Super users or CLI users can do anything their heart desires
        $oInput = Factory::service('Input');
        if (in_array('admin:superuser', $aAcl) || $oInput::isCli()) {
            return true;
        }

        // --------------------------------------------------------------------------

        /**
         * Test the ACL
         * We're going to use regular expressions here so we can allow for some
         * flexibility in the search, i.e admin:* would return true if the user has
         * access to any of admin.
         */

        $bHasPermission = false;

        /**
         * Replace :* with :.* - this is a common mistake when using the permission
         * system (i.e., assuming that star on it's own will match)
         */

        $sSearch = strtolower(preg_replace('/:\*/', ':.*', $sSearch));

        foreach ($aAcl as $sPermission) {

            $sPattern = '/^' . $sSearch . '$/';
            $bMatch   = preg_match($sPattern, $sPermission);

            if ($bMatch) {
                $bHasPermission = true;
                break;
            }
        }

        return $bHasPermission;
    }
public function hasPermission ( $ sSearch , $ mUser = null ) { //  Fetch the correct ACL if ( is_numeric ( $ mUser ) ) { $ oUser = $ this -> getById ( $ mUser ) ; if ( isset ( $ oUser -> acl ) ) { $ aAcl = $ oUser -> acl ; unset ( $ oUser ) ; } else { return false ; } } elseif ( isset ( $ mUser -> acl ) ) { $ aAcl = $ mUser -> acl ; } else { $ aAcl = ( array ) $ this -> activeUser ( 'acl' ) ; } // -------------------------------------------------------------------------- // Super users or CLI users can do anything their heart desires $ oInput = Factory :: service ( 'Input' ) ; if ( in_array ( 'admin:superuser' , $ aAcl ) || $ oInput :: isCli ( ) ) { return true ; } // -------------------------------------------------------------------------- /**
         * Test the ACL
         * We're going to use regular expressions here so we can allow for some
         * flexibility in the search, i.e admin:* would return true if the user has
         * access to any of admin.
         */ $ bHasPermission = false ; /**
         * Replace :* with :.* - this is a common mistake when using the permission
         * system (i.e., assuming that star on it's own will match)
         */ $ sSearch = strtolower ( preg_replace ( '/:\*/' , ':.*' , $ sSearch ) ) ; foreach ( $ aAcl as $ sPermission ) { $ sPattern = '/^' . $ sSearch . '$/' ; $ bMatch = preg_match ( $ sPattern , $ sPermission ) ; if ( $ bMatch ) { $ bHasPermission = true ; break ; } } return $ bHasPermission ; }
Determines whether the specified user has a certain ACL permission

@param string $sSearch   The permission to check for
@param mixed  $mUser     The user to check for; if null uses activeUser, if numeric, fetches user, if object
uses that object

@return  boolean
Determines whether the specified user has a certain ACL permission