Hi,

I'm assuming that based on the issue queue and lack of recent commits that this module is no longer actively maintained, and that the likelyhood of this patch making it in is extremely low, but I'm putting this out there for anyone who will gain some benefit from it.

The patch adds the ability to filter a User View based on the Administer Users by Role edit permissions, which in combination with the User management View defined in the latest 1.10 Beta of the Views Bulk Operations module (or a another User View) makes for a better user experience by only showing editable users instead of showing all users and simply erring when the user tries to edit a user they don't have permission to edit.

Hope someone finds this useful as it wasn't the easiest thing in the world to get working.

Cheers,
Deciphered.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sinasalek’s picture

Version: 7.x-1.0-beta1 » 6.x-1.4

The latest version of this module as a VBO action "delegate roles" which show only the roles that logged in user can manage.
For filtering views result by role you can achieve that by adding role filter to your views, this approach however is actually a workaround and doesn't work if you have multiply users able to delegate different roles.

Status: Needs review » Needs work

The last submitted patch, administerusersbyrole-DRUPAL-6--1-Views_editatble_filter-1.patch, failed testing.

sinasalek’s picture

Version: 6.x-1.4 » 7.x-1.0-beta1
Status: Needs work » Needs review

Tried on D7, and same problem there too. Also you might want to try Role Delegation module in combination with this module

Deciphered’s picture

Being from 2 years ago I seriously doubt I have any need for this anymore, so feel free to close it off completely, no idea what the particular project was or wether this patch or solution was used in the end.

Cheers,
Deciphered.

ptsimard’s picture

Version: 6.x-1.4 » 7.x-1.x-dev
Issue summary: View changes
FileSize
4.4 KB

Hello,

We have this use-case in our organisation and really needed to filter the view by editable permission.

Thanks to a lot to Deciphered for the patch logic. I re-factored and tweaked it to work with Drupal 7 and the latest 1.x dev.

Please review!

Thanks

ptsimard’s picture

Reworked the code in value_form() because the way I changed the form was giving an error:

Warning: Invalid argument supplied for foreach() in views_many_to_one_helper->ensure_my_table()

Here is the new patch

ptsimard’s picture

Ok, with this last patch, the filter User is editable will return true if a user has either edit or cancel permission. This allows listing the users with links Edit or Cancel (or both) depending on permissions.

Note: This patch still does not take into account any permissions suffixed with "and other roles" .

ptsimard’s picture

The latest patch missed the required code in administerusersbyrole.views.inc

Sorry for the shotgun patches. I really want this module to get in better shape.

AdamPS’s picture

Status: Needs review » Needs work

I've stepped in as a new co-maintainer and I share the desire to get the module into better shape!

I'm not a views expert, so sorry if I say something silly. But is there any reason that this is written to re-implement a detailed calculation done in _administerusersbyrole_can_edit_user rather than calling that function? It seems like rather a maintenance hazard as anyone changing the main code might break this aspect (which is probably not used and hence not tested by the majority of people).

Also you point out another problem yourself (although my current batch of fixes might make changes here anyway):

Note: This patch still does not take into account any permissions suffixed with "and other roles" .

As it happens I will be changing the _administerusersbyrole_can_edit_user code as part of fixing a bunch of other issues. So the patch potentially would need changes too. But before you take your time to do that, bear in mind that I would be reluctant to accept it unless it can be based on _administerusersbyrole_can_edit_user.

Another factor that might help you is that I plan to make the default admin/people form only show editable users.

AdamPS’s picture

One other thought occurred to me. I believe that the code here isn't required to be in administerusersbyrole. It would work equally well in your own private custom module (or even in an add-on contributed module something like "administerusersbyrole-viewsextra").

If you agree, it means that if your code is perhaps not polished enough or not maintainable enough to justify being in this small and simple module it doesn't in any way prevent you from achieving what you need.

On the other hand, if you can write it in terms of _administerusersbyrole_can_edit_user I think that would be a good function for the module.

ptsimard’s picture

OK. I'll take a look on Monday when I'm back at the office. See if I can improve it. Thanks for taking an interest.

kumkum29’s picture

Hello,

Have you made progress on the implementation of this new feature.
This feature is very useful for many cases.
Perhaps we can use a hook for implement this feature in a custom module? (more simply)

Thanks.

AdamPS’s picture

Version: 7.x-1.x-dev » 7.x-2.0
Status: Needs work » Fixed

In the latest release, this is possible. The solution is slightly different - not a filter but a query tag.

Edit the view, click Advanced then "Query settings" and add the tag "administerusersbyrole_edit_access". The view will only show users where there is edit permission.

Status: Fixed » Closed (fixed)

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