//added new step in installer to install addons module
This commit is contained in:
1 parent
d2e57706d2
commit
7b93630595
2 files changed
+52
-8
No files matched your search
@@ -95,7 +95,9 @@ class InstallControllerHttpProcess extends InstallControllerHttp
|
|||||||
$this->processConfigureShop();
|
$this->processConfigureShop();
|
||||||
elseif (Tools::getValue('installModules') && !empty($this->session->process_validated['configureShop']))
|
elseif (Tools::getValue('installModules') && !empty($this->session->process_validated['configureShop']))
|
||||||
$this->processInstallModules();
|
$this->processInstallModules();
|
||||||
elseif (Tools::getValue('installFixtures') && !empty($this->session->process_validated['installModules']))
|
elseif (Tools::getValue('installModulesAddons') && !empty($this->session->process_validated['installModules']))
|
||||||
|
$this->processInstallAddonsModules();
|
||||||
|
elseif (Tools::getValue('installFixtures') && !empty($this->session->process_validated['installModulesAddons']))
|
||||||
$this->processInstallFixtures();
|
$this->processInstallFixtures();
|
||||||
elseif (Tools::getValue('installTheme') && !empty($this->session->process_validated['installModules']))
|
elseif (Tools::getValue('installTheme') && !empty($this->session->process_validated['installModules']))
|
||||||
$this->processInstallTheme();
|
$this->processInstallTheme();
|
||||||
@@ -232,6 +234,23 @@ class InstallControllerHttpProcess extends InstallControllerHttp
|
|||||||
$this->ajaxJsonAnswer(true);
|
$this->ajaxJsonAnswer(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PROCESS : installModulesAddons
|
||||||
|
* Install modules from addons
|
||||||
|
*/
|
||||||
|
public function processInstallAddonsModules()
|
||||||
|
{
|
||||||
|
$this->initializeContext();
|
||||||
|
if ($module = Tools::getValue('module') && $id_module = Tools::getValue('id_module'))
|
||||||
|
$result = $this->model_install->installModulesAddons(array('name' => $module, 'id_module' => $id_module));
|
||||||
|
else
|
||||||
|
$result = $this->model_install->installModulesAddons();
|
||||||
|
if (!$result || $this->model_install->getErrors())
|
||||||
|
$this->ajaxJsonAnswer(false, $this->model_install->getErrors());
|
||||||
|
$this->session->process_validated = array_merge($this->session->process_validated, array('installModulesAddons' => true));
|
||||||
|
$this->ajaxJsonAnswer(true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PROCESS : installFixtures
|
* PROCESS : installFixtures
|
||||||
* Install fixtures (E.g. demo products)
|
* Install fixtures (E.g. demo products)
|
||||||
@@ -312,6 +331,8 @@ class InstallControllerHttpProcess extends InstallControllerHttp
|
|||||||
*/
|
*/
|
||||||
public function display()
|
public function display()
|
||||||
{
|
{
|
||||||
|
$this->initializeContext();
|
||||||
|
|
||||||
// The installer SHOULD take less than 32M, but may take up to 35/36M sometimes. So 42M is a good value :)
|
// The installer SHOULD take less than 32M, but may take up to 35/36M sometimes. So 42M is a good value :)
|
||||||
$low_memory = Tools::getMemoryLimit() < Tools::getOctets('42M');
|
$low_memory = Tools::getMemoryLimit() < Tools::getOctets('42M');
|
||||||
|
|
||||||
@@ -333,13 +354,18 @@ class InstallControllerHttpProcess extends InstallControllerHttp
|
|||||||
$this->process_steps[] = $populate_step;
|
$this->process_steps[] = $populate_step;
|
||||||
$this->process_steps[] = array('key' => 'configureShop', 'lang' => $this->l('Configure shop information'));
|
$this->process_steps[] = array('key' => 'configureShop', 'lang' => $this->l('Configure shop information'));
|
||||||
|
|
||||||
|
|
||||||
$install_modules = array('key' => 'installModules', 'lang' => $this->l('Install modules'));
|
$install_modules = array('key' => 'installModules', 'lang' => $this->l('Install modules'));
|
||||||
if ($low_memory)
|
if ($low_memory)
|
||||||
foreach ($this->model_install->getModulesList() as $module)
|
foreach ($this->model_install->getModulesList() as $module)
|
||||||
$install_modules['subtasks'][] = array('module' => $module);
|
$install_modules['subtasks'][] = array('module' => $module);
|
||||||
$this->process_steps[] = $install_modules;
|
$this->process_steps[] = $install_modules;
|
||||||
|
|
||||||
|
$install_modules = array('key' => 'installModulesAddons', 'lang' => $this->l('Install modules Addons'));
|
||||||
|
if ($low_memory)
|
||||||
|
foreach ($this->model_install->getAddonsModulesList() as $module)
|
||||||
|
$install_modules['subtasks'][] = array('module' => (string)$module['name'], 'id_module' => (string)$module['id_module']);
|
||||||
|
$this->process_steps[] = $install_modules;
|
||||||
|
|
||||||
// Fixtures are installed only if option is selected
|
// Fixtures are installed only if option is selected
|
||||||
if ($this->session->install_type == 'full')
|
if ($this->session->install_type == 'full')
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -585,7 +585,6 @@ class InstallModelInstall extends InstallAbstractModel
|
|||||||
'statsvisits',
|
'statsvisits',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $modules;
|
return $modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,18 +601,16 @@ class InstallModelInstall extends InstallAbstractModel
|
|||||||
return $addons_modules;
|
return $addons_modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PROCESS : installModules
|
* PROCESS : installModules
|
||||||
* Download module from addons and Install all modules in ~/modules/ directory
|
* Download module from addons and Install all modules in ~/modules/ directory
|
||||||
*/
|
*/
|
||||||
public function installModules($module = null)
|
public function installModulesAddons($module = null)
|
||||||
{
|
{
|
||||||
$modules = $module ? array($module) : $this->getModulesList();
|
$addons_modules = $module ? array($module) : $this->getAddonsModulesList();
|
||||||
|
$modules = array();
|
||||||
if (!InstallSession::getInstance()->safe_mode)
|
if (!InstallSession::getInstance()->safe_mode)
|
||||||
{
|
{
|
||||||
$addons_modules = $this->getAddonsModulesList();
|
|
||||||
|
|
||||||
foreach($addons_modules as $addons_module)
|
foreach($addons_modules as $addons_module)
|
||||||
if (file_put_contents(_PS_MODULE_DIR_.$addons_module['name'].'.zip', Tools::addonsRequest('module', array('id_module' => $addons_module['id_module']))))
|
if (file_put_contents(_PS_MODULE_DIR_.$addons_module['name'].'.zip', Tools::addonsRequest('module', array('id_module' => $addons_module['id_module']))))
|
||||||
if (Tools::ZipExtract(_PS_MODULE_DIR_.$addons_module['name'].'.zip', _PS_MODULE_DIR_))
|
if (Tools::ZipExtract(_PS_MODULE_DIR_.$addons_module['name'].'.zip', _PS_MODULE_DIR_))
|
||||||
@@ -622,6 +619,27 @@ class InstallModelInstall extends InstallAbstractModel
|
|||||||
unlink(_PS_MODULE_DIR_.$addons_module['name'].'.zip');
|
unlink(_PS_MODULE_DIR_.$addons_module['name'].'.zip');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$errors = array();
|
||||||
|
foreach ($modules as $module_name)
|
||||||
|
if (!$this->installModules($module_name))
|
||||||
|
$errors[] = $this->language->l('Cannot install module "%s"', $module_name);
|
||||||
|
|
||||||
|
if ($errors)
|
||||||
|
{
|
||||||
|
$this->setError($errors);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PROCESS : installModules
|
||||||
|
* Download module from addons and Install all modules in ~/modules/ directory
|
||||||
|
*/
|
||||||
|
public function installModules($module = null)
|
||||||
|
{
|
||||||
|
$modules = $module ? array($module) : $this->getModulesList();
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
foreach ($modules as $module_name)
|
foreach ($modules as $module_name)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user