Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into bootstrap

Conflicts:
	admin-dev/themes/default/template/controllers/carrier_wizard/helpers/form/form_ranges.tpl
	admin-dev/themes/default/template/controllers/groups/helpers/view/view.tpl
	admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl
	admin-dev/themes/default/template/controllers/modules/filters.tpl
	admin-dev/themes/default/template/controllers/modules/list.tpl
	admin-dev/themes/default/template/controllers/orders/form.tpl
	admin-dev/themes/default/template/helpers/form/form.tpl
	classes/Category.php
	classes/controller/AdminController.php
	controllers/admin/AdminAttributesGroupsController.php
	controllers/admin/AdminFeaturesController.php
	controllers/admin/AdminImportController.php
	controllers/admin/AdminLogsController.php
	install-dev/install_version.php
	install-dev/langs/ru/data/tab.xml
	js/admin_carrier_wizard.js
	modules/loyalty/loyalty.php
This commit is contained in:
Kevin Granger
2013-10-14 12:21:29 +02:00
316 changed files with 8504 additions and 1178 deletions
+10 -12
View File
@@ -398,8 +398,7 @@ var ajaxCart = {
else
{
$('#vouchers tbody').html('');
for (i=0;i<jsonData.discounts.length;i++)
for (i=0; i < jsonData.discounts.length; i++)
{
if (parseFloat(jsonData.discounts[i].price_float) > 0)
{
@@ -408,15 +407,14 @@ var ajaxCart = {
delete_link = '<a class="delete_voucher" href="'+jsonData.discounts[i].link+'" title="'+delete_txt+'"><img src="'+img_dir+'icon/delete.gif" alt="'+delete_txt+'" class="icon" /></a>';
$('#vouchers tbody').append($(
'<tr class="bloc_cart_voucher" id="bloc_cart_voucher_'+jsonData.discounts[i].id+'">'
+' <td class="quantity">1x</td>'
+' <td class="name" title="'+jsonData.discounts[i].description+'">'+jsonData.discounts[i].name+'</td>'
+' <td class="price">-'+jsonData.discounts[i].price+'</td>'
+' <td class="delete">' + delete_link + '</td>'
+'</tr>'
+ '<td class="quantity">1x</td>'
+ '<td class="name" title="'+jsonData.discounts[i].description+'">'+jsonData.discounts[i].name+'</td>'
+ '<td class="price">-'+jsonData.discounts[i].price+'</td>'
+ '<td class="delete">' + delete_link + '</td>'
+ '</tr>'
));
}
}
$('#vouchers').show();
}
@@ -708,18 +706,18 @@ $(document).ready(function(){
function() {
$(this).css('border-radius', '3px 3px 0px 0px');
if (ajaxCart.nb_total_products > 0 || cart_qty > 0)
$("#cart_block").stop(true, true).slideDown(450);
$("#header_right #cart_block").stop(true, true).slideDown(450);
},
function() {
$('#shopping_cart a').css('border-radius', '3px');
setTimeout(function() {
if (!shopping_cart.isHoveringOver() && !cart_block.isHoveringOver())
$("#cart_block").stop(true, true).slideUp(450);
$("#header_right #cart_block").stop(true, true).slideUp(450);
}, 200);
}
);
$("#cart_block").hover(
$("#header_right #cart_block").hover(
function() {
$('#shopping_cart a').css('border-radius', '3px 3px 0px 0px');
},
@@ -727,7 +725,7 @@ $(document).ready(function(){
$('#shopping_cart a').css('border-radius', '3px');
setTimeout(function() {
if (!shopping_cart.isHoveringOver())
$("#cart_block").stop(true, true).slideUp(450);
$("#header_right #cart_block").stop(true, true).slideUp(450);
}, 200);
}
);
+2 -2
View File
@@ -36,7 +36,7 @@
#cart_block #cart_block_summary {display:none}
#cart_block .quantity-formated {
display:inline-block;
margin-right:5px;
padding-right:2px;
min-width:18px;
vertical-align: top;
}
@@ -62,7 +62,7 @@
padding-bottom:10px
}
#cart_block #cart_block_list dt {padding:4px 0}
#cart_block #cart_block_list dt a {font-weight:bold; display: inline-block; width: 95px}
#cart_block #cart_block_list dt a {font-weight:bold; display: inline-block; max-width: 95px}
#cart_block #cart_block_list dd {
margin-left:20px
}
@@ -23,7 +23,7 @@
* International Registered Trademark & Property of PrestaShop SA
*}
<li {if isset($last) && $last == 'true'}class="last"{/if}>
<li class="category_{$node.id}{if isset($last) && $last == 'true'} last{/if}">
<a href="{$node.link|escape:'htmlall':'UTF-8'}" {if isset($currentCategoryId) && $node.id == $currentCategoryId}class="selected"{/if}
title="{$node.desc|strip_tags|trim|escape:'htmlall':'UTF-8'}">{$node.name|escape:'htmlall':'UTF-8'}</a>
{if $node.children|@count > 0}
+2 -4
View File
@@ -1925,7 +1925,7 @@ class BlockLayered extends Module
$(\'#error-treeview\').hide();
updElements(0, 0);
},
\'onComplete\': function() {
\'afterLoad\': function() {
lock_treeview_hidding = true;
$(\'#categories-treeview\').parent().parent().show();
if($($(\'#categories-treeview li\')[0]).attr(\'cleaned\'))
@@ -1934,9 +1934,7 @@ class BlockLayered extends Module
$($(\'#categories-treeview li\')[0]).removeClass(\'static\');
$($(\'#categories-treeview li span\')[0]).trigger(\'click\');
$($(\'#categories-treeview li\')[0]).children(\'div\').remove();
$($(\'#categories-treeview li\')[0]).
removeClass(\'collapsable lastCollapsable\').
addClass(\'last static\');
$($(\'#categories-treeview li\')[0]).removeClass(\'collapsable lastCollapsable\');
$(\'.hitarea\').live(\'click\', function(it)
{
$(this).parent().find(\'> .category_label\').click();
+33 -9
View File
@@ -72,12 +72,16 @@ class Blocktopmenu extends Module
!$this->registerHook('actionObjectCategoryAddAfter') ||
!$this->registerHook('actionObjectCmsUpdateAfter') ||
!$this->registerHook('actionObjectCmsDeleteAfter') ||
!$this->registerHook('actionObjectCmsAddAfter') ||
!$this->registerHook('actionObjectSupplierUpdateAfter') ||
!$this->registerHook('actionObjectSupplierDeleteAfter') ||
!$this->registerHook('actionObjectSupplierAddAfter') ||
!$this->registerHook('actionObjectManufacturerUpdateAfter') ||
!$this->registerHook('actionObjectManufacturerDeleteAfter') ||
!$this->registerHook('actionObjectManufacturerAddAfter') ||
!$this->registerHook('actionObjectProductUpdateAfter') ||
!$this->registerHook('actionObjectProductDeleteAfter') ||
!$this->registerHook('actionObjectProductAddAfter') ||
!$this->registerHook('categoryUpdate') ||
!$this->registerHook('actionShopDataDuplication') ||
!$this->installDB())
@@ -543,21 +547,21 @@ class Blocktopmenu extends Module
$selected = ($this->page_name == 'product' && (Tools::getValue('id_product') == $id)) ? ' class="sfHover"' : '';
$product = new Product((int)$id, true, (int)$id_lang);
if (!is_null($product->id))
$this->_menu .= '<li'.$selected.'><a href="'.htmlentities($product->getLink()).'">'.$product->name.'</a></li>'.PHP_EOL;
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($product->getLink()).'">'.$product->name.'</a></li>'.PHP_EOL;
break;
case 'CMS':
$selected = ($this->page_name == 'cms' && (Tools::getValue('id_cms') == $id)) ? ' class="sfHover"' : '';
$cms = CMS::getLinks((int)$id_lang, array($id));
if (count($cms))
$this->_menu .= '<li'.$selected.'><a href="'.htmlentities($cms[0]['link']).'">'.$cms[0]['meta_title'].'</a></li>'.PHP_EOL;
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($cms[0]['link']).'">'.$cms[0]['meta_title'].'</a></li>'.PHP_EOL;
break;
case 'CMS_CAT':
$category = new CMSCategory((int)$id, (int)$id_lang);
if (count($category))
{
$this->_menu .= '<li><a href="'.htmlentities($category->getLink()).'">'.$category->name.'</a>';
$this->_menu .= '<li><a href="'.Tools::HtmlEntitiesUTF8($category->getLink()).'">'.$category->name.'</a>';
$this->getCMSMenuItems($category->id);
$this->_menu .= '</li>'.PHP_EOL;
}
@@ -583,7 +587,7 @@ class Blocktopmenu extends Module
else
$manufacturer->link_rewrite = 0;
$link = new Link;
$this->_menu .= '<li'.$selected.'><a href="'.htmlentities($link->getManufacturerLink((int)$id, $manufacturer->link_rewrite)).'">'.$manufacturer->name.'</a></li>'.PHP_EOL;
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int)$id, $manufacturer->link_rewrite)).'">'.$manufacturer->name.'</a></li>'.PHP_EOL;
}
break;
@@ -603,7 +607,7 @@ class Blocktopmenu extends Module
if (!is_null($supplier->id))
{
$link = new Link;
$this->_menu .= '<li'.$selected.'><a href="'.htmlentities($link->getSupplierLink((int)$id, $supplier->link_rewrite)).'">'.$supplier->name.'</a></li>'.PHP_EOL;
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($link->getSupplierLink((int)$id, $supplier->link_rewrite)).'">'.$supplier->name.'</a></li>'.PHP_EOL;
}
break;
@@ -613,7 +617,7 @@ class Blocktopmenu extends Module
if (Validate::isLoadedObject($shop))
{
$link = new Link;
$this->_menu .= '<li'.$selected.'><a href="'.htmlentities($shop->getBaseURL()).'">'.$shop->name.'</a></li>'.PHP_EOL;
$this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($shop->getBaseURL()).'">'.$shop->name.'</a></li>'.PHP_EOL;
}
break;
case 'LNK':
@@ -625,7 +629,7 @@ class Blocktopmenu extends Module
$default_language = Configuration::get('PS_LANG_DEFAULT');
$link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int)Shop::getContextShopID());
}
$this->_menu .= '<li><a href="'.htmlentities($link[0]['link']).'"'.(($link[0]['new_window']) ? ' target="_blank"': '').'>'.$link[0]['label'].'</a></li>'.PHP_EOL;
$this->_menu .= '<li><a href="'.Tools::HtmlEntitiesUTF8($link[0]['link']).'"'.(($link[0]['new_window']) ? ' target="_blank"': '').'>'.$link[0]['label'].'</a></li>'.PHP_EOL;
}
break;
}
@@ -677,7 +681,7 @@ class Blocktopmenu extends Module
if (!empty($is_intersected))
{
$this->_menu .= '<li '.$selected.'>';
$this->_menu .= '<a href="'.htmlentities($category_link).'">'.$category->name.'</a>';
$this->_menu .= '<a href="'.Tools::HtmlEntitiesUTF8($category_link).'">'.$category->name.'</a>';
if (count($children))
{
@@ -858,6 +862,11 @@ class Blocktopmenu extends Module
$this->clearMenuCache();
}
public function hookActionObjectCmsAddAfter($params)
{
$this->clearMenuCache();
}
public function hookActionObjectSupplierUpdateAfter($params)
{
$this->clearMenuCache();
@@ -866,7 +875,12 @@ class Blocktopmenu extends Module
public function hookActionObjectSupplierDeleteAfter($params)
{
$this->clearMenuCache();
}
}
public function hookActionObjectSupplierAddAfter($params)
{
$this->clearMenuCache();
}
public function hookActionObjectManufacturerUpdateAfter($params)
{
@@ -878,6 +892,11 @@ class Blocktopmenu extends Module
$this->clearMenuCache();
}
public function hookActionObjectManufacturerAddAfter($params)
{
$this->clearMenuCache();
}
public function hookActionObjectProductUpdateAfter($params)
{
$this->clearMenuCache();
@@ -888,6 +907,11 @@ class Blocktopmenu extends Module
$this->clearMenuCache();
}
public function hookActionObjectProductAddAfter($params)
{
$this->clearMenuCache();
}
public function hookCategoryUpdate($params)
{
$this->clearMenuCache();
+5 -1
View File
@@ -116,7 +116,11 @@ class LoyaltyModule extends ObjectModel
$total += ($taxesEnabled == PS_TAX_EXC ? $product['price'] : $product['price_wt'])* (int)($product['cart_quantity']);
}
foreach ($cart->getCartRules(false) AS $cart_rule)
$total -= $cart_rule['value_real'];
if ($taxesEnabled == PS_TAX_EXC)
$total -= $cart_rule['value_tax_exc'];
else
$total -= $cart_rule['value_real'];
}
return self::getNbPointsByPrice($total);
+17 -193
View File
@@ -317,13 +317,20 @@ class Loyalty extends Module
include_once(dirname(__FILE__).'/LoyaltyModule.php');
$total_price = 0;
$taxesEnabled = Product::getTaxCalculationMethod();
$details = OrderReturn::getOrdersReturnDetail((int)$params['orderReturn']->id);
foreach ($details as $detail)
{
$total_price += Db::getInstance()->getValue('
SELECT ROUND(total_price_tax_incl, 2)
FROM '._DB_PREFIX_.'order_detail od
WHERE id_order_detail = '.(int)$detail['id_order_detail']);
if ($taxesEnabled == PS_TAX_EXC)
$total_price += Db::getInstance()->getValue('
SELECT ROUND(total_price_tax_excl, 2)
FROM '._DB_PREFIX_.'order_detail od
WHERE id_order_detail = '.(int)$detail['id_order_detail']);
else
$total_price += Db::getInstance()->getValue('
SELECT ROUND(total_price_tax_incl, 2)
FROM '._DB_PREFIX_.'order_detail od
WHERE id_order_detail = '.(int)$detail['id_order_detail']);
}
$loyalty_new = new LoyaltyModule();
@@ -474,8 +481,12 @@ class Loyalty extends Module
|| !Validate::isLoadedObject($loyalty = new LoyaltyModule((int)LoyaltyModule::getByOrderId((int)$params['order']->id))))
return false;
$taxesEnabled = Product::getTaxCalculationMethod();
$loyalty_new = new LoyaltyModule();
$loyalty_new->points = -1 * LoyaltyModule::getNbPointsByPrice(number_format($order_detail->total_price_tax_incl, 2, '.', ''));
if ($taxesEnabled == PS_TAX_EXC)
$loyalty_new->points = -1 * LoyaltyModule::getNbPointsByPrice(number_format($order_detail->total_price_tax_excl, 2, '.', ''));
else
$loyalty_new->points = -1 * LoyaltyModule::getNbPointsByPrice(number_format($order_detail->total_price_tax_incl, 2, '.', ''));
$loyalty_new->id_loyalty_state = (int)LoyaltyStateModule::getCancelId();
$loyalty_new->id_order = (int)$params['order']->id;
$loyalty_new->id_customer = (int)$loyalty->id_customer;
@@ -496,191 +507,4 @@ class Loyalty extends Module
return (array_key_exists($key, $translations)) ? $translations[$key] : $key;
}
public function renderForm()
{
$order_states = OrderState::getOrderStates($this->context->language->id);
$currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT')));
if (Tools::getValue('categoryBox'))
$selected_categories = Tools::getValue('categoryBox');
else
$selected_categories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY'));
$fields_form_1 = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Ratio'),
'name' => 'point_rate',
'prefix' => $currency->sign,
'suffix' => $this->l('= 1 reward point.'),
),
array(
'type' => 'text',
'label' => $this->l('1 point ='),
'name' => 'point_value',
'prefix' => $currency->sign,
'suffix' => $this->l('for the discount.'),
),
array(
'type' => 'text',
'label' => $this->l('Voucher details'),
'name' => 'voucher_details',
'lang' => true,
),
array(
'type' => 'text',
'label' => $this->l('Minimum amount in which the voucher can be used'),
'name' => 'minimal',
'prefix' => $currency->sign,
'class' => 'fixed-width-sm',
),
array(
'type' => 'select',
'label' => $this->l('Points are awarded when the order is'),
'name' => 'id_order_state_validation',
'options' => array(
'query' => $order_states,
'id' => 'id_order_state',
'name' => 'name',
)
),
array(
'type' => 'select',
'label' => $this->l('Points are cancelled when the order is'),
'name' => 'id_order_state_cancel',
'options' => array(
'query' => $order_states,
'id' => 'id_order_state',
'name' => 'name',
)
),
array(
'type' => 'switch',
'label' => $this->l('Give points on discounted products'),
'name' => 'PS_LOYALTY_NONE_AWARD',
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
)
),
array(
'type' => 'categories',
'label' => $this->l('Vouchers created by the loyalty system can be used in the following categories :'),
'name' => 'categoryBox',
'desc' => $this->l('Mark the box(es) of categories in which loyalty vouchers are usable.'),
'tree' => array(
'use_search' => false,
'id' => 'categoryBox',
'use_checkbox' => true,
'selected_categories' => $selected_categories,
),
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-primary')
),
);
$fields_form_2 = array(
'form' => array(
'legend' => array(
'title' => $this->l('Loyalty points progression'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Initial'),
'name' => 'default_loyalty_state',
'lang' => true,
),
array(
'type' => 'text',
'label' => $this->l('Unavailable'),
'name' => 'none_award_loyalty_state',
'lang' => true,
),
array(
'type' => 'text',
'label' => $this->l('Converted'),
'name' => 'convert_loyalty_state',
'lang' => true,
),
array(
'type' => 'text',
'label' => $this->l('Validation'),
'name' => 'validation_loyalty_state',
'lang' => true,
),
array(
'type' => 'text',
'label' => $this->l('Cancelled'),
'name' => 'cancel_loyalty_state',
'lang' => true,
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-primary')
),
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitLoyalty';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
return $helper->generateForm(array($fields_form_1, $fields_form_2));
}
public function getConfigFieldsValues()
{
$fields_values = array(
'point_rate' => Tools::getValue('PS_LOYALTY_POINT_RATE', Configuration::get('PS_LOYALTY_POINT_RATE')),
'point_value' => Tools::getValue('PS_LOYALTY_POINT_VALUE', Configuration::get('PS_LOYALTY_POINT_VALUE')),
'PS_LOYALTY_NONE_AWARD' => Tools::getValue('PS_LOYALTY_NONE_AWARD', Configuration::get('PS_LOYALTY_NONE_AWARD')),
'minimal' => Tools::getValue('PS_LOYALTY_MINIMAL', Configuration::get('PS_LOYALTY_MINIMAL')),
'id_order_state_validation' => Tools::getValue('id_order_state_validation', $this->loyaltyStateValidation->id_order_state),
'id_order_state_cancel' => Tools::getValue('id_order_state_cancel', $this->loyaltyStateCancel->id_order_state),
);
$languages = Language::getLanguages(false);
foreach ($languages as $lang)
{
$fields_values['voucher_details'][$lang['id_lang']] = Tools::getValue('voucher_details_'.(int)$lang['id_lang'], Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', (int)$lang['id_lang']));
$fields_values['default_loyalty_state'][$lang['id_lang']] = Tools::getValue('default_loyalty_state_'.(int)$lang['id_lang'], $this->loyaltyStateDefault->name[(int)($lang['id_lang'])]);
$fields_values['validation_loyalty_state'][$lang['id_lang']] = Tools::getValue('validation_loyalty_state_'.(int)$lang['id_lang'], $this->loyaltyStateValidation->name[(int)($lang['id_lang'])]);
$fields_values['cancel_loyalty_state'][$lang['id_lang']] = Tools::getValue('cancel_loyalty_state_'.(int)$lang['id_lang'], $this->loyaltyStateCancel->name[(int)($lang['id_lang'])]);
$fields_values['convert_loyalty_state'][$lang['id_lang']] = Tools::getValue('convert_loyalty_state_'.(int)$lang['id_lang'], $this->loyaltyStateConvert->name[(int)($lang['id_lang'])]);
$fields_values['none_award_loyalty_state'][$lang['id_lang']] = Tools::getValue('none_award_loyalty_state_'.(int)$lang['id_lang'], $this->loyaltyStateNoneAward->name[(int)($lang['id_lang'])]);
}
return $fields_values;
}
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
<module>
<name>mailalerts</name>
<displayName><![CDATA[Mail alerts]]></displayName>
<version><![CDATA[2.4]]></version>
<version><![CDATA[2.5]]></version>
<description><![CDATA[Sends e-mail notifications to customers and merchants.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
+4 -19
View File
@@ -6,24 +6,9 @@ if (!defined('_PS_VERSION_'))
function upgrade_module_2_5($object)
{
return Db::getInstance()->execute('
ALTER TABLE '._DB_PREFIX_.'mailalert_customer_oos
ADD '.mailalerts_stripslashes_field('id_lang').' INT( 10 ) UNSIGNED NOT NULL ,
ALTER TABLE `'._DB_PREFIX_.'mailalert_customer_oos`
ADD `id_lang` INT( 10 ) UNSIGNED NOT NULL ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (
'.mailalerts_stripslashes_field('id_customer').' ,
'.mailalerts_stripslashes_field('customer_email').' ,
'.mailalerts_stripslashes_field('id_product').' ,
'.mailalerts_stripslashes_field('id_product_attribute').' ,
'.mailalerts_stripslashes_field('id_shop').'
)'
);
}
function mailalerts_stripslashes_field($field)
{
$quotes = array('"\\\'"', '"\'"');
$dquotes = array('\'\\\\"\'', '\'"\'');
$backslashes = array('"\\\\\\\\"', '"\\\\"');
return '`'.bqSQL($field).'` = replace(replace(replace(`'.bqSQL($field).'`, '.$quotes[0].', '.$quotes[1].'), '.$dquotes[0].', '.$dquotes[1].'), '.$backslashes[0].', '.$backslashes[1].')';
ADD PRIMARY KEY (`id_customer` , `customer_email` , `id_product` , `id_product_attribute` , `id_shop`)
');
}
@@ -73,26 +73,26 @@ class ProductCommentsDefaultModuleFrontController extends ModuleFrontController
$errors = array();
// Validation
if (!Validate::isInt(Tools::getValue('id_product')))
$errors[] = $module_instance->l('ID product is incorrect');
$errors[] = $module_instance->l('ID product is incorrect', 'default');
if (!Tools::getValue('title') || !Validate::isGenericName(Tools::getValue('title')))
$errors[] = $module_instance->l('Title is incorrect');
$errors[] = $module_instance->l('Title is incorrect', 'default');
if (!Tools::getValue('content') || !Validate::isMessage(Tools::getValue('content')))
$errors[] = $module_instance->l('Comment is incorrect');
$errors[] = $module_instance->l('Comment is incorrect', 'default');
if (!$id_customer && (!Tools::isSubmit('customer_name') || !Tools::getValue('customer_name') || !Validate::isGenericName(Tools::getValue('customer_name'))))
$errors[] = $module_instance->l('Customer name is incorrect');
$errors[] = $module_instance->l('Customer name is incorrect', 'default');
if (!$this->context->customer->id && !Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'))
$errors[] = $module_instance->l('You must be logged in order to send a comment');
$errors[] = $module_instance->l('You must be logged in order to send a comment', 'default');
if (!count(Tools::getValue('criterion')))
$errors[] = $module_instance->l('You must give a rating');
$errors[] = $module_instance->l('You must give a rating', 'default');
$product = new Product(Tools::getValue('id_product'));
if (!$product->id)
$errors[] = $module_instance->l('Product not found');
$errors[] = $module_instance->l('Product not found', 'default');
if (!count($errors))
{
$customer_comment = ProductComment::getByCustomer(Tools::getValue('id_product'), $id_customer, true, $id_guest);
if (!$customer_comment || ($customer_comment && (strtotime($customer_comment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) < time()))
if (!$customer_comment || ($customer_comment && (strtotime($customer_comment['date_add']) + (int)Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) < time()))
{
$comment = new ProductComment();
+1 -1
View File
@@ -713,7 +713,7 @@ class ProductComments extends Module
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
'criterions' => ProductCommentCriterion::getByProduct((int)Tools::getValue('id_product'), $this->context->language->id),
'action_url' => '',
'averageTotal' => (int)$average['grade'],
'averageTotal' => round($average['grade']),
'too_early' => ($customerComment && (strtotime($customerComment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) > time()),
'nbComments' => (int)(ProductComment::getCommentNumber((int)Tools::getValue('id_product')))
));
+6 -6
View File
@@ -24,13 +24,13 @@
*}
<script type="text/javascript">
var productcomments_controller_url = '{$productcomments_controller_url}';
var confirm_report_message = "{l s='Are you sure you want report this comment?' mod='productcomments'}";
var secure_key = "{$secure_key}";
var confirm_report_message = '{l s='Are you sure you want report this comment?' mod='productcomments' js=1}';
var secure_key = '{$secure_key}';
var productcomments_url_rewrite = '{$productcomments_url_rewriting_activated}';
var productcomment_added = '{l s='Your comment has been added!' mod='productcomments'}';
var productcomment_added_moderation = '{l s='Your comment has been added and will be available once approved by a moderator' mod='productcomments'}';
var productcomment_title = '{l s='New comment' mod='productcomments'}';
var productcomment_ok = '{l s='OK' mod='productcomments'}';
var productcomment_added = '{l s='Your comment has been added!' mod='productcomments' js=1}';
var productcomment_added_moderation = '{l s='Your comment has been added and will be available once approved by a moderator' mod='productcomments' js=1}';
var productcomment_title = '{l s='New comment' mod='productcomments' js=1}';
var productcomment_ok = '{l s='OK' mod='productcomments' js=1}';
var moderation_active = {$moderation_active};
</script>
+4 -2
View File
@@ -29,8 +29,10 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>PrestaShop&trade; - {l s='Affiliation' mod='trackingfront'}</title>
<script type="text/javascript" src="{$smarty.const._PS_JS_DIR_}jquery/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="{$smarty.const._PS_JS_DIR_}jquery/jquery-ui-1.8.10.custom.min.js"></script>
<link type="text/css" rel="stylesheet" href="{$smarty.const._PS_JS_DIR_}jquery/datepicker/datepicker.css" />
<script type="text/javascript" src="{$smarty.const._PS_JS_DIR_}jquery/ui/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="{$smarty.const._PS_JS_DIR_}jquery/ui/jquery.ui.datepicker.min.js"></script>
<link type="text/css" rel="stylesheet" href="{$smarty.const._PS_JS_DIR_}jquery/ui/themes/base/jquery.ui.all.css" />
<link type="text/css" rel="stylesheet" href="{$smarty.const._PS_JS_DIR_}jquery/ui/themes/base/jquery.ui.datepicker.css" />
</head>
<body>
+18 -11
View File
@@ -50,6 +50,7 @@ class TrackingFront extends Module
$fakeEmployee = new Employee();
$fakeEmployee->stats_date_from = $this->context->cookie->stats_date_from;
$fakeEmployee->stats_date_to = $this->context->cookie->stats_date_to;
$result = Db::getInstance()->getRow('
SELECT `id_referrer`
FROM `'._DB_PREFIX_.'referrer`
@@ -95,10 +96,13 @@ class TrackingFront extends Module
$this->smarty->assign('errors', $errors);
}
$from = date('Y-m-d');
$to = date('Y-m-d');
if (Tools::isSubmit('submitDatePicker'))
{
$this->context->cookie->stats_date_from = Tools::getValue('datepickerFrom');
$this->context->cookie->stats_date_to = Tools::getValue('datepickerTo');
$from = Tools::getValue('datepickerFrom');
$to= Tools::getValue('datepickerTo');
}
if (Tools::isSubmit('submitDateDay'))
{
@@ -133,6 +137,8 @@ class TrackingFront extends Module
$from = (date('Y') - 1).date('-01-01');
$to = (date('Y') - 1).date('-12-31');
}
$this->context->cookie->stats_date_from = $from;
$this->context->cookie->stats_date_to = $to;
}
public function isLogged()
@@ -187,15 +193,16 @@ class TrackingFront extends Module
$echo = '
<script type="text/javascript">
$("#datepickerFrom").datepicker({
prevText:"",
nextText:"",
dateFormat:"yy-mm-dd"});
$("#datepickerTo").datepicker({
prevText:"",
nextText:"",
dateFormat:"yy-mm-dd"});
$(document).ready(function() {
$("#datepickerFrom").datepicker({
prevText:"",
nextText:"",
dateFormat:"yy-mm-dd"});
$("#datepickerTo").datepicker({
prevText:"",
nextText:"",
dateFormat:"yy-mm-dd"});
});
function updateValues()
{
$.getJSON("stats.php",{ajaxProductFilter:1,id_referrer:'.$referrer->id.',token:"'.$this->context->cookie->tracking_passwd.'",id_product:0},
+45 -1
View File
@@ -69,6 +69,7 @@ class Watermark extends Module
public function install()
{
$this->writeHtaccessSection();
if (!parent::install() || !$this->registerHook('watermark'))
return false;
Configuration::updateValue('WATERMARK_TRANSPARENCY', 60);
@@ -79,6 +80,7 @@ class Watermark extends Module
public function uninstall()
{
$this->removeHtaccessSection();
return (parent::uninstall()
&& Configuration::deleteByName('WATERMARK_TYPES')
&& Configuration::deleteByName('WATERMARK_TRANSPARENCY')
@@ -95,7 +97,7 @@ class Watermark extends Module
if (empty($transparency))
$this->_postErrors[] = $this->l('Transparency required.');
elseif ($transparency < 0 || $transparency > 100)
elseif ($transparency < 1 || $transparency > 100)
$this->_postErrors[] = $this->l('Transparency is not in allowed range.');
if (empty($yalign))
@@ -207,9 +209,51 @@ class Watermark extends Module
</fieldset>
</form>';
}
public function getAdminDir()
{
$admin_dir = str_replace('\\', '/', _PS_ADMIN_DIR_);
$admin_dir = explode('/', $admin_dir);
$len = count($admin_dir);
return $len > 1 ? $admin_dir[$len - 1] : _PS_ADMIN_DIR_;
}
public function removeHtaccessSection()
{
$key1 = "\n# start ~ module watermark section";
$key2 = "# end ~ module watermark section\n";
$path = _PS_ROOT_DIR_ . '/.htaccess';
if (file_exists($path) && is_writable($path)) {
$s = file_get_contents($path);
$p1 = strpos($s, $key1);
$p2 = strpos($s, $key2, $p1);
if ($p1 === false || $p2 === false) return false;
$s = substr($s, 0, $p1) . substr($s, $p2 + strlen($key2));
file_put_contents($path, $s);
}
return true;
}
public function writeHtaccessSection()
{
$admin_dir = $this->getAdminDir();
$source = "\n# start ~ module watermark section
Options +FollowSymLinks
RewriteEngine On
RewriteCond expr \"! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}*/$admin_dir/*'\"
RewriteRule [0-9/]+/[0-9]+\\.jpg$ - [F]
# end ~ module watermark section\n";
$path = _PS_ROOT_DIR_ . '/.htaccess';
file_put_contents($path, $source, FILE_APPEND);
}
public function getContent()
{
//Modify htaccess to prevent downlaod of original pictures
$this->removeHtaccessSection();
$this->writeHtaccessSection();
$this->_html = '<h2>'.$this->displayName.'</h2>';
if (Tools::isSubmit('btnSubmit'))