diff --git a/config.template.php b/config.template.php index 41abe8efc1a5b8039d470defa584ebbc138f3e47..5c8fe7c9cca78fdc3d29f1fc16a2663527f59a4c 100644 --- a/config.template.php +++ b/config.template.php @@ -119,9 +119,6 @@ $list_max_entries_per_page = '20'; // history_max_viewed default value = 5 $history_max_viewed = '5'; -// default_module default value = Home -$default_module = 'Home'; - // default_action default value = index $default_action = 'index'; diff --git a/include/Webservices/WebserviceField.php b/include/Webservices/WebserviceField.php index 3499c3a190dcbd489e480914b9c7ec8a3fe7570a..57be736e2405e7d4c1535e4d79f212e6188fb1b7 100644 --- a/include/Webservices/WebserviceField.php +++ b/include/Webservices/WebserviceField.php @@ -336,6 +336,7 @@ class WebserviceField{ function getPicklistDetails(){ $cache = Vtiger_Cache::getInstance(); + $fieldName = $this->getFieldName(); if($cache->getPicklistDetails($this->getTabId(),$this->getFieldName())){ return $cache->getPicklistDetails($this->getTabId(),$this->getFieldName()); } else { @@ -346,7 +347,26 @@ class WebserviceField{ foreach ($allRegions as $regionId => $regionDetails) { $picklistDetails[] = array('value' => $regionId, 'label' => $regionDetails['name']); } - } else { + }elseif ($fieldName == 'defaultlandingpage') { + $picklistDetails = array(); + $presence = array(0); + $restrictedModules = array('Webmails', 'Emails', 'Integration', 'Dashboard','ModComments'); + $query = 'SELECT name, tablabel, tabid FROM vtiger_tab WHERE presence IN (' . generateQuestionMarks($presence) . ') AND isentitytype = ? AND name NOT IN (' . generateQuestionMarks($restrictedModules) . ')'; + + $result = $this->pearDB->pquery($query, array($presence, '1', $restrictedModules)); + $numOfRows = $this->pearDB->num_rows($result); + + $picklistDetails[] = array('value' => 'Home', 'label' => vtranslate('Home', 'Home')); + for ($i = 0; $i < $numOfRows; $i++) { + $moduleName = $this->pearDB->query_result($result, $i, 'name'); + + // check the module access permission, if user has permission then show it in default module list + if (vtlib_isModuleActive($moduleName)) { + $moduleLabel = $this->pearDB->query_result($result, $i, 'tablabel'); + $picklistDetails[] = array('value' => $moduleName, 'label' => vtranslate($moduleLabel, $moduleName)); + } + } + } else { $hardCodedPickListNames = array('hdntaxtype','email_flag'); $hardCodedPickListValues = array('hdntaxtype'=> array( array('label' => 'Individual', 'value' => 'individual'), array('label' => 'Group', 'value' => 'group')), diff --git a/include/utils/VtlibUtils.php b/include/utils/VtlibUtils.php index c7f108a2b8d5ad9dc33aa7ceb085bc8b2ae77174..50fb375994ce10932bcf78fc0de4d88ecdb0cbca 100644 --- a/include/utils/VtlibUtils.php +++ b/include/utils/VtlibUtils.php @@ -158,6 +158,8 @@ function vtlib_toggleModuleAccess($modules, $enable_disable) { } else if($enable_disable === false) { $enable_disable = 1; $event_type = Vtiger_Module::EVENT_MODULE_DISABLED; + //Update default landing page to dashboard if module is disabled. + $adb->pquery('UPDATE vtiger_users SET defaultlandingpage = ? WHERE defaultlandingpage IN(' . generateQuestionMarks($modules) . ')', array_merge(array('Home'), $modules)); } $checkResult = $adb->pquery('SELECT name FROM vtiger_tab WHERE name IN ('. generateQuestionMarks($modules) .')', array($modules)); diff --git a/includes/main/WebUI.php b/includes/main/WebUI.php index bbc6e0aaf928ea146af2104af3158c365e7d1823..96ba9788ff8f6d16ef97ced54008bdfc2335f521 100644 --- a/includes/main/WebUI.php +++ b/includes/main/WebUI.php @@ -151,7 +151,7 @@ class Vtiger_WebUI extends Vtiger_EntryPoint { if(empty($module)) { if ($this->hasLogin()) { - $defaultModule = vglobal('default_module'); + $defaultModule = $currentUser->defaultlandingpage; $moduleModel = Vtiger_Module_Model::getInstance($defaultModule); if(!empty($defaultModule) && $defaultModule != 'Home' && $moduleModel && $moduleModel->isActive()) { $module = $defaultModule; $qualifiedModuleName = $defaultModule; $view = 'List'; diff --git a/layouts/v7/modules/Settings/Vtiger/ConfigEditorDetail.tpl b/layouts/v7/modules/Settings/Vtiger/ConfigEditorDetail.tpl index 859f3bec58004f9a3a02facf5033d7410de8dac2..bc17c893ba064d5d9df8c204dcf7ebdd5b028117 100644 --- a/layouts/v7/modules/Settings/Vtiger/ConfigEditorDetail.tpl +++ b/layouts/v7/modules/Settings/Vtiger/ConfigEditorDetail.tpl @@ -28,20 +28,18 @@ <div class="row form-group"><div class="col-lg-4 col-md-4 col-sm-4 fieldLabel"><label>{if $FIELD_NAME == 'upload_maxsize'}{if $FIELD_DATA[$FIELD_NAME] gt 5}{vtranslate($FIELD_DETAILS['label'], $QUALIFIED_MODULE,$FIELD_DATA[$FIELD_NAME])}{else}{vtranslate($FIELD_DETAILS['label'], $QUALIFIED_MODULE,5)}{/if}{else}{vtranslate($FIELD_DETAILS['label'], $QUALIFIED_MODULE)}{/if}</label></div> <div class="col-lg-8 col-md-8 col-sm-8 fieldValue break-word"> <div> - {if $FIELD_NAME == 'default_module'} - {vtranslate($FIELD_DATA[$FIELD_NAME], $FIELD_DATA[$FIELD_NAME])} - {else if $FIELD_DETAILS['fieldType'] == 'checkbox'} + {if $FIELD_DETAILS['fieldType'] == 'checkbox'} {vtranslate($FIELD_DATA[$FIELD_NAME], $QUALIFIED_MODULE)} {if $FIELD_NAME == 'email_tracking'} <div class="input-info-addon"><a class="fa fa-question-circle" data-toggle="tooltip" data-placement="right" title="{vtranslate('LBL_PERSONAL_EMAIL_TRACKING_INFO',$QUALIFIED_MODULE)}"></a></div> - {/if} - {else if $FIELD_NAME == 'default_reply_to'} + {/if} + {else if $FIELD_NAME == 'default_reply_to'} {vtranslate($FIELD_DATA[$FIELD_NAME])} <div class="input-info-addon"><a class="fa fa-info-circle" data-toggle="tooltip" data-placement="right" title="{vtranslate('LBL_DEFAULT_REPLY_TO_INFO',$QUALIFIED_MODULE)}"></a></div> - {else} + {else} {$FIELD_DATA[$FIELD_NAME]} - {/if} - {if $FIELD_NAME == 'upload_maxsize'} + {/if} + {if $FIELD_NAME == 'upload_maxsize'} {vtranslate('LBL_MB', $QUALIFIED_MODULE)} {/if} </div> diff --git a/layouts/v7/modules/Settings/Vtiger/ConfigEditorEdit.tpl b/layouts/v7/modules/Settings/Vtiger/ConfigEditorEdit.tpl index 084309c97eeff789645e4811ccf32e049ca08f3e..aaf21c73bcb8b85f289ad8b25fe99ca0f58d7be6 100644 --- a/layouts/v7/modules/Settings/Vtiger/ConfigEditorEdit.tpl +++ b/layouts/v7/modules/Settings/Vtiger/ConfigEditorEdit.tpl @@ -35,7 +35,7 @@ <select class="select2-container inputElement select2 col-lg-11" name="{$FIELD_NAME}" > {foreach key=optionName item=optionLabel from=$MODEL->getPicklistValues($FIELD_NAME)} - {if $FIELD_NAME != 'default_module' && $FIELD_NAME != 'default_reply_to'} + {if $FIELD_NAME != 'default_reply_to'} <option {if $optionLabel == $FIELD_DATA[$FIELD_NAME]} selected {/if}>{vtranslate($optionLabel, $QUALIFIED_MODULE)}</option> {else if $FIELD_NAME == 'default_reply_to'} <option value="{$optionName}" {if $optionName == $FIELD_DATA[$FIELD_NAME]} selected {/if}>{vtranslate($optionName)}</option> diff --git a/layouts/v7/modules/Users/DetailViewBlockView.tpl b/layouts/v7/modules/Users/DetailViewBlockView.tpl index b0ab68b8fe9d7085ff9814a791b9632c47385921..33ba6ff0023b9b68204654283e635585ab0e7bab 100644 --- a/layouts/v7/modules/Users/DetailViewBlockView.tpl +++ b/layouts/v7/modules/Users/DetailViewBlockView.tpl @@ -107,7 +107,11 @@ {/if} <span class="value textOverflowEllipsis" data-field-type="{$FIELD_MODEL->getFieldDataType()}" {if $FIELD_MODEL->get('uitype') eq '19' or $FIELD_MODEL->get('uitype') eq '20' or $FIELD_MODEL->get('uitype') eq '21'} style="white-space:normal;" {/if} {if $fieldDataType eq 'email'}title='{$FIELD_MODEL->get('fieldvalue')}'{/if} > + {if $FIELD_MODEL->getName() neq 'defaultlandingpage'} {include file=vtemplate_path($FIELD_MODEL->getUITypeModel()->getDetailViewTemplateName(),$MODULE_NAME) FIELD_MODEL=$FIELD_MODEL USER_MODEL=$USER_MODEL MODULE=$MODULE_NAME RECORD=$RECORD} + {else} + {vtranslate($FIELD_MODEL->get('fieldvalue'),$FIELD_MODEL->get('fieldvalue'))} + {/if} </span> {if $IS_AJAX_ENABLED && $FIELD_MODEL->isEditable() eq 'true' && $FIELD_MODEL->isAjaxEditable() eq 'true'} <span class="hide edit pull-left"> diff --git a/modules/Install/models/ConfigFileUtils.php b/modules/Install/models/ConfigFileUtils.php index b5b89fc41919dc70331407fb20d9ad06d8b75014..378d122b7cbaf26079e2daf3b5cc25d6b68b1524 100644 --- a/modules/Install/models/ConfigFileUtils.php +++ b/modules/Install/models/ConfigFileUtils.php @@ -210,9 +210,6 @@ ini_set('memory_limit','64M'); // history_max_viewed default value = 5 \$history_max_viewed = '5'; -// default_module default value = Home -\$default_module = 'Home'; - // default_action default value = index \$default_action = 'index'; diff --git a/modules/Install/views/Index.php b/modules/Install/views/Index.php index 4e20ac2fd677a496c8768b19b074e5d5f0f747c8..54a29e5f49bfd76b83e7b3f86111cdbd0e6a9003 100644 --- a/modules/Install/views/Index.php +++ b/modules/Install/views/Index.php @@ -38,15 +38,6 @@ class Install_Index_view extends Vtiger_View_Controller { $this->applyInstallFriendlyEnv(); date_default_timezone_set('Europe/London'); // to overcome the pre configuration settings - // Added to redirect to default module if already installed - $configFileName = 'config.inc.php'; - if(is_file($configFileName) && filesize($configFileName) > 0) { - $defaultModule = vglobal('default_module'); - $defaultModuleInstance = Vtiger_Module_Model::getInstance($defaultModule); - $defaultView = $defaultModuleInstance->getDefaultViewName(); - header('Location:index.php?module='.$defaultModule.'&view='.$defaultView); - exit; - } parent::preProcess($request); $viewer = $this->getViewer($request); diff --git a/modules/Migration/schema/720_to_721.php b/modules/Migration/schema/720_to_721.php index 94d12a36f0f74c2ed42903ef52321f09df4775dc..0e09a716af337e332a5715e8aed74827ebc79416 100644 --- a/modules/Migration/schema/720_to_721.php +++ b/modules/Migration/schema/720_to_721.php @@ -92,4 +92,49 @@ if (defined('VTIGER_UPGRADE')) { $db->pquery('UPDATE vtiger_emailtemplates SET module=? WHERE templatename IN ('. generateQuestionMarks($defaultContactTemplates).')', $updateContactParams); echo 'Email templates default moduleName updated'; + + //Migrate default module data from config editor to database + $moduleModel = Settings_Vtiger_ConfigModule_Model::getInstance(); + $configFieldData = $moduleModel->getViewableData(); + $defaultModule = $configFieldData['default_module']; + if(empty($defaultModule)){ + $defaultModule = 'Home'; + } + + $moduleInstance = Vtiger_Module_Model::getInstance('Users'); + $blockInstance = Vtiger_Block::getInstance('LBL_MORE_INFORMATION', $moduleInstance); + if ($blockInstance) { + $fieldInstance = Vtiger_Field::getInstance('defaultlandingpage', $moduleInstance); + if (!$fieldInstance) { + $fieldInstance = new Vtiger_Field(); + $fieldInstance->name = 'defaultlandingpage'; + $fieldInstance->column = 'defaultlandingpage'; + $fieldInstance->label = 'Default Landing Page'; + $fieldInstance->table = 'vtiger_users'; + $fieldInstance->columntype = 'VARCHAR(100)'; + $fieldInstance->defaultvalue = $defaultModule; + $fieldInstance->typeofdata = 'V~O'; + $fieldInstance->uitype = '32'; + $fieldInstance->presence = '0'; + + $blockInstance->addField($fieldInstance); + $configModuleInstance = Settings_Vtiger_ConfigModule_Model::getInstance(); + $defaultModules = $configModuleInstance->getPicklistValues('default_module'); + $fieldInstance->setPicklistValues($defaultModules); + echo "<br> Default landing page field added <br>"; + } + } + + $allUsers = Users_Record_Model::getAll(true); + $allUserIds = array_keys($allUsers); + + $db->pquery('UPDATE vtiger_users SET defaultlandingpage = ? WHERE id in ('. generateQuestionMarks($allUserIds) .')', array($defaultModule, $allUserIds)); + echo "Default landing page updated for all active users <br>"; + + //Recalculating user-preivilege file, as defaultlandingpage and other preference changes should be updated + foreach ($allUserIds as $userId) { + createUserPrivilegesfile($userId); + createUserSharingPrivilegesfile($userId); + } + echo "Re-calculated user privilege and sharing privileges files"; } \ No newline at end of file diff --git a/modules/Settings/ModuleManager/actions/Basic.php b/modules/Settings/ModuleManager/actions/Basic.php index 3f488c5052ea5343151cbf1ff75f57042f059282..717195716559021bd6661d167c6005a8dd4a4753 100644 --- a/modules/Settings/ModuleManager/actions/Basic.php +++ b/modules/Settings/ModuleManager/actions/Basic.php @@ -36,7 +36,6 @@ class Settings_ModuleManager_Basic_Action extends Settings_Vtiger_IndexAjax_View }else{ $moduleManagerModel->disableModule($moduleName); } - $response = new Vtiger_Response(); $response->emit(); } diff --git a/modules/Settings/Vtiger/models/ConfigModule.php b/modules/Settings/Vtiger/models/ConfigModule.php index 158cc871cb6bee0d74a68140fd4a57ff74529fbf..f316486258d21038c1f8694c1bed63a2fc3d2f1d 100644 --- a/modules/Settings/Vtiger/models/ConfigModule.php +++ b/modules/Settings/Vtiger/models/ConfigModule.php @@ -94,23 +94,6 @@ class Settings_Vtiger_ConfigModule_Model extends Settings_Vtiger_Module_Model { * @return <Array> list of module names */ public function getPicklistValues($fieldName) { - if ($fieldName === 'default_module') { - $db = PearDatabase::getInstance(); - - $presence = array(0); - $restrictedModules = array('Webmails', 'Emails', 'Integration', 'Dashboard','ModComments'); - $query = 'SELECT name, tablabel FROM vtiger_tab WHERE presence IN (' . generateQuestionMarks($presence) . ') AND isentitytype = ? AND name NOT IN (' . generateQuestionMarks($restrictedModules) . ')'; - - $result = $db->pquery($query, array($presence, '1', $restrictedModules)); - $numOfRows = $db->num_rows($result); - - $moduleData = array('Home' => 'Home'); - for ($i = 0; $i < $numOfRows; $i++) { - $row = $db->query_result_rowdata($result, $i); - $moduleData[$db->query_result($result, $i, 'name')] = $db->query_result($result, $i, 'tablabel'); - } - return $moduleData; - } return array('true', 'false'); } @@ -123,7 +106,6 @@ class Settings_Vtiger_ConfigModule_Model extends Settings_Vtiger_Module_Model { 'HELPDESK_SUPPORT_EMAIL_ID' => array('label' => 'LBL_HELPDESK_SUPPORT_EMAILID', 'fieldType' => 'input'), 'HELPDESK_SUPPORT_NAME' => array('label' => 'LBL_HELPDESK_SUPPORT_NAME', 'fieldType' => 'input'), 'upload_maxsize' => array('label' => 'LBL_MAX_UPLOAD_SIZE', 'fieldType' => 'input'), - 'default_module' => array('label' => 'LBL_DEFAULT_MODULE', 'fieldType' => 'picklist'), 'listview_max_textlength' => array('label' => 'LBL_MAX_TEXT_LENGTH_IN_LISTVIEW', 'fieldType' => 'input'), 'list_max_entries_per_page' => array('label' => 'LBL_MAX_ENTRIES_PER_PAGE_IN_LISTVIEW', 'fieldType' => 'input') ); @@ -171,8 +153,6 @@ class Settings_Vtiger_ConfigModule_Model extends Settings_Vtiger_Module_Model { return "LBL_INVALID_EMAILID"; } else if(array_key_exists('HELPDESK_SUPPORT_NAME',$updatedFields) && preg_match ('/[\'";?><]/', $updatedFields['HELPDESK_SUPPORT_NAME'])) { return "LBL_INVALID_SUPPORT_NAME"; - } else if(array_key_exists('default_module',$updatedFields) && !preg_match ('/[a-zA-z0-9]/', $updatedFields['default_module'])) { - return "LBL_INVALID_MODULE"; } else if((array_key_exists('upload_maxsize',$updatedFields) && !filter_var(ltrim($updatedFields['upload_maxsize'],'0'), FILTER_VALIDATE_INT)) || (array_key_exists('list_max_entries_per_page',$updatedFields) && !filter_var(ltrim($updatedFields['list_max_entries_per_page'], '0'), FILTER_VALIDATE_INT)) || (array_key_exists('listview_max_textlength',$updatedFields) && !filter_var(ltrim($updatedFields['listview_max_textlength'], '0'), FILTER_VALIDATE_INT))) { diff --git a/modules/Users/Users.php b/modules/Users/Users.php index 5aafae4603bf2cad1b008781695e5569ea54e16b..fc81bbf7f88f8c9cd9dddd7146a45cc240c725d1 100755 --- a/modules/Users/Users.php +++ b/modules/Users/Users.php @@ -860,7 +860,7 @@ class Users extends CRMEntity { if($current_user->id == $this->id) { $_SESSION['vtiger_authenticated_user_theme'] = $fldvalue; } - } elseif($uitype == 32) { + } elseif($uitype == 32 && $fieldname == 'language') { $languageList = Vtiger_Language::getAll(); $languageList = array_keys($languageList); if(!in_array($fldvalue, $languageList) || $fldvalue == '') { diff --git a/modules/Users/actions/SaveAjax.php b/modules/Users/actions/SaveAjax.php index 5188833bbf57d126b0247fac44e7853ad9f0fc46..61aaea6324e340447236a7129ac157c700dbfb78 100644 --- a/modules/Users/actions/SaveAjax.php +++ b/modules/Users/actions/SaveAjax.php @@ -65,6 +65,9 @@ class Users_SaveAjax_Action extends Vtiger_SaveAjax_Action { if(($fieldName == 'currency_decimal_separator' || $fieldName == 'currency_grouping_separator') && ($displayValue == ' ')) { $displayValue = vtranslate('Space', 'Users'); } + if($fieldName == 'defaultlandingpage'){ + $displayValue = vtranslate($fieldValue, $fieldValue); + } $result[$fieldName] = array('value' => $fieldValue, 'display_value' => $displayValue); } } diff --git a/modules/Users/models/Field.php b/modules/Users/models/Field.php index a7dd3518ab74a6cc3e89446ef080a104f713286d..036f35a8333d25a43e933e802d9258871b241fc7 100644 --- a/modules/Users/models/Field.php +++ b/modules/Users/models/Field.php @@ -74,8 +74,32 @@ class Users_Field_Model extends Vtiger_Field_Model { * @return <Array> List of picklist values if the field is of type picklist or multipicklist, null otherwise. */ public function getPicklistValues() { + $fieldName = $this->getName(); if($this->get('uitype') == 32) { - return Vtiger_Language_Handler::getAllLanguages(); + if($fieldName == 'language'){ + return Vtiger_Language_Handler::getAllLanguages(); + } else if($fieldName == 'defaultlandingpage'){ + $db = PearDatabase::getInstance(); + $currentUserPriviligesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel(); + $presence = array(0); + $restrictedModules = array('Webmails', 'Emails', 'Integration', 'Dashboard','ModComments'); + $query = 'SELECT name, tablabel, tabid FROM vtiger_tab WHERE presence IN (' . generateQuestionMarks($presence) . ') AND isentitytype = ? AND name NOT IN (' . generateQuestionMarks($restrictedModules) . ')'; + + $result = $db->pquery($query, array($presence, '1', $restrictedModules)); + $numOfRows = $db->num_rows($result); + + $moduleData = array('Home' => vtranslate('Home','Home')); + for ($i = 0; $i < $numOfRows; $i++) { + $tabId = $db->query_result($result, $i, 'tabid'); + // check the module access permission, if user has permission then show it in default module list + if($currentUserPriviligesModel->hasModulePermission($tabId)){ + $moduleName = $db->query_result($result, $i, 'name'); + $moduleLabel = $db->query_result($result, $i, 'tablabel'); + $moduleData[$moduleName] = vtranslate($moduleLabel,$moduleName); + } + } + return $moduleData; + } } else if ($this->get('uitype') == '115') { $db = PearDatabase::getInstance();