Skip to content

Commit

Permalink
OkayCMS 2.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
OkayCMS committed Jul 10, 2019
1 parent 5f37f69 commit 7b27853
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 33 deletions.
2 changes: 1 addition & 1 deletion 1DB_changes/okay_clean.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5865,7 +5865,7 @@ CREATE TABLE `ok_variants` (
`weight` decimal(10,2) DEFAULT '0.00',
`price` decimal(14,2) NOT NULL DEFAULT '0.00',
`compare_price` decimal(14,2) DEFAULT NULL,
`stock` mediumint(9) DEFAULT NULL,
`stock` mediumint(9) unsigned DEFAULT NULL,
`position` int(11) NOT NULL DEFAULT '0',
`attachment` varchar(255) NOT NULL DEFAULT '',
`external_id` varchar(36) NOT NULL DEFAULT '',
Expand Down
1 change: 1 addition & 0 deletions 1DB_changes/update_2.3.4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `ok_variants` CHANGE `stock` `stock` mediumint(9) unsigned NULL AFTER `compare_price`;
4 changes: 0 additions & 4 deletions api/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ public function get_comments($filter = array(), $count = false) {
$where .= $keyword_filter;
}

if(isset($filter['ip'])) {
$where .= $this->db->placehold(" OR c.ip=?", $filter['ip']);
}

if (!empty($order)) {
$order = "ORDER BY $order";
}
Expand Down
2 changes: 1 addition & 1 deletion api/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Config {

/*Версия системы*/
public $version = '2.3.3';
public $version = '2.3.4';
/*Тип системы*/
public $version_type = 'pro';

Expand Down
7 changes: 4 additions & 3 deletions api/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ public function get_resize_params($filename) {

/*Загрузка изображения*/
public function download_image($filename) {
$encoded_filename = rawurlencode($filename);
// Заливаем только есть такой файл есть в базе
$this->db->query('SELECT 1 FROM __images WHERE filename=? LIMIT 1', $filename);
$this->db->query('SELECT 1 FROM __images WHERE filename=? LIMIT 1', $encoded_filename);
if(!$this->db->result()) {
return false;
}
Expand Down Expand Up @@ -158,7 +159,7 @@ public function download_image($filename) {
// Перед долгим копированием займем это имя
fclose(fopen($local_file, 'w'));
if (copy($filename, $local_file) && filesize($local_file) > 0) {
$this->db->query('UPDATE __images SET filename=? WHERE filename=?', $new_name, $filename);
$this->db->query('UPDATE __images SET filename=? WHERE filename=?', $new_name, $encoded_filename);
return $new_name;
}
// Если по https не получилось сохранить изображение, попробуем на тот же урл постучаться на http
Expand All @@ -169,7 +170,7 @@ public function download_image($filename) {
preg_match('/\d{3}/', $headers[0], $matches);
// Если урл по http отдает 200, забираем изображение
if ($matches[0] == '200' && copy($filename_http, $local_file) && filesize($local_file) > 0) {
$this->db->query('UPDATE __images SET filename=? WHERE filename=?', $new_name, $filename);
$this->db->query('UPDATE __images SET filename=? WHERE filename=?', $new_name, $encoded_filename);
return $new_name;
} else {
@unlink($local_file);
Expand Down
6 changes: 4 additions & 2 deletions api/Managers.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ private function crypt_apr1_md5($plainpasswd, $salt = '') {
}

/*Проверка доступа к определнному модулю сайта*/
public function access($module) {
$manager = $this->get_manager();
public function access($module, $manager = null) {
if (empty($manager)) {
$manager = $this->get_manager();
}
if(is_array($manager->permissions)) {
return in_array($module, $manager->permissions);
} else {
Expand Down
27 changes: 27 additions & 0 deletions api/Okay.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,33 @@ public function translit_alpha($text) {
return $res;
}

public function clear_catalog() {
$this->db->query("DELETE FROM `__comments` WHERE `type`='product'");
$this->db->query("UPDATE `__purchases` SET `product_id`=0, `variant_id`=0");
$this->db->query("TRUNCATE TABLE `__brands`");
$this->db->query("TRUNCATE TABLE `__categories`");
$this->db->query("TRUNCATE TABLE `__categories_features`");
$this->db->query("TRUNCATE TABLE `__features`");
$this->db->query("TRUNCATE TABLE `__features_aliases_values`");
$this->db->query("TRUNCATE TABLE `__features_values`");
$this->db->query("TRUNCATE TABLE `__images`");
$this->db->query("TRUNCATE TABLE `__import_log`");
$this->db->query("TRUNCATE TABLE `__lang_brands`");
$this->db->query("TRUNCATE TABLE `__lang_categories`");
$this->db->query("TRUNCATE TABLE `__lang_features`");
$this->db->query("TRUNCATE TABLE `__lang_features_aliases_values`");
$this->db->query("TRUNCATE TABLE `__lang_features_values`");
$this->db->query("TRUNCATE TABLE `__lang_products`");
$this->db->query("TRUNCATE TABLE `__lang_variants`");
$this->db->query("TRUNCATE TABLE `__options_aliases_values`");
$this->db->query("TRUNCATE TABLE `__products`");
$this->db->query("TRUNCATE TABLE `__products_categories`");
$this->db->query("TRUNCATE TABLE `__products_features_values`");
$this->db->query("TRUNCATE TABLE `__related_blogs`");
$this->db->query("TRUNCATE TABLE `__related_products`");
$this->db->query("TRUNCATE TABLE `__variants`");
}

//Добавляет к массиву пар для транслита, пары для замены спецсимволов на буквенные обозначения
private function spec_pairs($pair) {
foreach ($this->spec_pairs as $symbol => $alias) {
Expand Down
14 changes: 14 additions & 0 deletions backend/core/BrandsAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ public function fetch() {

if(is_array($ids)) {
switch($this->request->post('action')) {
case 'disable': {
/*Выключить бренд*/
foreach ($ids as $id) {
$this->brands->update_brand($id, array('visible' => 0));
}
break;
}
case 'enable': {
/*Включить бренд*/
foreach ($ids as $id) {
$this->brands->update_brand($id, array('visible' => 1));
}
break;
}
case 'delete': {
/*Удаление брендов*/
foreach($ids as $id) {
Expand Down
3 changes: 3 additions & 0 deletions backend/core/IndexAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ public function __construct() {
$lang_id = $this->languages->lang_id();
$this->design->assign('lang_id', $lang_id);

$main_lang = $this->languages->get_first_language();
$this->design->assign('main_lang_id', $main_lang->id);

$this->design->assign('lang_link', $this->languages->get_lang_link());

/*Формирование меню*/
Expand Down
7 changes: 0 additions & 7 deletions backend/core/ProductAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,6 @@ public function fetch() {
$i++;
}
}

// Характеристики товара
// Свойства текущей категории
$category_features = array();
foreach($this->features->get_features(array('category_id'=>reset($product_categories)->id)) as $f) {
$category_features[] = $f->id;
}

// Удалим все значения свойств товара
$this->features_values->delete_product_value($product->id);
Expand Down
2 changes: 2 additions & 0 deletions backend/design/html/brands.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
</div>
<div class="okay_list_option">
<select name="action" class="selectpicker brands_action">
<option value="enable">{$btr->general_do_enable|escape}</option>
<option value="disable">{$btr->general_do_disable|escape}</option>
<option value="in_feed">{$btr->brands_in_xml|escape}</option>
<option value="out_feed">{$btr->brands_out_xml|escape}</option>
<option value="delete">{$btr->general_delete|escape}</option>
Expand Down
54 changes: 40 additions & 14 deletions backend/design/html/product.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,11 @@
<div class="toggle_arrow_wrap fn_toggle_card text-primary">
<a class="btn-minimize" href="javascript:;" ><i class="fa fn_icon_arrow fa-angle-down"></i></a>
</div>
{if $lang_id != $main_lang_id}
<div class="boxed boxed_attention mt-h mb-0">
{$btr->product_features_values_change_notice}
</div>
{/if}
</div>
<div class="toggle_body_wrap on fn_card">
<div class="features_wrap fn_features_wrap">
Expand All @@ -513,7 +518,7 @@
{/if}
</div>
<div class="feature_value">
<input class="feature_input fn_auto_option" data-id="{$feature_id}" type="text" name="features_values_text[{$feature_id}][]" value="{$feature_value->value|escape}"/>
<input class="feature_input fn_auto_option" data-id="{$feature_id}" type="text" name="features_values_text[{$feature_id}][]" value="{$feature_value->value|escape}"{if $lang_id != $main_lang_id} readonly{/if}/>
<input class="fn_value_id_input" type="hidden" name="features_values[{$feature_id}][]" value="{$feature_value->id}"/>
<button type="button" class="btn btn_mini{if $feature_value@first} btn-info fn_add{else} btn-danger fn_remove{/if} fn_feature_multi_values feature_multi_values">
<span class="fn_plus" {if !$feature_value@first}style="display: none;"{/if}>
Expand All @@ -535,7 +540,7 @@
</span>
</div>
<div class="feature_value">
<input class="feature_input fn_auto_option" data-id="{$feature_id}" type="text" name="features_values_text[{$feature_id}][]" value=""/>
<input class="feature_input fn_auto_option" data-id="{$feature_id}" type="text" name="features_values_text[{$feature_id}][]" value=""{if $lang_id != $main_lang_id} readonly{/if}/>
<input class="fn_value_id_input" type="hidden" name="features_values[{$feature_id}][]" value=""/>
<button type="button" class="btn btn_mini btn-info fn_add fn_feature_multi_values feature_multi_values">
<span class="fn_plus">
Expand Down Expand Up @@ -569,7 +574,7 @@
</span>
</div>
<div class="feature_value">
<input class="feature_input fn_auto_option" data-id="" type="text" name="" value=""/>
<input class="feature_input fn_auto_option" data-id="" type="text" name="" value=""{if $lang_id != $main_lang_id} readonly{/if}/>
<input class="fn_value_id_input" type="hidden" name="" value=""/>
<button type="button" class="btn btn_mini btn-info fn_add fn_feature_multi_values feature_multi_values">
<span class="fn_plus">
Expand Down Expand Up @@ -922,17 +927,26 @@
value.attr('name', "features_values_text["+feature.id+"][]");
id_input.attr('name', "features_values["+feature.id+"][]");
id_input.val(feature.values[iv].id)
value.devbridgeAutocomplete({
serviceUrl:'ajax/options_autocomplete.php',
minChars:0,
orientation:'auto',
params: {feature_id:feature.id},
noCache: false,
onSelect:function(suggestion){
id_input.val(suggestion.data.id);
$(this).trigger('change');
}
});
{/literal}
{if $lang_id == $main_lang_id}
{literal}
value.devbridgeAutocomplete({
serviceUrl:'ajax/options_autocomplete.php',
minChars:0,
orientation:'auto',
params: {feature_id:feature.id},
noCache: false,
onSelect:function(suggestion){
id_input.val(suggestion.data.id);
$(this).trigger('change');
},
onSearchStart:function(params){
id_input.val("");
}
});
{/literal}
{/if}
{literal}
if (iv > 0) {
new_line.find(".fn_feature_multi_values")
.removeClass("fn_add")
Expand All @@ -952,6 +966,9 @@
return false;
}

{/literal}
{if $lang_id == $main_lang_id}
{literal}
$(document).on("click",".fn_feature_multi_values.fn_add", function () {
var feature_id = $(this).closest(".feature_value").find(".fn_auto_option").data("id"),
new_value = new_feature_category.clone(true),
Expand Down Expand Up @@ -979,6 +996,9 @@
onSelect:function(suggestion){
id_input.val(suggestion.data.id);
$(this).trigger('change');
},
onSearchStart:function(params){
id_input.val("");
}
});
new_value.appendTo(".fn_feature_block_"+feature_id).fadeIn('slow');
Expand All @@ -1001,9 +1021,15 @@
onSelect:function(suggestion){
id_input.val(suggestion.data.id);
$(this).trigger('change');
},
onSearchStart:function(params){
id_input.val("");
}
});
});
{/literal}
{/if}
{literal}

// Добавление нового свойства товара
var new_feature = $(".fn_new_feature").clone(true);
Expand Down
1 change: 1 addition & 0 deletions backend/lang/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@
$backend_translations->product_rating_number = 'Number of votes:';
$backend_translations->product_rating_value = 'Rating value:';
$backend_translations->product_updated = 'Product updated';
$backend_translations->product_features_values_change_notice = 'Property management occurs only in the main language. To translate the value, go to the property page.';
$backend_translations->products_add = 'Add products';
$backend_translations->products_bestsellers = 'Bestsellers';
$backend_translations->products_create_dublicate = 'Create dublicate';
Expand Down
1 change: 1 addition & 0 deletions backend/lang/ge.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@
$backend_translations->product_rating_number = 'ხმების რაოდენობა:';
$backend_translations->product_rating_value = 'რეიტინგის მნიშვნელობა:';
$backend_translations->product_updated = 'პროდუქტი შეცვლილია';
$backend_translations->product_features_values_change_notice = 'ქონების მართვა ხდება მხოლოდ ძირითად ენაზე. ღირებულების თარგმნა, გადადით ქონების გვერდზე.';
$backend_translations->products_add = 'პროდუქტის დამატება';
$backend_translations->products_bestsellers = 'გაყიდვების ჰიტები';
$backend_translations->products_create_dublicate = 'დუბლიკატის შექმნა';
Expand Down
1 change: 1 addition & 0 deletions backend/lang/ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@
$backend_translations->product_rating_number = 'Количество голосов:';
$backend_translations->product_rating_value = 'Значение рейтинга:';
$backend_translations->product_updated = 'Товар изменен';
$backend_translations->product_features_values_change_notice = 'Управление свойствами происходит только на основном языке. Для перевода значения, перейдите на страницу свойства.';
$backend_translations->products_add = 'Добавить товар';
$backend_translations->products_bestsellers = 'Хиты продаж';
$backend_translations->products_create_dublicate = 'Создать дубликат';
Expand Down
1 change: 1 addition & 0 deletions backend/lang/ua.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@
$backend_translations->product_rating_number = 'Кількість голосів:';
$backend_translations->product_rating_value = 'Значення рейтингу:';
$backend_translations->product_updated = 'Товар змінений';
$backend_translations->product_features_values_change_notice = 'Управління властивостями відбувається тільки на основній мові. Для перекладу значення, перейдіть на сторінку властивості.';
$backend_translations->products_add = 'Додати товар';
$backend_translations->products_bestsellers = 'Хіти продажу';
$backend_translations->products_create_dublicate = 'Створити дублікат';
Expand Down
4 changes: 4 additions & 0 deletions cml/integration/import/ImportOrders.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public function import($xml_file) {
$order->id = $this->okay->orders->add_order($order);
}

if (empty($order->id)) {
return "error: empty order_id\n";
}

$purchases_ids = array();
// Товары
foreach ($xml_order->Товары->Товар as $xml_product) {
Expand Down
2 changes: 1 addition & 1 deletion payment/Robokassa/Robokassa.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function checkout_form($order_id)

foreach ($purchases as $key => $p) {
$one_product = array();
$one_product['name'] = substr(htmlentities($p->product_name . ($p->variant_name ? ' ' . $p->variant_name : '')), 0, 64);
$one_product['name'] = mb_substr(htmlentities($p->product_name . ($p->variant_name ? ' ' . $p->variant_name : '')), 0, 64);
if ($key == end($purchases)) {
$one_product['sum'] = $total_price;
} else {
Expand Down

0 comments on commit 7b27853

Please sign in to comment.