Bug in Vtiger - only admin user in history tab. How to solve it.

Bug in Vtiger - only admin user in history tab. How to solve it.

Many users, especially after upgrading the VtigerCRM system from 7.0 to 7.1, ran into a problem — on the order card, the lead on the history tab, all changes appear as if they were made by the Administrator, and not the one who actually did it. Often this is due to handlers that work after a record is changed and as a result, the changes relate to the administrator, not the user.

Many users, especially after upgrading the VtigerCRM system from 7.0 to 7.1, ran into a problem — on the order card, the lead on the history tab, all changes appear as if they were made by the Administrator, and not the one who actually did it. Often this is due to handlers that work after a record is changed and as a result, the changes relate to the administrator, not the user.

How to fix this problem:

Open the following file: modules/ModTracker/ModTrackerHandler.php

This is exactly the file that captures all the changes that users make in the system and fixes them in the database.

 

Find the following block in this file:

$moduleName = $data->getModuleName();

$isTrackingEnabled = ModTracker::isTrackingEnabledForModule($moduleName);

if(!$isTrackingEnabled) {

return;

}

And before this block we add up-to-date information about the user who edits the record:

$current_user_id=$_SESSION["authenticated_user_id"];

$current_user = Users_Record_Model::getInstanceById($current_user_id, 'Users');

$curid=$current_user->get('id'); 

global $current_user;

Then find the following line:

global $adb, $current_user;

And you can delete current_user:

global $adb;

Then find the following line:

$adb->pquery('INSERT INTO vtiger_modtracker_basic(id, crmid, module, whodid, changedon, status)

VALUES(?,?,?,?,?,?)', Array($this->id, $recordId, $moduleName,

$current_user->id, $changedOn, $status));

And replace it by:

$adb->pquery('INSERT INTO vtiger_modtracker_basic(id, crmid, module, whodid, changedon, status)

VALUES(?,?,?,?,?,?)', Array($this->id, $recordId, $moduleName,

$curid, $changedOn, $status));

As a result, you will see that now in the history we have recorded not only the administrator, but the user who made the change in the record in fact.