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.

Files: 
CommentFileSizeAuthor
#8 administerusersbyrole-views_editable_filter-928258-8.patch5 KBptsimard
PASSED: [[SimpleTest]]: [MySQL] 1,141 pass(es).
[ View ]
#7 administerusersbyrole-views_editable_filter-928258-7.patch4.68 KBptsimard
PASSED: [[SimpleTest]]: [MySQL] 1,141 pass(es).
[ View ]
#6 administerusersbyrole-views_editable_filter-928258-6.patch4.47 KBptsimard
PASSED: [[SimpleTest]]: [MySQL] 1,141 pass(es).
[ View ]
#5 administerusersbyrole-views_editable_filter-928258-5.patch4.4 KBptsimard
PASSED: [[SimpleTest]]: [MySQL] 1,141 pass(es).
[ View ]
administerusersbyrole-DRUPAL-6--1-Views_editatble_filter-1.patch3.34 KBDeciphered
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch administerusersbyrole-DRUPAL-6--1-Views_editatble_filter-1.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

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
StatusFileSize
new4.4 KB
PASSED: [[SimpleTest]]: [MySQL] 1,141 pass(es).
[ View ]

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

StatusFileSize
new4.47 KB
PASSED: [[SimpleTest]]: [MySQL] 1,141 pass(es).
[ View ]

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

StatusFileSize
new4.68 KB
PASSED: [[SimpleTest]]: [MySQL] 1,141 pass(es).
[ View ]

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

StatusFileSize
new5 KB
PASSED: [[SimpleTest]]: [MySQL] 1,141 pass(es).
[ View ]

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.