function fn_google_export_add_feature($new_features, $parent_feature_id, $show_process = false, $lang = DEFAULT_LANGUAGE) { static $company_id = 0; if (!$company_id) { $company_id = fn_get_default_company_id(); } foreach ($new_features as $feature_name => $feature_data) { foreach ($feature_data as $feature_type => $feature_variants) { if (fn_allowed_for('ULTIMATE')) { $f_id = db_query("INSERT INTO ?:product_features" . " (feature_type, categories_path, parent_id, display_on_product, display_on_catalog, status, position, comparison, company_id)" . " VALUES" . " (?s, '', ?i, 0, 0, 'A', 0, 'N', ?i)", $feature_type, $parent_feature_id, $company_id); fn_share_object_to_all('product_features', $f_id); } else { $f_id = db_query("INSERT INTO ?:product_features" . " (feature_type, categories_path, parent_id, display_on_product, display_on_catalog, status, position, comparison)" . " VALUES" . " (?s, '', ?i, 0, 0, 'A', 0, 'N')", $feature_type, $parent_feature_id); } db_query("INSERT INTO ?:product_features_descriptions" . " (feature_id, description, full_description, prefix, suffix, lang_code)" . " VALUES" . " (?i, ?s, '', '', '', ?s)", $f_id, $feature_name, $lang); if ($show_process) { fn_echo(' .'); } fn_google_export_add_feature_variants($f_id, $feature_variants, $show_process); } } }
function fn_ult_db_query_executed(&$query, &$result) { static $schema; if (Registry::get('runtime.skip_sharing_selection')) { return true; } if (empty($schema) && Registry::get('addons_initiated') === true) { $schema = fn_get_schema('sharing', 'schema'); } if (preg_match('/(?:INSERT|REPLACE)\\s?INTO\\s?([a-zA-Z_0-9]+)/i', $query, $tables)) { $object = str_replace(Registry::get('config.table_prefix'), '', $tables[1]); if (isset($schema[$object])) { $object_id = db_get_field('SELECT LAST_INSERT_ID()'); if (empty($object_id)) { preg_match('/VALUES\\s?\\((.*?)\\)/i', $query, $values); $values = explode(',', $values[1]); if (preg_match('/\\((.*?)\\)\\sVALUES/i', $query, $fields)) { $fields = explode(',', $fields[1]); } else { $fields = fn_get_table_fields($object, array(), false); } $data = array(); foreach ($fields as $key => $field) { $data[str_replace('`', '', trim($field))] = trim(str_replace('\'', '', $values[$key])); } $object_id = $data[$schema[$object]['table']['key_field']]; } if (Registry::get('sharing_owner.' . $object)) { db_query('REPLACE INTO ?:ult_objects_sharing (`share_company_id`, `share_object_id`, `share_object_type`) VALUES (?i, ?s, ?s)', Registry::get('sharing_owner.' . $object), $object_id, $object); } if (!empty($object_id) && $schema[$object]['have_owner'] === false) { fn_share_object_to_all($object, $object_id); } } } elseif (preg_match('/(?:DELETE)\\s?FROM\\s?([a-zA-Z_]+)/i', $query, $tables)) { $object = str_replace(Registry::get('config.table_prefix'), '', $tables[1]); if (isset($schema[$object])) { preg_match('/' . $schema[$object]['table']['key_field'] . '\\s?=\\s?\'?\\"?([0-9a-zA-Z]+)/i', $query, $_object); if (!empty($_object[1])) { $object_id = $_object[1]; db_query('DELETE FROM ?:ult_objects_sharing WHERE share_object_id = ?s AND share_object_type = ?s', $object_id, $object); } } } }