// Optimizations and clean ajax.php
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16087 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -161,79 +161,6 @@ if (Tools::isSubmit('toggleScreencast'))
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('getAdminHomeElement'))
|
||||
{
|
||||
$result = array();
|
||||
|
||||
$protocol = Tools::usingSecureMode() ? 'https' : 'http';
|
||||
$isoUser = Context::getContext()->language->iso_code;
|
||||
$isoCountry = Context::getContext()->country->iso_code;
|
||||
$stream_context = @stream_context_create(array('http' => array('method'=> 'GET', 'timeout' => 5)));
|
||||
|
||||
// SCREENCAST
|
||||
if (@fsockopen('api.prestashop.com', 80, $errno, $errst, 3))
|
||||
$result['screencast'] = 'OK';
|
||||
else
|
||||
$result['screencast'] = 'NOK';
|
||||
|
||||
// PREACTIVATION
|
||||
$content = @file_get_contents($protocol.'://api.prestashop.com/partner/preactivation/preactivation-block.php?version=1.0&shop='.urlencode(Configuration::get('PS_SHOP_NAME')).'&protocol='.$protocol.'&url='.urlencode($_SERVER['HTTP_HOST']).'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)Context::getContext()->language->id.'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&date_creation='._PS_CREATION_DATE_.'&v='._PS_VERSION_.'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $stream_context);
|
||||
if (!$content)
|
||||
$result['partner_preactivation'] = 'NOK';
|
||||
else
|
||||
{
|
||||
$content = explode('|', $content);
|
||||
if ($content[0] == 'OK' && Validate::isCleanHtml($content[2]) && Validate::isCleanHtml($content[1]))
|
||||
{
|
||||
$result['partner_preactivation'] = $content[2];
|
||||
$content[1] = explode('#%#', $content[1]);
|
||||
foreach ($content[1] as $partnerPopUp)
|
||||
if ($partnerPopUp)
|
||||
{
|
||||
$partnerPopUp = explode('%%', $partnerPopUp);
|
||||
if (!Configuration::get('PS_PREACTIVATION_'.strtoupper($partnerPopUp[0])))
|
||||
{
|
||||
$result['partner_preactivation'] .= $partnerPopUp[1];
|
||||
Configuration::updateValue('PS_PREACTIVATION_'.strtoupper($partnerPopUp[0]), 'TRUE');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
$result['partner_preactivation'] = 'NOK';
|
||||
}
|
||||
|
||||
// PREACTIVATION PAYPAL WARNING
|
||||
$content = @file_get_contents('https://api.prestashop.com/partner/preactivation/preactivation-warnings.php?version=1.0&partner=paypal&iso_country='.Tools::strtolower(Context::getContext()->country->iso_code).'&iso_lang='.Tools::strtolower(Context::getContext()->language->iso_code).'&id_lang='.(int)Context::getContext()->language->id.'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $stream_context);
|
||||
$content = explode('|', $content);
|
||||
if ($content[0] == 'OK' && Validate::isCleanHtml($content[1]))
|
||||
Configuration::updateValue('PS_PREACTIVATION_PAYPAL_WARNING', $content[1]);
|
||||
else
|
||||
Configuration::updateValue('PS_PREACTIVATION_PAYPAL_WARNING', '');
|
||||
|
||||
// DISCOVER PRESTASHOP
|
||||
$content = @file_get_contents($protocol.'://api.prestashop.com/partner/prestashop/prestashop-link.php?iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)Context::getContext()->language->id, false, $stream_context);
|
||||
if (!$content)
|
||||
$result['discover_prestashop'] = 'NOK';
|
||||
else
|
||||
{
|
||||
$content = explode('|', $content);
|
||||
if ($content[0] == 'OK' && Validate::isCleanHtml($content[1]))
|
||||
$result['discover_prestashop'] = $content[1];
|
||||
else
|
||||
$result['discover_prestashop'] = 'NOK';
|
||||
|
||||
if (@fsockopen('api.prestashop.com', 80, $errno, $errst, 3))
|
||||
$result['discover_prestashop'] .= '<iframe frameborder="no" style="margin: 0px; padding: 0px; width: 315px; height: 290px;" src="'.$protocol.'://api.prestashop.com/rss/news2.php?v='._PS_VERSION_.'&lang='.$isoUser.'"></iframe>';
|
||||
|
||||
$content = @file_get_contents($protocol.'://api.prestashop.com/partner/paypal/paypal-tips.php?protocol='.$protocol.'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)Context::getContext()->language->id, false, $stream_context);
|
||||
$content = explode('|', $content);
|
||||
if ($content[0] == 'OK' && Validate::isCleanHtml($content[1]))
|
||||
$result['discover_prestashop'] .= $content[1];
|
||||
}
|
||||
|
||||
die(Tools::jsonEncode($result));
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('getChildrenCategories') && Tools::isSubmit('id_category_parent'))
|
||||
{
|
||||
$children_categories = Category::getChildrenWithNbSelectedSubCat(Tools::getValue('id_category_parent'), Tools::getValue('selectedCat'), Context::getContext()->language->id, null, Tools::getValue('use_shop_context'));
|
||||
|
||||
@@ -2698,9 +2698,7 @@ class ProductCore extends ObjectModel
|
||||
*/
|
||||
public static function sqlStock($product_alias, $product_attribute = 0, $inner_join = false, Shop $shop = null)
|
||||
{
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$id_shop = ($shop !== null ? (int)$shop->id : null);
|
||||
$sql = (($inner_join) ? ' INNER ' : ' LEFT ').'
|
||||
JOIN '._DB_PREFIX_.'stock_available stock
|
||||
ON (stock.id_product = '.pSQL($product_alias).'.id_product';
|
||||
@@ -2715,7 +2713,7 @@ class ProductCore extends ObjectModel
|
||||
$sql .= ' AND stock.id_product_attribute = IFNULL('.pSQL($product_attribute).'.id_product_attribute, 0)';
|
||||
}
|
||||
|
||||
$sql .= StockAvailable::addSqlShopRestriction(null, $shop->id, 'stock').' )';
|
||||
$sql .= StockAvailable::addSqlShopRestriction(null, $id_shop, 'stock').' )';
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
@@ -293,9 +293,6 @@ class StockAvailableCore extends ObjectModel
|
||||
*/
|
||||
public static function getQuantityAvailableByProduct($id_product = null, $id_product_attribute = null, $id_shop = null)
|
||||
{
|
||||
if ($id_shop === null)
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
|
||||
// if null, it's a product without attributes
|
||||
if ($id_product_attribute === null)
|
||||
$id_product_attribute = 0;
|
||||
@@ -309,7 +306,6 @@ class StockAvailableCore extends ObjectModel
|
||||
$query->where('id_product = '.(int)$id_product);
|
||||
|
||||
$query->where('id_product_attribute = '.(int)$id_product_attribute);
|
||||
|
||||
$query = StockAvailable::addSqlShopRestriction($query, $id_shop);
|
||||
|
||||
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
|
||||
@@ -527,9 +523,6 @@ class StockAvailableCore extends ObjectModel
|
||||
*/
|
||||
public static function dependsOnStock($id_product, $id_shop = null)
|
||||
{
|
||||
if ($id_shop === null)
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('depends_on_stock');
|
||||
$query->from('stock_available');
|
||||
@@ -550,9 +543,6 @@ class StockAvailableCore extends ObjectModel
|
||||
*/
|
||||
public static function outOfStock($id_product, $id_shop = null)
|
||||
{
|
||||
if ($id_shop === null)
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('out_of_stock');
|
||||
$query->from('stock_available');
|
||||
|
||||
Reference in New Issue
Block a user