function save() { $jshopConfig = JSFactory::getConfig(); $tab = JRequest::getVar('tab'); $db = JFactory::getDBO(); $dispatcher = JDispatcher::getInstance(); $extconf = array('imageheader' => 'header.jpg', 'imagefooter' => 'footer.jpg'); $post = JRequest::get("post"); $dispatcher->trigger('onBeforeSaveConfig', array(&$post, &$extconf)); //general $array = array('display_price_admin', 'display_price_front', 'use_ssl', 'savelog', 'savelogpaymentdata'); if ($tab == 1) { foreach ($array as $key => $value) { if (!isset($post[$value])) { $post[$value] = 0; } } } if ($tab == 3) { $result = array(); if ($jshopConfig->other_config != '') { $result = unserialize($jshopConfig->other_config); } $config = new stdClass(); include $jshopConfig->path . 'lib/default_config.php'; foreach ($image_other_config as $k) { $result[$k] = $post[$k]; } $post['other_config'] = serialize($result); } if ($tab == 5) { $vendor = JSFactory::getTable('vendor', 'jshop'); $post = JRequest::get("post"); $vendor->id = $post['vendor_id']; $vendor->main = 1; $vendor->bind($post); $vendor->store(); } //category/product $array = array('show_buy_in_category', 'show_tax_in_product', 'show_tax_product_in_cart', 'show_plus_shipping_in_product', 'hide_product_not_avaible_stock', 'hide_buy_not_avaible_stock', 'show_sort_product', 'show_count_select_products', 'show_delivery_time', 'demo_type', 'product_show_manufacturer_logo', 'product_show_weight', 'product_attribut_first_value_empty', 'show_hits', 'allow_reviews_prod', 'allow_reviews_only_registered', 'hide_text_product_not_available', 'use_plugin_content', 'product_list_show_weight', 'product_list_show_manufacturer', 'show_product_code', 'product_list_show_min_price', 'show_product_list_filters', 'product_list_show_vendor', 'product_show_vendor', 'product_show_vendor_detail', 'product_show_button_back', 'product_list_show_product_code', 'radio_attr_value_vertical', 'attr_display_addprice', 'product_list_show_price_description', 'display_button_print', 'product_list_show_price_default'); if ($tab == 6) { foreach ($array as $key => $value) { if (!isset($post[$value])) { $post[$value] = 0; } } $result = array(); if ($jshopConfig->other_config != '') { $result = unserialize($jshopConfig->other_config); } $config = new stdClass(); include $jshopConfig->path . 'lib/default_config.php'; foreach ($catprod_other_config as $k) { $result[$k] = $post[$k]; } $post['other_config'] = serialize($result); } //case $array = array('hide_shipping_step', 'hide_payment_step', 'order_send_pdf_client', 'order_send_pdf_admin', 'hide_tax', 'show_registerform_in_logintemplate', 'sorting_country_in_alphabet', 'show_weight_order', 'discount_use_full_sum', 'show_cart_all_step_checkout', "show_product_code_in_cart", 'show_return_policy_in_email_order', 'client_allow_cancel_order', 'admin_not_send_email_order_vendor_order', 'not_redirect_in_cart_after_buy', 'calcule_tax_after_discount'); if ($tab == 7) { if (!$post['next_order_number']) { unset($post['next_order_number']); } foreach ($array as $key => $value) { if (!isset($post[$value])) { $post[$value] = 0; } } $result = array(); if ($jshopConfig->other_config != '') { $result = unserialize($jshopConfig->other_config); } $config = new stdClass(); include $jshopConfig->path . 'lib/default_config.php'; foreach ($checkout_other_config as $k) { $result[$k] = $post[$k]; } $post['other_config'] = serialize($result); } //shop function $array = array('without_shipping', 'without_payment', 'enable_wishlist', 'shop_user_guest', 'user_as_catalog', 'use_rabatt_code', 'admin_show_product_basic_price', 'admin_show_attributes', 'admin_show_delivery_time', 'admin_show_languages', 'use_different_templates_cat_prod', 'admin_show_product_video', 'admin_show_product_related', 'admin_show_product_files', 'admin_show_product_bay_price', 'admin_show_product_basic_price', 'admin_show_product_labels', 'admin_show_product_extra_field', 'admin_show_vendors', 'admin_show_freeattributes', 'use_extend_attribute_data'); if ($tab == 8) { foreach ($array as $key => $value) { if (!isset($post[$value])) { $post[$value] = 0; } } $post['without_shipping'] = intval(!$post['without_shipping']); $post['without_payment'] = intval(!$post['without_payment']); $result = array(); if ($jshopConfig->other_config != '') { $result = unserialize($jshopConfig->other_config); } $config = new stdClass(); include $jshopConfig->path . 'lib/default_config.php'; foreach ($adminfunction_other_config as $k) { $result[$k] = $post[$k]; } $post['other_config'] = serialize($result); } if ($tab == 9) { $config = new stdClass(); include $jshopConfig->path . 'lib/default_config.php'; foreach ($fields_client_sys as $k => $v) { foreach ($v as $v2) { $post['field'][$k][$v2]['require'] = 1; $post['field'][$k][$v2]['display'] = 1; } } foreach ($post['field'] as $k => $v) { foreach ($v as $k2 => $v2) { if (!$post['field'][$k][$k2]['display']) { $post['field'][$k][$k2]['require'] = 0; } } } $post['fields_register'] = serialize($post['field']); } if ($tab == 10) { $result = array(); $config = new stdClass(); include $jshopConfig->path . 'lib/default_config.php'; if ($jshopConfig->other_config != '') { $result = unserialize($jshopConfig->other_config); } foreach ($other_config as $k) { $result[$k] = $post[$k]; } $post['other_config'] = serialize($result); } if ($tab != 4) { $config = new jshopConfig($db); $config->id = $jshopConfig->load_id; if (!$config->bind($post)) { JError::raiseWarning("", _JSHOP_ERROR_BIND); $this->setRedirect('index.php?option=com_jshopping&controller=config'); return 0; } if ($tab == 6 && $jshopConfig->admin_show_product_extra_field) { if (!isset($post['product_list_display_extra_fields'])) { $post['product_list_display_extra_fields'] = array(); } if (!isset($post['filter_display_extra_fields'])) { $post['filter_display_extra_fields'] = array(); } if (!isset($post['product_hide_extra_fields'])) { $post['product_hide_extra_fields'] = array(); } if (!isset($post['cart_display_extra_fields'])) { $post['cart_display_extra_fields'] = array(); } $config->setProductListDisplayExtraFields($post['product_list_display_extra_fields']); $config->setFilterDisplayExtraFields($post['filter_display_extra_fields']); $config->setProductHideExtraFields($post['product_hide_extra_fields']); $config->setCartDisplayExtraFields($post['cart_display_extra_fields']); } $config->transformPdfParameters(); if (!$config->store()) { JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE . " " . $config->_error); $this->setRedirect('index.php?option=com_jshopping&controller=config'); return 0; } } if (isset($_FILES['header'])) { if ($_FILES['header']['size']) { @unlink($jshopConfig->path . "images/" . $extconf['imageheader']); move_uploaded_file($_FILES['header']['tmp_name'], $jshopConfig->path . "images/" . $extconf['imageheader']); } } if (isset($_FILES['footer'])) { if ($_FILES['footer']['size']) { @unlink($jshopConfig->path . "images/" . $extconf['imagefooter']); move_uploaded_file($_FILES['footer']['tmp_name'], $jshopConfig->path . "images/" . $extconf['imagefooter']); } } if (isset($post['update_count_prod_rows_all_cats']) && $tab == 6 && $post['update_count_prod_rows_all_cats']) { $count_products_to_page = intval($post['count_products_to_page']); $count_products_to_row = intval($post['count_products_to_row']); $query = "update `#__jshopping_categories` set `products_page`='" . $count_products_to_page . "', `products_row`='" . $count_products_to_row . "'"; $db->setQuery($query); $db->query(); $query = "update `#__jshopping_manufacturers` set `products_page`='" . $count_products_to_page . "', `products_row`='" . $count_products_to_row . "'"; $db->setQuery($query); $db->query(); } $dispatcher->trigger('onAfterSaveConfig', array()); if ($this->getTask() == 'apply') { switch ($tab) { case 1: $task = "general"; break; case 2: $task = "currency"; break; case 3: $task = "image"; break; case 5: $task = "storeinfo"; break; case 6: $task = "catprod"; break; case 7: $task = "checkout"; break; case 8: $task = "adminfunction"; break; case 9: $task = "fieldregister"; break; case 10: $task = "otherconfig"; break; } $this->setRedirect('index.php?option=com_jshopping&controller=config&task=' . $task, _JSHOP_CONFIG_SUCCESS); } else { $this->setRedirect('index.php?option=com_jshopping&controller=config', _JSHOP_CONFIG_SUCCESS); } }