Initial commit

This commit is contained in:
2019-11-20 07:44:43 +01:00
commit 5bf49c4a81
41188 changed files with 5459177 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
<?php
/*
* 2007-2018 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-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\AutoUpgrade\TaskRunner\Miscellaneous;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeFileNames;
use PrestaShop\Module\AutoUpgrade\TaskRunner\AbstractTask;
/**
* List the files modified in the current installation regards to the original version.
*/
class CheckFilesVersion extends AbstractTask
{
public function run()
{
// do nothing after this request (see javascript function doAjaxRequest )
$this->next = '';
$upgrader = $this->container->getUpgrader();
$changedFileList = $upgrader->getChangedFilesList();
if ($changedFileList === false) {
$this->nextParams['status'] = 'error';
$this->nextParams['msg'] = $this->translator->trans('Unable to check files for the installed version of PrestaShop.', array(), 'Modules.Autoupgrade.Admin');
return;
}
foreach (array('core', 'translation', 'mail') as $type) {
if (!isset($changedFileList[$type])) {
$changedFileList[$type] = array();
}
}
if ($upgrader->isAuthenticPrestashopVersion() === true) {
$this->nextParams['status'] = 'ok';
$this->nextParams['msg'] = $this->translator->trans('Core files are ok', array(), 'Modules.Autoupgrade.Admin');
} else {
$this->nextParams['status'] = 'warn';
$this->nextParams['msg'] = $this->translator->trans(
'%modificationscount% file modifications have been detected, including %coremodifications% from core and native modules:',
array(
'%modificationscount%' => count(array_merge($changedFileList['core'], $changedFileList['mail'], $changedFileList['translation'])),
'%coremodifications%' => count($changedFileList['core']),
),
'Modules.Autoupgrade.Admin'
);
}
$this->nextParams['result'] = $changedFileList;
$this->container->getFileConfigurationStorage()->save($changedFileList['translation'], UpgradeFileNames::TRANSLATION_FILES_CUSTOM_LIST);
$this->container->getFileConfigurationStorage()->save($changedFileList['mail'], UpgradeFileNames::MAILS_CUSTOM_LIST);
}
}

View File

@@ -0,0 +1,84 @@
<?php
/*
* 2007-2018 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-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\AutoUpgrade\TaskRunner\Miscellaneous;
use PrestaShop\Module\AutoUpgrade\TaskRunner\AbstractTask;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeFileNames;
/**
* get the list of all modified and deleted files between current version
* and target version (according to channel configuration).
*/
class CompareReleases extends AbstractTask
{
public function run()
{
// do nothing after this request (see javascript function doAjaxRequest )
$this->next = '';
$channel = $this->container->getUpgradeConfiguration()->get('channel');
$upgrader = $this->container->getUpgrader();
switch ($channel) {
case 'archive':
$version = $this->container->getUpgradeConfiguration()->get('archive.version_num');
break;
case 'directory':
$version = $this->container->getUpgradeConfiguration()->get('directory.version_num');
break;
default:
preg_match('#([0-9]+\.[0-9]+)(?:\.[0-9]+){1,2}#', _PS_VERSION_, $matches);
$upgrader->branch = $matches[1];
$upgrader->channel = $channel;
if ($this->container->getUpgradeConfiguration()->get('channel') == 'private' && !$this->container->getUpgradeConfiguration()->get('private_allow_major')) {
$upgrader->checkPSVersion(false, array('private', 'minor'));
} else {
$upgrader->checkPSVersion(false, array('minor'));
}
$version = $upgrader->version_num;
}
$diffFileList = $upgrader->getDiffFilesList(_PS_VERSION_, $version);
if (!is_array($diffFileList)) {
$this->nextParams['status'] = 'error';
$this->nextParams['msg'] = sprintf('Unable to generate diff file list between %1$s and %2$s.', _PS_VERSION_, $version);
} else {
$this->container->getFileConfigurationStorage()->save($diffFileList, UpgradeFileNames::FILES_DIFF_LIST);
if (count($diffFileList) > 0) {
$this->nextParams['msg'] = $this->translator->trans(
'%modifiedfiles% files will be modified, %deletedfiles% files will be deleted (if they are found).',
array(
'%modifiedfiles%' => count($diffFileList['modified']),
'%deletedfiles%' => count($diffFileList['deleted']),
),
'Modules.Autoupgrade.Admin');
} else {
$this->nextParams['msg'] = $this->translator->trans('No diff files found.', array(), 'Modules.Autoupgrade.Admin');
}
$this->nextParams['result'] = $diffFileList;
}
}
}

View File

@@ -0,0 +1,56 @@
<?php
/*
* 2007-2018 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-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\AutoUpgrade\TaskRunner\Miscellaneous;
use PrestaShop\Module\AutoUpgrade\ChannelInfo;
use PrestaShop\Module\AutoUpgrade\TaskRunner\AbstractTask;
use PrestaShop\Module\AutoUpgrade\Twig\Block\ChannelInfoBlock;
/**
* display informations related to the selected channel : link/changelog for remote channel,
* or configuration values for special channels.
*/
class GetChannelInfo extends AbstractTask
{
public function run()
{
// do nothing after this request (see javascript function doAjaxRequest )
$this->next = '';
$channel = $this->container->getUpgradeConfiguration()->getChannel();
$channelInfo = (new ChannelInfo($this->container->getUpgrader(), $this->container->getUpgradeConfiguration(), $channel));
$channelInfoArray = $channelInfo->getInfo();
$this->nextParams['result']['available'] = $channelInfoArray['available'];
$this->nextParams['result']['div'] = (new ChannelInfoBlock(
$this->container->getUpgradeConfiguration(),
$channelInfo,
$this->container->getTwig())
)->render();
}
}

View File

@@ -0,0 +1,130 @@
<?php
/*
* 2007-2018 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-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\AutoUpgrade\TaskRunner\Miscellaneous;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeFileNames;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfigurationStorage;
use PrestaShop\Module\AutoUpgrade\TaskRunner\AbstractTask;
use PrestaShop\Module\AutoUpgrade\Upgrader;
/**
* update configuration after validating the new values.
*/
class UpdateConfig extends AbstractTask
{
public function run()
{
// nothing next
$this->next = '';
// Was coming from AdminSelfUpgrade::currentParams before
$request = $this->getRequestParams();
$config = array();
// update channel
if (isset($request['channel'])) {
$config['channel'] = $request['channel'];
$config['archive.filename'] = Upgrader::DEFAULT_FILENAME;
// Switch on default theme if major upgrade (i.e: 1.6 -> 1.7)
$config['PS_AUTOUP_CHANGE_DEFAULT_THEME'] = ($request['channel'] === 'major');
}
if (isset($request['private_release_link'], $request['private_release_md5'])) {
$config['channel'] = 'private';
$config['private_release_link'] = $request['private_release_link'];
$config['private_release_md5'] = $request['private_release_md5'];
$config['private_allow_major'] = $request['private_allow_major'];
}
// if (!empty($request['archive_name']) && !empty($request['archive_num']))
if (!empty($request['archive_prestashop'])) {
$file = $request['archive_prestashop'];
if (!file_exists($this->container->getProperty(UpgradeContainer::DOWNLOAD_PATH) . DIRECTORY_SEPARATOR . $file)) {
$this->error = true;
$this->logger->info($this->translator->trans('File %s does not exist. Unable to select that channel.', array($file), 'Modules.Autoupgrade.Admin'));
return false;
}
if (empty($request['archive_num'])) {
$this->error = true;
$this->logger->info($this->translator->trans('Version number is missing. Unable to select that channel.', array(), 'Modules.Autoupgrade.Admin'));
return false;
}
$config['channel'] = 'archive';
$config['archive.filename'] = $request['archive_prestashop'];
$config['archive.version_num'] = $request['archive_num'];
// $config['archive_name'] = $request['archive_name'];
$this->logger->info($this->translator->trans('Upgrade process will use archive.', array(), 'Modules.Autoupgrade.Admin'));
}
if (isset($request['directory_num'])) {
$config['channel'] = 'directory';
if (empty($request['directory_num']) || strpos($request['directory_num'], '.') === false) {
$this->error = true;
$this->logger->info($this->translator->trans('Version number is missing. Unable to select that channel.', array(), 'Modules.Autoupgrade.Admin'));
return false;
}
$config['directory.version_num'] = $request['directory_num'];
}
if (isset($request['skip_backup'])) {
$config['skip_backup'] = $request['skip_backup'];
}
if (!$this->writeConfig($config)) {
$this->error = true;
$this->logger->info($this->translator->trans('Error on saving configuration', array(), 'Modules.Autoupgrade.Admin'));
}
}
protected function getRequestParams()
{
return empty($_REQUEST['params']) ? array() : $_REQUEST['params'];
}
/**
* update module configuration (saved in file UpgradeFiles::configFilename) with $new_config.
*
* @param array $config
*
* @return bool true if success
*/
private function writeConfig($config)
{
if (!$this->container->getFileConfigurationStorage()->exists(UpgradeFileNames::CONFIG_FILENAME) && !empty($config['channel'])) {
$this->container->getUpgrader()->channel = $config['channel'];
$this->container->getUpgrader()->checkPSVersion();
$this->container->getState()->setInstallVersion($this->container->getUpgrader()->version_num);
}
$this->container->getUpgradeConfiguration()->merge($config);
$this->logger->info($this->translator->trans('Configuration successfully updated.', array(), 'Modules.Autoupgrade.Admin') . ' <strong>' . $this->translator->trans('This page will now be reloaded and the module will check if a new version is available.', array(), 'Modules.Autoupgrade.Admin') . '</strong>');
return (new UpgradeConfigurationStorage($this->container->getProperty(UpgradeContainer::WORKSPACE_PATH) . DIRECTORY_SEPARATOR))->save($this->container->getUpgradeConfiguration(), UpgradeFileNames::CONFIG_FILENAME);
}
}