There are many reasons the check engine light can come on, an O2 sensor is only one of them. As a matter of fact, a rough running engine in and of itself can cause a check engine light. Since he is experiencing a rough running engine, I would tend to suspect he has a check engine light due to a misfire code. A bad O2 sensor typically won't cause an engine misfire. Neither will the magnet on the cam for the engine control module, although this CAN lead to a check engine light. I also don't believe the magnet on the cam will cause an idle variation. The magnet and sensor for the cam are only used at very specific times, and not at idle.
Since the history of the car isn't known, i would suspect the basics first, possibly it is just worn out or incorrect spark plugs.