Most sites I've worked on have zillions of users but only those with role "x" can create content of type "y"

This info could be leveraged to smallify this dropdown

... I think this module could end up being really useful

CommentFileSizeAuthor
#6 author_select.patch1.98 KBbleen
#4 author_select.patch1.86 KBbleen

Comments

mcrittenden’s picture

Title: configureable by role? » Configurable by role?
Status: Active » Postponed (maintainer needs more info)

Ah, great idea. So ideally you'd like it if the only options in the dropdown list were users with permission to add content of that type?

bleen’s picture

Assigned: Unassigned » bleen
Status: Postponed (maintainer needs more info) » Active

exactly ... I'm happy to help when I have a few free minutes ... Lemme take a swing at a patch this weekend

mcrittenden’s picture

Title: Configurable by role? » Only allow selecting of authors with access to post content of that type

Sounds great, thanks. If you don't have time or just lose interest, just let me know.

bleen’s picture

Status: Active » Needs review
StatusFileSize
new1.86 KB

The more I think about this the more I think maybe there should be a config setting for this. Its conceivable that some sites will want ALL users (regardless of roles) in the dropdown, but I feel like most sites would prefer it this way.

I'm also not sure if the anon user should always be in the list, or only if it has correct permissions. For now, always...

Thoughts?

In any event, this is a good start IMO.

mcrittenden’s picture

Status: Needs review » Needs work

Awesome, thanks for the patch.

+    else{
+      $result = db_query("SELECT name FROM {users} WHERE uid = 1 ORDER BY name");
+    }

Can't we remove the ORDER BY here?

+    // Always include anonymous user and user 1

IMO, yeah, anon probably should be treated like any other role, and not always included.

+    if (empty($roles)) {
+      $result = db_query("SELECT u.name FROM {users} AS u LEFT JOIN {users_roles} AS ur ON u.uid = ur.uid WHERE (u.uid = 1 OR ur.rid IN (%s)) ORDER BY name", implode(',', $roles));
+    }

Should be if !empty?

As for the option, I agree that it would be a good idea, but I'm unsure where to put it. It doesn't really deserve a page of its own, so maybe on the User Settings page?

bleen’s picture

StatusFileSize
new1.98 KB

This patch fixes the minor issues pointed out above ... and no longer includes the anon user unless it has the correct permissions.

As for the setting ... maybe it go on the content config page (/admin/content/node-type/story)?

mcrittenden’s picture

Status: Needs work » Needs review
mcrittenden’s picture

Assigned: bleen » Unassigned
Status: Needs review » Fixed

Tested and committed, and rolled beta2. IMO, you're right that this will almost always be the default behavior, so it's OK to go ahead and commit this without a setting (temporarily). Setting can be handled in #858294: Add a setting to allow selecting ANY user, not just users with permission to post that content type.

Thanks for the awesome patch!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ChrisLaFrancis’s picture

I ran into an issue with trying to change the author of blog entries after I migrated a website from Ning to Drupal. Basically, the problem is that the permissions for blog entries are listed as "create blog entries" and "edit any blog entries" rather than "create (content type) content" and "edit any (content type) content"... so for the "blog" content type, the word "entries" replaces "content".

Anyway, in author_select.module I changed line 48 from

$permissions = array('create ' . $node->type . ' content', 'edit any ' . $node->type . ' content');

to

$permissions = array('create ' . $node->type . ' content', 'edit any ' . $node->type . ' content', 'edit own ' . $node->type . ' content', 'create ' . $node->type . ' entries', 'edit any ' . $node->type . ' entries', 'edit own ' . $node->type . ' entries');

Also, you'll notice that I included the "edit own" permissions for all content types, as well as the "edit any" permissions.

Hope this helps someone else out if they run into the same issue.

mcrittenden’s picture

@fivefrank: would you mind creating a new issue for that? That's a good point.

ChrisLaFrancis’s picture

Done. Sorry it took so long.

http://drupal.org/node/890312