Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • vtiger/vtigercrm
  • varma/vtigercrm
  • alanbell/vtigercrm
  • mariusz.krzaczkowski/vtigercrm
  • manu.k/vtigercrm
  • adrgranado/vtigercrm
  • uma.s/vtigercrm
  • sardoj/vtigercrm
  • preexo/vtigercrm
  • david.valminos/vtigercrm
  • luca.saba/vtigercrm
  • dubwise/vtigercrm
  • valmir.ttcasolucoes/vtigercrm
  • lord_alan/vtigercrm
  • adrien.futschik/vtigercrm
  • edonit.rexhepi/vtigercrm
  • robert.heinze/vtigercrm
  • nrdimatteo/vtigercrm
  • sebastianzahan/vtigercrm
  • Miky/vtigercrm
  • germanf/vtigercrm
  • bernhardkau1/vtigercrm
  • olegtsoy/vtigercrm
  • grandel/vtigercrm
  • mario.thummler/vtigercrm
  • sutharsan/vtigercrm
  • james.douglas/vtigercrm
  • vikas/vtigercrm
  • jeffmchristensen/vtigercrm
  • lukasz.g/vtigercrm
  • nicolas.gasnier/vtigercrm
  • hamish.theitcompany/vtigercrm
  • engrbm87/vtigercrm
  • Quoc/vtigercrm
  • peter.maria.engeli/vtigercrm
  • kiranraju.j/vtigercrm
  • manuel.lozano/vtigercrm
  • dhaupin/vtigercrm
  • Ragupathyranesh/vtigercrm
  • Stefanbauer/vtigercrm
  • ruben.estrada/vtigercrm
  • sg_mwi1/vtigercrm
  • khaluk/vtigercrm
  • franzfroemel/vtigercrm
  • milan9615/vtigercrm
  • carlos.martin/vtigercrm
  • cmaggi/vtigercrm
  • Soltoon.theLeader/vtigercrm
  • alex.kaplun/vtigercrm
  • navid.hosseini/vtigercrm
  • maie/vtigercrm
  • simonetravaglini/vtigercrm
  • bertrand.wattel/vtigercrm
  • balaji.m/vtigercrm
  • mclarke4/vtigercrm
  • lajeeshk/vtigercrm
  • liam/vtigercrm
  • novikov.sergey/vtigercrm
  • johnwayne.williamson/vtigercrm
  • florian.strahberger-schramm/vtigercrm
  • daniel.schaefer/vtigercrm
  • christopher.gunther/vtigercrm
  • adrien.faveraux/vtigercrm
  • carsten.brandt/vtigercrm
  • stephane.molano/vtigercrm
  • krastan.petrov/vtigercrm
  • alfredo.bravo/vtigercrm
  • flipflop.Joe/vtigercrm
  • mirko.stagni/vtigercrm
  • remigio.ruberto/vtigercrm
  • gautam.dhudashiya/vtigercrm
  • manish.devitechnosolutions1/vtigercrm
  • matinbeigi/vtigercrm
  • devs/vtigercrm
  • happy.dev/vtigercrm
  • m.gigon/vtigercrm
  • manuelmigone/vtigercrm
  • eduardo.gqf/vtigercrm
  • elsayedEl-araby/vtigercrm
  • mirza.mehran/vtigercrm
  • maurice.courtois/vtigercrm
  • zuhri.utama/vtigercrm
  • shilpa.k/vtigercrm
  • Ignazio/vtigercrm
  • code80team/vtigercrm
  • code80/vtigercrm
  • nilay.automatesmb/cache
  • greeshma.kk/vtigercrm
  • vijay.tilak/vtigercrm
  • Paolo.Palamini/vtigercrm
  • estevan/vtigercrm
  • mobilcmcdk/vtigercrm
  • massimiliano.vessi/vtigercrm
  • daniel.voelskow/vtigercrm
  • james1/vtigercrm
  • lokesh.s/vtigercrm
  • rdb/vtigercrm
  • neftaliyagua/vtigercrm
  • angelo.paglialonga/vtigercrm
  • webmarka/vtigercrm
  • javanile/vtigercrm
  • akshath/vtigercrm
  • Hemanth/vtigercrm
  • opencrmitalia/vtigercrm
  • direzione/vtigercrm
  • umadas306/vtigercrm
  • jd-wraptec/vtigercrm
  • felipe.camacho/vtigercrm
  • Martin.allen/vtigercrm
  • amit.r/vtigercrm
  • vicus/vtigercrm
  • dev.osmi/vtigercrm
  • laurent.guillout/vtigercrm
  • christian.blaeul/vtigercrm
  • ap.js100/vtigercrm
  • yoann.mourot/vtigercrm-temp
  • christian.cruz/vtigercrm
  • zyli/vtigercrm
  • kaushik.p/vtigercrm
  • Madhuk/vtigercrm
  • cinakzm/vtigercrm
  • raquel.martinez/vtigercrm
  • tosajibadhi/vtigercrm
  • melvin.i/vtigercrm-melvin
  • ashashingadia/vtigercrm
  • stefanwarnat/vtigercrm
  • saran.s/vtigercrm
  • eduardomozart/vtigercrm
  • Daniel.Lennartz1/vtigercrm
  • juergen.fassmann/vtigercrm
  • Michel.Ram/vtigercrm
  • vincenzo.bruno/vtigercrm
132 results
Show changes
Showing
with 291 additions and 183 deletions
......@@ -67,9 +67,9 @@ class ListViewController {
$rowCount = $this->db->num_rows($result);
$columnName = $field->getColumnName();
if($field->referenceFieldName) {
if(isset($field->referenceFieldName) && $field->referenceFieldName) {
preg_match('/(\w+) ; \((\w+)\) (\w+)/', $field->referenceFieldName, $matches);
if (count($matches) != 0) {
if (php7_count($matches) != 0) {
list($full, $parentReferenceFieldName, $referenceModule, $referenceFieldName) = $matches;
}
$columnName = $parentReferenceFieldName.$referenceFieldName;
......@@ -84,10 +84,10 @@ class ListViewController {
}
$idList = array_keys($idList);
if(count($idList) == 0) {
if(php7_count($idList) == 0) {
return;
}
if($parentReferenceFieldName) {
if(isset($parentReferenceFieldName) && $parentReferenceFieldName) {
$moduleList = $referenceFieldInfoList[$field->referenceFieldName];
} else {
$moduleList = $referenceFieldInfoList[$fieldName];
......@@ -127,7 +127,7 @@ class ListViewController {
$fields = $this->queryGenerator->getFields();
$headerFields = array();
foreach($fields as $fieldName) {
if(array_key_exists($fieldName, $moduleFields)) {
if(is_array($moduleFields) && array_key_exists($fieldName, $moduleFields)) {
$headerFields[$fieldName] = $moduleFields[$fieldName];
}
}
......@@ -142,7 +142,7 @@ class ListViewController {
$meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule());
$baseModule = $module;
$moduleFields = $this->queryGenerator->getModuleFields();
$accessibleFieldList = array_keys($moduleFields);
$accessibleFieldList = is_array($moduleFields) ? array_keys($moduleFields) : array();
$listViewFields = array_intersect($fields, $accessibleFieldList);
$referenceFieldList = $this->queryGenerator->getReferenceFieldList();
......@@ -166,7 +166,7 @@ class ListViewController {
//if the assigned to is related to the reference field
preg_match('/(\w+) ; \((\w+)\) (\w+)/', $fieldName, $matches);
if(count($matches) > 0) {
if(php7_count($matches) > 0) {
list($full, $referenceParentField, $module, $fieldName) = $matches;
$columnName = strtolower($referenceParentField.$fieldName);
} else {
......@@ -179,8 +179,8 @@ class ListViewController {
$idList[] = $id;
}
}
if(count($idList) > 0) {
if(!is_array($this->ownerNameList[$fieldName])) {
if(php7_count($idList) > 0) {
if(isset($this->onwerNameList[$fieldName]) && !is_array($this->ownerNameList[$fieldName])) {
$this->ownerNameList[$fieldName] = getOwnerNameList($idList);
} else {
//array_merge API loses key information so need to merge the arrays
......@@ -208,7 +208,7 @@ class ListViewController {
//performance optimization for uitype 61
$attachmentsCache = array();
$attachmentIds = array();
if(count($fileTypeFields)) {
if(php7_count($fileTypeFields)) {
foreach($fileTypeFields as $fileTypeField) {
for ($i = 0; $i < $rowCount; ++$i) {
$attachmentId = $db->query_result($result,$i,$fileTypeField);
......@@ -216,7 +216,7 @@ class ListViewController {
}
}
}
if(count($attachmentIds)) {
if(php7_count($attachmentIds)) {
$getAttachmentsNamesSql = 'SELECT attachmentsid,name FROM vtiger_attachments WHERE attachmentsid IN (' . generateQuestionMarks($attachmentIds) . ')';
$attachmentNamesRes = $db->pquery($getAttachmentsNamesSql,$attachmentIds);
$attachmentNamesRowCount = $db->num_rows($attachmentNamesRes);
......@@ -228,11 +228,16 @@ class ListViewController {
}
$moduleInstance = Vtiger_Module_Model::getInstance("PBXManager");
$outgoingCallPermission = false;
if($moduleInstance && $moduleInstance->isActive()) {
$outgoingCallPermission = PBXManager_Server_Model::checkPermissionForOutgoingCall();
$clickToCallLabel = vtranslate("LBL_CLICK_TO_CALL");
}
$emailModuleInstance = Vtiger_Module_Model::getInstance("Emails");
//checking the email module is active.
$isEmailModuleActive = $emailModuleInstance ? $emailModuleInstance->isActive() : false;
$data = array();
for ($i = 0; $i < $rowCount; ++$i) {
//Getting the recordId
......@@ -255,7 +260,7 @@ class ListViewController {
$fieldDataType = $field->getFieldDataType();
// for reference fields read the value differently
preg_match('/(\w+) ; \((\w+)\) (\w+)/', $fieldName, $matches);
if(count($matches) > 0) {
if(php7_count($matches) > 0) {
list($full, $referenceParentField, $module, $fieldName) = $matches;
$matches = null;
$rawValue = $this->db->query_result($result, $i, strtolower($referenceParentField.$fieldName));
......@@ -268,7 +273,7 @@ class ListViewController {
}
if(in_array($uitype,array(15,33,16))){
$value = html_entity_decode($rawValue,ENT_QUOTES,$default_charset);
$value = isset($rawValue) ? html_entity_decode($rawValue,ENT_QUOTES,$default_charset) : '';
} else {
$value = $rawValue;
}
......@@ -300,7 +305,6 @@ class ListViewController {
} else{
$value = textlength_check($value);
}
$value = $fileicon.$value;
} elseif($module == 'Documents' && $fieldName == 'filesize') {
$downloadType = $db->query_result($result,$i,'filelocationtype');
if($downloadType == 'I') {
......@@ -412,7 +416,8 @@ class ListViewController {
}
} elseif ($fieldDataType == 'email') {
global $current_user;
if($current_user->internal_mailer == 1){
// checking email module is active and internal mail composer is on
if($isEmailModuleActive && $current_user->internal_mailer == 1){
//check added for email link in user detailview
$value = "<a class='emailField' data-rawvalue=\"$rawValue\" onclick=\"Vtiger_Helper_Js.getInternalMailer($recordId,".
"'$fieldName','$module');\">".textlength_check($value)."</a>";
......@@ -456,10 +461,10 @@ class ListViewController {
} elseif($field->getFieldDataType() == 'reference') {
$referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList();
$moduleList = $referenceFieldInfoList[$fieldName];
if(count($moduleList) == 1) {
if(php7_count($moduleList) == 1) {
$parentModule = $moduleList[0];
} else {
$parentModule = $this->typeList[$value];
$parentModule = isset($this->typeList[$value]) ? $this->typeList[$value] : '';
}
if(!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) {
$parentMeta = $this->queryGenerator->getMeta($parentModule);
......@@ -491,7 +496,7 @@ class ListViewController {
}
} elseif ( in_array($uitype,array(7,9,90)) ) {
$value = "<span align='right'>".textlength_check($value)."</span>";
} elseif($field && $field->isNameField) {
} elseif($field && isset($field->isNameField) && $field->isNameField) {
$value = "<a href='?module=$field->moduleName&view=Detail&".
"record=$recordId' title='".vtranslate($field->moduleName, $field->moduleName)."'>$value</a>";
} elseif($field->getUIType() == 61) {
......
......@@ -49,7 +49,7 @@ class ListViewSession {
return 1;
}
function getRequestStartPage(){
public static function getRequestStartPage(){
$start = $_REQUEST['start'];
if(!is_numeric($start)){
$start = 1;
......@@ -75,10 +75,12 @@ class ListViewSession {
}
$cv = new CustomView();
$viewId = $cv->getViewId($currentModule);
$recordNavigationInfo = array();
$searchKey = array();
if(!empty($_SESSION[$currentModule.'_DetailView_Navigation'.$viewId])){
$recordNavigationInfo = Zend_Json::decode($_SESSION[$currentModule.'_DetailView_Navigation'.$viewId]);
$pageNumber =0;
if(count($recordNavigationInfo) == 1){
if(php7_count($recordNavigationInfo) == 1){
foreach ($recordNavigationInfo as $recordIdList) {
if(in_array($currentRecordId,$recordIdList)){
$reUseData = true;
......@@ -92,18 +94,18 @@ class ListViewSession {
$recordList[] = $recordId;
$recordPageMapping[$recordId] = $start;
if($recordId == $currentRecordId){
$searchKey = count($recordList)-1;
$searchKey = php7_count($recordList)-1;
$_REQUEST['start'] = $start;
}
}
}
if($searchKey > $displayBufferRecordCount -1 && $searchKey < count($recordList)-$displayBufferRecordCount){
if($searchKey > $displayBufferRecordCount -1 && $searchKey < php7_count($recordList)-$displayBufferRecordCount){
$reUseData= true;
}
}
}
$list_query = $_SESSION[$currentModule.'_listquery'];
$list_query = isset($_SESSION[$currentModule.'_listquery'])?$_SESSION[$currentModule.'_listquery']:'';
if($reUseData === false && !empty($list_query)){
$recordNavigationInfo = array();
......@@ -166,7 +168,7 @@ class ListViewSession {
$recordNavigationInfo = array();
if($searchKey !== false){
foreach ($navigationRecordList as $index => $recordId) {
if(!is_array($recordNavigationInfo[$current])){
if(!isset($recordNavigationInfo[$current])){
$recordNavigationInfo[$current] = array();
}
if($index == $firstPageRecordCount || $index == ($firstPageRecordCount+$pageCount * $list_max_entries_per_page)){
......@@ -182,7 +184,7 @@ class ListViewSession {
return $recordNavigationInfo;
}
function getRequestCurrentPage($currentModule, $query, $viewid, $queryMode = false) {
static function getRequestCurrentPage($currentModule, $query, $viewid, $queryMode = false) {
global $list_max_entries_per_page, $adb;
$start = 1;
if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true'&& $_REQUEST['start']!="last"){
......@@ -221,7 +223,7 @@ class ListViewSession {
$_SESSION[$currentModule.'_listquery'] = $query;
}
function hasViewChanged($currentModule) {
static function hasViewChanged($currentModule) {
if(empty($_SESSION['lvs'][$currentModule]['viewname'])) return true;
if(empty($_REQUEST['viewname'])) return false;
if($_REQUEST['viewname'] != $_SESSION['lvs'][$currentModule]['viewname']) return true;
......@@ -248,4 +250,4 @@ class ListViewSession {
}
}
}
?>
\ No newline at end of file
?>
......@@ -32,7 +32,6 @@ class PopulateComboValues
{
global $log;
$tableName = Vtiger_Util_Helper::validateStringForSql($tableName);
$log->debug("Entering insertComboValues(".$values.", ".$tableName.") method ...");
global $adb;
//inserting the value in the vtiger_picklistvalues_seq for the getting uniqueID for each picklist values...
$i=0;
......@@ -137,7 +136,6 @@ class PopulateComboValues
function insertNonPicklistValues($values, $tableName)
{
global $log;
$log->debug("Entering insertNonPicklistValues(".$values.", ".$tableName.") method ...");
global $adb;
$i=0;
foreach ($values as $val => $cal)
......
......@@ -32,7 +32,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
}
public function getModuleFields() {
if ($this->moduleFields == null) {
if (!isset($this->moduleFields) || $this->moduleFields == null) {
$moduleFields = parent::getModuleFields();
//add reference fields also in the list
......@@ -79,7 +79,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
}
$this->moduleFields = $moduleFields;
}
return $this->moduleFields;
return isset($this->moduleFields) ? $this->moduleFields : null;
}
public function parseAdvFilterList($advFilterList, $glue = '') {
......@@ -90,8 +90,9 @@ class EnhancedQueryGenerator extends QueryGenerator {
$dateSpecificConditions = $customView->getStdFilterConditions();
$specialDateTimeConditions = Vtiger_Functions::getSpecialDateTimeCondtions();
foreach ($advFilterList as $groupindex => $groupcolumns) {
if(! $groupcolumns)continue;
$filtercolumns = $groupcolumns['columns'];
if (count($filtercolumns) > 0) {
if (php7_count($filtercolumns) > 0) {
$this->startGroup('');
foreach ($filtercolumns as $index => $filter) {
//If comparator is "e" or "n" then do not escapeSqlString.
......@@ -172,7 +173,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
$value = array();
$value[] = $this->fixDateTimeValue($name, $date, true);
// Still fixDateTimeValue returns only date value, we need to append time because it is DT type
for ($i = 0; $i < count($value); $i++) {
for ($i = 0; $i < php7_count($value); $i++) {
$values = explode(' ', $value[$i]);
if ($values[1] == '') {
$values[1] = '00:00:00';
......@@ -196,7 +197,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
}
}
$this->endGroup();
$groupConditionGlue = $groupcolumns['condition'];
$groupConditionGlue = isset($groupcolumns['condition']) ? $groupcolumns['condition'] : "";
if ($groupConditionGlue) {
$this->addConditionGlue($groupConditionGlue);
}
......@@ -219,7 +220,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
if ($fieldObject && isset($fieldObject->referenceFieldName)) {
// if its a reference field then we need to add the fieldname to table name
preg_match('/(\w+) ; \((\w+)\) (\w+)/', $fieldObject->referenceFieldName, $matches);
if (count($matches) != 0) {
if (php7_count($matches) != 0) {
list($full, $referenceField, $referenceModule, $fieldname) = $matches;
}
$field = $fieldObject;
......@@ -232,7 +233,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
public function getSelectClauseColumnSQL() {
$columns = array();
$moduleFields = $this->getModuleFields();
$accessibleFieldList = array_keys($moduleFields);
$accessibleFieldList = is_array($moduleFields) ? array_keys($moduleFields) : array();
$moduleFields = $this->getModuleFields();
......@@ -241,7 +242,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
foreach ($this->fields as $field) {
// handle for reference field
preg_match('/(\w+) ; \((\w+)\) (\w+)/', $field, $matches);
if (count($matches) != 0) {
if (php7_count($matches) != 0) {
list($full, $referenceField, $referenceModule, $fieldname) = $matches;
$parentReferenceFieldModel = null;
$parentReferenceFieldModel = $moduleFields[$field];
......@@ -311,7 +312,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
$referenceParentFieldName = '';
// for reference field do not add the table names to the list
preg_match('/(\w+) ; \((\w+)\) (\w+)/', $fieldName, $matches);
if (count($matches) != 0) {
if (php7_count($matches) != 0) {
list($full, $referenceParentFieldName, $referenceModuleName, $fieldName) = $matches;
}
......@@ -394,7 +395,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
if (empty($fieldName))
continue;
$field = $moduleFields[$fieldName];
$field = isset($moduleFields) ? $moduleFields[$fieldName] : null;
if (empty($field))
continue; // not accessible field.
......@@ -402,7 +403,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
$referenceParentFieldName = '';
// for reference field do not add the table names to the list
preg_match('/(\w+) ; \((\w+)\) (\w+)/', $fieldName, $matches);
if (count($matches) != 0) {
if (php7_count($matches) != 0) {
list($full, $referenceParentFieldName, $referenceModuleName, $fieldName) = $matches;
}
......@@ -531,7 +532,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
$tableJoinMapping[$table] = 'INNER JOIN';
}
$ownerFields = $this->meta->getOwnerFields();
if (count($ownerFields) > 0) {
if (php7_count($ownerFields) > 0) {
$ownerField = $ownerFields[0];
}
......@@ -578,7 +579,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
foreach ($tableJoinCondition as $fieldName => $conditionInfo) {
foreach ($conditionInfo as $tableName => $condition) {
if ($tableList[$tableName]) {
if (isset($tableList[$tableName])) {
$tableNameAlias = $tableName.'2';
$condition = str_replace($tableName, $tableNameAlias, $condition);
} else {
......@@ -624,11 +625,11 @@ class EnhancedQueryGenerator extends QueryGenerator {
$parentReferenceField = '';
$baseFieldName = $fieldName = $conditionInfo['name'];
$parentReferenceField = $referenceModule = '';
$field = $moduleFieldList[$fieldName];
$field = isset($moduleFieldList) ? $moduleFieldList[$fieldName] : null;
// if its a reference field then we need to add the fieldname to table name
preg_match('/(\w+) ; \((\w+)\) (\w+)/', $baseFieldName, $matches);
if (count($matches) != 0) {
if (php7_count($matches) != 0) {
list($full, $parentReferenceField, $referenceModule, $fieldName) = $matches;
}
......@@ -643,12 +644,12 @@ class EnhancedQueryGenerator extends QueryGenerator {
$operator = strtolower($conditionInfo['operator']);
if ($operator == 'between' && $this->isDateType($field->getFieldDataType())) {
$start = explode(' ', $conditionInfo['value'][0]);
if (count($start) == 2)
if (php7_count($start) == 2)
$conditionInfo['value'][0] = getValidDBInsertDateTimeValue($start[0].' '.$start[1]);
$end = explode(' ', $conditionInfo['values'][1]);
$end = explode(' ', $conditionInfo['value'][1]);
// Dates will be equal for Today, Tomorrow, Yesterday.
if (count($end) == 2) {
if (php7_count($end) == 2) {
if ($start[0] == $end[0]) {
$dateTime = new DateTime($conditionInfo['value'][0]);
$nextDay = $dateTime->modify('+1 days');
......@@ -725,7 +726,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
$values = explode(',', $value);
$startDateValue = explode(' ', $values[0]);
$endDateValue = explode(' ', $values[1]);
if (count($startDateValue) == 2 && count($endDateValue) == 2) {
if (php7_count($startDateValue) == 2 && php7_count($endDateValue) == 2) {
$fieldSql .= " CONCAT($dateFieldColumnName,' ',$timeFieldColumnName) $valueSql";
} else {
$fieldSql .= "$dateFieldColumnName $valueSql";
......@@ -735,7 +736,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
$value = $value[0];
}
$values = explode(' ', $value);
if (count($values) == 2) {
if (php7_count($values) == 2) {
$fieldSql .= "$fieldGlue CONCAT($dateFieldColumnName,' ',$timeFieldColumnName) $valueSql ";
} else {
$fieldSql .= "$fieldGlue $dateFieldColumnName $valueSql";
......@@ -877,7 +878,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
$parentReferenceField = '';
preg_match('/(\w+) ; \((\w+)\) (\w+)/', $fieldName, $matches);
if (count($matches) != 0) {
if (php7_count($matches) != 0) {
list($full, $parentReferenceField, $referenceModule, $fieldName) = $matches;
}
if ($orderByFieldModel && $orderByFieldModel->getFieldDataType() == 'reference') {
......
......@@ -19,6 +19,7 @@ require_once 'include/Webservices/RelatedModuleMeta.php';
*
* @author MAK
*/
#[\AllowDynamicProperties]
class QueryGenerator {
protected $module;
protected $customViewColumnList;
......@@ -52,6 +53,7 @@ class QueryGenerator {
public static $AND = 'AND';
public static $OR = 'OR';
protected $customViewFields;
protected $referenceModuleField;
/**
* Import Feature
*/
......@@ -222,12 +224,12 @@ class QueryGenerator {
$this->addCondition($name, $value, 'BETWEEN');
}
}
if($this->conditionInstanceCount <= 0 && is_array($this->advFilterList) && count($this->advFilterList) > 0) {
if($this->conditionInstanceCount <= 0 && is_array($this->advFilterList) && php7_count($this->advFilterList) > 0) {
$this->startGroup('');
} elseif($this->conditionInstanceCount > 0 && is_array($this->advFilterList) && count($this->advFilterList) > 0) {
} elseif($this->conditionInstanceCount > 0 && is_array($this->advFilterList) && php7_count($this->advFilterList) > 0) {
$this->addConditionGlue(self::$AND);
}
if(is_array($this->advFilterList) && count($this->advFilterList) > 0) {
if(is_array($this->advFilterList) && php7_count($this->advFilterList) > 0) {
$this->parseAdvFilterList($this->advFilterList);
}
if($this->conditionInstanceCount > 0) {
......@@ -242,7 +244,7 @@ class QueryGenerator {
$dateSpecificConditions = $customView->getStdFilterConditions();
foreach ($advFilterList as $groupindex=>$groupcolumns) {
$filtercolumns = $groupcolumns['columns'];
if(count($filtercolumns) > 0) {
if(php7_count($filtercolumns) > 0) {
$this->startGroup('');
foreach ($filtercolumns as $index=>$filter) {
$nameComponents = explode(':',$filter['columnname']);
......@@ -316,7 +318,7 @@ class QueryGenerator {
$value = array();
$value[] = $this->fixDateTimeValue($name, $date, false);
// Still fixDateTimeValue returns only date value, we need to append time because it is DT type
for($i=0;$i<count($value);$i++){
for($i=0;$i<php7_count($value);$i++){
$values = explode(' ', $value[$i]);
if($values[1] == ''){
$values[1] = '00:00:00';
......@@ -569,7 +571,7 @@ class QueryGenerator {
}
}
$ownerFields = $this->meta->getOwnerFields();
if (count($ownerFields) > 0) {
if (php7_count($ownerFields) > 0) {
$ownerField = $ownerFields[0];
}
$baseTable = $this->meta->getEntityBaseTable();
......@@ -705,12 +707,12 @@ class QueryGenerator {
$operator = strtolower($conditionInfo['operator']);
if($operator == 'between' && $this->isDateType($field->getFieldDataType())){
$start = explode(' ', $conditionInfo['value'][0]);
if(count($start) == 2)
if(php7_count($start) == 2)
$conditionInfo['value'][0] = getValidDBInsertDateTimeValue($start[0].' '.$start[1]);
$end = explode(' ', $conditionInfo['values'][1]);
// Dates will be equal for Today, Tomorrow, Yesterday.
if(count($end) == 2){
if(php7_count($end) == 2){
if($start[0] == $end[0]){
$dateTime = new DateTime($conditionInfo['value'][0]);
$nextDay = $dateTime->modify('+1 days');
......@@ -748,7 +750,7 @@ class QueryGenerator {
$instance = CRMEntity::getInstance($module);
$referenceTable = $instance->table_name;
// PriceBook don't have any owner fields
if(count($this->ownerFields) > 0 ||
if(php7_count($this->ownerFields) > 0 ||
$this->getModule() == 'Quotes' || $this->getModule() == 'PriceBooks') {
$referenceTable .= $fieldName;
}
......@@ -761,8 +763,14 @@ class QueryGenerator {
}
$columnList[] = "$referenceTable.$column";
}
if(count($columnList) > 1) {
$columnSql = getSqlForNameInDisplayFormat(array('first_name'=>$columnList[0],'last_name'=>$columnList[1]),'Users');
if(php7_count($columnList) > 1) {
if ($module == "Users") {
// Special case
$columnSql = getSqlForNameInDisplayFormat(array('first_name'=>$columnList[0],'last_name'=>$columnList[1]),'Users');
} else {
// Leads or contacts
$columnSql = getSqlForNameInDisplayFormat(array('firstname'=>$columnList[0],'lastname'=>$columnList[1]), $module);
}
} else {
$columnSql = implode('', $columnList);
}
......@@ -798,7 +806,7 @@ class QueryGenerator {
$values = explode(',', $value);
$startDateValue = explode(' ', $values[0]);
$endDateValue = explode(' ', $values[1]);
if(count($startDateValue) == 2 && count($endDateValue) == 2) {
if(php7_count($startDateValue) == 2 && php7_count($endDateValue) == 2) {
$fieldSql .= " CONCAT($dateFieldColumnName,' ',$timeFieldColumnName) $valueSql";
} else {
$fieldSql .= "$dateFieldColumnName $valueSql";
......@@ -808,7 +816,7 @@ class QueryGenerator {
$value = $value[0];
}
$values = explode(' ', $value);
if(count($values) == 2) {
if(php7_count($values) == 2) {
$fieldSql .= "$fieldGlue CONCAT($dateFieldColumnName,' ',$timeFieldColumnName) $valueSql ";
} else {
$fieldSql .= "$fieldGlue $dateFieldColumnName $valueSql";
......@@ -986,7 +994,7 @@ class QueryGenerator {
if($this->isDateType($field->getFieldDataType())) {
$start = explode(' ', $valueArray[0]);
$end = explode(' ',$valueArray[1]);
if($operator == 'between' && count($start) == 2 && count($end) == 2){
if($operator == 'between' && php7_count($start) == 2 && php7_count($end) == 2){
$valueArray[0] = getValidDBInsertDateTimeValue($start[0].' '.$start[1]);
if($start[0] == $end[0]){
......@@ -1004,12 +1012,12 @@ class QueryGenerator {
}else{
$valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
$dateTimeStart = explode(' ',$valueArray[0]);
if($dateTimeStart[1] == '00:00:00' && $operator != 'between' && $field->getFieldDataType()=='date') {
if(isset($dateTimeStart[1]) && $dateTimeStart[1] == '00:00:00' && $operator != 'between' && $field->getFieldDataType()=='date') {
$valueArray[0] = $dateTimeStart[0];
}
$valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
$dateTimeEnd = explode(' ', $valueArray[1]);
if(($dateTimeEnd[1] == '00:00:00' || $dateTimeEnd[1] == '23:59:59') && $field->getFieldDataType()=='date' ) {
if(isset($dateTimeEnd[1]) && ($dateTimeEnd[1] == '00:00:00' || $dateTimeEnd[1] == '23:59:59') && $field->getFieldDataType()=='date' ) {
$valueArray[1] = $dateTimeEnd[0];
}
}
......@@ -1026,29 +1034,60 @@ class QueryGenerator {
return $sql;
}
foreach ($valueArray as $value) {
$isvaluefn = false; /* flag to use when value becomes a sql function */
if(!$this->isStringType($field->getFieldDataType())) {
$value = trim($value);
}
if ($operator == 'empty' || $operator == 'y') {
$sql[] = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName(), $field));
continue;
}
if($operator == 'ny'){
$sql[] = sprintf("IS NOT NULL AND %s != ''", $this->getSQLColumn($field->getFieldName(), $field));
// If value is empty and comparator is equals then we have to check IS NULL (same as "is empty" condition)
if ($operator == 'empty' || $operator == 'y') {
$sqlFieldDataType = $field->getFieldDataType();
if($sqlFieldDataType == 'date' || $sqlFieldDataType == 'birthday'){
$sqlFormat = sprintf("IS NULL OR %s = '0000-00-00'", $this->getSQLColumn($field->getFieldName(), $field));
} else if($sqlFieldDataType == 'datetime'){
$sqlFormat = sprintf("IS NULL OR %s = '0000-00-00 00:00:00'", $this->getSQLColumn($field->getFieldName(), $field));
} else {
$sqlFormat = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName(), $field));
}
$sql[] = $sqlFormat;
continue;
}
if ($operator == 'ny') {
$sqlFieldDataType = $field->getFieldDataType();
if ($sqlFieldDataType == 'date' || $sqlFieldDataType == 'birthday') {
$sqlFormat = sprintf("IS NOT NULL AND %s != '0000-00-00'", $this->getSQLColumn($field->getFieldName(), $field));
} else if ($sqlFieldDataType == 'datetime') {
$sqlFormat = sprintf("IS NOT NULL AND %s != '0000-00-00 00:00:00'", $this->getSQLColumn($field->getFieldName(), $field));
} else {
$sqlFormat = sprintf("IS NOT NULL AND %s != ''", $this->getSQLColumn($field->getFieldName(), $field));
}
$sql[] = $sqlFormat;
continue;
}
if ($operator == 'k') {
$sql[] = sprintf("IS NULL OR %s NOT LIKE '%%%s%%'", $this->getSQLColumn($field->getFieldName(), $field), $value);
continue;
}
if((strtolower(trim($value)) == 'null') ||
(trim($value) == '' && !$this->isStringType($field->getFieldDataType())) &&
($operator == 'e' || $operator == 'n')) {
if($operator == 'e'){
$sql[] = "IS NULL";
$sql[] = "= ''";
continue;
} else {
$sql[] = "IS NOT NULL";
$sql[] = "!= ''";
continue;
}
$trimmedValue = is_array($value) ? NULL : trim($value);
if((strtolower($trimmedValue) == 'null') ||
($trimmedValue == '' && !$this->isStringType($field->getFieldDataType())) &&
($operator == 'e' || $operator == 'n')) {
if($operator == 'e'){
$sql[] = "IS NULL";
$sqlFieldDataType = $field->getFieldDataType();
if($sqlFieldDataType == 'date' || $sqlFieldDataType == 'birthday'){
$sql[] = "= '0000-00-00'";
} else if($sqlFieldDataType == 'datetime'){
$sql[] = "= '0000-00-00 00:00:00'";
} else {
$sql[] = "= ''";
}
continue;
} else {
$sql[] = "IS NOT NULL";
$sql[] = "!= ''";
continue;
}
} elseif($field->getFieldDataType() == 'boolean') {
$value = strtolower($value);
if ($value == 'yes') {
......@@ -1059,7 +1098,7 @@ class QueryGenerator {
} elseif($this->isDateType($field->getFieldDataType())) {
// For "after" and "before" conditions
$values = explode(' ',$value);
if(($operator == 'a' || $operator == 'b') && count($values) == 2){
if(($operator == 'a' || $operator == 'b') && php7_count($values) == 2){
if($operator == 'a'){
// for after comparator we should check the date after the given
$dateTime = new DateTime($value);
......@@ -1092,11 +1131,12 @@ class QueryGenerator {
}
if($field->getFieldName() == 'birthday' && !$this->isRelativeSearchOperators(
$operator)) {
$value = "DATE_FORMAT(".$db->quote($value).", '%m%d')";
} else {
$value = $db->sql_escape_string($value);
}
$operator)) {
$value = "DATE_FORMAT(".$db->quote($value).", '%m%d')";
$isvaluefn = true;
} else {
$value = is_array($value) ? NULL : $db->sql_escape_string($value);
}
if(trim($value) == '' && ($operator == 's' || $operator == 'ew' || $operator == 'c')
&& ($this->isStringType($field->getFieldDataType()) ||
......@@ -1126,9 +1166,6 @@ class QueryGenerator {
case 'c': $sqlOperator = "LIKE";
$value = "%$value%";
break;
case 'k': $sqlOperator = "NOT LIKE";
$value = "%$value%";
break;
case 'l': $sqlOperator = "<";
break;
case 'g': $sqlOperator = ">";
......@@ -1149,14 +1186,32 @@ class QueryGenerator {
$sql[] = "IS NULL";
}
if( ($field->getFieldName() != 'birthday' || ($field->getFieldName() == 'birthday'
&& $this->isRelativeSearchOperators($operator)))){
$value = "'$value'";
}
if(($this->isNumericType($field->getFieldDataType())) && empty($value)) {
$value = '0';
}
/**
* While searching in decimal type columns, then value will be stored like 100.1234 (as float value).
* When user search for 100 then also it should show up 100.1234 for which we are altering comparator and
* value here. If we search 'equal' or 'not equal' we will change to 'like' or 'not like'
* NOTE : Same thing handled in ReportRun->generateAdvFilterSql() api
*/
if($this->isFloatType($field->getFieldDataType()) && !empty($value)
&& in_array($operator, array('e', 'n') )){
$sqlOperator = ($operator == 'e') ? ' LIKE ' : ' NOT LIKE ';
if ((float) $value == round((float)$value)) {
// if given value is witn out any decimals (Ex:- 1234), then we search with '1234.%'
$value = $value.'.';
}
$value = $value."%";
}
if( ($field->getFieldName() != 'birthday' || ($field->getFieldName() == 'birthday'
&& $this->isRelativeSearchOperators($operator)))){
if($field->getFieldDataType() !== 'integer'){
$value = "'$value'";
}
}
if($this->isNumericType($field->getFieldDataType()) && empty($value)) {
$value = '0';
}
$sql[] = "$sqlOperator $value";
}
return $sql;
......@@ -1184,6 +1239,14 @@ class QueryGenerator {
protected function isNumericType($type) {
return ($type == 'integer' || $type == 'double' || $type == 'currency');
}
/**
* Function to identify given type is a floating(decimal) type or not. Column types like decimal will store
* information as floating values. All those column related field types comes under this
*/
protected function isFloatType($type) {
return ($type == 'double' || $type == 'currency' || $type == 'multicurrency');
}
protected function isStringType($type) {
return ($type == 'string' || $type == 'text' || $type == 'email' || $type == 'reference');
......@@ -1195,7 +1258,7 @@ class QueryGenerator {
public function fixDateTimeValue($name, $value, $first = true) {
$moduleFields = $this->getModuleFields();
$field = $moduleFields[$name];
$field = isset($moduleFieldList) ? $moduleFields[$name] : null;
$type = $field ? $field->getFieldDataType() : false;
if($type == 'datetime') {
if(strrpos($value, ' ') === false) {
......@@ -1231,7 +1294,7 @@ class QueryGenerator {
}
public function hasConditionals() {
if(count($this->conditionals) > 0) {
if(php7_count($this->conditionals) > 0) {
return true;
}
return false;
......@@ -1277,7 +1340,7 @@ class QueryGenerator {
public function addUserSearchConditions($input) {
global $log,$default_charset;
if($input['searchtype']=='advance') {
if(isset($input['searchtype']) && $input['searchtype']=='advance') {
$json = new Zend_Json();
$advft_criteria = $_REQUEST['advft_criteria'];
......@@ -1285,13 +1348,13 @@ class QueryGenerator {
$advft_criteria_groups = $_REQUEST['advft_criteria_groups'];
if(!empty($advft_criteria_groups)) $advft_criteria_groups = $json->decode($advft_criteria_groups);
if(empty($advft_criteria) || count($advft_criteria) <= 0) {
if(empty($advft_criteria) || php7_count($advft_criteria) <= 0) {
return ;
}
$advfilterlist = getAdvancedSearchCriteriaList($advft_criteria, $advft_criteria_groups, $this->getModule());
if(empty($advfilterlist) || count($advfilterlist) <= 0) {
if(empty($advfilterlist) || php7_count($advfilterlist) <= 0) {
return ;
}
......@@ -1302,7 +1365,7 @@ class QueryGenerator {
}
foreach ($advfilterlist as $groupindex=>$groupcolumns) {
$filtercolumns = $groupcolumns['columns'];
if(count($filtercolumns) > 0) {
if(php7_count($filtercolumns) > 0) {
$this->startGroup('');
foreach ($filtercolumns as $index=>$filter) {
$name = explode(':',$filter['columnname']);
......@@ -1324,7 +1387,7 @@ class QueryGenerator {
}
}
$this->endGroup();
} elseif($input['type']=='dbrd') {
} elseif(isset($input['type']) && $input['type']=='dbrd') {
if($this->conditionInstanceCount > 0) {
$this->startGroup(self::$AND);
} else {
......@@ -1333,8 +1396,8 @@ class QueryGenerator {
$allConditionsList = $this->getDashBoardConditionList();
$conditionList = $allConditionsList['conditions'];
$relatedConditionList = $allConditionsList['relatedConditions'];
$noOfConditions = count($conditionList);
$noOfRelatedConditions = count($relatedConditionList);
$noOfConditions = php7_count($conditionList);
$noOfRelatedConditions = php7_count($relatedConditionList);
foreach ($conditionList as $index=>$conditionInfo) {
$this->addCondition($conditionInfo['fieldname'], $conditionInfo['value'],
$conditionInfo['operator']);
......@@ -1368,7 +1431,7 @@ class QueryGenerator {
if(isset($input['search_text']) && $input['search_text']!="") {
// search other characters like "|, ?, ?" by jagi
$value = $input['search_text'];
$stringConvert = function_exists(iconv) ? @iconv("UTF-8",$default_charset,$value)
$stringConvert = function_exists("iconv") ? @iconv("UTF-8",$default_charset,$value)
: $value;
if(!$this->isStringType($type)) {
$value=trim($stringConvert);
......@@ -1378,7 +1441,7 @@ class QueryGenerator {
global $mod_strings;
// Get all the keys for the for the Picklist value
$mod_keys = array_keys($mod_strings, $value);
if(sizeof($mod_keys) >= 1) {
if(php7_sizeof($mod_keys) >= 1) {
// Iterate on the keys, to get the first key which doesn't start with LBL_ (assuming it is not used in PickList)
foreach($mod_keys as $mod_idx=>$mod_key) {
$stridx = strpos($mod_key, 'LBL_');
......
......@@ -8,11 +8,11 @@
* All Rights Reserved.
******************************************************************************** */
require_once 'vendor/autoload.php';
require_once 'include/Webservices/Retrieve.php';
require_once 'include/Webservices/Create.php';
require_once 'include/Webservices/Delete.php';
require_once 'include/Webservices/DescribeObject.php';
require_once 'includes/Loader.php';
vimport ('includes.runtime.Globals');
vimport ('includes.runtime.BaseModel');
......@@ -145,18 +145,25 @@ function vtws_convertlead($entityvalues, $user) {
try {
$accountIdComponents = vtws_getIdComponents($entityIds['Accounts']);
$accountId = $accountIdComponents[1];
$contactIdComponents = vtws_getIdComponents($entityIds['Contacts']);
$contactId = $contactIdComponents[1];
if(!empty($entityIds['Potentials'])){
$accountId = null;
if (isset($entityIds['Accounts']) && $entityIds['Accounts']) {
$accountIdComponents = vtws_getIdComponents($entityIds['Accounts']);
$accountId = $accountIdComponents[1];
}
$contactId = null;
if (isset($entityIds['Contacts']) && $entityIds['Contacts']) {
$contactIdComponents = vtws_getIdComponents($entityIds['Contacts']);
$contactId = $contactIdComponents[1];
}
$potentialId = null;
if(isset($entityIds['Potentials']) && $entityIds['Potentials']){
$potentialIdComponents = vtws_getIdComponents($entityIds['Potentials']);
$potentialId = $potentialIdComponents[1];
}
if (!empty($accountId) && !empty($contactId) && !empty($potentialId)) {
if (!empty($contactId) && !empty($potentialId)) {
$sql = "insert into vtiger_contpotentialrel values(?,?)";
$result = $adb->pquery($sql, array($contactId, $potentialId));
if ($result === false) {
......
......@@ -12,7 +12,7 @@ require_once 'include/Webservices/Retrieve.php';
require_once 'include/Webservices/Create.php';
require_once 'include/Webservices/Delete.php';
require_once 'include/Webservices/DescribeObject.php';
require_once 'includes/Loader.php';
require_once 'vendor/autoload.php';
vimport('includes.runtime.Globals');
vimport('includes.runtime.BaseModel');
......
......@@ -64,7 +64,7 @@ function vtws_create($elementType, $element, $user) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED,
"Permission to access reference type is denied" . $referenceObject->getEntityName());
}
} else if ($element[$fieldName] !== NULL) {
} else if (array_key_exists($fieldName, $element) && $element[$fieldName] !== NULL) {
unset($element[$fieldName]);
}
}
......@@ -72,7 +72,7 @@ function vtws_create($elementType, $element, $user) {
if ($meta->hasMandatoryFields($element)) {
$ownerFields = $meta->getOwnerFields();
if (is_array($ownerFields) && sizeof($ownerFields) > 0) {
if (is_array($ownerFields) && php7_sizeof($ownerFields) > 0) {
foreach ($ownerFields as $ownerField) {
if (isset($element[$ownerField]) && $element[$ownerField] !== null &&
!$meta->hasAssignPrivilege($element[$ownerField])) {
......@@ -88,4 +88,4 @@ function vtws_create($elementType, $element, $user) {
return null;
}
}
?>
\ No newline at end of file
?>
......@@ -14,7 +14,7 @@
public static $recordModuleString = 'record_module';
public static $recordSource = 'WEBSERVICE';
function sanitizeDataWithColumn($row,$meta){
static function sanitizeDataWithColumn($row,$meta){
$newRow = array();
if(isset($row['count(*)'])){
......@@ -30,7 +30,7 @@
return $newRow;
}
function sanitizeDataWithCountColumn($row,$meta){
static function sanitizeDataWithCountColumn($row,$meta){
$newRow = array();
foreach($row as $col=>$val){
$newRow['count'] = $val;
......@@ -38,8 +38,8 @@
return $newRow;
}
function filterAndSanitize($row,$meta){
$recordLabel = $row['label'];
static function filterAndSanitize($row,$meta){
$recordLabel = isset($row['label']) ? $row['label'] :"";
$row = DataTransform::filterAllColumns($row,$meta);
$row = DataTransform::sanitizeData($row,$meta);
if(!empty($recordLabel)){
......@@ -48,7 +48,7 @@
return $row;
}
function sanitizeData($newRow,$meta,$t=null){
static function sanitizeData($newRow,$meta,$t=null){
$newRow = DataTransform::sanitizeReferences($newRow,$meta);
$newRow = DataTransform::sanitizeOwnerFields($newRow,$meta,$t);
......@@ -57,7 +57,7 @@
return $newRow;
}
function sanitizeForInsert($row,$meta){
static function sanitizeForInsert($row,$meta){
global $adb;
$associatedToUser = false;
$parentTypeId = null;
......@@ -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"]) && $row["id"]){
unset($row["id"]);
}
if(isset($row[$meta->getObectIndexColumn()])){
......@@ -139,6 +139,7 @@
$row = DataTransform::sanitizeDateFieldsForInsert($row,$meta);
$row = DataTransform::sanitizeCurrencyFieldsForInsert($row,$meta);
$row = DataTransform::sanitizeStringFields($row,$meta);
// New field added to store Source of Created Record
if (!isset($row['source'])) {
......@@ -149,14 +150,14 @@
}
function filterAllColumns($row,$meta){
static function filterAllColumns($row,$meta){
$recordString = DataTransform::$recordString;
$allFields = $meta->getFieldColumnMapping();
$newRow = array();
foreach($allFields as $field=>$col){
$newRow[$field] = $row[$field];
$newRow[$field] = isset($row[$field]) ? $row[$field] : null;
}
if(isset($row[$recordString])){
$newRow[$recordString] = $row[$recordString];
......@@ -165,7 +166,7 @@
}
function sanitizeFields($row,$meta){
static function sanitizeFields($row,$meta){
$default_charset = VTWS_PreserveGlobal::getGlobal('default_charset');
$recordString = DataTransform::$recordString;
......@@ -187,7 +188,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.
......@@ -198,21 +199,24 @@
}
foreach ($row as $field => $value) {
$row[$field] = html_entity_decode($value, ENT_QUOTES, $default_charset);
$row[$field] = $value ? html_entity_decode($value, ENT_QUOTES, $default_charset) : $value;
}
return $row;
}
function sanitizeReferences($row,$meta){
static function sanitizeReferences($row,$meta){
global $adb,$log;
$references = $meta->getReferenceFieldDetails();
foreach($references as $field=>$typeList){
if($meta->getEntityName() == 'Users' && $field == 'roleid'){
continue;
}
if(strtolower($meta->getEntityName()) == "emails"){
if(isset($row['parent_id'])){
if (isset($row['parent_id']) && $row['parent_id'] !== null && strpos($row['parent_id'], '@') !== false) {
list($row['parent_id'], $fieldId) = explode('@', $row['parent_id']);
}
}
if($row[$field]){
if(isset($row[$field]) && $row[$field]){
$found = false;
foreach ($typeList as $entity) {
$webserviceObject = VtigerWebserviceObject::fromName($adb,$entity);
......@@ -242,7 +246,7 @@
return $row;
}
function sanitizeOwnerFields($row,$meta,$t=null){
static function sanitizeOwnerFields($row,$meta,$t=null){
global $adb;
$ownerFields = $meta->getOwnerFields();
foreach($ownerFields as $index=>$field){
......@@ -270,7 +274,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){
......@@ -288,7 +292,7 @@
return $row;
}
function sanitizeDateFieldsForInsert($row,$meta){
static function sanitizeDateFieldsForInsert($row,$meta){
global $current_user;
$moduleFields = $meta->getModuleFields();
foreach($moduleFields as $fieldName=>$fieldObj){
......@@ -302,7 +306,7 @@
return $row;
}
function sanitizeCurrencyFieldsForInsert($row,$meta){
static function sanitizeCurrencyFieldsForInsert($row,$meta){
global $current_user;
$moduleFields = $meta->getModuleFields();
foreach($moduleFields as $fieldName=>$fieldObj){
......@@ -312,7 +316,7 @@
$row[$fieldName."_raw"] = $row[$fieldName];
$row[$fieldName] = CurrencyField::convertToUserFormat($row[$fieldName],$current_user);
} else if($fieldObj->getUIType() == '72') {
$currencyConversionRate = $row['conversion_rate'];
$currencyConversionRate = isset($row['conversion_rate']) ? $row['conversion_rate'] : 0;
if (!empty($currencyConversionRate)) {
$rawBaseCurrencyValue = CurrencyField::convertToDollar($row[$fieldName], $currencyConversionRate);
$row[$fieldName."_raw"] = $rawBaseCurrencyValue;
......@@ -329,5 +333,16 @@
}
return $row;
}
static function sanitizeStringFields($row,$meta){
if(in_array($meta->getEntityName(),array('Groups', 'Currency', 'Tax', 'ProductTaxes'))){
foreach ($row as $field => $value) {
if(is_string($value)){
$row[$field] = vtlib_purify($value);
}
}
}
return $row;
}
}
?>
......@@ -8,6 +8,7 @@
* All Rights Reserved.
*************************************************************************************/
#[\AllowDynamicProperties]
abstract class EntityMeta{
public static $RETRIEVE = "DetailView";
......@@ -276,4 +277,4 @@ abstract class EntityMeta{
abstract public function getName($webserviceId);
abstract public function isModuleEntity();
}
?>
\ No newline at end of file
?>
......@@ -82,7 +82,7 @@ require_once 'include/Webservices/DescribeObject.php';
$accessableModules = array_diff($accessableModules,$ignoreModules);
if(count($accessableModules)<=0)
if(php7_count($accessableModules)<=0)
{
$output['lastModifiedTime'] = $mtime;
$output['more'] = false;
......
......@@ -51,7 +51,7 @@ class VtigerInventoryMeta extends VtigerCRMObjectMeta {
$field['displaytype'] = 1;
$field['uitype'] = 1;
$fieldDataType = 'V';
$typeOfData = $fieldType.'~O';
$typeOfData = $fieldDataType.'~O';
$field['typeofdata'] = $typeOfData;
$field['tabid'] = null;
......@@ -61,4 +61,4 @@ class VtigerInventoryMeta extends VtigerCRMObjectMeta {
}
}
?>
\ No newline at end of file
?>
......@@ -19,6 +19,10 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
public function create($elementType, $element) {
self::$CREATE_OPERATI0N = true;
if (!$element['hdnTaxType']) {
$element['hdnTaxType'] = Inventory_TaxRecord_Model::getSelectedDefaultTaxMode();
}
$element = $this->sanitizeInventoryForInsert($element);
$element = $this->sanitizeShippingTaxes($element);
$lineItems = $element['LineItems'];
......@@ -164,14 +168,20 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
vglobal('updateInventoryProductRel_deduct_stock', $currentValue);
} else {
$prevAction = $_REQUEST['action'];
$prevAjaxAction = $_REQUEST['ajxaction'];
// This is added as we are passing data in user format, so in the crmentity insertIntoEntity API
// should convert to database format, we have added a check based on the action name there. But
// while saving Invoice and Purchase Order we are also depending on the same action file names to
// not to update stock if its an ajax save. In this case also we do not want line items to change.
$_REQUEST['action'] = 'FROM_WS';
//To avoid deletion of lineitems we use the ajaxaction DETAILVIEW as if we were updating signle fields from the detail view:
$_REQUEST['ajxaction'] = 'DETAILVIEW';
$parent = parent::revise($element);
$_REQUEST['action'] = $prevAction;
$_REQUEST['ajxaction'] = $prevAjaxAction;
$parent['LineItems'] = $handler->getAllLineItemForParent($parentId);
}
return array_merge($element,$parent);
......@@ -194,7 +204,7 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
$element['LineItems'] = $lineItems;
$recordCompoundTaxesElement = $this->getCompoundTaxesElement($element, $lineItems);
$element = array_merge($element, $recordCompoundTaxesElement);
$element['productid'] = $lineItems[0]['productid'];
$element['productid'] = isset($lineItems[0]['productid']) ? $lineItems[0]['productid'] : "";
$element['LineItems_FinalDetails'] = $this->getLineItemFinalDetails($idComponents[1]);
return $element;
}
......@@ -224,10 +234,6 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
*/
protected function sanitizeInventoryForInsert($element) {
if (!$element['hdnTaxType']) {
$element['hdnTaxType'] = Inventory_TaxRecord_Model::getSelectedDefaultTaxMode();
}
if (!empty($element['hdnTaxType'])) {
$_REQUEST['taxtype'] = $element['hdnTaxType'];
}
......@@ -266,7 +272,7 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
}
$lineItems = $element['LineItems'];
$totalNoOfProducts = count($lineItems);
$totalNoOfProducts = php7_count($lineItems);
$_REQUEST['totalProductCount'] = $totalNoOfProducts;
$_REQUEST['REQUEST_FROM_WS'] = true;
......@@ -474,7 +480,7 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
$result = $this->pearDB->pquery('SELECT * FROM vtiger_inventorychargesrel WHERE recordid = ?', array($id));
$rowData = $this->pearDB->fetch_array($result);
if ($rowData['charges']) {
if (isset($rowData['charges']) && $rowData['charges']) {
$allCharges = getAllCharges();
$shippingTaxes = array();
$allShippingTaxes = getAllTaxes('all', 'sh');
......
......@@ -92,7 +92,7 @@ class VtigerLineItemMeta extends VtigerCRMActorMeta {
if(in_array($fieldName,$mandatoryFieldList)){
$typeOfData = $fieldType.'~M';
}else if(($dbField->not_null == 1 && $fieldName != 'incrementondel'
&& $dbField->primary_key != 1) || $dbField->unique_key == 1){
&& $dbField->primary_key != 1) || (property_exists($dbField, 'unique_key') && $dbField->unique_key == 1)) {
$typeOfData = $fieldType.'~M';
}else{
$typeOfData = $fieldType.'~O';
......@@ -105,4 +105,4 @@ class VtigerLineItemMeta extends VtigerCRMActorMeta {
}
}
?>
\ No newline at end of file
?>
......@@ -156,7 +156,7 @@ class VtigerLineItemOperation extends VtigerActorOperation {
list($typeId,$recordId) = vtws_getIdComponents($element['productid']);
$productTaxInfo = $this->getProductTaxList($recordId);
}
if(count($productTaxInfo) == 0 && strcasecmp($parent['hdnTaxType'], $this->Individual) !==0) {
if(php7_count($productTaxInfo) == 0 && strcasecmp($parent['hdnTaxType'], $this->Individual) !==0) {
$meta = $this->getMeta();
$moduleFields = $meta->getModuleFields();
foreach ($moduleFields as $fieldName=>$field) {
......@@ -169,9 +169,9 @@ class VtigerLineItemOperation extends VtigerActorOperation {
}
private function updateTaxes($createdElement){
if (count($this->taxList) > 0 || (is_array($this->inActiveTaxList) && count($this->inActiveTaxList) > 0)) {
if (php7_count($this->taxList) > 0 || (is_array($this->inActiveTaxList) && php7_count($this->inActiveTaxList) > 0)) {
$taxList = $this->taxList;
if (is_array($this->inActiveTaxList) && count($this->inActiveTaxList) > 0) {
if (is_array($this->inActiveTaxList) && php7_count($this->inActiveTaxList) > 0) {
$taxList = array_merge($taxList, $this->inActiveTaxList);
}
$id = vtws_getIdComponents($createdElement['id']);
......@@ -206,7 +206,7 @@ class VtigerLineItemOperation extends VtigerActorOperation {
$meta = $this->getMeta();
$moduleFields = $meta->getModuleFields();
$productTaxList = $this->getProductTaxList($productId);
if (count($productTaxList) > 0) {
if (php7_count($productTaxList) > 0) {
$this->providedTaxList = array();
foreach ($moduleFields as $fieldName => $field) {
if (preg_match('/tax\d+/', $fieldName) != 0) {
......@@ -383,7 +383,7 @@ class VtigerLineItemOperation extends VtigerActorOperation {
$this->newId = $id[1];
$updatedLineItemList[] = $this->_create($elementType, $lineItem);
if($element == $lineItem){
$createdElement = $updatedLineItemList[count($updatedLineItemList) - 1];
$createdElement = $updatedLineItemList[php7_count($updatedLineItemList) - 1];
}
}
$this->setCache($parentId, $updatedLineItemList);
......
......@@ -9,7 +9,7 @@
*************************************************************************************/
function setBuiltIn($json){
$json->useBuiltinEncoderDecoder = true;
Zend_Json::$useBuiltinEncoderDecoder = true;
}
class OperationManager{
......@@ -132,10 +132,10 @@
}
function handleType($type,$value){
$result;
$value = stripslashes($value);
$result = null;
$value = $value ? stripslashes($value) : "";
$type = strtolower($type);
if($this->inParamProcess[$type]){
if(isset($this->inParamProcess[$type]) && $this->inParamProcess[$type]){
$result = call_user_func($this->inParamProcess[$type],$value);
}else{
$result = $value;
......@@ -148,9 +148,18 @@
try{
$operation = strtolower($this->operationName);
if(!$this->preLogin){
$params[] = $user;
$params["user"] = $user;
return call_user_func_array($this->handlerMethod,$params);
}else{
/* PHP 8.x fix to match target handler arguments (named parameter) */
if ($this->handlerMethod == "vtws_login") {
if (isset($params["accessKey"])) {
$params["pwd"] = $params["accessKey"];
unset($params["accessKey"]);
}
}
$userDetails = call_user_func_array($this->handlerMethod,$params);
if(is_array($userDetails)){
return $userDetails;
......@@ -201,4 +210,4 @@
}
?>
\ No newline at end of file
?>
......@@ -18,7 +18,8 @@ class VTWS_PreserveGlobal{
//To not push null value . Ideally we should not push null value for any name
//But current user null is dangerous so we are checking for only current user
if(!empty(${$name}) || $name != 'current_user') {
if(!is_array(VTWS_PreserveGlobal::$globalData[$name])){
if(!isset(VTWS_PreserveGlobal::$globalData[$name]) ||
!is_array(VTWS_PreserveGlobal::$globalData[$name])){
VTWS_PreserveGlobal::$globalData[$name] = array();
}
......@@ -33,7 +34,7 @@ class VTWS_PreserveGlobal{
//$name store the name of the global.
global ${$name};
if(is_array(VTWS_PreserveGlobal::$globalData[$name]) && count(VTWS_PreserveGlobal::$globalData[$name]) > 0){
if(is_array(VTWS_PreserveGlobal::$globalData[$name]) && php7_count(VTWS_PreserveGlobal::$globalData[$name]) > 0){
${$name} = array_pop(VTWS_PreserveGlobal::$globalData[$name]);
}
${$name};
......@@ -48,7 +49,7 @@ class VTWS_PreserveGlobal{
foreach (VTWS_PreserveGlobal::$globalData as $name => $detail) {
//$name store the name of the global.
global ${$name};
if(is_array(VTWS_PreserveGlobal::$globalData[$name]) && count(VTWS_PreserveGlobal::$globalData[$name]) > 0) {
if(is_array(VTWS_PreserveGlobal::$globalData[$name]) && php7_count(VTWS_PreserveGlobal::$globalData[$name]) > 0) {
${$name} = array_pop(VTWS_PreserveGlobal::$globalData[$name]);
}
}
......
......@@ -10,7 +10,7 @@
require_once("include/Webservices/QueryParser.php");
function vtws_query($q,$user){
function vtws_query($query,$user){
static $vtws_query_cache = array();
......@@ -19,10 +19,10 @@
// Cache the instance for re-use
$moduleRegex = "/[fF][rR][Oo][Mm]\s+([^\s;]+)/";
$moduleName = '';
if(preg_match($moduleRegex, $q, $m)) $moduleName = trim($m[1]);
if(preg_match($moduleRegex, $query, $m)) $moduleName = trim($m[1]);
if(!isset($vtws_create_cache[$moduleName]['webserviceobject'])) {
$webserviceObject = VtigerWebserviceObject::fromQuery($adb,$q);
$webserviceObject = VtigerWebserviceObject::fromQuery($adb,$query);
$vtws_query_cache[$moduleName]['webserviceobject'] = $webserviceObject;
} else {
$webserviceObject = $vtws_query_cache[$moduleName]['webserviceobject'];
......@@ -61,9 +61,9 @@
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED,"Permission to read is denied");
}
$result = $handler->query($q);
$result = $handler->query($query);
VTWS_PreserveGlobal::flush();
return $result;
}
?>
\ No newline at end of file
?>
......@@ -78,7 +78,7 @@
$meta->isUpdateMandatoryFields($element);
$ownerFields = $meta->getOwnerFields();
if(is_array($ownerFields) && sizeof($ownerFields) >0){
if(is_array($ownerFields) && php7_sizeof($ownerFields) >0){
foreach($ownerFields as $ownerField){
if(isset($element[$ownerField]) && $element[$ownerField]!==null &&
!$meta->hasAssignPrivilege($element[$ownerField])){
......
......@@ -71,7 +71,7 @@
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED,
"Permission to access reference type is denied ".$referenceObject->getEntityName());
}
}else if($element[$fieldName] !== NULL){
}else if(array_key_exists($fieldName, $element) && $element[$fieldName] !== NULL){
unset($element[$fieldName]);
}
}
......@@ -79,7 +79,7 @@
$meta->hasMandatoryFields($element);
$ownerFields = $meta->getOwnerFields();
if(is_array($ownerFields) && sizeof($ownerFields) >0){
if(is_array($ownerFields) && php7_sizeof($ownerFields) >0){
foreach($ownerFields as $ownerField){
if(isset($element[$ownerField]) && $element[$ownerField]!==null &&
!$meta->hasAssignPrivilege($element[$ownerField])){
......@@ -93,4 +93,4 @@
return $entity;
}
?>
\ No newline at end of file
?>