function fn_get_discussion($object_id, $object_type, $get_posts = false, $params = array()) { static $cache = array(); static $customer_companies = null; $_cache_key = $object_id . '_' . $object_type; if (empty($cache[$_cache_key])) { $discussion = db_get_row("SELECT thread_id, type, object_type FROM ?:discussion WHERE object_id = ?i AND object_type = ?s ?p", $object_id, $object_type, fn_get_discussion_company_condition('?:discussion.company_id')); if (empty($discussion) && $object_type == 'M') { $company_discussion_type = Registry::ifGet('addons.discussion.company_discussion_type', 'D'); if ($company_discussion_type != 'D') { $discussion = array('object_type' => 'M', 'object_id' => $object_id, 'type' => $company_discussion_type); if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) { $discussion['company_id'] = Registry::get('runtime.company_id'); } $discussion['thread_id'] = db_query('INSERT INTO ?:discussion ?e', $discussion); } } if (!empty($discussion) && AREA == 'C' && $object_type == 'M' && Registry::ifGet('addons.discussion.company_only_buyers', 'Y') == 'Y') { if (empty($_SESSION['auth']['user_id'])) { $discussion['disable_adding'] = true; } else { if ($customer_companies === null) { $customer_companies = db_get_hash_single_array('SELECT company_id FROM ?:orders WHERE user_id = ?i', array('company_id', 'company_id'), $_SESSION['auth']['user_id']); } if (empty($customer_companies[$object_id])) { $discussion['disable_adding'] = true; } } } fn_set_hook('get_discussion', $object_id, $object_type, $discussion); $cache[$_cache_key] = $discussion; } if (!empty($cache[$_cache_key]) && !isset($cache[$_cache_key]['posts']) && $get_posts == true) { $params['thread_id'] = $cache[$_cache_key]['thread_id']; $params['avail_only'] = AREA == 'C'; // FIXME $discussion_object_types = fn_get_discussion_objects(); list($cache[$_cache_key]['posts'], $cache[$_cache_key]['search']) = fn_get_discussion_posts($params, Registry::get('addons.discussion.' . $discussion_object_types[$cache[$_cache_key]['object_type']] . '_posts_per_page')); $cache[$_cache_key]['average_rating'] = fn_get_average_rating($cache[$_cache_key]); } $saved_post_data = fn_restore_post_data('post_data'); if (!empty($saved_post_data)) { $cache[$_cache_key]['post_data'] = $saved_post_data; } return !empty($cache[$_cache_key]) ? $cache[$_cache_key] : false; }
$vendors_per_page = Registry::get('settings.Vendors.vendors_per_page'); list($companies, $search) = fn_get_companies($params, $auth, $vendors_per_page); foreach ($companies as &$company) { $company['logos'] = fn_get_logos($company['company_id']); } Tygh::$app['view']->assign('companies', $companies); Tygh::$app['view']->assign('search', $search); } elseif ($mode == 'apply_for_vendor') { if (Registry::get('settings.Vendors.apply_for_vendor') != 'Y') { return array(CONTROLLER_STATUS_NO_PAGE); } $restored_company_data = fn_restore_post_data('company_data'); if ($restored_company_data) { Tygh::$app['view']->assign('company_data', $restored_company_data); } $restored_user_data = fn_restore_post_data('user_data'); if ($restored_user_data) { Tygh::$app['view']->assign('user_data', $restored_user_data); } $profile_fields = fn_get_profile_fields('A', array(), CART_LANGUAGE, array('get_custom' => true, 'get_profile_required' => true)); Tygh::$app['view']->assign('profile_fields', $profile_fields); Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); fn_add_breadcrumb(__('apply_for_vendor_account')); $_SESSION['apply_for_vendor']['return_url'] = !empty($_REQUEST['return_previous_url']) ? $_REQUEST['return_previous_url'] : fn_url(''); } elseif ($mode == 'products') { $company_data = !empty($_REQUEST['company_id']) ? fn_get_company_data($_REQUEST['company_id']) : array(); if (empty($company_data)) { return array(CONTROLLER_STATUS_NO_PAGE); } $company_id = $company_data['company_id'];
foreach ($company_countries as $code) { if (isset($countries_list[$code])) { $_countries[$code] = $countries_list[$code]; unset($countries_list[$code]); } } $company_data['countries_list'] = $_countries; unset($_countries, $company_countries); } Tygh::$app['view']->assign('countries_list', $countries_list); if ($mode == 'add') { $schema = fn_init_clone_schemas(); Tygh::$app['view']->assign('clone_schema', $schema); } // Get "Company" settings from the DB $settings_values = fn_restore_post_data('update'); $section = Settings::instance()->getSectionByName('Company'); $settings_data = Settings::instance()->getList($section['section_id'], 0, false, $company_id, CART_LANGUAGE); foreach ($settings_data['main'] as $field_id => &$field_data) { unset($field_data['update_for_all']); if (!empty($settings_values) && !empty($settings_values[$field_id])) { $field_data['value'] = $settings_values[$field_id]; } elseif ($mode == 'add') { unset($field_data['value']); } } Tygh::$app['view']->assign('company_settings', $settings_data['main']); unset($settings_data, $section); } Tygh::$app['view']->assign('company_data', $company_data); Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE));
} if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($mode == 'send_form') { $suffix = ''; if (fn_image_verification('use_for_form_builder', $_REQUEST) == false) { fn_save_post_data('form_values'); return array(CONTROLLER_STATUS_REDIRECT, "pages.view?page_id={$_REQUEST['page_id']}"); } if (fn_send_form($_REQUEST['page_id'], empty($_REQUEST['form_values']) ? array() : $_REQUEST['form_values'])) { $suffix = '&sent=Y'; } return array(CONTROLLER_STATUS_OK, "pages.view?page_id={$_REQUEST['page_id']}" . $suffix); } return; } if ($mode == 'view' && !empty($_REQUEST['page_id'])) { $page_is_https = db_get_field("SELECT value FROM ?:form_options WHERE element_type = ?s AND page_id = ?i", FORM_IS_SECURE, $_REQUEST['page_id']); // if form is secure, redirect to https connection if (!defined('HTTPS') && $page_is_https == 'Y') { return array(CONTROLLER_STATUS_REDIRECT, Registry::get('config.https_location') . '/' . Registry::get('config.current_url')); } elseif (defined('HTTPS') && Registry::get('settings.Security.keep_https') != 'Y' && $page_is_https != 'Y') { return array(CONTROLLER_STATUS_REDIRECT, Registry::get('config.http_location') . '/' . Registry::get('config.current_url')); } $restored_form_values = fn_restore_post_data('form_values'); if (!empty($restored_form_values)) { Registry::get('view')->assign('form_values', $restored_form_values); } } elseif ($mode == 'sent' && !empty($_REQUEST['page_id'])) { $page = fn_get_page_data($_REQUEST['page_id'], CART_LANGUAGE); Registry::get('view')->assign('page', $page); }
<?php /*************************************************************************** * * * (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * * * * This is commercial software, only users who have purchased a valid * * 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. * ****************************************************************************/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($mode == 'view') { $restored_send_data = fn_restore_post_data('send_data'); if (!empty($restored_send_data)) { Registry::get('view')->assign('send_data', $restored_send_data); } $params = array('object_id' => (int) $_REQUEST['product_id'], 'object' => $controller, 'lang_code' => CART_LANGUAGE); $provider_settings = fn_get_sb_provider_settings($params); Registry::get('view')->assign('display_button_block', fn_sb_display_block($provider_settings)); Registry::get('view')->assign('provider_settings', $provider_settings); Registry::get('view')->assign('provider_meta_data', fn_get_sb_providers_meta_data($params)); }
} } } fn_redirect($redirect_url, true); } // // Display login form in the mainbox // if ($mode == 'login_form') { if (defined('AJAX_REQUEST') && empty($auth)) { exit; } if (!empty($auth['user_id'])) { return array(CONTROLLER_STATUS_REDIRECT, fn_url()); } $stored_user_login = fn_restore_post_data('user_login'); if (!empty($stored_user_login)) { Registry::get('view')->assign('stored_user_login', $stored_user_login); } if (AREA != 'A') { fn_add_breadcrumb(__('sign_in')); } Registry::get('view')->assign('view_mode', 'simple'); } elseif ($mode == 'password_change' && AREA == 'A') { if (defined('AJAX_REQUEST') && empty($auth)) { exit; } if (empty($auth['user_id'])) { return array(CONTROLLER_STATUS_REDIRECT, fn_url()); } $profile_id = 0;
return array(CONTROLLER_STATUS_OK, 'products.manage'); } if ($mode == 'delete_template') { if (!empty($_REQUEST['template_id'])) { fn_delete_ebay_template($_REQUEST['template_id']); } } return array(CONTROLLER_STATUS_OK, 'ebay.manage'); } if ($mode == 'manage') { $params = $_REQUEST; list($templates, $search) = fn_get_ebay_templates($params, Registry::get('settings.Appearance.admin_items_per_page'), DESCR_SL); Tygh::$app['view']->assign('templates', $templates); Tygh::$app['view']->assign('search', $search); } elseif ($mode == 'add') { $template_data = fn_restore_post_data('template_data'); if (isset($_REQUEST['site_id'])) { $template_data['site_id'] = $_REQUEST['site_id']; } if (isset($template_data['site_id'])) { Ebay::instance()->site_id = $template_data['site_id']; } // [Page sections] Registry::set('navigation.tabs', array('detailed' => array('title' => __('general'), 'js' => true), 'shippings' => array('title' => __('shippings'), 'js' => true), 'payments' => array('title' => __('payments'), 'js' => true), 'returnPolicy' => array('title' => __('return_policy'), 'js' => true))); // [/Page sections] $ebay_root_categories = fn_get_ebay_categories(0); Tygh::$app['view']->assign('ebay_root_categories', $ebay_root_categories); Tygh::$app['view']->assign('template_data', $template_data); } elseif ($mode == 'update') { $template_data = fn_get_ebay_template($_REQUEST['template_id']); if (isset($_REQUEST['site_id'])) {
} elseif ($mode == 'clear_cache') { fn_clear_cache(); fn_set_notification('N', __('notice'), __('cache_cleared')); if (empty($_REQUEST['redirect_url'])) { $_REQUEST['redirect_url'] = 'index.index'; } return array(CONTROLLER_STATUS_REDIRECT); } elseif ($mode == 'clear_thumbnails') { Storage::instance('images')->deleteDir('thumbnails'); fn_set_notification('N', __('notice'), __('thumbnails_removed')); if (empty($_REQUEST['redirect_url'])) { $_REQUEST['redirect_url'] = 'index.index'; } return array(CONTROLLER_STATUS_REDIRECT); } elseif ($mode == 'cdn') { $stored_cdn_data = fn_restore_post_data('cdn_data'); if (Cdn::instance()->getOption('is_active') === false && Cdn::instance()->isActive()) { Cdn::instance()->save(array('is_active' => true)); fn_set_notification('N', __('notice'), __('text_cdn_setup')); } if (Cdn::instance()->getHost()) { Registry::get('view')->assign('cdn_test_url', 'http://' . Cdn::instance()->getHost() . '/js/tygh/core.js'); } if (!empty($stored_cdn_data)) { Registry::get('view')->assign('cdn_data', $stored_cdn_data); } else { Registry::get('view')->assign('cdn_data', Cdn::instance()->getOptions()); } } function fn_get_amazon_regions() {
list($features, $features_search) = fn_get_product_features($feature_params, PRODUCT_FEATURES_THRESHOLD); if ($features_search['total_items'] <= PRODUCT_FEATURES_THRESHOLD) { Tygh::$app['view']->assign('feature_items', $features); } else { Tygh::$app['view']->assign('feature_items_too_many', true); } } // // 'Add new product' page // if ($mode == 'add') { Tygh::$app['view']->assign('taxes', fn_get_taxes()); // [Page sections] Registry::set('navigation.tabs', array('detailed' => array('title' => __('general'), 'js' => true), 'images' => array('title' => __('images'), 'js' => true), 'seo' => array('title' => __('seo'), 'js' => true), 'qty_discounts' => array('title' => __('qty_discounts'), 'js' => true), 'addons' => array('title' => __('addons'), 'js' => true))); // [/Page sections] $product_data = fn_restore_post_data('product_data'); Tygh::$app['view']->assign('product_data', $product_data); // // 'Multiple products addition' page // } elseif ($mode == 'm_add') { // // 'product update' page // } elseif ($mode == 'update') { $selected_section = empty($_REQUEST['selected_section']) ? 'detailed' : $_REQUEST['selected_section']; // Get current product data $skip_company_condition = false; if (fn_allowed_for('ULTIMATE') && fn_ult_is_shared_product($_REQUEST['product_id']) == 'Y') { $skip_company_condition = true; }