Adding a default page to user preferences

Adding a default page to user preferences

Vtiger 7.3 brought us many performance and functionality improvements. Among other things, an interesting feature has been added - in the settings of an individual user, choose which page to open by default after authorization. Previously, this could only be done globally from the system settings.

If for some reason you cannot upgrade to version 7.3, then you can implement this separate functionality in Vtiger. To do this, you will need to run the script for adding a field, as well as make changes to the Vtiger code. So let's get started.

The first thing to do is add the field we need. We write the script we need:

<?php

 

// Turn on debugging level

$Vtiger_Utils_Log = true;

chdir('../');

require_once('vtlib/Vtiger/Menu.php');

require_once('vtlib/Vtiger/Block.php');

require_once('vtlib/Vtiger/Field.php');

 

// Include necessary classes

include_once('vtlib/Vtiger/Module.php');

 

// Define instances

$users = Vtiger_Module::getInstance('Users');

$blockInstance = new Vtiger_Block();

 

// Nouvelle instance pour le nouveau bloc

$block = Vtiger_Block::getInstance('LBL_MORE_INFORMATION', $users);

 

 

// Add Default User Module

$fieldInstance = new Vtiger_Field();

$fieldInstance->name = 'user_default_module';

$fieldInstance->table = 'vtiger_users';

$fieldInstance->column = 'user_default_module';

$fieldInstance->label = 'User Default Module ';

$fieldInstance->columntype = 'varchar(50)';

$fieldInstance->uitype = 15;

$fieldInstance->typeofdata = 'V~O';

$block->addField($fieldInstance);

 

?>

We put the script in the scripts folder at the root of the CRM system with the name add_lp_field.php. If this folder does not exist, create it. Next, run this file once from the browser at scripts / add_lp_field.php.

Now we need to make a number of changes to the CRM files.

Change the file includes / main / WebUI.php

After these lines (around 104-105):

  $currentUser = $this->getLogin();

  vglobal('current_user', $currentUser);

 

Add following:

        $user_default_module = $currentUser->user_default_module;

        if (empty($user_default_module)) {

            $user_default_module = vglobal('default_module');

        }

vglobal('user_default_module', $user_default_module);

 

Then go to lines 165-166, try to find following:

 

if(empty($module)) {

  if ($this->hasLogin()) {

$defaultModule = vglobal('default_module');

 

Remove line $defaultModule = vglobal('default_module');

Instead add following:

$defaultModule = vglobal('user_default_module');

Then go to file modules/Vtiger/models/Field.php.

Add new function near line 248:

    public function getModulesList(){

        global $adb;

        // vtlib customization: Ignore disabled and Tools modules

        $query = 'select distinct vtiger_tab.tablabel, vtiger_tab.name as tabname from vtiger_tab where (vtiger_tab.presence != 1 and vtiger_tab.parent != "Tools" and vtiger_tab.parent != "")';

 

        // END

        $result = $adb->pquery($query, array());

        while($row = $adb->fetch_array($result)){

            $modules[$row['tablabel']] = $row['tabname'];

        }

        return $modules;

    }

Then you need to call this function in в getPicklistValues.

Go to line 317, try to find this lines:

}else{

  $picklistValues = Vtiger_Util_Helper::getPickListValues($fieldName);

  }

 

 After them add following code:

            $fieldName = $this->getName();

            if ($fieldName === 'user_default_module'){

             $picklistValues = $this->getModulesList();

            }

 

If you have successfully completed the above actions, then you should have a new field shown in the picture in the user settings. And after authorization, this user should go to the page specified in the settings

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