{
# this fragment is to force SSL redirection for webdav activated account in case it is not already enabled
# could be removed if core fragment 20IbaysContent introduce forced ssl for DAV
   use esmith::AccountsDB;
   my $adb = esmith::AccountsDB->open_ro();
   $OUT = "";
   foreach my $ibay ($adb->ibays)
   {
        my %properties = $ibay->props;
        my $key = $ibay->key;
        my $dynamicContent = $properties{'CgiBin'} || "disabled";
        my $secureEXEC = $properties{'ModDAVsecureEXEC'} || 'enabled';
        my $access = $properties{'PublicAccess'} || 'none';
        $OUT .= "\n    # ibay $key disabled for httpd so no DAV access\n" if $access eq 'none';
        next if $access eq 'none';
        # true if have to be password accessible from somewhere.
        my $ispassibay = $access =~ /-pw/;
        my $satisfy = ($access eq 'global-pw-remote')? 'any': 'all';
        if ($properties{'ModDav'})
        {
            if ($properties{'ModDav'} eq 'enabled')
            {
		# we force SSL redirection in case DAV is enabled
                if (( $port ne $httpsPort ) && (($ibay->prop('SSL') || 'disabled') ne 'enabled'))
		{
                    my $portspec = ($httpsPort eq 443) ? "" : ":$httpsPort";
                    $OUT .= "    RewriteEngine on\n";
                    $OUT .= "    RewriteRule ^/$key(/.*|\$) https://%{HTTP_HOST}${portspec}/$key\$1 \[L,R\]\n";
                }
	    }
	}
    }
}

