Closed (fixed)
Project:
Site User List
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
12 May 2007 at 04:57 UTC
Updated:
24 May 2007 at 02:49 UTC
First, excellent work, and a great module! My question: Is there a way to display the user's role in the Site User List?
Comments
Comment #1
pukku commentedNot right now. User roles aren't stored directly in an SQL table; they're serialized and stored in a data column, with a bunch of other info. This means that it isn't possible to grab this data in SQL, which is a requirement for Site User List. I have an idea of how this would be fixable: the module would need to implement hook_user, and turn the data into table data. Then, there is the issue of display — it would be easy to search by role, but as each role would be one column, displaying them gets more complicated.
user.module gets around this by using a pager, and only loading 10 users at once, so it can afford to run user_load; as a site gets larger, having user_load run on more and more users would slow it down far too much for site_user_list.module to be effective.
Comment #2
pukku commentedHi! The following solution isn't really the best way to do this; it could potentially slow down the site user list a lot (as it calls
user_loadon every user every time the site user list is viewed), but with the new codebase, this is at least theoretically possible. I suggest creating a small local module to provide this (see code below), but if you want to test it out, create a dummy profile field, and edit the template settings for that field (atadmin/settings/site_user_list/fields). Set your field to be displayed, turn on eval for the template, and make the template be$tu = user_load(array('uid' => $r['@uid'])); return theme('item_list', $tu->roles);. If you want to do something else with the user object once you have it, then by all means do so...A better way to do this would be to create a local module. (Warning: I haven't actually done the steps below, so I might have a mistake or two. If you run into problems, let me know...)
First, create a new directory called
modulesin the directory your settings.php is located in (unless such a directory already exists). Inside that directory create another directory called something like 'small_local_modules'. Inside that directory, create a file called 'site_user_list_role_column.info'. Make that file read:Then, create a file called 'site_user_list_role_column.module'. The contents of that file should be
If you enable this local module, and go to admin/settings/site_user_list/fields, you should now see an available field called 'User Roles'. If you enable this field, it should display the roles.
BTW: this requires the most recent version of site_user_list, which was just uploaded to cvs. You may need to wait a bit for the tarballs to update properly.
Comment #3
anonymous562 commentedJust updated to the latest CVS. I'm ready to get cracking on this, but you indicated to create a folder called 'modules' in the same place as my settings.php file. I can't locate this file...
Comment #4
pukku commentedHi! This is located somewhere in your sites folder. If you're just using a default install of drupal, try sites/default. If you're hosted somewhere and they have multiple folders (besides 'all' and 'default') in the sites folder, it will depend on the name of your site...
Comment #5
pukku commentedBTW: if you can wait a few days, I might have an easier solution to creating your own columns in place.
Ricky
Comment #6
anonymous562 commentedGot it. I can wait, no problem. Do you still want me to try out the code anyway, or are you going to ditch it in favor of something else?
Comment #7
pukku commentedMy plan is to provide a way for sites to create their own template columns without needing a local module. It's basically a generic version of the module I gave you.
If you want to try it and see if it works, that would be interesting, but if not, there's no real need...
Ricky
Comment #8
anonymous562 commentedWorks perfectly! This is great!! One small request: (if this is hard to do, please just say so, and it's fine). Is there a way to exclude the "authenticated user" role from being displayed? My site is going to be set that administrators approve all registrations, so EVERYONE will be an authenticated user, and I don't need to have that displayed.
Again, it's an extremely minor request, and I don't care one way or the other. But if it's a simple fix, just let me know. Thanks again!!
Comment #9
pukku commentedWell, the code I gave you was just a simple template kind of thing. The user's uid is in
$r['@uid'], and I just runuser_load()with the uid. This results in a user object. The template I gave you just passes the list of roles for that user directly totheme_item_list; you could do something else with it if you wanted to.Note that this may become very slow as you get more and more users...
Ricky
Comment #10
anonymous562 commentedI probably won't have more than 150 members or so, and they won't be accessing the list that often. I'm not too concerned.
How should I proceed with upgrades from now on? You said in a few days you'd be releasing code that might make this process more "built in" - so should I ditch the stuff I've done to this point, and just get your new code later?
Comment #11
pukku commentedHi! What I'm planning on adding shortly is just a way to have extra, non-database columns added in, so that you can put your own templates in easily. When that happens, you can just configure a new template column, copy over the template, make sure it works, and then disable the local module you created. Then just go back to the settings to rebuild everything, and it will all be happy...
Ricky
Comment #12
pukku commentedHi! Actually, for handling roles, I've gone ahead and created a sub-module called site_user_list_roles, which handles working with roles. It's located in the same directory as site_user_list, so you'll either have to get the new files from CVS or wait a few hours for a new tarball.
Let me know if this does what you need...
Thanks,
Ricky
Comment #13
pukku commented