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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

benoit.pointet’s picture

And here's the patch.

agentrickard’s picture

Status: Active » Needs review

Please set patches to "needs review".

Looks like fun!

agentrickard’s picture

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?
benoit.pointet’s picture

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.

agentrickard’s picture

Any useful alias, like du-add or similar.

benoit.pointet’s picture

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

agentrickard’s picture

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