protected function setup() { $md5_psfiles = $this->getXmlMd5File('prestashop/' . _PS_VERSION_ . '.xml', 'ps_root_dir', _PS_VERSION_); list(, , , , $pp_files, ) = $vars1 = $this->getSetupVars1(); $this->setupOverriddenFiles($vars1); foreach ($pp_files as $pp_file) { list($setup_rel_path, $setup_amended_rel_path, $rel_path, $file, , ) = $this->getSetupVars2($vars1, $pp_file); if ($this->install_mode) { $compatibility = $this->checkVersionCompatibility($file, $rel_path, $pp_file); if ($compatibility[self::VERSION_CHECK_INDEX] == false) { if (is_array($md5_psfiles)) { $ps_files = array_keys($md5_psfiles); } $do_copy = !file_exists($file); if (!$do_copy) { if (is_array($ps_files) && in_array($setup_amended_rel_path, $ps_files)) { $do_copy = PSM::md5Compare($file, $md5_psfiles[$setup_amended_rel_path]); } } if ($do_copy) { $this->backupFile($file); if (!is_dir(dirname($file))) { mkdir(dirname($file), 0755, true); } @chmod($file, 0755); Tools::deleteFile($file); Tools::copy($pp_file, $file); } } } else { $restore = PSM::md5filesCompare($pp_file, $file); if ($restore) { $this->restoreFile($file); $delete = PSM::md5filesCompare($pp_file, $file); if ($delete) { if (is_array($md5_psfiles)) { $ps_files = array_keys($md5_psfiles); } if (is_array($ps_files) && !in_array($setup_rel_path, $ps_files)) { Tools::deleteFile($file); } } } } } if ($this->install_mode) { // backward compatibility foreach (array('css', 'js') as $type) { $bw_file = _PS_THEME_DIR_ . $type . '/modules/' . $this->module->name . '/' . $type . '/pp_theme_custom.' . $type; if (is_file($bw_file)) { $dir = _PS_THEME_DIR_ . $type . '/modules/' . $this->module->name; $file = $dir . '/custom.' . $type; if (!is_file($file)) { mkdir($dir, 0755, true); Tools::copy($bw_file, $file); } if (is_file($file)) { Tools::deleteFile($bw_file); } } } } if ($this->install_mode) { $result = $this->updateDB(); if ($result) { $this->insertData(false); } } $this->setupSmarty($this->install_mode); $this->getPPSetupEx()->setup(); $this->setupPlugins(); $this->setupExtraModules(); if (!$this->install_mode) { $this->cleanup(); } PSM::clearCache(); if ($this->install_mode) { PSM::protectDirectory(_PS_ROOT_DIR_, array(_PS_MODULE_DIR_)); PSM::protectDirectory(_PS_MODULE_DIR_ . 'pproperties'); PSM::protectDirectory(self::getBackupRootDirectory()); } }
function psmppropertiesIntegration($vars, $install) { Tools::deleteDirectory($vars['base']); if ($install) { if (file_exists($vars['base'])) { return array('error_delete_directory' => $vars['base']); } mkdir($vars['dirname'], 0755, true); Tools::copy(_PS_MODULE_DIR_ . $vars['module']->name . '/ppsetup.php', $vars['ppsetup']); PSM::protectDirectory($vars['base']); if (!is_file($vars['ppsetup'])) { return array('error_create_file' => $vars['ppsetup']); } } return true; }