diff --git a/modules/Migration/schema/660_to_700.php b/modules/Migration/schema/660_to_700.php index ac9ef266663cdfca3170bd0423948a60d179412f..ddb4cf246852d8d1b49ef6c6a8f6327e78ccc6e0 100644 --- a/modules/Migration/schema/660_to_700.php +++ b/modules/Migration/schema/660_to_700.php @@ -2102,6 +2102,37 @@ if(defined('VTIGER_UPGRADE')) { $db->pquery('DELETE FROM vtiger_settings_field WHERE name IN ('.generateQuestionMarks($duplicateOtherBlockFields).') AND blockid=?', array($duplicateOtherBlockFields, $otherBlockId)); //Migration of data to vtiger_settings blocks and fields ends + $result = $db->pquery('SELECT cvid, entitytype FROM vtiger_customview WHERE viewname=?', array('All')); + if ($result && $db->num_rows($result) > 0) { + while ($row = $db->fetch_array($result)) { + $cvId = $row['cvid']; + $cvModel = CustomView_Record_Model::getInstanceById($cvId); + $cvSelectedFields = $cvModel->getSelectedFields(); + + $moduleModel = Vtiger_Module_Model::getInstance($row['entitytype']); + if ($moduleModel) { + $fields = $moduleModel->getFields(); + $cvSelectedFieldModels = array(); + + foreach ($fields as $fieldModel) { + $cvSelectedFieldModels[] = decode_html($fieldModel->getCustomViewColumnName()); + } + + foreach ($cvSelectedFields as $cvSelectedField) { + if (!in_array($cvSelectedField, $cvSelectedFieldModels)) { + $fieldData = explode(':', $cvSelectedField); + $fieldName = $fieldData[2]; + $fieldInstance = Vtiger_Field_Model::getInstance($fieldName, $moduleModel); + if ($fieldInstance) { + $columnname = decode_html($fieldInstance->getCustomViewColumnName()); + $db->pquery('UPDATE vtiger_cvcolumnlist SET columnname=? WHERE cvid=? AND columnname=?', array($columnname, $cvId, $cvSelectedField)); + } + } + } + } + } + } + //Update existing package modules Install_Utils_Model::installModules();