Manipulation of the magnetic state of a porphyrin-based molecule on gold: From Kondo to quantum nanomagnet via the charge fluctuation regime