public function doAction() { $path = rex_path::addon($this->addonkey); $temppath = rex_path::addon('.new.' . $this->addonkey); if (($msg = $this->extractArchiveTo($temppath)) !== true) { return $msg; } if ($this->addon->isAvailable() && ($msg = $this->checkRequirements()) !== true) { return $msg; } // ---- include update.php if ($this->addon->isInstalled() && file_exists($temppath . rex_package::FILE_UPDATE)) { try { $this->addon->includeFile('../.new.' . $this->addonkey . '/' . rex_package::FILE_UPDATE); } catch (rex_functional_exception $e) { return $e->getMessage(); } catch (rex_sql_exception $e) { return 'SQL error: ' . $e->getMessage(); } if (($msg = $this->addon->getProperty('updatemsg', '')) != '') { return $msg; } if (!$this->addon->getProperty('update', true)) { return rex_i18n::msg('package_no_reason'); } } // ---- backup $assets = $this->addon->getAssetsPath(); if (rex_addon::get('install')->getConfig('backups')) { $archivePath = rex_path::addonData('install', $this->addonkey . '/'); rex_dir::create($archivePath); $archive = $archivePath . strtolower(preg_replace('/[^a-z0-9-_.]/i', '_', $this->addon->getVersion('0'))) . '.zip'; rex_install_archive::copyDirToArchive($path, $archive); if (is_dir($assets)) { rex_install_archive::copyDirToArchive($assets, $archive, 'assets'); } } // ---- copy plugins to new addon dir foreach ($this->addon->getRegisteredPlugins() as $plugin) { $pluginPath = $temppath . '/plugins/' . $plugin->getName(); if (!is_dir($pluginPath)) { rex_dir::copy($plugin->getPath(), $pluginPath); } elseif ($plugin->isInstalled() && is_dir($pluginPath . '/assets')) { rex_dir::copy($pluginPath . '/assets', $plugin->getAssetsPath()); } } // ---- update main addon dir rex_dir::delete($path); rename($temppath, $path); // ---- update assets $origAssets = $this->addon->getPath('assets'); if ($this->addon->isInstalled() && is_dir($origAssets)) { rex_dir::copy($origAssets, $assets); } $this->addon->setProperty('version', $this->file['version']); rex_install_packages::updatedPackage($this->addonkey, $this->fileId); }