first commit

This commit is contained in:
2024-10-25 14:16:28 +02:00
commit 925276dbb2
33795 changed files with 4780077 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
/**
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,113 @@
<?php
/**
* 2007-2017 Amazzing
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Amazzing <mail@amazzing.ru>
* @copyright 2007-2017 Amazzing
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
function upgrade_module_0_9_6($module_obj)
{
if (!defined('_PS_VERSION_')) {
exit;
}
// make sure all new tables are installed
$module_obj->prepareDatabase();
$new_tables = array_keys($module_obj->getTables());
$table_names_correlation = array(
'a_blog_post' => 'blog_posts',
'a_blog_post_stats' => 'blog_posts_stats',
'a_blog_post_lang' => 'blog_posts_lang',
'a_blog_category' => 'blog_categories',
'a_blog_category_lang' => 'blog_categories_lang',
'a_blog_post_category' => 'blog_posts_categories',
'a_blog_block' => 'blog_blocks',
'a_blog_block_lang' => 'blog_blocks_lang',
'a_blog_comment' => 'blog_comments',
'a_blog_user' => 'blog_users',
'a_blog_settings' => 'blog_settings',
);
$sql = array();
foreach ($new_tables as $new_name) {
if (empty($table_names_correlation[$new_name])) {
continue;
} else {
$prev_name = $table_names_correlation[$new_name];
}
$prev_name = _DB_PREFIX_.$prev_name;
$new_name = _DB_PREFIX_.$new_name;
$new_columns = $module_obj->db->executeS('SHOW COLUMNS FROM '.pSQL($new_name));
$new_column_names = array();
foreach ($new_columns as $col) {
$new_column_names[$col['Field']] = $col['Field'];
}
if (count($module_obj->db->executeS('SHOW TABLES LIKE \''.pSQL($prev_name).'\''))) {
$prev_rows = $module_obj->db->executeS('SELECT * FROM '.pSQL($prev_name));
$new_rows = $column_names = $upd_segment = array();
foreach ($prev_rows as $row) {
if (!$column_names) {
$prev_column_names = array_keys($row);
foreach ($new_column_names as $ncn) {
if (in_array($ncn, $prev_column_names)) {
$column_names[$ncn] = $ncn;
$upd_segment[] = pSQL($ncn).' = VALUES('.pSQL($ncn).')';
}
}
}
$new_row = array();
foreach ($row as $name => $value) {
if (isset($column_names[$name])) {
$new_row[] = '\''.pSQL($value).'\'';
}
}
$new_rows[] = '('.implode(', ', $new_row).')';
}
if ($new_rows && $column_names) {
$query = '
INSERT INTO '.pSQL($new_name).'
('.pSQL(implode(', ', $column_names)).')
VALUES '.implode(', ', $new_rows).'
ON DUPLICATE KEY UPDATE
'.implode(', ', $upd_segment);
$sql[] = $query;
$sql[] = 'DROP TABLE IF EXISTS '.pSQL($prev_name);
}
}
}
if ($sql) {
$module_obj->runSql($sql);
}
// update possible duplicating URLs in posts
$urls_data = $module_obj->db->executeS('
SELECT id_post, id_lang, link_rewrite FROM '._DB_PREFIX_.'a_blog_post_lang
');
foreach ($urls_data as $row) {
$has_duplicate = $module_obj->db->getValue('
SELECT id_post FROM '._DB_PREFIX_.'a_blog_post_lang
WHERE link_rewrite = \''.pSQL($row['link_rewrite']).'\'
AND id_post <> '.(int)$row['id_post'].'
AND id_lang = '.(int)$row['id_lang'].'
');
if ($has_duplicate) {
$new_link_rewrite = $row['id_post'].'-'.$row['link_rewrite'];
$module_obj->db->execute('
UPDATE '._DB_PREFIX_.'a_blog_post_lang
SET link_rewrite = \''.pSQL($new_link_rewrite).'\'
WHERE id_post = '.(int)$row['id_post'].'
AND id_lang = '.(int)$row['id_lang'].'
');
}
}
return true;
}

View File

@@ -0,0 +1,69 @@
<?php
/**
* 2007-2017 Amazzing
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Amazzing <mail@amazzing.ru>
* @copyright 2007-2017 Amazzing
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
function upgrade_module_1_0_0($module_obj)
{
if (!defined('_PS_VERSION_')) {
exit;
}
include_once(_PS_MODULE_DIR_.$module_obj->name.'/classes/BlogFields.php');
$module_obj->fields = new BlogFields();
$module_obj->shop_ids = Shop::getContextListShopID();
// update settings
$general_settings = $module_obj->getSettings('general');
$new_settings = array(
'cat_' => 'category',
'post_' => 'post',
'c_' => 'comment',
);
foreach ($new_settings as $prefix => $type) {
$fields = $module_obj->getSettingsFields($type);
$settings = array();
foreach ($fields as $name => $field) {
if (!empty($general_settings[$prefix.$name])) {
$value = $general_settings[$prefix.$name];
} elseif (!empty($general_settings[$name])) {
$value = $general_settings[$name];
} else {
$value = $field['value'];
}
$settings[$name] = $value;
}
$module_obj->saveSettings($type, $settings);
}
// update blocks
$blocks = $module_obj->db->executeS('
SELECT * FROM '._DB_PREFIX_.'a_blog_block
');
$block_fields = $module_obj->getSettingsFields('block');
$block_rows = array();
foreach ($blocks as $row) {
$settings = Tools::jsonDecode($row['settings'], true);
foreach ($block_fields as $name => $field) {
if (!isset($settings[$name])) {
$settings[$name] = $field['value'];
}
}
$settings = Tools::jsonEncode($settings);
$block_rows[] = '(\''.implode('\', \'', array_map('pSQL', $row)).'\')';
}
$module_obj->db->execute('
REPLACE INTO '._DB_PREFIX_.'a_blog_block VALUES
'.implode(', ', $block_rows).'
');
return true;
}

View File

@@ -0,0 +1,111 @@
<?php
/**
* 2007-2017 Amazzing
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Amazzing <mail@amazzing.ru>
* @copyright 2007-2017 Amazzing
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
function upgrade_module_1_2_0($module_obj)
{
if (!defined('_PS_VERSION_')) {
exit;
}
$module_obj->prepareDatabase();
$module_obj->db->execute('
ALTER TABLE '._DB_PREFIX_.'a_blog_post
ADD publish_from DATETIME NOT NULL AFTER date_add,
ADD INDEX publish_from (publish_from),
ADD publish_to DATETIME NOT NULL AFTER publish_from,
ADD INDEX publish_to (publish_to)
');
$module_obj->db->execute('
UPDATE '._DB_PREFIX_.'a_blog_post
SET publish_from = date_add
');
// update compact variable in blocks
$blocks = $module_obj->db->executeS('
SELECT * FROM '._DB_PREFIX_.'a_blog_block
');
$rows = array();
foreach ($blocks as $b) {
$settings = Tools::jsonDecode($b['settings'], true);
if ($settings['display_type'] == 'compact_list') {
$settings['display_type'] = 'list';
$settings['compact'] = 1;
}
$b['settings'] = Tools::jsonEncode($settings);
$rows[] = '(\''.implode('\', \'', $b).'\')';
}
if ($rows) {
$module_obj->db->execute('
REPLACE INTO '._DB_PREFIX_.'a_blog_block
VALUES '.implode(', ', $rows).'
');
}
// update show_date and show_tags for post/category
$multishop_general_settings = $module_obj->db->executeS('
SELECT * FROM '._DB_PREFIX_.'a_blog_settings WHERE name = \'general\'
');
$show_date_array = array();
foreach ($multishop_general_settings as $s) {
$value = Tools::jsonDecode($s['value'], true);
$show_date_array[$s['id_shop']] = isset($value['show_date']) ? $value['show_date'] : 0;
}
$rows = array();
$settings_rows = $module_obj->db->executeS('
SELECT * FROM '._DB_PREFIX_.'a_blog_settings
');
foreach ($settings_rows as $row) {
if (in_array($row['name'], array('category', 'post'))) {
$decoded_value = Tools::jsonDecode($row['value'], true);
$decoded_value['show_date'] = !empty($show_date_array[$row['id_shop']]) ? '1' : '0';
$decoded_value['show_tags'] = '1';
$row['value'] = Tools::jsonEncode($decoded_value);
$rows[] = '(\''.implode('\', \'', $row).'\')';
}
}
if ($rows) {
$module_obj->db->execute('
REPLACE INTO '._DB_PREFIX_.'a_blog_settings
VALUES '.implode(', ', $rows).'
');
}
// new exceptions system
$exc_data = $module_obj->db->executeS('
SELECT hme.*, h.name AS hook_name
FROM '._DB_PREFIX_.'hook_module_exceptions hme
LEFT JOIN '._DB_PREFIX_.'hook h ON h.id_hook = hme.id_hook
WHERE id_module = '.(int)$module_obj->id.'
');
$hook_exceptions = $hook_rows = array();
foreach ($exc_data as $d) {
$hook_exceptions[$d['id_shop']][$d['hook_name']][] = $d['file_name'];
}
foreach ($hook_exceptions as $id_shop => $exceptions) {
foreach ($exceptions as $hook_name => $e) {
$e = implode(',', array_map('pSQL', $e));
$hook_rows[] = '(\''.pSQL($hook_name).'\', '.(int)$id_shop.', 1, \''.$e.'\')';
}
}
if ($hook_rows) {
$module_obj->db->execute('
INSERT INTO '._DB_PREFIX_.'a_blog_hook_settings
(hook_name, id_shop, exc_type, exc_controllers)
VALUES '.implode(', ', $hook_rows).'
ON DUPLICATE KEY UPDATE
exc_type = VALUES(exc_type),
exc_controllers = VALUES(exc_controllers)
');
}
return true;
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* 2007-2017 Amazzing
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Amazzing <mail@amazzing.ru>
* @copyright 2007-2017 Amazzing
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
function upgrade_module_1_2_2($module_obj)
{
if (!defined('_PS_VERSION_')) {
exit;
}
$module_obj->prepareInitialSettings();
return true;
}

View File

@@ -0,0 +1,78 @@
<?php
/**
* 2007-2017 Amazzing
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Amazzing <mail@amazzing.ru>
* @copyright 2007-2017 Amazzing
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
function upgrade_module_1_3_0($module_obj)
{
if (!defined('_PS_VERSION_')) {
exit;
}
// prepare postlist settings basing on category settings
$category_settings = $module_obj->getSettings('category');
$category_settings = upgradeCoverTitleIntroSettings($category_settings);
$postlist_settings = array();
$postlist_fields = array_keys($module_obj->getSettingsFields('postlist'));
foreach ($postlist_fields as $name) {
if (isset($category_settings[$name])) {
$postlist_settings[$name] = $category_settings[$name];
unset($category_settings[$name]);
}
}
$shop_ids = Shop::getShops(false, null, true);
$module_obj->saveSettings('postlist', $postlist_settings, $shop_ids);
$module_obj->saveSettings('category', $category_settings, $shop_ids);
// upgrade blocks settings
$replacements = array(
'latest' => 'post_latest',
'selectedposts' => 'post_selected',
'mostviewed' => 'post_mostviewed',
'random' => 'post_random',
'related' => 'post_relatedtopost',
);
$block_rows = $module_obj->db->executeS('SELECT * FROM '._DB_PREFIX_.'a_blog_block');
foreach ($block_rows as &$r) {
$settings = Tools::jsonDecode($r['settings'], true);
if (isset($settings['type']) && isset($replacements[$settings['type']])) {
$settings['type'] = $replacements[$settings['type']];
}
$settings = upgradeCoverTitleIntroSettings($settings);
$r['settings'] = Tools::jsonEncode($settings);
$r = '(\''.implode('\', \'', array_map('pSQL', $r)).'\')';
}
if ($block_rows) {
$module_obj->db->execute('REPLACE INTO '._DB_PREFIX_.'a_blog_block VALUES '.implode(', ', $block_rows));
}
$module_obj->addRelatedBlocksIfRequired();
$module_obj->prepareDatabase();
$module_obj->prepareInitialSettings();
$module_obj->registerHook('displayAdminProductsExtra');
$module_obj->registerHook('actionProductSave');
return true;
}
function upgradeCoverTitleIntroSettings($settings)
{
$replacements = array(
'show_cover' => 'cover_type',
'show_title' => 'title_truncate',
'show_intro' => 'truncate',
);
foreach ($replacements as $a => $b) {
if (isset($settings[$a]) && !$settings[$a]) {
$settings[$b] = '';
}
unset($settings[$a]);
}
return $settings;
}