Updated: Comment #20

Problem/Motivation

This module's purpose is to provide new permissions to avoid admins allowed to edit users to be able to edit user settings. Currently, they can't access the user settings page but they can access users Fields and Display settings. These are important things that should also be locked.

Proposed resolution

Create a new specific permission to access the users Fields and Display settings.

Remaining tasks

  • Create the new permission
  • Apply the permission to the user Fields settings
  • Apply the permission to the user Display settings

#2096901: Apply coding standards (to apply the last patch)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DuaelFr’s picture

Assigned: DuaelFr » Unassigned
Status: Active » Needs review
FileSize
711 bytes

This patch is part of the #1day1patch initiative.

tchurch’s picture

Assigned: Unassigned » tchurch

I will look at this patch over the weekend (hopefully) but my first comment would be that we should get new permissions for both of these items.
I think both under one new permission.

tchurch’s picture

Status: Needs review » Needs work

This patch needs changes to it.
1) to add extra permission to control this
2) to use the correct function naming conventions

I have some new code which I'm quickly testing and then I'll post back a new patch for others to test.

tchurch’s picture

Version: 7.x-1.x-dev » 7.x-1.0
Status: Needs work » Needs review
FileSize
1.36 KB

Here is a new patch.

Let me know what you think.

tchurch’s picture

Status: Needs review » Active
tchurch’s picture

Status: Active » Needs review
tchurch’s picture

Version: 7.x-1.0 » 7.x-1.x-dev

Status: Needs review » Needs work
tchurch’s picture

Status: Needs work » Needs review

Automatic testing failed because of format reasons but the code itself works.
Can someone test it?

tchurch’s picture

Before this is committed you might also want to look at this module.

https://drupal.org/project/field_ui_permissions

It seems to do the same thing but for all entity types.

DuaelFr’s picture

#4 is good for me

#10 is good to know but I think that User Settings Access should restrict anything related to User accounts and not rely on another module to manage Fields access. (The less you have the better you are)

tchurch’s picture

The problem I now have is that this code change clashes with fields_ui_permissions. If both modules are active then fields_ui_permissions controls it and ignores this modules new setting. I'm trying to investigate it to see if there's a solution but not having a lot of luck (or time).
I would prefer if fields_ui_permissions did the work as it combines this check with other entity types too.

DuaelFr’s picture

Adding a module to manage all entity types when you only need to restrict users and when another module (yours) already does half the work is a bit overkill. If everyone did that kind of things, this would cause a lot of performances issues and make the website harder to maintain.
Your module's purpose is to help developpers to allow their users to administrate accounts but not user general settings. Even if an other module can complete yours, you have to offer the developpers a full set of functionnalities matching your module's scope.

If you are really afraid of a conflict with fields_ui_permissions, we could just add a if (!module_exists('fields_ui_permissions')) around my patched lines.

GuyPaddock’s picture

Status: Needs review » Needs work
DuaelFr’s picture

Status: Needs work » Needs review
FileSize
4.59 KB

Patch rerolled

Status: Needs review » Needs work
DuaelFr’s picture

Status: Needs work » Needs review
FileSize
1.41 KB

This one will apply when the #2096901: Apply coding standards issue will be close :)

Status: Needs review » Needs work
YesCT’s picture

https://drupal.org/contributor-tasks/write-issue-summary has instructions for how to make a good issue summary. it will help others jump in to work on this.

DuaelFr’s picture

Status: Needs work » Needs review
DuaelFr’s picture

@YesCT : job done

DuaelFr’s picture

Issue summary: View changes

Update issue summary

inno81’s picture

Issue summary: View changes

This patch works for me!

claudiu.cristea’s picture

Title: Restrict access to admin/config/people/accounts/fields and admin/config/people/accounts/display » Restrict access to all admin/config/people/accounts/* and DS manage display
Assigned: tchurch » Unassigned
Category: Feature request » Bug report
FileSize
886 bytes
claudiu.cristea’s picture

FileSize
1.05 KB

Improved.

claudiu.cristea’s picture

FileSize
959 bytes
1.13 KB

Small fix when access callback is not defined.

DuaelFr’s picture

+++ b/user_settings_access.module
@@ -41,7 +41,21 @@ function user_settings_access_help($path, $arg) {
+    if (preg_match('@^admin\/config\/people\/accounts(\/(.*)+)?$@', $route)) {

Can be simplified using only a strpos() call.
Good job, though. Thanks.

claudiu.cristea’s picture

Can be simplified using only a strpos() call.

We need to catch:

  • admin/config/people/accounts
  • admin/config/people/accounts/fields
  • admin/config/people/accounts/*

but not

  • admin/config/people/accounts-whatever
DuaelFr’s picture

I'm not sure that path you want to avoid is a real use case but what I'm sure is that using a regular expression on every route of the website can be a real performances hole.

After a quick thinking I don't know if we really want that this module alters all admin/config/people/accounts/* routes. We do know that we want to restrict access to admin/config/people/accounts/fields and admin/config/people/accounts/display because these are Core routes. But, if we restrict admin/config/people/accounts/* routes we are going to interfere with other modules and people would not understand why they have to use 'administer account settings' permission instead of the one defined in the module that created the route.
If you really want to restrict all these routes, I guess, you should alter the routes that are using the Core's 'adminster users' permission and only these ones. I'm not sure that this is the purpose of this module, though.

djpable’s picture

I confirm that path "admin/config/people/accounts/fields" is still accessible after the patch at #27, with this Warning:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'administer account settings' not found or invalid function name in field_ui_admin_access()

steinmb’s picture

Status: Needs review » Needs work