Phase transitions in disordered systems under random magnetic fields: Mean-Field Theory