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

benoit.pointet’s picture

StatusFileSize
new5.88 KB

And here's the patch.

agentrickard’s picture

Status: Active » Needs review

Please set patches to "needs review".

Looks like fun!

agentrickard’s picture

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?
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.

bluegeek9’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

Drupal 7 in End of Life and no longer supported. We encourage you to upgrade to a supported version of Drupal. For more information, see https://www.drupal.org/upgrade.

//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support of this project makes other volunteer contributions more sustainable.
There are multiple ways to show appreciation for the work contributed to this project, including:
  • Triaging issues and adding more context to existing issues.
  • Writing documentation or patches for this project.