See the last few posts on this Comm Center thread by Jesse Goldbaum, particularly this message. Add support for the Sloan magnitudes, and also use the SDSS transform given in the last message to make R from Sloan r and g.