Hello,

it would be a nice feature to disable the vertical tabs based on the user role.

Best regards
Frank

CommentFileSizeAuthor
#7 interdiff.txt915 bytesrafaolf
#7 2244533-7.patch992 bytesrafaolf
#4 2244533-4.patch1.58 KBrafaolf

Comments

jive01’s picture

agreed... it says it can do this (additional_settings) whatever that means....

skwashd’s picture

I'd accept a patch for this enhancement. I recommend the following implementation:

* Create hook_permission() to add a permission for hiding the tabs
* Call user_access() in the top of the hook_form_alter() implementation and if the tabs shouldn't be hidden return early

rafaolf’s picture

Assigned: Unassigned » rafaolf

Going to look into this.

rafaolf’s picture

Assigned: rafaolf » Unassigned
Status: Active » Needs review
StatusFileSize
new1.58 KB

Per @skwashd comment, I've created the role-based permission.

Also, if the current user doesn't have the permission to disable or enable the vertical tab, it was loading the variable status. Which implies that the user won't be able to see these tabs if they aren't enabled and not even change this visibility setting. So, I've made a permission verification before hiding them.

rodrigoeg’s picture

Assigned: Unassigned » rodrigoeg
rodrigoeg’s picture

Assigned: rodrigoeg » Unassigned
Status: Needs review » Needs work

The parts of the patch that adds and controls the permission are working fine. Please check the following comments about the code and the proposed change:

  1. +++ b/hide_vtabs.module
    @@ -9,6 +9,17 @@ define('HIDE_VTAB_STATUS_ENABLED', 1);
    +      'title' => t('Administer vertical tabs on content types.'),
    

    The title normally does not have a full stop at the end of the phrase.

  2. +++ b/hide_vtabs.module
    @@ -53,7 +65,8 @@ function hide_vtabs_form_node_form_alter(&$form, &$form_state) {
    +  // Checks if current role has permission to hide the vertical tabs
    

    This line is bypassing the configuration when the user does not have permission to change the configuration (if a user has permission to edit contents but does not have the permission 'administer hide_vtabs', he/she will always see the tabs). It maybe can cause some confusions when configuring this option and also will change the behavior for site that already uses this module.

Also, I think another approach of the solution would be adding a control of tabs visualization per role.

rafaolf’s picture

Status: Needs work » Needs review
StatusFileSize
new992 bytes
new915 bytes

@rodrigoeg,

Patch fixed. Also, I've opened a new feature (https://www.drupal.org/node/2668198) to make it role-based on content type level.

rodrigoeg’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @rafaolf,
I have reviewed and tested this new version. Moving to RTBC.

  • jribeiro committed 7f439e6 on 7.x-1.x authored by rafaolf
    Issue #2244533 by rafaolf: Option to make it role based
    
jribeiro’s picture

Status: Reviewed & tested by the community » Fixed

Pushed to dev branch. Thanks for the work guys.

Status: Fixed » Closed (fixed)

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