OK - I want to do something very tricky with master users and if I get it to work I'm adding it to the wiki for everyone to use.
So far I have a MySQL database that servers multiple domains. I can set a flag making someone a domain owner that allows that person to become master of that domain. Here's the query for that.
password_query = SELECT user_name, domain_name, password FROM users WHERE user_name = '%n' AND domain_name = '%d' AND owns_domain='1' AND '%d'='%{login_domain}'
So - here's where we get tricky.
I have another table called "ownership" where I have 2 fields which is a pairing of email addresses (login_id) and domains owned (owned_object). Data might look like this:
joe@blow.com domain1.com joe@blow.com domain2.com
Since joe@blow.com owns both domain1.com and domain2.com I want him to be able to log in as anyone in those 2 domains as a master user.
Examples: tom@domain1.com*joe@blow.com harry@domain2.com*joe@blow.com
So the idea is to create a MySQL query so that if the master user matches the domain part of the login user then it returns true and allows the login.
What MySQL query will do that?