Index: branches/5.1.x/units/links/links_config.php =================================================================== diff -u -N -r13633 -r13746 --- branches/5.1.x/units/links/links_config.php (.../links_config.php) (revision 13633) +++ branches/5.1.x/units/links/links_config.php (.../links_config.php) (revision 13746) @@ -1,6 +1,6 @@ Link WHERE Status=1', NULL, 'la_prompt_ActiveLinks', 0, 1); INSERT INTO StatItem VALUES (DEFAULT, 'In-Link', 'SELECT COUNT(*) AS TotalLinks FROM <%prefix%>Link', NULL, 'la_prompt_TotalLinks', 0, 2); Index: branches/5.1.x/install/upgrades.php =================================================================== diff -u -N -r13095 -r13746 --- branches/5.1.x/install/upgrades.php (.../upgrades.php) (revision 13095) +++ branches/5.1.x/install/upgrades.php (.../upgrades.php) (revision 13746) @@ -1,6 +1,6 @@ "('CustomField', 'LinkAddress', 1, 1, 'la_fld_LinkAddress', 'lu_fld_LinkAddress', 'In-Link', 'la_section_BusinessLocation', 1, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, {CUSTOM_FIELD_ID})", + 'LinkCity' => "('CustomField', 'LinkCity', 1, 1, 'la_fld_LinkCity', 'lu_fld_LinkCity', 'In-Link', 'la_section_BusinessLocation', 2, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, {CUSTOM_FIELD_ID})", + 'LinkState' => "('CustomField', 'LinkState', 1, 1, 'la_fld_LinkState', 'lu_fld_LinkState', 'In-Link', 'la_section_BusinessLocation', 3, DEFAULT, 0, 'select', NULL, NULL, NULL, NULL, NULL, NULL, {CUSTOM_FIELD_ID})", + 'LinkZipCode' => "('CustomField', 'LinkZipCode', 1, 1, 'la_fld_LinkZipCode', 'lu_fld_LinkZipCode', 'In-Link', 'la_section_BusinessLocation', 4, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, {CUSTOM_FIELD_ID})", + 'LinkCountry' => "('CustomField', 'LinkCountry', 1, 1, 'la_fld_LinkCountry', 'lu_fld_LinkCountry', 'In-Link', 'la_section_BusinessLocation', 5, DEFAULT, 0, 'select', NULL, NULL, NULL, NULL, NULL, NULL, {CUSTOM_FIELD_ID})", + 'LinkPhone' => "('CustomField', 'LinkPhone', 1, 1, 'la_fld_LinkPhone', 'lu_fld_LinkPhone', 'In-Link', 'la_section_BusinessLocation', 6, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, {CUSTOM_FIELD_ID})", + ); + + // get all in-link custom fields ides at once + $sql = 'SELECT CustomFieldId, FieldName + FROM ' . TABLE_PREFIX . 'CustomField + WHERE Type = 4 AND IsSystem = 0'; + $custom_field_ids = $this->Conn->GetCol($sql, 'FieldName'); + + foreach ($custom_fields as $field_name => $custom_field_sql) { + $sql = 'SELECT FieldName + FROM ' . TABLE_PREFIX . 'SearchConfig + WHERE (FieldName = ' . $this->Conn->qstr($field_name) . ') AND (LOWER(ModuleName) = "in-link")'; + $found = $this->Conn->GetOne($sql); + + if (!$found) { + // replace sql and insert new search config record + $sql = str_replace('{CUSTOM_FIELD_ID}', $custom_field_ids[$field_name], $custom_field_sql); + $sql = 'INSERT INTO ' . TABLE_PREFIX . 'SearchConfig VALUES ' . $sql; + $this->Conn->Query($sql); + } + } + } + } } \ No newline at end of file