The attached patch provides 4 drush commands:
* domain-user-domains : lists the domains a given user is assigned to
* domain-user-users : lists the users a given domain is assigned to
* domain-user-assign : assigns a given user to a given domain
* domain-user-unassign : unassigns a given user from a given domain

Comments

StatusFileSize
new5.88 KB

And here's the patch.

Status:Active» Needs review

Please set patches to "needs review".

Looks like fun!

StatusFileSize
new6.23 KB

Revised patch. Some notes.

  • Thanks for the initial patch. These are very useful.
  • I removed the _user prefix from the commands. I know why it was there, but unfortunately, the domain_user namespace is reserved for other uses.
  • Be consistent with your variable names. There were @params that didn't match function signatures.
  • Returning your own errors created redundant messaging. Those have been removed.
  • While you check for $domain returns correctly, you falsely assume that _drush_user_get_uid always returns correctly.
  • "Add" and "remove" are just as correct and easier to remember than assign and unassign.
  • Please follow coding style carefully, especially indentations.
  • Please write proper code comments -- especially writing complete sentences with proper punctuation and capitalization.

The last two items are documented in the developer's guide.

New patch needs review.

Questions:

  1. Should we add aliases for these commands?
  2. Should we allow multiple users/domains to be passed in a comma-separated list?

New patch at #3 looks good.

What aliases did you have in mind?
IMHO, allowing multiples users/domains to be passed is a nice-to-have, it can easily be achieved with a shell script.

b.

Any useful alias, like du-add or similar.

I guess such aliases should be added for all domain drush commands as a coherent whole, and not only for that one.

Right. The existing commands should already have aliases, where appropriate.