public static function api_access_control($model, $httpMethod = 'GET')
    {
        $policy = self::config()->access_control_policy;
        if ($policy === false) {
            return true;
        } // if access control is disabled, skip
        else {
            $policy = constant('self::' . $policy);
        }

        if ($policy === self::ACL_CHECK_MODEL_ONLY) {
            $access = true;
        } else {
            $access = false;
        }

        if ($policy === self::ACL_CHECK_CONFIG_ONLY || $policy === self::ACL_CHECK_CONFIG_AND_MODEL) {
            if (!is_string($model)) {
                $className = get_class($model);
            } else {
                $className = $model;
            }

            $access = self::api_access_config_check($className, $httpMethod);
        }

        if ($policy === self::ACL_CHECK_MODEL_ONLY || $policy === self::ACL_CHECK_CONFIG_AND_MODEL) {
            if ($access) {
                $access = self::model_permission_check($model, $httpMethod);
            }
        }

        return $access;
    }
public static function api_access_control($model, $httpMethod = 'GET')
    {
        $policy = self::config()->access_control_policy;
        if ($policy === false) {
            return true;
        } // if access control is disabled, skip
        else {
            $policy = constant('self::' . $policy);
        }

        if ($policy === self::ACL_CHECK_MODEL_ONLY) {
            $access = true;
        } else {
            $access = false;
        }

        if ($policy === self::ACL_CHECK_CONFIG_ONLY || $policy === self::ACL_CHECK_CONFIG_AND_MODEL) {
            if (!is_string($model)) {
                $className = get_class($model);
            } else {
                $className = $model;
            }

            $access = self::api_access_config_check($className, $httpMethod);
        }

        if ($policy === self::ACL_CHECK_MODEL_ONLY || $policy === self::ACL_CHECK_CONFIG_AND_MODEL) {
            if ($access) {
                $access = self::model_permission_check($model, $httpMethod);
            }
        }

        return $access;
    }
public static function api_access_control ( $ model , $ httpMethod = 'GET' ) { $ policy = self :: config ( ) -> access_control_policy ; if ( $ policy === false ) { return true ; } // if access control is disabled, skip else { $ policy = constant ( 'self::' . $ policy ) ; } if ( $ policy === self :: ACL_CHECK_MODEL_ONLY ) { $ access = true ; } else { $ access = false ; } if ( $ policy === self :: ACL_CHECK_CONFIG_ONLY || $ policy === self :: ACL_CHECK_CONFIG_AND_MODEL ) { if ( ! is_string ( $ model ) ) { $ className = get_class ( $ model ) ; } else { $ className = $ model ; } $ access = self :: api_access_config_check ( $ className , $ httpMethod ) ; } if ( $ policy === self :: ACL_CHECK_MODEL_ONLY || $ policy === self :: ACL_CHECK_CONFIG_AND_MODEL ) { if ( $ access ) { $ access = self :: model_permission_check ( $ model , $ httpMethod ) ; } } return $ access ; }
Checks a class or model api access
depending on access_control_policy and the provided model.
- 1st config check
- 2nd permission check if config access passes

@param  string|DataObject  $model      Model's classname or DataObject
@param  string             $httpMethod API request HTTP method
@return boolean                        true if access is granted, false otherwise
Checks a class or model api access depending on access_control_policy and the provided model . - 1st config check - 2nd permission check if config access passes