There wouldn't be two different rules. It's simple. If you've been engaged, or have engaged, you can't switch. If you haven't you can. If freelancer was real, that is what would happen. A ship wouldn't be able to go through a docking proceedure whilst under fire, and the station definately wouldn't open itself up to hostile attack by opening the docking bay doors.
If hostiles are spotted on scanners, however, you would have time to dock and prepare for battle.
This encompasses traders also. If a pirate has engaged the trader, the trader should not switch. The same rules applies for both situations, not a different rule for each.