VtigerCRM provides a very convenient tool - tracking history of changes in module record. For example, you can go to the Accounts detail view and see the "Updates" tab in it. It displays the entire history that occurs with this entity - who created it, who edited it or added a comment. This tab will only be visible if the ModTracker module is activated.
However, not all users would find this tab useful. Most administrators prefer to disable this functionality entirely or only show it to specific groups of users.
In this article, I'll show you how you can hide the Updates tab from all users except administrators.
To do this, you need access to the Vtiger files.
The first thing you need to do is add the new function at the end of the file modules/Vtiger/models/Module.php:
public function isUpdateDisplayEnabled(): bool
{
$userModel = Users_Record_Model::getCurrentUserModel();
return $userModel->isAdminUser();
}
The purpose of this function is very simple: here we put the business logic itself - show or hide the Updates tab. If the function returns true, then the tab is shown. If false, hide it.
Second, remove the Updates tab from the user interface. To do this, go to the modules/Vtiger/models/DetailView.php file, find the getDetailViewRelatedLinks function. This function generates a list of all links, tabs and buttons that appear in the recording card. We need to find the addition of the tab we need and run it through our new function. To do this, find the block we need:
if($parentModuleModel->isTrackingEnabled()) {
$relatedLinks[] = array(
'linktype' => 'DETAILVIEWTAB',
'linklabel' => 'LBL_UPDATES',
'linkurl' => $recordModel->getDetailViewUrl().'&mode=showRecentActivities&page=1',
'linkicon' => ''
);
}
And change it to following:
if($parentModuleModel->isTrackingEnabled() && $parentModuleModel->isUpdateDisplayEnabled()) {
$relatedLinks[] = array(
'linktype' => 'DETAILVIEWTAB',
'linklabel' => 'LBL_UPDATES',
'linkurl' => $recordModel->getDetailViewUrl().'&mode=showRecentActivities&page=1',
'linkicon' => ''
);
}
After that, the tab will disappear from all users except administrators.
But we still have one problem - the tab is accessible via a direct link, namely: index.php?Module=Leads&view = Detail&record=191769&mode=showRecentActivities&page=1&tab_label = Lead%20LBL_UPDATES&app=MARKETING
Those, if the user knows the direct link and pushes it into the browser, he will still see the content of this tab. To disable direct access, go to the modules/Vtiger/views/Detail.php file, find the _showRecentActivities function, in the area of position 421 we find the line
$recordModel = Vtiger_Record_Model::getInstanceById($parentRecordId);
And change it to following:
$recordModel = Vtiger_Record_Model::getInstanceById($parentRecordId);
$moduleModel = $recordModel->getModule();
if (!$moduleModel->isUpdateDisplayEnabled()) {
throw new AppException('Not authorized to view updates page!');
}
After these manipulations, you can see the changes - the Updates tab is not available for all users except administrators, and you cannot go to the tab using a direct link.