Esempio n. 1
1
function fn_get_seo_rules($params = array(), $items_per_page = 0, $lang_code = DESCR_SL)
{
    $lang_code = fn_get_corrected_seo_lang_code($lang_code);
    $global_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' GROUP BY dispatch");
    $local_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s", $lang_code);
    if ($diff = array_diff($global_total, $local_total)) {
        foreach ($diff as $disp) {
            fn_create_seo_name(0, 's', str_replace('.', '-', $disp), 0, $disp, DESCR_SL);
        }
    }
    // Init filter
    $params = fn_init_view('seo_rules', $params);
    // Set default values to input params
    $params['page'] = empty($params['page']) ? 1 : $params['page'];
    // default page is 1
    $condition = '';
    if (isset($params['name']) && fn_string_no_empty($params['name'])) {
        $condition .= db_quote(" AND name LIKE ?l", "%" . trim($params['name']) . "%");
    }
    if (isset($params['controller']) && fn_string_no_empty($params['controller'])) {
        $condition .= db_quote(" AND dispatch LIKE ?l", "%" . trim($params['controller']) . "%");
    }
    $limit = '';
    if (!empty($items_per_page)) {
        $total = db_get_field("SELECT COUNT(*) FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p", $lang_code, $condition);
        $limit = fn_paginate($params['page'], $total, $items_per_page);
    }
    $seo_data = db_get_array("SELECT name, dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p ORDER BY dispatch {$limit}", $lang_code, $condition);
    return array($seo_data, $params);
}
function fn_get_seo_redirects($params = array(), $items_per_page = 0, $lang_code = DESCR_SL)
{
    // Init filter
    $params = LastView::instance()->update('seo_redirects', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $condition = '';
    if (isset($params['src']) && fn_string_not_empty($params['src'])) {
        $condition .= db_quote(" AND src LIKE ?l", "%" . trim($params['src']) . "%");
    }
    if (!empty($params['type'])) {
        $condition .= db_quote(" AND type = ?s", $params['type']);
    }
    if (!empty($params['lang_code'])) {
        $condition .= db_quote(" AND lang_code = ?s", $params['lang_code']);
    }
    $condition .= fn_get_seo_company_condition('?:seo_redirects.company_id');
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:seo_redirects WHERE 1 ?p", $condition);
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $seo_redirects = db_get_hash_array("SELECT * FROM ?:seo_redirects WHERE 1 ?p ORDER BY src {$limit}", 'redirect_id', $condition);
    if (!empty($seo_redirects)) {
        foreach ($seo_redirects as $key => $seo_redirect) {
            $seo_redirects[$key]['parsed_url'] = fn_generate_seo_url_from_schema($seo_redirect);
        }
    }
    return array($seo_redirects, $params);
}
Esempio n. 3
0
function fn_update_product_filter($filter_data, $filter_id, $lang_code = DESCR_SL)
{
    if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) {
        if (!empty($filter_id) && !fn_check_company_id('product_filters', 'filter_id', $filter_id)) {
            fn_company_access_denied_notification();
            return false;
        }
        if (!empty($filter_id)) {
            unset($filter_data['company_id']);
        }
    }
    // Parse filter type
    if (strpos($filter_data['filter_type'], 'FF-') === 0 || strpos($filter_data['filter_type'], 'RF-') === 0 || strpos($filter_data['filter_type'], 'DF-') === 0) {
        $filter_data['feature_id'] = str_replace(array('RF-', 'FF-', 'DF-'), '', $filter_data['filter_type']);
        $filter_data['feature_type'] = db_get_field("SELECT feature_type FROM ?:product_features WHERE feature_id = ?i", $filter_data['feature_id']);
    } else {
        $filter_data['field_type'] = str_replace(array('R-', 'B-'), '', $filter_data['filter_type']);
        $filter_fields = fn_get_product_filter_fields();
    }
    if (!empty($filter_id)) {
        db_query('UPDATE ?:product_filters SET ?u WHERE filter_id = ?i', $filter_data, $filter_id);
        db_query('UPDATE ?:product_filter_descriptions SET ?u WHERE filter_id = ?i AND lang_code = ?s', $filter_data, $filter_id, $lang_code);
    } else {
        $filter_data['filter_id'] = $filter_id = db_query('INSERT INTO ?:product_filters ?e', $filter_data);
        foreach (fn_get_translation_languages() as $filter_data['lang_code'] => $_d) {
            db_query("INSERT INTO ?:product_filter_descriptions ?e", $filter_data);
        }
    }
    fn_set_hook('update_product_filter', $filter_data, $filter_id, $lang_code);
    return $filter_id;
}
Esempio n. 4
0
function fn_get_banner_name($banner_id, $lang_code = CART_LANGUAGE)
{
    if (!empty($banner_id)) {
        return db_get_field("SELECT banner FROM ?:banner_descriptions WHERE banner_id = ?i AND lang_code = ?s", $banner_id, $lang_code);
    }
    return false;
}
Esempio n. 5
0
 public function processWebHook($data)
 {
     $data = $this->service->processWebHook($data);
     if (empty($data['action'])) {
         return false;
     }
     if ($data['action'] == 'subscribe') {
         fn_em_update_subscriber($data, 0, false);
     } elseif ($data['action'] == 'unsubscribe') {
         $subscriber_id = db_get_field("SELECT subscriber_id FROM ?:em_subscribers WHERE email = ?s", $data['email']);
         if (!empty($subscriber_id)) {
             fn_em_delete_subscribers(array($subscriber_id), false);
         }
     } elseif ($data['action'] == 'update') {
         $subscriber_id = db_get_field("SELECT subscriber_id FROM ?:em_subscribers WHERE email = ?s", $data['old_email']);
         if (!empty($subscriber_id)) {
             fn_em_update_subscriber($data, $subscriber_id, false);
         }
     } elseif ($data['action'] == 'email_update') {
         $subscriber_id = db_get_field("SELECT subscriber_id FROM ?:em_subscribers WHERE email = ?s", $data['old_email']);
         if (!empty($subscriber_id)) {
             fn_em_update_subscriber(array('email' => $data['new_email']), $subscriber_id, false);
         }
     }
 }
Esempio n. 6
0
/**
 * Gets mobile product url
 *
 * @param $product_id
 * @param string $lang_code
 * @return bool
 */
function fn_twg_exim_get_product_mobile_url($product_id, $lang_code = '')
{
    $company_id = 0;
    $company_url = '';
    if (fn_allowed_for('ULTIMATE')) {
        if (Registry::get('runtime.company_id')) {
            $company_id = Registry::get('runtime.company_id');
        } else {
            $company_id = db_get_field('SELECT company_id FROM ?:products WHERE product_id = ?i', $product_id);
        }
        $company_url = '&company_id=' . $company_id;
    } else {
        $company_url = '';
    }
    $settings = TwigmoSettings::get('customer_connections.' . $company_id);
    $use_twg = !empty($settings['access_id']) && ($settings['use_for_phones'] == 'Y' || $settings['use_for_tablets'] == 'Y');
    if ($use_twg && fn_twg_use_https_for_customer($company_id)) {
        $protocol = 'https';
    } else {
        $protocol = 'http';
    }
    $url = fn_url('products.view?product_id=' . $product_id . $company_url, 'C', $protocol, $lang_code);
    fn_set_hook('exim_get_product_url', $url, $product_id, $options, $lang_code);
    return $url;
}
Esempio n. 7
0
 public function import($db_already_cloned)
 {
     General::setProgressTitle(__CLASS__);
     if (!$db_already_cloned) {
         if (!General::cloneImportedDB($this->store_data)) {
             return false;
         }
     } else {
         General::setEmptyProgressBar(__('importing_data'));
         General::setEmptyProgressBar(__('importing_data'));
     }
     General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
     $main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
     if (is_file($main_sql)) {
         //Process main sql
         if (!db_import_sql_file($main_sql)) {
             return false;
         }
     }
     General::processAddons($this->store_data, __CLASS__);
     General::setEmptyProgressBar(General::getUnavailableLangVar('updating_languages'));
     General::updateAltLanguages('language_values', 'name');
     General::updateAltLanguages('settings_descriptions', array('object_id', 'object_type'));
     General::updateAltLanguages('shipping_service_descriptions', 'service_id');
     General::updateAltLanguages('privilege_descriptions', 'privilege');
     General::updateAltLanguages('privilege_section_descriptions', 'section_id');
     General::updateAltLanguages('state_descriptions', 'state_id');
     General::updateAltLanguages('country_descriptions', 'code');
     General::processBlocks();
     General::setEmptyProgressBar();
     if (db_get_field("SHOW TABLES LIKE '?:mailing_lists'")) {
         db_query("ALTER TABLE ?:mailing_lists DROP `show_on_sidebar`");
     }
     return true;
 }
Esempio n. 8
0
 public function import($db_already_cloned)
 {
     General::setProgressTitle(__CLASS__);
     if (!$db_already_cloned) {
         if (!General::cloneImportedDB($this->store_data)) {
             return false;
         }
     } else {
         General::setEmptyProgressBar(__('importing_data'));
         General::setEmptyProgressBar(__('importing_data'));
     }
     $main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
     General::backupSettings();
     if (is_file($main_sql)) {
         //Process main sql
         if (!db_import_sql_file($main_sql)) {
             return false;
         }
     }
     $payflow_enabled = db_get_field("SELECT processor_params FROM ?:payments WHERE processor_id = (SELECT processor_id FROM ?:payment_processors WHERE processor_script = 'payflow_pro.php')");
     if (!empty($payflow_enabled)) {
         $payflow_params = unserialize($payflow_enabled);
         unset($payflow_params['country']);
         $payflow_params['currency'] = 840;
         db_query("UPDATE ?:payments SET processor_params = ?s WHERE processor_id = (SELECT processor_id FROM ?:payment_processors WHERE processor_script = 'payflow_pro.php')", serialize($payflow_params));
     }
     General::setEmptyProgressBar();
     General::setEmptyProgressBar();
     General::setEmptyProgressBar();
     General::setEmptyProgressBar();
     return true;
 }
Esempio n. 9
0
function fn_get_single_map_data($order_info, $auth = null)
{
    $data = array();
    $data["order_date"] = date('d-m-Y', $order_info['timestamp']);
    $data["email"] = $order_info['email'];
    $data["customer_name"] = $order_info['firstname'] . ' ' . $order_info['lastname'];
    $data["order_id"] = $order_info['order_id'];
    $products = $order_info['products'];
    $products_arr = array();
    $currencies = Registry::get('currencies');
    $currency = isset($order_info['secondary_currency']) ? $currencies[$order_info['secondary_currency']] : $currencies[CART_SECONDARY_CURRENCY];
    #modified by Hungryweb 12.10.2015
    //$data["currency_iso"] = $currency['currency_code'];
    $data["currency_iso"] = 'USD';
    foreach ($products as $product) {
        $product_id = is_array($product) ? $product['product_id'] : intval($product);
        $product_data = array();
        $product_data['url'] = fn_get_product_url($product_id);
        #modified by Hungryweb 12.10.2015
        //$product_data['name'] = fn_get_product_name($product_id,CART_LANGUAGE,false);
        $product_data['name'] = fn_specific_development_get_category($product['product_id']) . ' ' . fn_get_product_name($product_id, CART_LANGUAGE, false);
        $product_data['description'] = db_get_field("SELECT full_description FROM ?:product_descriptions WHERE product_id = ?i AND lang_code = ?s", $product_id, CART_LANGUAGE);
        if (isset($product_data['description'])) {
            $product_data['description'] = strip_tags(html_entity_decode($product_data['description'], ENT_NOQUOTES, 'UTF-8'));
        }
        $product_data['image'] = fn_get_product_image_url($product_id);
        $price = is_array($product) ? $product['base_price'] : fn_get_product_price($product_id, 1, $auth);
        $product_data['price'] = fn_format_rate_value($price, 'F', '2', '.', ',', $currency['coefficient']);
        $products_arr[$product_id] = $product_data;
    }
    $data['products'] = $products_arr;
    return $data;
}
Esempio n. 10
0
function fn_get_seo_rules($params = array(), $items_per_page = 0, $lang_code = DESCR_SL)
{
    $condition = fn_get_seo_company_condition('?:seo_names.company_id');
    $lang_code = fn_get_corrected_seo_lang_code($lang_code);
    $global_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' ?p GROUP BY dispatch", $condition);
    $local_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p", $lang_code, $condition);
    if ($diff = array_diff($global_total, $local_total)) {
        foreach ($diff as $disp) {
            fn_create_seo_name(0, 's', str_replace('.', '-', $disp), 0, $disp, '', DESCR_SL);
        }
    }
    // Init filter
    $params = LastView::instance()->update('seo_rules', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    if (isset($params['name']) && fn_string_not_empty($params['name'])) {
        $condition .= db_quote(" AND name LIKE ?l", "%" . trim($params['name']) . "%");
    }
    if (isset($params['rule_params']) && fn_string_not_empty($params['rule_params'])) {
        $condition .= db_quote(" AND dispatch LIKE ?l", "%" . trim($params['rule_params']) . "%");
    }
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p", $lang_code, $condition);
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $seo_data = db_get_array("SELECT name, dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p ORDER BY dispatch {$limit}", $lang_code, $condition);
    return array($seo_data, $params);
}
Esempio n. 11
0
 public function import($db_already_cloned)
 {
     General::setProgressTitle(__CLASS__);
     if (!$db_already_cloned) {
         if (!General::cloneImportedDB($this->store_data)) {
             return false;
         }
     } else {
         General::setEmptyProgressBar(__('importing_data'));
         General::setEmptyProgressBar(__('importing_data'));
     }
     General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
     General::processAddons($this->store_data, __CLASS__);
     $main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
     if (is_file($main_sql)) {
         //Process main sql
         if (!db_import_sql_file($main_sql)) {
             return false;
         }
     }
     //        General::restoreSettings();
     if (db_get_field("SELECT status FROM ?:addons WHERE addon = 'searchanise'") != 'D') {
         db_query("UPDATE ?:addons SET status = 'D' WHERE addon = 'searchanise'");
         fn_set_notification('W', __('warning'), General::getUnavailableLangVar('uc_searchanise_disabled'));
     }
     General::setActualLangValues();
     General::updateAltLanguages('language_values', 'name');
     General::updateAltLanguages('ult_language_values', array('name', 'company_id'));
     General::updateAltLanguages('settings_descriptions', array('object_id', 'object_type'));
     General::setEmptyProgressBar();
     General::setEmptyProgressBar();
     General::setEmptyProgressBar();
     General::setEmptyProgressBar();
     return true;
 }
Esempio n. 12
0
 public static function processUa($ua)
 {
     $result = 'unknown';
     if (!file_exists(TWIGMO_UA_RULES_FILE)) {
         return $result;
     }
     $rules = unserialize(fn_get_contents(TWIGMO_UA_RULES_FILE));
     if (!is_array($rules)) {
         return $result;
     }
     $ua_meta = self::getUaMeta($ua, $rules);
     // Save stat
     foreach ($ua_meta as $section => $value) {
         $where = array('section' => $section, 'value' => $value, 'month' => date('Y-m-1'));
         $count = db_get_field('SELECT count FROM ?:twigmo_ua_stat WHERE ?w', $where);
         if ($count) {
             db_query('UPDATE ?:twigmo_ua_stat SET count=count+1 WHERE ?w', $where);
         } else {
             $where['count'] = 1;
             db_query('INSERT INTO ?:twigmo_ua_stat ?e', $where);
         }
     }
     if ($ua_meta['device'] and in_array($ua_meta['device'], array('phone', 'tablet'))) {
         $result = $ua_meta['device'];
     }
     return $result;
 }
Esempio n. 13
0
function fn_delete_feature($feature_id)
{
    $feature_type = db_get_field("SELECT feature_type FROM ?:product_features WHERE feature_id = ?i", $feature_id);
    if ($feature_type == 'G') {
        $fids = db_get_fields("SELECT feature_id FROM ?:product_features WHERE parent_id = ?i", $feature_id);
        if (!empty($fids)) {
            foreach ($fids as $fid) {
                fn_delete_feature($fid);
            }
        }
    }
    db_query("DELETE FROM ?:product_features WHERE feature_id = ?i", $feature_id);
    db_query("DELETE FROM ?:product_features_descriptions WHERE feature_id = ?i", $feature_id);
    db_query("DELETE FROM ?:product_features_values WHERE feature_id = ?i", $feature_id);
    $v_ids = db_get_fields("SELECT variant_id FROM ?:product_feature_variants WHERE feature_id = ?i", $feature_id);
    // Delete variant images
    foreach ($v_ids as $v_id) {
        fn_delete_image_pairs($v_id, 'feature_variant');
    }
    db_query("DELETE FROM ?:product_feature_variants WHERE feature_id = ?i", $feature_id);
    db_query("DELETE FROM ?:product_feature_variant_descriptions WHERE variant_id IN (?n)", $v_ids);
    $filter_ids = db_get_fields("SELECT filter_id FROM ?:product_filters WHERE feature_id = ?i", $feature_id);
    foreach ($filter_ids as $_filter_id) {
        fn_delete_product_filter($_filter_id);
    }
}
Esempio n. 14
0
function fn_add_bean_bag_filling_apply_option_modifiers_post($product_options, &$base_value, $type, $orig_options, $orig_value, $fields, $extra)
{
    if (AREA == 'A') {
        return;
        //var_dump($_REQUEST); die();
        //var_dump($product_options, $base_value, $type, $orig_options, $orig_value, $fields, $extra); die();
        if (!empty($product_options) && $type == 'P') {
            $opt = array_pop($product_options);
            if ($opt == "346") {
                $bean_bag_150 = Registry::get('addons.add_bean_bag_filling.bean_bag_filling_150');
                $bean_bag_300 = Registry::get('addons.add_bean_bag_filling.bean_bag_filling_300');
                $exist_bean_bag_150 = db_get_field("SELECT product_id FROM ?:products WHERE product_id = ?i", $bean_bag_150);
                $exist_bean_bag_300 = db_get_field("SELECT product_id FROM ?:products WHERE product_id = ?i", $bean_bag_300);
                $p_prices = db_get_hash_array("SELECT price, product_id FROM ?:product_prices WHERE product_id in (?n)", 'product_id', array($exist_bean_bag_150, $exist_bean_bag_300));
                $p_data = db_get_row("SELECT bean_bag_filling_150, bean_bag_filling_300, bean_bag_quantity_150, bean_bag_quantity_300 FROM ?:products WHERE product_id = ?i", $extra['product_data']['product_id']);
                $mod_ = 0;
                //fn_write_die($p_data);
                $price_ = 0;
                if (!empty($p_data['bean_bag_quantity_150']) && $p_data['bean_bag_filling_150'] == 'Y' && !empty($exist_bean_bag_150)) {
                    $mod_ += $p_data['bean_bag_quantity_150'] * $p_prices[$exist_bean_bag_150]['price'];
                    $price_ += $mod_;
                }
                if (!empty($p_data['bean_bag_quantity_300']) && $p_data['bean_bag_filling_300'] == 'Y' && !empty($exist_bean_bag_300)) {
                    $mod_ += $p_data['bean_bag_quantity_300'] * $p_prices[$exist_bean_bag_300]['price'];
                    $price_ += $mod_;
                }
            }
            $base_value += $price_;
        }
        return $base_value;
    }
    //var_dump($base_value); die();
}
Esempio n. 15
0
function fn_retargeting_get_main_category($product_id, $lang_code = DESCR_SL)
{
    $category = '';
    if (!empty($product_id)) {
        $category = db_get_field("SELECT ?:category_descriptions.category FROM ?:category_descriptions RIGHT JOIN ?:products_categories ON ?:category_descriptions.category_id = ?:products_categories.category_id AND ?:products_categories.product_id = ?i AND link_type = 'M' WHERE lang_code = ?s", $product_id, $lang_code);
    }
    return $category;
}
Esempio n. 16
0
function fn_is_add_to_cart_allowed($product_id)
{
    // No need to involve heavy SQL requests performed by fn_get_products()
    if (Registry::get('addons.catalog_mode.add_to_cart_empty_buy_now_url') == 'Y' && db_get_field("SELECT buy_now_url FROM ?:products WHERE product_id = ?i", $product_id) == '') {
        return true;
    }
    return false;
}
Esempio n. 17
0
function fn_vendor_data_premoderation_set_admin_notification(&$auth)
{
    if ($auth['company_id'] == 0 && fn_check_permissions('premoderation', 'products_approval', 'admin')) {
        $count = db_get_field('SELECT COUNT(*) FROM ?:products WHERE approved = ?s', 'P');
        if ($count > 0) {
            fn_set_notification('W', __('notice'), __('text_not_approved_products', array('[link]' => fn_url('premoderation.products_approval?approval_status=P'))), 'K');
        }
    }
}
Esempio n. 18
0
function fn_is_email_exists($email)
{
    $condition = db_quote(" (?p ) ", db_quote('email = ?s', $email));
    //$condition .= db_quote(" AND user_id != ?i", $user_id);
    // fn_set_hook('user_exist', $user_id, $user_data, $condition);
    $is_exist = db_get_field("SELECT user_id FROM ?:users WHERE {$condition}");
    //var_dump($is_exist); die();
    return $is_exist;
}
Esempio n. 19
0
function fn_rus_spsr_calculate_cart_items(&$cart, &$cart_products, $auth)
{
    if (!empty($cart['products'])) {
        foreach ($cart['products'] as $key => $product) {
            $spsr_product_type = db_get_field("SELECT spsr_product_type FROM ?:products WHERE product_id = ?i", $product['product_id']);
            $cart['products'][$key]['spsr_product_type'] = $cart_products[$key]['spsr_product_type'] = $spsr_product_type;
        }
    }
}
function fn_exim_put_product_combination($product_id, $product_name, $combination_code, $combination, $amount, &$counter, $lang_code = CART_LANGUAGE)
{
    $pair_delimiter = ':';
    $set_delimiter = ',';
    if (!empty($combination)) {
        // Get product_id
        $object_id = 0;
        if (!empty($product_id)) {
            $object_exists = db_get_field('SELECT COUNT(*) FROM ?:products WHERE product_id = ?i', $product_id);
            if ($object_exists) {
                $object_id = $product_id;
            }
        }
        if (empty($object_id) && !empty($product_name)) {
            $object_id = db_get_field('SELECT product_id FROM ?:product_descriptions WHERE product = ?s AND lang_code = ?s', $product_name, $lang_code);
        }
        if (empty($object_id)) {
            $counter['S']++;
            return false;
        }
        $options = explode($set_delimiter, $combination);
        if (!empty($options)) {
            $_combination = array();
            foreach ($options as $option_pair) {
                $pair = explode($pair_delimiter, $option_pair);
                if (is_array($pair)) {
                    array_walk($pair, 'fn_trim_helper');
                    $option_id = db_get_field("SELECT o.option_id FROM ?:product_options_descriptions as d INNER JOIN ?:product_options as o ON o.option_id = d.option_id AND o.product_id = ?i WHERE d.option_name = ?s AND d.lang_code = ?s LIMIT 1", $object_id, $pair[0], $lang_code);
                    $variant_id = db_get_field("SELECT v.variant_id FROM ?:product_option_variants_descriptions as d INNER JOIN ?:product_option_variants as v ON v.variant_id = d.variant_id AND v.option_id = ?i WHERE d.variant_name = ?s AND d.lang_code = ?s LIMIT 1", $option_id, $pair[1], $lang_code);
                    if (empty($option_id) || empty($variant_id)) {
                        $counter['S']++;
                        return false;
                    }
                    $_combination[$option_id] = $variant_id;
                }
            }
            $combination = fn_get_options_combination($_combination);
            $combination_hash = fn_generate_cart_id($object_id, array('product_options' => $_combination));
            $object_exists = db_get_field('SELECT COUNT(*) FROM ?:product_options_inventory WHERE combination_hash = ?i AND product_id = ?i', $combination_hash, $object_id);
            $_data = array('product_id' => $object_id, 'product_code' => $combination_code, 'combination_hash' => $combination_hash, 'combination' => $combination, 'amount' => $amount);
            if ($object_exists) {
                db_query('UPDATE ?:product_options_inventory SET ?u WHERE combination_hash = ?i', $_data, $combination_hash);
                fn_echo(fn_get_lang_var('updating') . ' ' . fn_get_lang_var('product_combinations') . '...');
                $counter['E']++;
            } else {
                db_query('INSERT INTO ?:product_options_inventory ?e', $_data);
                fn_echo(fn_get_lang_var('creating') . ' ' . fn_get_lang_var('product_combinations') . '...');
                $counter['N']++;
            }
            fn_echo('<b>' . $object_id . '</b>.<br />');
            return $combination;
        }
    }
    $counter['S']++;
    return false;
}
Esempio n. 21
0
function fn_sms_notifications_update_product_amount($new_amount, $product_id)
{
    if ($new_amount <= Registry::get('settings.General.low_stock_threshold') && Registry::get('addons.sms_notifications.sms_product_negative_amount') == 'Y') {
        $lang_code = Registry::get('settings.Appearence.admin_default_language');
        Registry::get('view')->assign('product_id', $product_id);
        Registry::get('view')->assign('product', db_get_field("SELECT product FROM ?:product_descriptions WHERE product_id = ?i AND lang_code = ?s", $product_id, $lang_code));
        $body = Registry::get('view')->display('addons/sms_notifications/views/sms/components/low_stock_sms.tpl', false);
        fn_send_sms_notification($body);
    }
}
Esempio n. 22
0
function fn_import_check_em_subscriber_company_id(&$primary_object_id, &$object, &$pattern, &$options, &$processed_data, &$processing_groups, &$skip_record)
{
    if (!empty($primary_object_id) && Registry::get('runtime.company_id')) {
        $company_id = db_get_field('SELECT company_id FROM ?:em_subscribers WHERE company_id = ?s', $primary_object_id);
        if ($company_id != Registry::get('runtime.company_id')) {
            $processed_data['S']++;
            $skip_record = true;
        }
    }
}
 /**
  * The function gets usergroup name by usergroup id
  *
  * @param int $usergroup_id Usergroup id
  * @param string $lang_code 2-letter language code
  * @return string usergroup name
  */
 function fn_exim_get_usergroup($usergroup_id, $lang_code = '')
 {
     if ($usergroup_id < ALLOW_USERGROUP_ID_FROM) {
         $default_usergroups = fn_get_default_usergroups($lang_code);
         $usergroup = !empty($default_usergroups[$usergroup_id]['usergroup']) ? $default_usergroups[$usergroup_id]['usergroup'] : '';
     } else {
         $usergroup = db_get_field("SELECT usergroup FROM ?:usergroup_descriptions WHERE usergroup_id = ?i AND lang_code = ?s", $usergroup_id, $lang_code);
     }
     return $usergroup;
 }
Esempio n. 24
0
function fn_isAlreadyPAID($transactionID)
{
    $orderID = db_get_field('SELECT order_id FROM ?:paynl_transactions WHERE transaction_id =?s', $transactionID);
    $arrTransactions = db_get_field('SELECT count(*) FROM ?:paynl_transactions WHERE order_id =?s AND status = "PAID" ', $orderID);
    if (intval($arrTransactions) > 0) {
        return true;
    } else {
        return false;
    }
}
Esempio n. 25
0
function fn_get_logs($params, $items_per_page = null)
{
    // Init filter
    $params = fn_init_view('logs', $params);
    if ($items_per_page === null) {
        $items_per_page = Registry::get('settings.Appearance.admin_elements_per_page');
    }
    $sortings = array('timestamp' => '?:logs.timestamp', 'user' => array('?:users.lastname', '?:users.firstname'));
    $directions = array('asc' => 'asc', 'desc' => 'desc');
    $fields = array('?:logs.*', '?:users.firstname', '?:users.lastname');
    if (empty($params['sort_order']) || empty($directions[$params['sort_order']])) {
        $params['sort_order'] = 'asc';
    }
    if (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) {
        $params['sort_by'] = 'timestamp';
        $params['sort_order'] = 'desc';
    }
    $params['page'] = empty($params['page']) ? 1 : $params['page'];
    if (is_array($sortings[$params['sort_by']])) {
        $sorting = join(' ' . $directions[$params['sort_order']] . ', ', $sortings[$params['sort_by']]) . ' ' . $directions[$params['sort_order']];
    } else {
        $sorting = $sortings[$params['sort_by']] . ' ' . $directions[$params['sort_order']];
    }
    $join = "LEFT JOIN ?:users USING(user_id)";
    $condition = '';
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($time_from, $time_to) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:logs.timestamp >= ?i AND ?:logs.timestamp <= ?i)", $time_from, $time_to);
    }
    if (isset($params['q_user']) && fn_string_no_empty($params['q_user'])) {
        $condition .= db_quote(" AND (?:users.lastname LIKE ?l OR ?:users.firstname LIKE ?l)", "%" . trim($params['q_user']) . "%", "%" . trim($params['q_user']) . "%");
    }
    if (!empty($params['q_type'])) {
        $condition .= db_quote(" AND (?:logs.type LIKE ?l OR ?:logs.type LIKE ?l)", "%{$params['q_type']}%", "%{$params['q_type']}%");
    }
    if (!empty($params['q_action'])) {
        $condition .= db_quote(" AND (?:logs.action LIKE ?l OR ?:logs.action LIKE ?l)", "%{$params['q_action']}%", "%{$params['q_action']}%");
    }
    $limit = '';
    $total = 0;
    if (!empty($items_per_page)) {
        $total = db_get_field("SELECT COUNT(DISTINCT(?:logs.log_id)) FROM ?:logs ?p WHERE 1 ?p", $join, $condition);
        $limit = fn_paginate($params['page'], $total, $items_per_page);
    }
    $data = db_get_array("SELECT " . join(', ', $fields) . " FROM ?:logs ?p WHERE 1 ?p ORDER BY {$sorting} {$limit}", $join, $condition);
    if (!$total) {
        $total = count($data);
    }
    foreach ($data as $k => $v) {
        $data[$k]['backtrace'] = !empty($v['backtrace']) ? unserialize($v['backtrace']) : array();
        $data[$k]['content'] = !empty($v['content']) ? unserialize($v['content']) : array();
    }
    return array($data, $params, $total);
}
Esempio n. 26
0
function fn_get_store_locations($params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    $default_params = array('page' => 1, 'q' => '', 'match' => 'any');
    $params = array_merge($default_params, $params);
    $fields = array('?:store_locations.*', '?:store_location_descriptions.*', '?:country_descriptions.country as country_title');
    $join = db_quote(" LEFT JOIN ?:store_location_descriptions ON ?:store_locations.store_location_id = ?:store_location_descriptions.store_location_id AND ?:store_location_descriptions.lang_code = ?s", $lang_code);
    $join .= db_quote(" LEFT JOIN ?:country_descriptions ON ?:store_locations.country = ?:country_descriptions.code AND ?:country_descriptions.lang_code = ?s", $lang_code);
    $condition = 1;
    if (AREA == 'C') {
        $condition .= " AND status = 'A'";
    }
    // Search string condition for SQL query
    if (!empty($params['q'])) {
        if ($params['match'] == 'any') {
            $pieces = explode(' ', $params['q']);
            $search_type = ' OR ';
        } elseif ($params['match'] == 'all') {
            $pieces = explode(' ', $params['q']);
            $search_type = ' AND ';
        } else {
            $pieces = array($params['q']);
            $search_type = '';
        }
        $_condition = array();
        foreach ($pieces as $piece) {
            $tmp = db_quote("?:store_location_descriptions.name LIKE ?l", "%{$piece}%");
            // check search words
            $tmp .= db_quote(" OR ?:store_location_descriptions.description LIKE ?l", "%{$piece}%");
            $tmp .= db_quote(" OR ?:store_location_descriptions.city LIKE ?l", "%{$piece}%");
            $tmp .= db_quote(" OR ?:country_descriptions.country LIKE ?l", "%{$piece}%");
            $_condition[] = '(' . $tmp . ')';
        }
        $_cond = implode($search_type, $_condition);
        if (!empty($_condition)) {
            $condition .= ' AND (' . $_cond . ') ';
        }
        unset($_condition);
    }
    $condition .= AREA == 'C' && defined('CART_LOCALIZATION') ? fn_get_localizations_condition('?:store_locations.localization') : '';
    $sorting = "?:store_locations.position, ?:store_location_descriptions.name";
    $limit = '';
    $total = 0;
    if (!empty($items_per_page)) {
        $total = db_get_field("SELECT COUNT(?:store_locations.store_location_id) FROM ?:store_locations ?p WHERE ?p", $join, $condition);
        $limit = fn_paginate($params['page'], $total, $items_per_page);
    }
    $data = db_get_array('SELECT ?p FROM ?:store_locations ?p WHERE ?p GROUP BY ?:store_locations.store_location_id ORDER BY ?p ?p', implode(', ', $fields), $join, $condition, $sorting, $limit);
    if (!$total) {
        $total = count($data);
    }
    return array($data, $params, $total);
}
Esempio n. 27
0
function fn_get_feature_by_id($feature_id, $category_id, $id_path, $number_of_variants)
{
    $feature = array();
    $category_ids = db_get_fields("SELECT category_id FROM ?:categories WHERE id_path LIKE ?l", $id_path . '/%');
    $category_ids[] = $category_id;
    $feature['id'] = $feature_id;
    $feature['name'] = db_get_field('SELECT description FROM ?:product_features_descriptions WHERE feature_id = ?i AND lang_code = ?s', $feature_id, CART_LANGUAGE);
    $feature['variants'] = db_get_array('SELECT ?:product_features_values.variant_id, ?:product_feature_variant_descriptions.variant FROM ?:product_features_values LEFT JOIN ?:products ON ?:products.product_id = ?:product_features_values.product_id LEFT JOIN ?:product_feature_variants ON ?:product_feature_variants.variant_id = ?:product_features_values.variant_id LEFT JOIN ?:product_feature_variant_descriptions ON ?:product_feature_variant_descriptions.variant_id = ?:product_feature_variants.variant_id AND ?:product_feature_variant_descriptions.lang_code = ?s INNER JOIN ?:products_categories ON ?:products_categories.product_id = ?:products.product_id WHERE ?:product_features_values.feature_id = ?i AND ?:products_categories.category_id IN (?n) GROUP BY ?:product_features_values.variant_id ORDER BY ?:product_feature_variant_descriptions.variant ASC', CART_LANGUAGE, $feature_id, $category_ids);
    if (!empty($number_of_variants) && !empty($feature['variants']) && count($feature['variants']) > $number_of_variants) {
        $feature['variants'] = array_slice($feature['variants'], 0, $number_of_variants);
        $feature['view_all'] = 'Y';
    }
    return $feature;
}
Esempio n. 28
0
function fn_rus_russianpost_install()
{
    $objects = fn_rus_russianpost_schema();
    foreach ($objects as $object) {
        $service = array('status' => $object['status'], 'module' => $object['module'], 'code' => $object['code'], 'sp_file' => $object['sp_file'], 'description' => $object['description']);
        $service_id = db_get_field('SELECT service_id FROM ?:shipping_services WHERE module = ?s AND code = ?s', $object['module'], $object['code']);
        if (empty($service_id)) {
            $service['service_id'] = db_query('INSERT INTO ?:shipping_services ?e', $service);
            foreach (Languages::getAll() as $service['lang_code'] => $lang_data) {
                db_query('INSERT INTO ?:shipping_service_descriptions ?e', $service);
            }
        }
    }
}
Esempio n. 29
0
function fn_gift_registry_get_userlog($params, $items_per_page = 0)
{
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $sortings = array('timestamp' => 'timestamp', 'amount' => 'amount');
    $sorting = db_sort($params, $sortings, 'timestamp', 'desc');
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:reward_point_changes WHERE user_id = ?i", $params['user_id']);
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $userlog = db_get_array("SELECT change_id, action, timestamp, amount, reason FROM ?:reward_point_changes WHERE user_id = ?i {$sorting} {$limit}", $params['user_id']);
    return array($userlog, $params);
}
Esempio n. 30
-1
function fn_get_cities($params = array(), $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $fields = array('c.city_id', 'c.country_code', 'c.state_code', 'c.city_code', 'c.status', 'cd.city');
    $condition = '';
    if (!empty($params['only_avail'])) {
        $condition .= db_quote(" AND c.status = ?s", 'A');
    }
    if (!empty($params['q'])) {
        $condition .= db_quote(" AND cd.city LIKE ?l", '%' . $params['q'] . '%');
    }
    if (!empty($params['state_code'])) {
        $condition .= db_quote(" AND c.state_code = ?s", $params['state_code']);
    }
    if (!empty($params['country_code'])) {
        $condition .= db_quote(" AND c.country_code = ?s", $params['country_code']);
    }
    $join = "LEFT JOIN ?:rus_city_descriptions as cd ON cd.city_id = c.city_id AND cd.lang_code = ?s ";
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT count(*) FROM ?:rus_cities as c {$join} WHERE 1 ?p", $lang_code, $condition);
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $cities = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:rus_cities as c {$join} WHERE 1 ?p ORDER BY cd.city {$limit}", $lang_code, $condition);
    foreach ($cities as &$city) {
        if (empty($city['city'])) {
            $city['city'] = db_get_field("SELECT city FROM ?:rus_city_descriptions WHERE city_id = ?i AND lang_code = 'ru'", $city['city_id']);
        }
    }
    return array($cities, $params);
}