vtigervtigercrm

Regenerate user_privileges files


I'm on a vtiger 7.3, and I was wondering if the sharing_privileges_* and user_privileges_* files can be regenerated from the database.

I've read that if you re-assign a role to a user the files will be regenerated. But I tried deleting both sharing_privileges_* and user_privileges_* and then the users don't even show up on the crm, so in that case it's not possible to assign it a role.

Don't worry, my backups are fine! It's just curiosity.


Solution

  • check if your users are present in the vtiger_users table in the database. If they're not there, you will have to create them again.

    To regenerate the sharing_privileges_* and user_privileges_* files, put this code in a file in the root directory of vtiger and run it from your browser or via command line:

    <?php
    
    require_once 'vtlib/Vtiger/Module.php';
    require_once 'include/utils/VtlibUtils.php';
    require_once 'config.inc.php';
    require_once 'includes/Loader.php';
    require_once 'modules/Users/CreateUserPrivilegeFile.php';
    vimport ('includes.runtime.EntryPoint');
    
    $current_user = Users::getActiveAdminUser();
    
    vtlib_RecreateUserPrivilegeFiles();
    
    Settings_SharingAccess_Module_Model::recalculateSharingRules();