当前位置: 首页>>代码示例>>PHP>>正文


PHP fn_find_array_in_set函数代码示例

本文整理汇总了PHP中fn_find_array_in_set函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_find_array_in_set函数的具体用法?PHP fn_find_array_in_set怎么用?PHP fn_find_array_in_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fn_find_array_in_set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fn_get_products


//.........这里部分代码省略.........
        $u_condition .= db_quote(" {$union_condition} (inventory.product_code LIKE ?l OR products.product_code LIKE ?l)", "%{$pcode}%", "%{$pcode}%");
        $inventory_condition .= db_quote(" AND inventory.product_code LIKE ?l", "%{$pcode}%");
    }
    if (isset($params['amount_to']) && fn_is_numeric($params['amount_to']) || isset($params['amount_from']) && fn_is_numeric($params['amount_from']) || !empty($params['pcode']) || Registry::get('settings.General.inventory_tracking') == 'Y' && Registry::get('settings.General.show_out_of_stock_products') == 'N' && $params['area'] == 'C') {
        $join .= " LEFT JOIN ?:product_options_inventory as inventory ON inventory.product_id = products.product_id {$inventory_condition}";
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (products.timestamp >= ?i AND products.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    if (!empty($params['item_ids'])) {
        $condition .= db_quote(" AND products.product_id IN (?n)", explode(',', $params['item_ids']));
    }
    if (isset($params['popularity_from']) && fn_is_numeric($params['popularity_from'])) {
        $params['extend'][] = 'popularity';
        $condition .= db_quote(' AND popularity.total >= ?i', $params['popularity_from']);
    }
    if (isset($params['popularity_to']) && fn_is_numeric($params['popularity_to'])) {
        $params['extend'][] = 'popularity';
        $condition .= db_quote(' AND popularity.total <= ?i', $params['popularity_to']);
    }
    if (!empty($params['order_ids'])) {
        $arr = strpos($params['order_ids'], ',') !== false || !is_array($params['order_ids']) ? explode(',', $params['order_ids']) : $params['order_ids'];
        $condition .= db_quote(" AND ?:order_details.order_id IN (?n)", $arr);
        $join .= " LEFT JOIN ?:order_details ON ?:order_details.product_id = products.product_id";
    }
    $limit = '';
    $group_by = 'products.product_id';
    // Show enabled products
    $_p_statuses = array('A');
    if ($params['p_status']) {
        $_p_statuses = array('A', 'H');
    }
    $condition .= $params['area'] == 'C' ? ' AND (' . fn_find_array_in_set($auth['usergroup_ids'], 'products.usergroup_ids', true) . ')' . db_quote(' AND products.status IN (?a)', $_p_statuses) : '';
    // -- JOINS --
    if (in_array('product_name', $params['extend'])) {
        $fields['product'] = 'descr1.product as product';
        $join .= db_quote(" LEFT JOIN ?:product_descriptions as descr1 ON descr1.product_id = products.product_id AND descr1.lang_code = ?s ", $lang_code);
    }
    // get prices
    $price_condition = '';
    if (in_array('prices', $params['extend'])) {
        //        //$fields['price'] = 'MIN(IF(prices.percentage_discount = 0, prices.price, prices.price - (prices.price * prices.percentage_discount)/100)) as price';
        $join .= " LEFT JOIN ?:product_prices as prices ON prices.product_id = products.product_id AND prices.lower_limit = 1";
        $price_condition = db_quote(' AND prices.usergroup_id IN (?n)', $params['area'] == 'A' ? USERGROUP_ALL : array_merge(array(USERGROUP_ALL), $auth['usergroup_ids']));
        $condition .= $price_condition;
        //$price_usergroup_cond_2 = db_quote(' AND usergroup_id IN (?n)', (($params['area'] == 'A') ? USERGROUP_ALL : array_merge(array(USERGROUP_ALL), $auth['usergroup_ids'])));
        $extraConditionString = "";
        if (count($extraCondition) > 0) {
            $extraConditionString = "WHERE " . implode(" AND ", $extraCondition);
        }
        $fields['price'] = 'case  
		when p2.min_price > 0 then p2.min_price 
                else p3.price2 
	end';
        $join .= "  LEFT JOIN (SELECT product_id, MIN(price) as min_price FROM ?:product_options_inventory_prices " . $extraConditionString . " GROUP BY product_id) AS p2 ON p2.product_id = products.product_id\n                    LEFT JOIN (SELECT product_id, MIN(IF(percentage_discount = 0, price, price - (price * percentage_discount)/100)) as price2  FROM ?:product_prices WHERE lower_limit = 1 GROUP by product_id) AS p3 ON p3.product_id=products.product_id ";
    }
    /*
    // get prices for search by price
    if (in_array('prices2', $params['extend'])) {
        $price_usergroup_cond_2 = db_quote(' AND prices_2.usergroup_id IN (?n)', (($params['area'] == 'A') ? USERGROUP_ALL : array_merge(array(USERGROUP_ALL), $auth['usergroup_ids'])));
        $join .= " LEFT JOIN ?:product_prices as prices_2 ON prices.product_id = prices_2.product_id AND prices_2.lower_limit = 1 AND prices_2.price < prices.price " . $price_usergroup_cond_2;
        $condition .= ' AND prices_2.price IS NULL';
        $price_condition .= ' AND prices_2.price IS NULL';
    }
    */
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:67,代码来源:fn.catalog.php

示例2: fn_get_page_data

/**
 * Gets page data
 *
 * @param mixed $page_id Page identifier
 * @param string $lang_code 2 letters language code
 * @param bool $preview Page data for preview (ignore cahce)
 * @return array|bool Page data on success, false otherwise
 */
function fn_get_page_data($page_id, $lang_code = CART_LANGUAGE, $preview = false, $area = AREA)
{
    static $cache = array();
    if (empty($page_id)) {
        return false;
    }
    fn_set_hook('get_page_data_pre', $page_id, $lang_code, $preview, $area);
    if (empty($cache[$page_id])) {
        $condition = fn_get_company_condition('?:pages.company_id');
        if ($area != 'A' && !$preview) {
            $condition .= " AND (" . fn_find_array_in_set($_SESSION['auth']['usergroup_ids'], '?:pages.usergroup_ids', true) . ")";
        }
        $field_list = "?:pages.*, ?:page_descriptions.*";
        $join = " INNER JOIN ?:page_descriptions ON ?:pages.page_id = ?:page_descriptions.page_id";
        $condition .= db_quote(" AND ?:pages.page_type IN (?a)", array_keys(fn_get_page_object_by_type()));
        fn_set_hook('pre_get_page_data', $field_list, $join, $condition, $lang_code);
        $page_data = db_get_row("SELECT {$field_list} FROM ?:pages ?p WHERE ?:pages.page_id = ?i AND ?:page_descriptions.lang_code = ?s ?p", $join, $page_id, $lang_code, $condition);
        if (empty($page_data) || $area != 'A' && ($page_data['status'] == 'D' || $page_data['use_avail_period'] == 'Y' && ($page_data['avail_from_timestamp'] > TIME || $page_data['avail_till_timestamp'] < TIME)) && empty($preview)) {
            return false;
        }
        fn_set_hook('get_page_data', $page_data, $lang_code, $preview, $area);
        // Generate meta description automatically
        if (empty($page_data['meta_description']) && defined('AUTO_META_DESCRIPTION') && $area != 'A') {
            $page_data['meta_description'] = fn_generate_meta_description($page_data['description']);
        }
        $cache[$page_id] = $page_data;
    }
    return !empty($cache[$page_id]) ? $cache[$page_id] : false;
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:37,代码来源:fn.cms.php

示例3: fn_searchanise_get_products_before_select

function fn_searchanise_get_products_before_select(&$params, &$join, &$condition, &$u_condition, &$inventory_condition, &$sortings, &$total, &$items_per_page, &$lang_code, &$having)
{
    // disable by core
    if (AREA == 'A' || fn_se_check_disabled() || !empty($params['having']) || !empty($params['disable_searchanise']) || empty($params['search_performed']) || !empty($params['block_data']) || empty($params['q']) && fn_se_get_simple_setting('use_navigation') !== 'Y' || fn_se_get_import_status(fn_se_get_company_id(), $lang_code) != 'done' || !empty($params['pid']) || !empty($params['b_id']) || !empty($params['item_ids']) || !empty($params['feature']) || !empty($params['downloadable']) || !empty($params['tracking']) || !empty($params['shipping_freight_from']) || !empty($params['shipping_freight_to']) || !empty($params['exclude_pid']) || !empty($params['get_query']) || !empty($params['only_short_fields']) || isset($params['supplier_id']) || isset($params['amount_to']) || isset($params['amount_from']) || isset($params['q']) && Registry::get('settings.General.search_objects') || isset($params['compact']) && $params['compact'] == 'Y' || !empty($_REQUEST['sort_by']) && !in_array($_REQUEST['sort_by'], fn_se_get_valid_sortings()) || !empty($params['force_get_by_ids']) && empty($params['pid']) && empty($params['product_id'])) {
        return;
    }
    // disable by addons
    if (!empty($params['rating']) || !empty($params['bestsellers']) || !empty($params['also_bought_for_product_id']) || !empty($params['for_required_product']) || !empty($params['ppcode']) && $params['ppcode'] == 'Y' || isset($params['tag']) && fn_string_not_empty($params['tag']) || Registry::ifGet('addons.age_verification.status', 'D') == 'A' || Registry::ifGet('addons.vendor_data_premoderation.status', 'D') == 'A' || !empty($params['picker_for']) && $params['picker_for'] == 'gift_certificates') {
        return;
    }
    list($restrict_by, $query_by, $union) = fn_se_prepare_request_params($params);
    //
    // Categories
    //
    if (!empty($params['cid'])) {
        $cids = is_array($params['cid']) ? $params['cid'] : array($params['cid']);
        $c_condition = '';
        if (AREA == 'C') {
            $_c_statuses = array('A', 'H');
            // Show enabled categories
            $cids = db_get_fields("SELECT a.category_id FROM ?:categories as a WHERE a.category_id IN (?n) AND a.status IN (?a)", $cids, $_c_statuses);
            $c_condition = db_quote('AND a.status IN (?a) AND (' . fn_find_array_in_set(Tygh::$app['session']['auth']['usergroup_ids'], 'a.usergroup_ids', true) . ')', $_c_statuses);
        }
        $sub_categories_ids = db_get_fields("SELECT a.category_id FROM ?:categories as a LEFT JOIN ?:categories as b ON b.category_id IN (?n) WHERE a.id_path LIKE CONCAT(b.id_path, '/%') ?p", $cids, $c_condition);
        $sub_categories_ids = fn_array_merge($cids, $sub_categories_ids, false);
        if (empty($sub_categories_ids)) {
            $params['force_get_by_ids'] = true;
            $params['pid'] = $params['product_id'] = 0;
            return;
        }
        if (!empty($params['subcats']) && $params['subcats'] == 'Y') {
            $restrict_by['category_id'] = join('|', $sub_categories_ids);
        } else {
            $restrict_by['category_id'] = join('|', $cids);
        }
    }
    //
    // Sortings
    //
    if (!empty($_REQUEST['search_performed']) && empty($_REQUEST['sort_by']) && SE_USE_RELEVANCE_AS_DEFAULT_SORTING == 'Y') {
        $params['sort_by'] = 'relevance';
        $params['sort_order'] = 'asc';
    }
    if (!empty($params['sort_by']) && !in_array($params['sort_by'], fn_se_get_valid_sortings())) {
        return;
    }
    if ($params['sort_by'] == 'product') {
        $sort_by = 'title';
    } elseif ($params['sort_by'] == 'relevance') {
        $params['sort_order'] = 'asc';
        $sort_by = 'relevance';
    } else {
        $sort_by = $params['sort_by'];
    }
    $sort_order = $params['sort_order'] == 'asc' ? 'asc' : 'desc';
    //
    // Items_per_page
    //
    $items_per_page = empty($params['items_per_page']) ? 10 : (int) $params['items_per_page'];
    if (!empty($params['limit'])) {
        $max_results = $params['limit'];
    } else {
        $max_results = $items_per_page;
    }
    $get_items = true;
    $get_facets = false;
    if (!fn_allowed_for('ULTIMATE:FREE') && AREA == 'C' && !empty($params['dispatch']) && in_array($params['dispatch'], fn_se_get_facet_valid_locations()) && fn_se_check_product_filter_block() == true) {
        $get_facets = true;
    }
    $request_params = array('sortBy' => $sort_by, 'sortOrder' => $sort_order, 'union' => $union, 'queryBy' => $query_by, 'restrictBy' => $restrict_by, 'items' => $get_items == true ? 'true' : 'false', 'facets' => $get_facets == true ? 'true' : 'false', 'maxResults' => $max_results, 'startIndex' => ($params['page'] - 1) * $items_per_page);
    if ($request_params['sortBy'] == 'null') {
        unset($request_params['sortBy']);
    }
    if (!empty($params['q']) && fn_strlen($params['q']) > 0) {
        $request_params['q'] = $params['q'];
        $request_params['suggestions'] = 'true';
        $request_params['query_correction'] = 'false';
        $request_params['suggestionsMaxResults'] = 1;
    } else {
        $request_params['q'] = '';
    }
    $result = fn_searchanise_send_search_request($request_params, $lang_code);
    if ($result == false) {
        //revert to standart sorting
        if ($params['sort_by'] == 'relevance') {
            $params['sort_by'] = '';
        }
        Registry::set('runtime.se_use_relevance_sorting', false);
        return;
    }
    if (!empty($result['suggestions']) && count($result['suggestions']) > 0) {
        $params['suggestion'] = reset($result['suggestions']);
    }
    if (!empty($result['items'])) {
        foreach ($result['items'] as $product) {
            $params['pid'][] = $product['product_id'];
        }
        if ($params['sort_by'] == 'relevance') {
            $sortings['relevance'] = "FIELD(products.product_id, '" . join("','", $params['pid']) . "')";
            $params['sort_order'] = 'asc';
//.........这里部分代码省略.........
开发者ID:ambient-lounge,项目名称:site,代码行数:101,代码来源:func.php

示例4: fn_get_checkout_payment_buttons

function fn_get_checkout_payment_buttons(&$cart, &$cart_products, &$auth)
{
    $checkout_buttons = array();
    fn_set_hook('get_checkout_payment_buttons_pre', $cart, $cart_products, $auth, $checkout_buttons);
    if (Registry::get('settings.General.disable_anonymous_checkout') == 'Y' && empty($auth['user_id'])) {
        $url = fn_url("auth.login_form?return_url=" . urlencode(fn_url('checkout.cart')));
        return array(__('payments.signin_to_checkout', array("[url]" => $url)));
    }
    $ug_condition = 'AND (' . fn_find_array_in_set($auth['usergroup_ids'], 'b.usergroup_ids', true) . ')';
    $checkout_payments = db_get_fields("SELECT b.payment_id FROM ?:payment_processors as a LEFT JOIN ?:payments as b ON a.processor_id = b.processor_id WHERE a.type != 'P' AND b.status = 'A' ?p", $ug_condition);
    if (!empty($checkout_payments)) {
        foreach ($checkout_payments as $_payment_id) {
            fn_set_hook('get_checkout_payment_buttons', $cart, $cart_products, $auth, $checkout_buttons, $checkout_payments, $_payment_id);
            $processor_data = fn_get_processor_data($_payment_id);
            if (!empty($processor_data['processor_script']) && file_exists(Registry::get('config.dir.payments') . $processor_data['processor_script'])) {
                include Registry::get('config.dir.payments') . $processor_data['processor_script'];
            }
        }
    }
    fn_set_hook('get_checkout_payment_buttons_post', $cart, $cart_products, $auth, $checkout_buttons);
    return $checkout_buttons;
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:22,代码来源:fn.cart.php

示例5: fn_get_polls

/**
 * Get polls
 *
 * @param array $params array of search parameters
 * @param string $lang_code language to get descriptions for
 * @return array array with found polls in first element and filtered parameters in second
 */
function fn_get_polls($params, $lang_code = CART_LANGUAGE)
{
    $auth = $_SESSION['auth'];
    $condition = '';
    if (!empty($params['item_ids'])) {
        $condition .= db_quote(" AND ?:pages.page_id IN (?n)", explode(',', $params['item_ids']));
    }
    if (AREA != 'A') {
        $condition .= " AND (" . fn_find_array_in_set($auth['usergroup_ids'], '?:pages.usergroup_ids', true) . ")";
    }
    $_data = db_get_array("SELECT ?:pages.page_id, ?:page_descriptions.page FROM ?:pages LEFT JOIN ?:page_descriptions ON ?:page_descriptions.page_id = ?:pages.page_id AND ?:page_descriptions.lang_code = ?s LEFT JOIN ?:polls ON ?:polls.page_id = ?:pages.page_id WHERE ?:pages.status = ?s AND ?:pages.page_type = ?s AND (?:pages.use_avail_period = ?s OR (?:pages.use_avail_period = ?s AND ?:pages.avail_from_timestamp <= ?i AND ?:pages.avail_till_timestamp >= ?i)) ?p ORDER BY position", $lang_code, 'A', PAGE_TYPE_POLL, 'N', 'Y', TIME, TIME, $condition);
    $polls = array();
    foreach ($_data as $k => $_poll) {
        $polls[$k] = fn_get_poll_data($_poll['page_id']);
        $polls[$k]['page'] = $_poll['page'];
    }
    return array($polls, $params);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:25,代码来源:func.php

示例6: fn_get_attachment

function fn_get_attachment($attachment_id, $object_type = null, $object_id = null)
{
    if ($object_type === null) {
        $auth = $_SESSION['auth'];
        $ug_cond = ' AND (' . fn_find_array_in_set($auth['usergroup_ids'], 'usergroup_ids', true) . ')';
        $data = db_get_row("SELECT * FROM ?:attachments WHERE attachment_id = ?i ?p AND status = 'A'", $attachment_id, $ug_cond);
        if (!empty($data['filename'])) {
            $directory = DIR_ATTACHMENTS . '/' . $data['object_type'] . '/' . $data['object_id'];
            $data['path'] = $directory . '/' . $data['filename'];
        }
        return $data;
    }
    $revision_id = 0;
    if (AREA == 'A' && Registry::is_exist('revisions') && !Registry::get('revisions.working')) {
        $revisions = Registry::get('revisions');
        if (!empty($revisions['objects'][$object_type]) && !empty($revisions['objects'][$object_type]['tables'])) {
            $object_data = $revisions['objects'][$object_type];
            if ($object_data['attachments']) {
                $rev_data = db_get_row("SELECT max(revision) as revision, revision_id FROM ?:revisions WHERE object = ?s AND object_id = ?i GROUP BY revision_id", $object_type, $object_id);
                if ($rev_data) {
                    $revision = $rev_data['revision'];
                    $revision_id = $rev_data['revision_id'];
                }
            }
        }
    }
    if ($revision_id) {
        $_ = 'rev_';
        $revision_condition = db_quote(" AND revision = ?s AND revision_id = ?i", $revision, $revision_id);
    } else {
        $_ = '';
        $revision_condition = '';
    }
    if (AREA == 'A') {
        $data = db_get_row("SELECT * FROM ?:{$_}attachments WHERE attachment_id = ?i ?p", $attachment_id, $revision_condition);
    }
    if (!empty($data['filename'])) {
        $directory = DIR_ATTACHMENTS . '/' . $data['object_type'] . ($revision_condition ? '_rev' : '') . '/' . $object_id;
        $data['path'] = $directory . '/' . $data['filename'];
    }
    return $data;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:42,代码来源:func.php

示例7: getShippingsList

 /**
  * Gets list of shippings
  *
  * @param  array  $group     Group products information
  * @param  string $lang_code 2 letters language code
  * @param  string $area      Current working area
  * @return array  Shippings list
  */
 public static function getShippingsList($group, $lang = CART_LANGUAGE, $area = AREA)
 {
     /**
      * Changes params before shipping list selecting
      *
      * @param array $group Group products information
      * @param string $lang_code 2 letters language code
      * @param string $area Current working area
      */
     fn_set_hook('shippings_get_shippings_list_pre', $group, $lang, $area);
     $shippings = self::_getCompanyShippings($group['company_id']);
     $condition = '';
     /**
      * Changes company shipping list before main selecting
      *
      * @param array $group Group products information
      * @param array $shippings List of company shippings
      * @param string $condition WHERE condition
      */
     fn_set_hook('shippings_get_shippings_list', $group, $shippings, $condition);
     $package_weight = $group['package_info']['W'];
     $fields = array("?:shippings.shipping_id", "?:shipping_descriptions.shipping", "?:shipping_descriptions.delivery_time", "?:shippings.rate_calculation", "?:shippings.service_params", "?:shippings.destination", "?:shippings.min_weight", "?:shippings.max_weight", "?:shippings.service_id", "?:shipping_services.module", "?:shipping_services.code as service_code");
     $join = "LEFT JOIN ?:shipping_descriptions ON ?:shippings.shipping_id = ?:shipping_descriptions.shipping_id ";
     $join .= "LEFT JOIN ?:shipping_services ON ?:shipping_services.service_id = ?:shippings.service_id ";
     $condition .= db_quote('?:shippings.status = ?s', 'A');
     $condition .= db_quote(' AND ?:shippings.shipping_id IN (?n)', $shippings);
     $condition .= db_quote(' AND (?:shippings.min_weight <= ?d', $package_weight);
     $condition .= db_quote(' AND (?:shippings.max_weight >= ?d OR ?:shippings.max_weight = 0.00))', $package_weight);
     $condition .= db_quote(' AND ?:shipping_descriptions.lang_code = ?s', $lang);
     if ($area == 'C') {
         $condition .= " AND (" . fn_find_array_in_set($_SESSION['auth']['usergroup_ids'], '?:shippings.usergroup_ids', true) . ")";
     }
     $order_by = '?:shippings.position';
     fn_set_hook('shippings_get_shippings_list_conditions', $group, $shippings, $fields, $join, $condition, $order_by);
     $shippings_info = db_get_hash_array('SELECT ' . implode(', ', $fields) . ' FROM ?:shippings ' . $join . ' WHERE ?p ORDER BY ?p', 'shipping_id', $condition, $order_by);
     foreach ($shippings_info as $key => $shipping_info) {
         $shippings_info[$key]['rate_info'] = self::_getRateInfoByLocation($shipping_info['shipping_id'], $group['package_info']['location']);
         $shippings_info[$key]['service_params'] = !empty($shippings_info[$key]['service_params']) ? unserialize($shippings_info[$key]['service_params']) : array();
     }
     /**
      * Changes shippings data
      *
      * @param array $group Group products information
      * @param string $lang_code 2 letters language code
      * @param string $area Current working area
      * @param array $shippings_info List of selected shippings
      */
     fn_set_hook('shippings_get_shippings_list_post', $group, $lang, $area, $shippings_info);
     return $shippings_info;
 }
开发者ID:askzap,项目名称:ultimate,代码行数:58,代码来源:Shippings.php

示例8: fn_load_products_extra_data

/**
 * Lazily loads additional data related to products after they have been fetched from DB.
 * Used to ease main product loading SQL-query.
 *
 * @param array $products List of products
 * @param array $params Parameters passed to fn_get_products()
 * @param string $lang_code Language code passed to fn_get_products()
 *
 * @return array List of products with additional data merged into.
 */
function fn_load_products_extra_data($products, $params, $lang_code)
{
    $products = fn_array_elements_to_keys($products, 'product_id');
    $product_ids = array_keys($products);
    $extra_fields = array();
    // Fields from "products" table
    $extra_fields['?:products'] = array('primary_key' => 'product_id', 'fields' => empty($params['only_short_fields']) ? array('*') : array('product_id', 'product_code', 'product_type', 'status', 'company_id', 'list_price', 'amount', 'weight', 'tracking', 'is_edp'));
    // Load prices lazily when they are needed and no sorting or filtering by price is applied
    if (in_array('prices', $params['extend']) && $params['sort_by'] != 'price' && !in_array('prices2', $params['extend'])) {
        $extra_fields['?:product_prices'] = array('primary_key' => 'product_id', 'fields' => array('price' => 'MIN(IF(' . '?:product_prices.percentage_discount = 0,' . '?:product_prices.price,' . '?:product_prices.price - (?:product_prices.price * ?:product_prices.percentage_discount)/100' . '))'), 'condition' => db_quote(' AND ?:product_prices.lower_limit = 1 AND ?:product_prices.usergroup_id IN (?n)', $params['area'] == 'A' ? USERGROUP_ALL : array_unique(array_merge(array(USERGROUP_ALL), $_SESSION['auth']['usergroup_ids']))), 'group_by' => ' GROUP BY ?:product_prices.product_id');
    }
    // Descriptions
    $extra_fields['?:product_descriptions']['primary_key'] = 'product_id';
    $extra_fields['?:product_descriptions']['condition'] = db_quote(" AND ?:product_descriptions.lang_code = ?s", $lang_code);
    if (in_array('search_words', $params['extend'])) {
        $extra_fields['?:product_descriptions']['fields'][] = 'search_words';
    }
    if (in_array('description', $params['extend'])) {
        $extra_fields['?:product_descriptions']['fields'][] = 'short_description';
        if (in_array('full_description', $params['extend'])) {
            $extra_fields['?:product_descriptions']['fields'][] = 'full_description';
        } else {
            $extra_fields['?:product_descriptions']['fields']['full_description'] = "IF(?:product_descriptions.short_description = '', ?:product_descriptions.full_description, '')";
        }
    }
    // Categories
    if (in_array('categories', $params['extend'])) {
        $categories_join = ' INNER JOIN ?:categories ON ?:categories.category_id = ?:products_categories.category_id';
        if ($params['area'] == 'C') {
            if (!fn_is_preview_action($_SESSION['auth'], $params)) {
                $categories_join .= ' AND (' . fn_find_array_in_set($_SESSION['auth']['usergroup_ids'], '?:categories.usergroup_ids', true) . ')';
            }
            $categories_join .= db_quote(' AND ?:categories.status IN (?a) ', array('A', 'H'));
        }
        $extra_fields['?:products_categories'] = array('primary_key' => 'product_id', 'fields' => array('category_ids' => 'GROUP_CONCAT(' . 'IF(?:products_categories.link_type = "M",' . ' CONCAT(?:products_categories.category_id, "M"),' . ' ?:products_categories.category_id)' . ')', 'position' => '?:products_categories.position'), 'condition' => fn_get_localizations_condition('?:categories.localization', true), 'join' => $categories_join, 'group_by' => ' GROUP BY ?:products_categories.product_id');
        if (!empty($params['cid'])) {
            $extra_fields['?:products_categories']['group_by'] .= db_quote(' ,?:products_categories.category_id = ?i', $params['cid']);
        }
    }
    /**
     * Allows you to extend configuration of extra fields that should be lazily loaded for products.
     *
     * @see fn_load_extra_data_by_item_ids()
     * @param array  $extra_fields
     * @param array  $products     List of products
     * @param array  $product_ids  List of product identifiers
     * @param array  $params       Parameters passed to fn_get_products()
     * @param string $lang_code    Language code passed to fn_get_products()
     */
    fn_set_hook('load_products_extra_data', $extra_fields, $products, $product_ids, $params, $lang_code);
    // Execute extra data loading SQL-queries and merge results into $products array
    fn_merge_extra_data_to_entity_list(fn_load_extra_data_by_entity_ids($extra_fields, $product_ids), $products);
    // Categories post-processing
    if (in_array('categories', $params['extend'])) {
        foreach ($products as $k => $v) {
            list($products[$k]['category_ids'], $products[$k]['main_category']) = fn_convert_categories($v['category_ids']);
        }
    }
    /**
     * Allows you lazily load extra data for products after they were fetched from DB or post-process lazy-loaded
     * additional data related to products.
     *
     * @param array  $products    List of products
     * @param array  $product_ids List of product identifiers
     * @param array  $params      Parameters passed to fn_get_products()
     * @param string $lang_code   Language code passed to fn_get_products()
     */
    fn_set_hook('load_products_extra_data_post', $products, $product_ids, $params, $lang_code);
    return $products;
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:80,代码来源:fn.catalog.php

示例9: die

* license  and  accept  to the terms of the  License Agreement can install *
* and use this program.                                                    *
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'poll_submit') {
        if (empty($_REQUEST['page_id'])) {
            return array(CONTROLLER_STATUS_NO_PAGE);
        }
        $condition = " AND (" . fn_find_array_in_set(Tygh::$app['session']['auth']['usergroup_ids'], '?:pages.usergroup_ids', true) . ")";
        $poll_data = db_get_row("SELECT * FROM ?:pages INNER JOIN ?:page_descriptions ON ?:pages.page_id = ?:page_descriptions.page_id WHERE ?:pages.page_id = ?i AND ?:page_descriptions.lang_code = ?s ?p", $_REQUEST['page_id'], CART_LANGUAGE, $condition);
        if (empty($poll_data) || $poll_data['status'] == 'D' || $poll_data['use_avail_period'] == 'Y' && ($poll_data['avail_from_timestamp'] > TIME || $poll_data['avail_till_timestamp'] < TIME)) {
            return array(CONTROLLER_STATUS_REDIRECT);
        }
        $ip = fn_get_ip();
        if (db_get_field('SELECT vote_id FROM ?:polls_votes WHERE page_id = ?i AND ip_address = ?s', $_REQUEST['page_id'], fn_ip_to_db($ip['host']))) {
            return array(CONTROLLER_STATUS_REDIRECT);
        }
        $prefix = isset($_REQUEST['obj_prefix']) ? $_REQUEST['obj_prefix'] : '';
        if (fn_image_verification('polls', $_REQUEST) == false) {
            return array(CONTROLLER_STATUS_REDIRECT);
        }
        if (!empty($_REQUEST['answer'])) {
            $answer = $_REQUEST['answer'];
        } else {
开发者ID:ambient-lounge,项目名称:site,代码行数:31,代码来源:pages.post.php

示例10: die

<?php

//
// $Id: pages.post.php 8091 2009-10-19 08:29:55Z lexa $
//
if (!defined('AREA')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'poll_submit') {
        if (empty($_REQUEST['page_id'])) {
            return array(CONTROLLER_STATUS_NO_PAGE);
        }
        $condition = " AND (" . fn_find_array_in_set($_SESSION['auth']['usergroup_ids'], '?:pages.usergroup_ids', true) . ")";
        $poll_data = db_get_row("SELECT * FROM ?:pages INNER JOIN ?:page_descriptions ON ?:pages.page_id = ?:page_descriptions.page_id WHERE ?:pages.page_id = ?i AND ?:page_descriptions.lang_code = ?s ?p", $_REQUEST['page_id'], CART_LANGUAGE, $condition);
        if (empty($poll_data) || $poll_data['status'] == 'D' || $poll_data['use_avail_period'] == 'Y' && ($poll_data['avail_from_timestamp'] > TIME || $poll_data['avail_till_timestamp'] < TIME)) {
            return array(CONTROLLER_STATUS_REDIRECT);
        }
        $ip = fn_get_ip();
        if (db_get_field('SELECT vote_id FROM ?:polls_votes WHERE page_id = ?i AND ip_address = ?s', $_REQUEST['page_id'], $ip['host'])) {
            return array(CONTROLLER_STATUS_REDIRECT);
        }
        if (Registry::get('settings.Image_verification.use_for_polls') == 'Y' && fn_image_verification('poll_' . $_REQUEST['page_id'], empty($_REQUEST['verification_answer']) ? '' : $_REQUEST['verification_answer']) == false) {
            return array(CONTROLLER_STATUS_REDIRECT);
        }
        if (!empty($_REQUEST['answer'])) {
            $answer = $_REQUEST['answer'];
        } else {
            $answer = array();
        }
        if (!empty($_REQUEST['answer_text'])) {
开发者ID:diedsmiling,项目名称:busenika,代码行数:31,代码来源:pages.post.php

示例11: fn_calculate_shipping_rates

function fn_calculate_shipping_rates(&$cart, &$cart_products, $auth, $calculate_selected = false)
{
    $shipping_rates = array();
    $condition = '';
    if ($calculate_selected == true) {
        $shipping_ids = !empty($cart['shipping']) ? array_keys($cart['shipping']) : array();
        if (!empty($shipping_ids)) {
            $condition = db_quote(" AND a.shipping_id IN (?n)", $shipping_ids);
        } else {
            return array();
        }
    }
    $condition .= fn_get_localizations_condition('a.localization');
    $location = fn_get_customer_location($auth, $cart);
    $destination_id = fn_get_available_destination($location);
    $package_infos = fn_prepare_package_info($cart, $cart_products);
    foreach ($package_infos as $o_id => $package_info) {
        $c = fn_get_company_condition('a.company_id', false, $o_id, false, true);
        $companies = Registry::get('s_companies');
        if (!empty($companies) && !empty($companies[$o_id]['shippings'])) {
            if (trim($c)) {
                $c = "{$c} OR ";
            }
            $c .= db_quote('a.shipping_id IN (?n)', explode(',', $companies[$o_id]['shippings']));
            $c = "({$c})";
        }
        if (trim($c)) {
            $c = " AND {$c}";
        }
        //TODO select companies shippings
        fn_set_hook('calculate_shipping_rates', $c, $o_id);
        if (AREA == 'C') {
            $condition .= " AND (" . fn_find_array_in_set($auth['usergroup_ids'], 'a.usergroup_ids', true) . ")";
        }
        $shipping_methods = db_get_hash_array("SELECT a.shipping_id, a.rate_calculation, a.service_id, a.self_service, b.shipping as name, b.delivery_time FROM ?:shippings as a LEFT JOIN ?:shipping_descriptions as b ON a.shipping_id = b.shipping_id AND b.lang_code = ?s WHERE (a.min_weight <= ?d AND (a.max_weight >= ?d OR a.max_weight = 0.00)) AND a.status = 'A' ?p ?p ORDER BY a.position", 'shipping_id', CART_LANGUAGE, $package_info['W'], $package_info['W'], $condition, $c);
        if (empty($shipping_methods)) {
            continue;
        }
        $found_rates = array();
        foreach ($shipping_methods as $method) {
            // Manual rate calculation
            if ($method['rate_calculation'] == 'M') {
                if ($destination_id !== false) {
                    $rate_data = db_get_row("SELECT rate_id, rate_value FROM ?:shipping_rates WHERE shipping_id = ?i AND destination_id = ?i", $method['shipping_id'], $destination_id);
                    if (!empty($rate_data)) {
                        $found_rates[$method['shipping_id']] = fn_calculate_shipping_rate($package_info, $rate_data['rate_value']);
                    }
                }
                // Realtime rate calculation
            } else {
                $charge = db_get_field("SELECT rate_value FROM ?:shipping_rates WHERE shipping_id = ?i AND destination_id = 0", $method['shipping_id']);
                $rate_data = fn_calculate_realtime_shipping_rate($method['service_id'], $location, $package_info, $auth);
                if ($rate_data !== false) {
                    $found_rates[$method['shipping_id']] = $rate_data['cost'];
                    $found_rates[$method['shipping_id']] += fn_calculate_shipping_rate($package_info, $charge);
                }
            }
        }
        $shipping_freight = 0;
        foreach ($cart_products as $v) {
            if (($v['is_edp'] != 'Y' || $v['is_edp'] == 'Y' && $v['edp_shipping'] == 'Y') && $v['free_shipping'] != 'Y') {
                $shipping_freight += $v['shipping_freight'] * $v['amount'];
            }
        }
        foreach ($shipping_methods as $method) {
            $shipping_rates[$method['shipping_id']]['name'] = $method['name'];
            $shipping_rates[$method['shipping_id']]['delivery_time'] = $method['delivery_time'];
            $shipping_rates[$method['shipping_id']]['rates'] = array();
            $shipping_rates[$method['shipping_id']]['self_service'] = $method['self_service'];
        }
        foreach ($found_rates as $shipping_id => $rate_value) {
            /*if (!isset($shipping_rates[$shipping_id])) {
            			$shipping_rates[$shipping_id]['name'] = $shipping_methods[$shipping_id]['name'];
            			$shipping_rates[$shipping_id]['delivery_time'] = $shipping_methods[$shipping_id]['delivery_time'];
            		}*/
            $shipping_rates[$shipping_id]['rates'][$o_id] = $rate_value + $shipping_freight;
        }
    }
    return $shipping_rates;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:80,代码来源:fn.cart.php

示例12: processResponse

 /**
  * Gets shipping cost and information about possible errors
  *
  * @param string $response
  * @internal param string $resonse Reponse from Shipping service server
  * @return array Shipping cost and errors
  */
 public function processResponse($response)
 {
     $return = array('cost' => false, 'error' => false, 'delivery_time' => false);
     $location = $this->_shipping_info['package_info']['location'];
     $service_params = $this->_shipping_info['service_params'];
     $destination_id = fn_get_available_destination($location);
     if (!empty($destination_id)) {
         $condition = db_quote(" AND a.status = ?s AND b.lang_code = ?s", 'A', DESCR_SL);
         $condition .= ' AND (' . fn_find_array_in_set(array($destination_id), 'a.pickup_destinations_ids', true) . ')';
         $join = db_quote(" LEFT JOIN ?:store_location_descriptions as b ON a.store_location_id = b.store_location_id");
         $fields = array('a.*', 'b.*');
         $fields = implode(', ', $fields);
         $_stores = db_get_hash_array("SELECT {$fields} FROM ?:store_locations as a {$join} WHERE 1 {$condition}", 'store_location_id');
         if (!empty($_stores)) {
             $stores = array();
             if (!empty($service_params['active_stores'])) {
                 foreach ($service_params['active_stores'] as $key => $id) {
                     if (isset($_stores[$id])) {
                         $stores[$id] = $_stores[$id];
                         $stores[$id]['shipping_position'] = $key;
                     }
                 }
                 if (!empty($service_params['sorting'])) {
                     $sorting = $service_params['sorting'];
                 } else {
                     $sorting = 'shipping_position';
                 }
                 $stores = fn_sort_array_by_key($stores, $sorting);
             } else {
                 $stores = $_stores;
             }
             if (!empty($stores)) {
                 $this->_fillSessionData($stores);
             } else {
                 $this->_internalError(__('stores_sort_nothing_found'));
             }
         } else {
             $this->_internalError(__('stores_nothing_found'));
         }
         if (empty($this->_error_stack)) {
             $pickup_surcharge = $this->_checkStoreCost($stores);
             $return['cost'] = $pickup_surcharge;
         } else {
             $return['error'] = $this->processErrors($response);
         }
     } else {
         $this->_internalError(__('destination_nothing_found'));
         $return['error'] = $this->processErrors($response);
     }
     return $return;
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:58,代码来源:Pickup.php

示例13: fn_get_page_data

function fn_get_page_data($page_id, $lang_code = CART_LANGUAGE, $preview = false)
{
    static $cache = array();
    if (empty($page_id)) {
        return false;
    }
    if (empty($cache[$page_id])) {
        $condition = '';
        $condition .= fn_get_company_condition('?:pages.company_id');
        if (AREA != 'A') {
            $condition .= " AND (" . fn_find_array_in_set($_SESSION['auth']['usergroup_ids'], '?:pages.usergroup_ids', true) . ")";
        }
        $cache[$page_id] = db_get_row("SELECT * FROM ?:pages INNER JOIN ?:page_descriptions ON ?:pages.page_id = ?:page_descriptions.page_id WHERE ?:pages.page_id = ?i AND ?:page_descriptions.lang_code = ?s ?p", $page_id, $lang_code, $condition);
        if (empty($cache[$page_id]) || AREA != 'A' && ($cache[$page_id]['status'] == 'D' || $cache[$page_id]['use_avail_period'] == 'Y' && ($cache[$page_id]['avail_from_timestamp'] > TIME || $cache[$page_id]['avail_till_timestamp'] < TIME)) && empty($preview)) {
            return false;
        }
        fn_set_hook('get_page_data', $cache[$page_id], $lang_code);
        // Generate meta description automatically
        if (empty($cache[$page_id]['meta_description']) && defined('AUTO_META_DESCRIPTION') && AREA != 'A') {
            $cache[$page_id]['meta_description'] = fn_generate_meta_description($cache[$page_id]['description']);
        }
    }
    return !empty($cache[$page_id]) ? $cache[$page_id] : false;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:24,代码来源:fn.cms.php

示例14: fn_get_attachment

function fn_get_attachment($attachment_id)
{
    $auth = Tygh::$app['session']['auth'];
    $condition = '';
    if (AREA != 'A') {
        $condition = ' AND (' . fn_find_array_in_set($auth['usergroup_ids'], 'usergroup_ids', true) . ") AND status = 'A'";
    }
    $data = db_get_row("SELECT * FROM ?:attachments WHERE attachment_id = ?i ?p", $attachment_id, $condition);
    fn_set_hook('attachments_get_attachment', $data, $attachment_id);
    if (!empty($data)) {
        Storage::instance('attachments')->get($data['object_type'] . '/' . $data['object_id'] . '/' . $data['filename']);
    }
    exit;
}
开发者ID:ambient-lounge,项目名称:site,代码行数:14,代码来源:func.php

示例15: fn_get_checkout_payment_buttons

function fn_get_checkout_payment_buttons(&$cart, &$cart_products, &$auth)
{
    $checkout_buttons = array();
    $ug_condition = 'AND (' . fn_find_array_in_set($auth['usergroup_ids'], 'b.usergroup_ids', true) . ')';
    $checkout_payments = db_get_fields("SELECT b.payment_id FROM ?:payment_processors as a LEFT JOIN ?:payments as b ON a.processor_id = b.processor_id WHERE a.type != 'P' AND b.status = 'A' ?p", $ug_condition);
    if (!empty($checkout_payments)) {
        foreach ($checkout_payments as $_payment_id) {
            $processor_data = fn_get_processor_data($_payment_id);
            if (!empty($processor_data['processor_script']) && file_exists(DIR_PAYMENT_FILES . $processor_data['processor_script'])) {
                include DIR_PAYMENT_FILES . $processor_data['processor_script'];
            }
        }
    }
    return $checkout_buttons;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:15,代码来源:checkout.php


注:本文中的fn_find_array_in_set函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。