Diagrammatic theory of magnetic and quadrupolar contributions to sum-frequency generation in composite systems.