7 wires, 3 sources, switchable power in 2 wires - how to put it back?
I tried to test out different combinations, blowing up a fuse in the process. In the end I gave up and called an electrician.

He figured it out by testing out which wires make a circuit with the wall plugs. He had some sort of multimeter for testing it.

I believe the wiring was done similar to the following diagram (while ignoring ground wires):