Index: in-link/install/upgrades.php =================================================================== --- in-link/install/upgrades.php (revision 13608) +++ in-link/install/upgrades.php (working copy) @@ -137,5 +137,43 @@ } } } + /** + * Update to 5.0.4-B1 + * + * @param string $mode when called mode {before, after) + */ + function Upgrade_5_0_4_B1($mode) + { + if ($mode == 'after') { + // check in-link custom fields if need to add to search config + $custom_fields = Array ( + 'LinkAddress' => "('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 = '" . $field_name . "' AND (LOWER(ModuleName) = 'in-link') "; + + if (!$this->Conn->GetOne($sql)) { + // 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 Index: in-link/install/install_data.sql =================================================================== --- in-link/install/install_data.sql (revision 13608) +++ in-link/install/install_data.sql (working copy) @@ -201,6 +201,12 @@ INSERT INTO SearchConfig VALUES ('Link', 'Modified', 0, 1, 'lu_fielddesc_link_modified', 'lu_field_modified', 'In-Link', 'la_text_link', 5, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL); INSERT INTO SearchConfig VALUES ('Link', 'Hits', 0, 1, 'lu_fielddesc_link_hits', 'lu_field_hits', 'In-Link', 'la_text_link', 6, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL); INSERT INTO SearchConfig VALUES ('Link', 'CachedRating', 0, 0, 'lu_fielddesc_link_cachedrating', 'lu_field_cachedrating', 'In-Link', 'la_text_link', 7, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO SearchConfig VALUES ('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, NULL); +INSERT INTO SearchConfig VALUES ('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, NULL); +INSERT INTO SearchConfig VALUES ('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, NULL); +INSERT INTO SearchConfig VALUES ('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, NULL); +INSERT INTO SearchConfig VALUES ('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, NULL); +INSERT INTO SearchConfig VALUES ('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, NULL); INSERT INTO StatItem VALUES (DEFAULT, 'In-Link', 'SELECT COUNT(*) as LinkCount FROM <%prefix%>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);