From 58d5c7e09c192d13012dd4a86f8a8bb3f9c06803 Mon Sep 17 00:00:00 2001 From: root <you@example.com> Date: Tue, 21 May 2024 12:02:26 +0530 Subject: [PATCH] Fixes : php warnings in contacts module --- include/Webservices/DataTransform.php | 8 ++++---- include/utils/utils.php | 2 +- layouts/v7/modules/Vtiger/BreadCrumbs.tpl | 2 +- layouts/v7/modules/Vtiger/Export.tpl | 6 +++--- layouts/v7/modules/Vtiger/RecentActivities.tpl | 2 ++ modules/Emails/models/Record.php | 2 +- modules/Vtiger/actions/ExportData.php | 12 +++++++----- modules/Vtiger/helpers/Util.php | 2 +- .../layouts/v7/modules/Import/ImportAdvanced.tpl | 6 +++--- .../layouts/v7/modules/Import/ImportBasicStep.tpl | 4 ++-- .../layouts/v7/modules/Import/ImportResult.tpl | 2 +- .../layouts/v7/modules/Import/ImportStepOne.tpl | 2 +- .../layouts/v7/modules/Import/ImportStepThree.tpl | 2 +- .../layouts/v7/modules/Import/Import_Mapping.tpl | 2 +- .../modules/Import/modules/Import/actions/Data.php | 4 ++-- .../modules/Import/modules/Import/helpers/Utils.php | 6 +++++- .../Import/modules/Import/readers/CSVReader.php | 4 +++- .../modules/Import/modules/Import/views/Main.php | 1 + 18 files changed, 40 insertions(+), 29 deletions(-) diff --git a/include/Webservices/DataTransform.php b/include/Webservices/DataTransform.php index 79c67225d..7ac0ba081 100644 --- a/include/Webservices/DataTransform.php +++ b/include/Webservices/DataTransform.php @@ -103,7 +103,7 @@ } $references = $meta->getReferenceFieldDetails(); foreach($references as $field=>$typeList){ - if(strpos($row[$field],'x')!==false){ + if(isset($row[$field]) && strpos($row[$field],'x')!==false){ $row[$field] = vtws_getIdComponents($row[$field]); $row[$field] = $row[$field][1]; } @@ -130,7 +130,7 @@ } } } - if($row["id"]){ + if(isset($row["id"])){ unset($row["id"]); } if(isset($row[$meta->getObectIndexColumn()])){ @@ -187,7 +187,7 @@ } if(!isset($row['id'])){ - if($row[$meta->getObectIndexColumn()] ){ + if(isset($row[$meta->getObectIndexColumn()] )){ $row['id'] = vtws_getId($meta->getEntityId(),$row[$meta->getObectIndexColumn()]); }else{ //TODO Handle this. @@ -273,7 +273,7 @@ foreach ($moduleFields as $fieldName => $fieldObj) { if (in_array($fieldObj->getUIType(), $supportedUITypes)) { //while doing retrieve operation we have record_id and on query operation we have id. - $id = $row['record_id'] ? $row['record_id'] : $row['id']; + $id = isset($row['record_id']) ? $row['record_id'] : (isset($row['id']) ? $row['id'] : null); $ids = Vtiger_Functions::getAttachmentIds($id, $meta->getEntityId()); if($ids) { foreach($ids as $id){ diff --git a/include/utils/utils.php b/include/utils/utils.php index c7e28588e..da1002d9d 100755 --- a/include/utils/utils.php +++ b/include/utils/utils.php @@ -2439,7 +2439,7 @@ function getRecordGroupId($record) { * Function to delete record from $_SESSION[$moduleName.'_DetailView_Navigation'.$cvId] */ function deleteRecordFromDetailViewNavigationRecords($recordId, $cvId, $moduleName) { - $recordNavigationInfo = Zend_Json::decode($_SESSION[$moduleName . '_DetailView_Navigation' . $cvId]); + $recordNavigationInfo = Zend_Json::decode(isset($_SESSION[$moduleName . '_DetailView_Navigation' . $cvId])); if (!empty($recordNavigationInfo) && (php7_count($recordNavigationInfo) != 0)) { foreach ($recordNavigationInfo as $key => $recordIdList) { $recordIdList = array_diff($recordIdList, array($recordId)); diff --git a/layouts/v7/modules/Vtiger/BreadCrumbs.tpl b/layouts/v7/modules/Vtiger/BreadCrumbs.tpl index d0a860e3d..74ea4350c 100644 --- a/layouts/v7/modules/Vtiger/BreadCrumbs.tpl +++ b/layouts/v7/modules/Vtiger/BreadCrumbs.tpl @@ -13,7 +13,7 @@ {foreach key=CRUMBID item=STEPTEXT from=$BREADCRUMB_LABELS name=breadcrumbLabels} {assign var=INDEX value=$smarty.foreach.breadcrumbLabels.index} {assign var=INDEX value=$INDEX+1} - <li class="step {if $smarty.foreach.breadcrumbLabels.first} first {$FIRSTBREADCRUMB} {else} {$ADDTIONALCLASS} {/if} {if $smarty.foreach.breadcrumbLabels.last} last {/if} {if $ACTIVESTEP eq $INDEX}active{/if}" + <li class="step {if $smarty.foreach.breadcrumbLabels.first} first {if isset($FIRSTBREADCRUMB)} {$FIRSTBREADCRUMB} {/if} {else} {if isset($ADDTIONALCLASS)} {$ADDTIONALCLASS} {/if}{/if} {if $smarty.foreach.breadcrumbLabels.last} last {/if} {if $ACTIVESTEP eq $INDEX}active{/if}" id="{$CRUMBID}" data-value="{$INDEX}" style="z-index:{$ZINDEX}"> <a href="#"> <span class="stepNum">{$INDEX}</span> diff --git a/layouts/v7/modules/Vtiger/Export.tpl b/layouts/v7/modules/Vtiger/Export.tpl index 8f84d447e..881caeebf 100644 --- a/layouts/v7/modules/Vtiger/Export.tpl +++ b/layouts/v7/modules/Vtiger/Export.tpl @@ -19,9 +19,9 @@ <input type="hidden" name="selected_ids" value={ZEND_JSON::encode($SELECTED_IDS)}> <input type="hidden" name="excluded_ids" value={ZEND_JSON::encode($EXCLUDED_IDS)}> <input type="hidden" id="page" name="page" value="{$PAGE}" /> - <input type="hidden" name="search_key" value= "{$SEARCH_KEY}" /> + <input type="hidden" name="search_key" {if isset($SEARCH_KEY)} value= "{$SEARCH_KEY}" {/if}/> <input type="hidden" name="operator" value="{$OPERATOR}" /> - <input type="hidden" name="search_value" value="{$ALPHABET_VALUE}" /> + <input type="hidden" name="search_value" {if isset($ALPHABET_VALUE)} value="{$ALPHABET_VALUE}" {/if}/> <input type="hidden" name="search_params" value='{Vtiger_Util_Helper::toSafeHTML(ZEND_JSON::encode($SEARCH_PARAMS))}' /> <input type="hidden" name="orderby" value="{$ORDER_BY}" /> <input type="hidden" name="sortorder" value="{$SORT_ORDER}" /> @@ -72,7 +72,7 @@ <input type="radio" name="mode" value="ExportAllData" id="group3" {if empty($SELECTED_IDS)} checked="checked" {/if} style="margin:2px 0 -4px" /> <label style="font-weight:normal" for="group3"> {vtranslate('LBL_EXPORT_ALL_DATA',$MODULE)}</label> </div> - {if $MULTI_CURRENCY} + {if isset($MULTI_CURRENCY)} <br> <div class="row"> <div class="col-lg-8 col-md-8 col-lg-pull-0"><strong>{vtranslate('LBL_EXPORT_LINEITEM_CURRENCY',$MODULE)}: </strong> diff --git a/layouts/v7/modules/Vtiger/RecentActivities.tpl b/layouts/v7/modules/Vtiger/RecentActivities.tpl index ab22c6e86..a3351c2a4 100644 --- a/layouts/v7/modules/Vtiger/RecentActivities.tpl +++ b/layouts/v7/modules/Vtiger/RecentActivities.tpl @@ -84,6 +84,8 @@ {assign var=FIELD_DATA_TYPE value=$FIELDMODEL->getFieldInstance()->getFieldDataType()} {assign var=PRE_DISPLAY_VALUE value=$FIELDMODEL->getDisplayValue(decode_html($FIELDMODEL->get('prevalue')))} {assign var=POST_DISPLAY_VALUE value=$FIELDMODEL->getDisplayValue(decode_html($FIELDMODEL->get('postvalue')))} + {assign var=TIME_PRE_DISPLAY_VALUE value=$FIELDMODEL->getDisplayValue(decode_html($FIELDMODEL->get('prevalue')))} + {assign var=TIME_POST_DISPLAY_VALUE value=$FIELDMODEL->getDisplayValue(decode_html($FIELDMODEL->get('postvalue')))} {if in_array($FIELD_NAME,array('time_start','time_end')) && in_array($MODULE_NAME,array('Events','Calendar'))} {assign var=CALENDAR_RECORD_MODEL value =Vtiger_Record_Model::getInstanceById($RECORD_ID)} diff --git a/modules/Emails/models/Record.php b/modules/Emails/models/Record.php index e20d76b4f..5595d222b 100644 --- a/modules/Emails/models/Record.php +++ b/modules/Emails/models/Record.php @@ -173,7 +173,7 @@ class Emails_Record_Model extends Vtiger_Record_Model { $plainBody = decode_emptyspace_html($description); $plainBody = preg_replace(array("/<p>/i","/<br>/i","/<br \/>/i"),array("\n","\n","\n"),$plainBody); $plainBody .= "\n\n".$currentUserModel->get('signature'); - $plainBody = strip_tags($plainBody); + $plainBody = utf8_encode(strip_tags($plainBody)); $plainBody = Emails_Mailer_Model::convertToAscii($plainBody); $plainBody = $this->convertUrlsToTrackUrls($plainBody, $id,'plain'); $mailer->AltBody = $plainBody; diff --git a/modules/Vtiger/actions/ExportData.php b/modules/Vtiger/actions/ExportData.php index 454b0d234..d8c4e51ac 100644 --- a/modules/Vtiger/actions/ExportData.php +++ b/modules/Vtiger/actions/ExportData.php @@ -110,7 +110,7 @@ class Vtiger_ExportData_Action extends Vtiger_Mass_Action { $fieldInstances = $this->moduleFieldInstances; $orderBy = $request->get('orderby'); - $orderByFieldModel = $fieldInstances[$orderBy]; + $orderByFieldModel = isset($fieldInstances[$orderBy]) ? $fieldInstances[$orderBy] : ""; $sortOrder = $request->get('sortorder'); if ($mode !== 'ExportAllData') { @@ -293,14 +293,16 @@ class Vtiger_ExportData_Action extends Vtiger_Mass_Action { continue; } //Track if the value had quotes at beginning - $beginsWithDoubleQuote = strpos($value, '"') === 0; - $endsWithDoubleQuote = substr($value,-1) === '"'?1:0; + if (is_string($value)) { + $beginsWithDoubleQuote = strpos($value, '"') === 0; + $endsWithDoubleQuote = substr($value,-1) === '"'?1:0; + $value = trim($value,"\""); + } - $value = trim($value,"\""); $uitype = $fieldInfo->get('uitype'); $fieldname = $fieldInfo->get('name'); - if(!$this->fieldDataTypeCache[$fieldName]) { + if(!isset($this->fieldDataTypeCache[$fieldName])) { $this->fieldDataTypeCache[$fieldName] = $fieldInfo->getFieldDataType(); } $type = $this->fieldDataTypeCache[$fieldName]; diff --git a/modules/Vtiger/helpers/Util.php b/modules/Vtiger/helpers/Util.php index f793b582a..0dc1862dc 100644 --- a/modules/Vtiger/helpers/Util.php +++ b/modules/Vtiger/helpers/Util.php @@ -115,7 +115,7 @@ class Vtiger_Util_Helper { */ public static function toVtiger6SafeHTML($input) { $allowableTags = '<a><br>'; - return strip_tags($input, $allowableTags); + return strip_tags((string) $input, $allowableTags); } /** * Function to validate the input with given pattern. diff --git a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportAdvanced.tpl b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportAdvanced.tpl index 6c5909cbb..32e4210fa 100644 --- a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportAdvanced.tpl +++ b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportAdvanced.tpl @@ -27,15 +27,15 @@ <div class='modal-body'> {assign var=LABELS value=[]} - {if $FORMAT eq 'vcf'} + {if isset($FORMAT) eq 'vcf'} {$LABELS["step1"] = 'LBL_UPLOAD_VCF'} - {else if $FORMAT eq 'ics'} + {else if isset($FORMAT) eq 'ics'} {$LABELS["step1"] = 'LBL_UPLOAD_ICS'} {else} {$LABELS["step1"] = 'LBL_UPLOAD_CSV'} {/if} - {if $DUPLICATE_HANDLING_NOT_SUPPORTED eq 'true'} + {if isset($DUPLICATE_HANDLING_NOT_SUPPORTED) eq 'true'} {$LABELS["step3"] = 'LBL_FIELD_MAPPING'} {else} {$LABELS["step2"] = 'LBL_DUPLICATE_HANDLING'} diff --git a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportBasicStep.tpl b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportBasicStep.tpl index 3dc4cb650..966cd6887 100644 --- a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportBasicStep.tpl +++ b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportBasicStep.tpl @@ -32,7 +32,7 @@ {/if} {if $FORMAT neq 'ics'} - {if $DUPLICATE_HANDLING_NOT_SUPPORTED eq 'true'} + {if isset($DUPLICATE_HANDLING_NOT_SUPPORTED) eq 'true'} {$LABELS["step3"] = 'LBL_FIELD_MAPPING'} {else} {$LABELS["step2"] = 'LBL_DUPLICATE_HANDLING'} @@ -56,7 +56,7 @@ <a class="cancelLink" data-dismiss="modal" href="#">{vtranslate('LBL_CANCEL', $MODULE)}</a> {else} <div id="importStepOneButtonsDiv"> - {if $DUPLICATE_HANDLING_NOT_SUPPORTED eq 'true'} + {if isset($DUPLICATE_HANDLING_NOT_SUPPORTED) eq 'true'} <button class="btn btn-success btn-lg" id="skipDuplicateMerge" onclick="Vtiger_Import_Js.uploadAndParse('0');">{vtranslate('LBL_NEXT_BUTTON_LABEL', $MODULE)}</button> {else} <button class="btn btn-success btn-lg" id ="importStep2" onclick="Vtiger_Import_Js.importActionStep2();">{vtranslate('LBL_NEXT_BUTTON_LABEL', $MODULE)}</button> diff --git a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportResult.tpl b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportResult.tpl index 8691a62f7..a53a55683 100644 --- a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportResult.tpl +++ b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportResult.tpl @@ -18,7 +18,7 @@ <div class="summaryWidgetContainer"> <input type="hidden" name="module" value="{$FOR_MODULE}" /> <h4>{'LBL_TOTAL_RECORDS_SCANNED'|@vtranslate:$MODULE} : {$IMPORT_RESULT.TOTAL}</h4> - {if $ERROR_MESSAGE neq ''}<span>{$ERROR_MESSAGE}</span>{/if} + {if isset($ERROR_MESSAGE) && $ERROR_MESSAGE neq ''}<span>{$ERROR_MESSAGE}</span>{/if} <hr> <div>{include file="Import_Result_Details.tpl"|@vtemplate_path:'Import'}</div> </div> diff --git a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepOne.tpl b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepOne.tpl index 72d070aad..6629fb095 100644 --- a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepOne.tpl +++ b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepOne.tpl @@ -71,7 +71,7 @@ {/foreach} </td> </tr> - {if $MULTI_CURRENCY} + {if isset($MULTI_CURRENCY)} <tr id="lineitem_currency_container" style="height:50px"> <td>{vtranslate('LBL_IMPORT_LINEITEMS_CURRENCY',$MODULE)}</td> <td> diff --git a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepThree.tpl b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepThree.tpl index e27a7527d..517634478 100644 --- a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepThree.tpl +++ b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepThree.tpl @@ -19,7 +19,7 @@ <input type="checkbox" name="save_map" id="save_map"> <label for="save_map">{'LBL_SAVE_AS_CUSTOM_MAPPING'|@vtranslate:$MODULE}</label> <input type="text" name="save_map_as" id="save_map_as" class = "form-control"> </div> -{if !$IMPORTABLE_FIELDS} +{if !isset($IMPORTABLE_FIELDS)} {assign var=IMPORTABLE_FIELDS value=$AVAILABLE_FIELDS} {/if} {include file="Import_Default_Values_Widget.tpl"|@vtemplate_path:'Import' IMPORTABLE_FIELDS=$IMPORTABLE_FIELDS} \ No newline at end of file diff --git a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/Import_Mapping.tpl b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/Import_Mapping.tpl index dea8a75ed..7d1078fdf 100644 --- a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/Import_Mapping.tpl +++ b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/Import_Mapping.tpl @@ -10,7 +10,7 @@ {strip} <input type="hidden" name="merge_type" value='{$USER_INPUT->get('merge_type')}' /> <input type="hidden" name="merge_fields" value='{$MERGE_FIELDS}' /> - <input type="hidden" name="lineitem_currency" value='{$LINEITEM_CURRENCY}'> + <input type="hidden" name="lineitem_currency" value='{if isset($LINEITEM_CURRENCY)}{$LINEITEM_CURRENCY}{else}''{/if}'> <input type="hidden" id="mandatory_fields" name="mandatory_fields" value='{$ENCODED_MANDATORY_FIELDS}' /> <input type="hidden" name="field_mapping" id="field_mapping" value="" /> <input type="hidden" name="default_values" id="default_values" value="" /> diff --git a/pkg/vtiger/modules/Import/modules/Import/actions/Data.php b/pkg/vtiger/modules/Import/modules/Import/actions/Data.php index 9ccaf0d4d..d4ca1b2ad 100644 --- a/pkg/vtiger/modules/Import/modules/Import/actions/Data.php +++ b/pkg/vtiger/modules/Import/modules/Import/actions/Data.php @@ -652,7 +652,7 @@ class Import_Data_Action extends Vtiger_Action_Controller { unset($this->allPicklistValues[$fieldName]); } } else { - $fieldData[$fieldName] = $picklistDetails[$picklistValueInLowerCase]; + $fieldData[$fieldName] = isset($picklistDetails[$picklistValueInLowerCase]); } } else if ($fieldDataType == 'currency') { // While exporting we are exporting as user format, we should import as db format while importing @@ -773,7 +773,7 @@ class Import_Data_Action extends Vtiger_Action_Controller { $fieldData['source'] = $this->recordSource; if ($fieldData != null && $checkMandatoryFieldValues) { foreach ($moduleFields as $fieldName => $fieldInstance) { - if ((($fieldData[$fieldName] == '') || ($fieldData[$fieldName] == null)) && $fieldInstance->isMandatory()) { + if ((empty($fieldData[$fieldName]) || !isset($fieldData[$fieldName])) && $fieldInstance->isMandatory()) { return null; } } diff --git a/pkg/vtiger/modules/Import/modules/Import/helpers/Utils.php b/pkg/vtiger/modules/Import/modules/Import/helpers/Utils.php index 5e16ff426..fed3847c3 100644 --- a/pkg/vtiger/modules/Import/modules/Import/helpers/Utils.php +++ b/pkg/vtiger/modules/Import/modules/Import/helpers/Utils.php @@ -9,7 +9,9 @@ * All Rights Reserved. * *********************************************************************************** */ //required for auto detecting file endings for files create in mac -ini_set("auto_detect_line_endings", true); +if (version_compare(PHP_VERSION, '8.1.0') <= 0) { + ini_set("auto_detect_line_endings", true); +} class Import_Utils_Helper { @@ -142,6 +144,7 @@ class Import_Utils_Helper { } public static function getAssignedToUserList($module) { + $current_user = Users_Record_Model::getCurrentUserModel(); $cache = Vtiger_Cache::getInstance(); if($cache->getUserList($module,$current_user->id)){ return $cache->getUserList($module,$current_user->id); @@ -153,6 +156,7 @@ class Import_Utils_Helper { } public static function getAssignedToGroupList($module) { + $current_user = Users_Record_Model::getCurrentUserModel(); $cache = Vtiger_Cache::getInstance(); if($cache->getGroupList($module,$current_user->id)){ return $cache->getGroupList($module,$current_user->id); diff --git a/pkg/vtiger/modules/Import/modules/Import/readers/CSVReader.php b/pkg/vtiger/modules/Import/modules/Import/readers/CSVReader.php index 008969489..7c383d23b 100644 --- a/pkg/vtiger/modules/Import/modules/Import/readers/CSVReader.php +++ b/pkg/vtiger/modules/Import/modules/Import/readers/CSVReader.php @@ -7,7 +7,9 @@ * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. *************************************************************************************/ -ini_set("auto_detect_line_endings", true); +if(version_compare(PHP_VERSION, '8.1.0') <= 0) { + ini_set("auto_detect_line_endings", true); +} class Import_CSVReader_Reader extends Import_FileReader_Reader { diff --git a/pkg/vtiger/modules/Import/modules/Import/views/Main.php b/pkg/vtiger/modules/Import/modules/Import/views/Main.php index 6cceb2e0f..fe6179cc5 100644 --- a/pkg/vtiger/modules/Import/modules/Import/views/Main.php +++ b/pkg/vtiger/modules/Import/modules/Import/views/Main.php @@ -118,6 +118,7 @@ class Import_Main_View extends Vtiger_View_Controller{ public static function showResult($importInfo, $importStatusCount) { $moduleName = $importInfo['module']; $ownerId = $importInfo['user_id']; + $skippedRecords = $importStatusCount['SKIPPED']; $viewer = new Vtiger_Viewer(); -- GitLab