There is a way to make merge duplicate from all modules, accessible for admins user only at once ?

Hi.

I would like to make all merge duplicate from recordlist, only accessible for admins users at once. Without passing for each file recordList.php if it's possible.

Thanks

  • There may be better answers out there, and I will be interested in others' opinions,  but in our case we extended the RecordListView to disable the Merge button if not admin.

    custom/clients/base/views/recordlist/recordlist.js 

    ({
        extendsFrom: 'RecordlistView',
        initialize: function (options) {
            this._super('initialize', [options]);
        },
       render: function()
       {
          this._super('render');
          this.hideActions();
        },
        hideActions: function(){
          var user_type = app.user.get('type');
          if(user_type != 'admin'){ 
            if(merge_button.isVisible()) merge_button.setDisabled(true);
          }
        } 
    });

    This disables the Merge action in the list view dropdown in all Record List Views.

    You will likely also want to disable merge when using the "Find Duplicates" action.

    When you go to a record and use the "Find Duplicates" it takes you to a different view which has its own merge action button.

    You can choose to disable Find Duplicates in Record View or simply hide the Merge Action for non-admin users.

    custom/clients/base/views/find-duplicates-headerpane/find-duplicates-headerpane.php

    $viewdefs['base']['view']['find-duplicates-headerpane'] = array(
        'template' => 'headerpane',
        'title' => 'LBL_DUP_MERGE',
        'buttons' => array(
            array(
                'name'    => 'cancel_button',
                'type'    => 'button',
                'label'   => 'LBL_CANCEL_BUTTON_LABEL',
                'css_class' => 'btn-invisible btn-link',
            ),
            array(
                'name'    => 'merge_duplicates_button',
                'type'    => 'button',
                'label'   => 'LBL_MERGE_DUPLICATES',
                'css_class' => 'btn-primary disabled',
                'acl_action' => 'admin',
            ),
            array(
                'name' => 'sidebar_toggle',
                'type' => 'sidebartoggle',
            ),
        ),
    );
    

    Note that these are small changes but significant, the latter totally overrides what is available in the find duplicates headerpane, so if Sugar adds more buttons you won't see them until you revise your custom file. This is the sort of thing that delays our releases of new versions, when you have enough of these it gets tedious to check them all... which is why I am hoping someone has a better solution :)

    FrancescaS