/**
 * Check if secure connection is available
 */
function fn_settings_actions_security_secure_admin(&$new_value, $old_value)
{
    if ($new_value !== 'N') {
        $suffix = '';
        if (fn_allowed_for('ULTIMATE')) {
            $suffix = '&company_id=' . Registry::get('runtime.company_id');
        }
        $admin_url = fn_url('index.index?check_https=Y' . $suffix, 'A', 'https');
        $content = Http::get($admin_url);
        if (empty($content) || $content != 'OK') {
            // Disable https
            Settings::instance()->updateValue('secure_admin', 'N', 'Security');
            $new_value = 'N';
            $error = Http::getErrorFields();
            $error_warning = __('warning_https_is_disabled', array('[href]' => Registry::get('config.resources.kb_https_failed_url')));
            $error_warning .= fn_settings_actions_build_detailed_error_message($error);
            fn_set_notification('W', __('warning'), $error_warning);
        }
    }
}