How to hide Updates tab in DetailView of VtigerCRM?

How to hide Updates tab in DetailView of VtigerCRM?

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.

Popular Posts

My most popular posts

Maximum productivity on remote job
Business

Maximum productivity on remote job

I started my own business and intentionally did my best to work from anywhere in the world. Sometimes I sit with my office with a large 27-inch monitor in my apartment in Cheboksary. Sometimes I’m in the office or in some cafe in another city.

Hello! I am Sergey Emelyanov and I am hardworker
Business PHP

Hello! I am Sergey Emelyanov and I am hardworker

I am a programmer. I am an entrepreneur in my heart. I started making money from the age of 11, in the harsh 90s, handing over glassware to a local store and exchanging it for sweets. I earned so much that was enough for various snacks.

Hire Professional CRM developer for $25 per hour

I will make time for your project. Knowledge of Vtiger CRM, SuiteCRM, Laravel, and Vue.js. I offer cooperation options that will help you take advantage of external experience, optimize costs and reduce risks. Full transparency of all stages of work and accounting for time costs. Pay only development working hours after accepting the task. Accept PayPal and Payoneer payment systems. How to hire professional developer? Just fill in the form

Telegram
@sergeyem
Telephone
+4915211100235