So... I was trying to find inspiration, so I looked into sm.org and found a very old mod (multiple badges) that did a similar thing. I was wondering how it could 'optimize' the database request for these.
Well, it doesn't... It's even worse than what I had in mind -- it does a query per badge, lol.
At this point, I have only two solutions:
- either I insert a FIND_IN_SET(additional_groups) in the LMD function when it comes to the 'mg' table, and then I turn the group entry into an array with membergroup settings for each...
- or I simply give up, and use the code I wrote weeks ago and that I always stop myself from committing. i.e. the global setting in the membergroup settings page, determining whether to show the main group badge, the post group badge, or both, or none.
I'm wary of using FIND_IN_SET(), but OTOH it's also likely that we'll rewrite the additional_groups field to only contain 'public' groups, meaning we'll need to join with a new table to get a proper list of all groups one belongs to, so that would be less of an issue in this case.. (Except that I don't know that there's a point in offering users the ability to create a badge for a user group....?!)
'm a bit lost -- as usual... Hard to get back into the game after this hectic week.