예제 #1
0
 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);
 }
예제 #2
0
 public function doAction()
 {
     global $I18N, $REX;
     // $REX is needed for update.inc.php
     $path = rex_path::addon($this->addonkey);
     $temppath = rex_path::addon('.new.' . $this->addonkey);
     if (($msg = $this->extractArchiveTo($temppath)) !== true) {
         return $msg;
     }
     // ---- include update.php
     if (file_exists($temppath . 'update.inc.php')) {
         try {
             require $temppath . 'update.inc.php';
         } catch (rex_install_functional_exception $e) {
             return $e->getMessage();
         }
         if (($msg = OOAddon::getProperty($this->addonkey, 'updatemsg', '')) != '') {
             return $msg;
         }
         if (!OOAddon::getProperty($this->addonkey, 'update', true)) {
             return $I18N->msg('package_no_reason');
         }
     }
     // ---- backup
     $assets = rex_path::addonAssets($this->addonkey);
     if (OOAddon::getProperty('install', 'backups')) {
         $archivePath = rex_path::addonData('install', $this->addonkey . '/');
         rex_dir::create($archivePath);
         $archive = $archivePath . strtolower(preg_replace('/[^a-z0-9-_.]/i', '_', OOAddon::getVersion($this->addonkey))) . '.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 (OOPlugin::getRegisteredPlugins($this->addonkey) as $plugin) {
         $pluginPath = $temppath . '/plugins/' . $plugin;
         if (!is_dir($pluginPath)) {
             rex_dir::copy(rex_path::plugin($this->addonkey, $plugin), $pluginPath);
         } elseif (OOPlugin::isInstalled($this->addonkey, $plugin) && is_dir($pluginPath . '/files')) {
             rex_dir::copy($pluginPath . '/files', rex_path::pluginAssets($this->addonkey, $plugin));
         }
     }
     // ---- update main addon dir
     rex_dir::delete($path);
     rename($temppath, $path);
     // ---- update assets
     $origAssets = rex_path::addon($this->addonkey, 'assets');
     if (is_dir($origAssets)) {
         rex_dir::copy($origAssets, $assets);
     }
     OOAddon::setProperty($this->addonkey, 'version', $this->file['version']);
     rex_install_packages::updatedPackage($this->addonkey, $this->fileId);
 }