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); }
/** * set the property for the metainfo. * added Entrys in metaTables and prefixes */ public static function setProperty() { global $REX; $metaTables = OOAddon::getProperty('metainfo', 'metaTables', array()); $metaTables['asd_'] = $REX['TABLE_PREFIX'] . 'asd_news'; OOAddon::setProperty('metainfo', 'metaTables', $metaTables); $prefixes = OOAddon::getProperty('metainfo', 'prefixes', array()); if (!in_array('asd_', $prefixes)) { $prefixes[] = 'asd_'; } OOAddon::setProperty('metainfo', 'prefixes', $prefixes); }
/** * set the property for the metainfo. * added Entrys in metaTables and prefixes */ public static function setProperty() { global $REX; $metaTables = OOAddon::getProperty('metainfo', 'metaTables', array()); $metaTables[self::PREFIX] = $REX['TABLE_PREFIX'] . self::TABLE; OOAddon::setProperty('metainfo', 'metaTables', $metaTables); $prefixes = OOAddon::getProperty('metainfo', 'prefixes', array()); if (!in_array(self::PREFIX, $prefixes)) { $prefixes[] = self::PREFIX; } OOAddon::setProperty('metainfo', 'prefixes', $prefixes); }
function setProperty($plugin, $property, $value) { global $REX; // Plugin in Liste aufnehmen $plugins = OOPlugin::getRegisteredPlugins(); if (!in_array($plugin, $plugins)) { $plugins[$plugin] = $plugin; OOAddon::setProperty('community', 'pluginlist', $plugins); } if (!isset($REX['ADDON']['plugins']['community'][$plugin])) { $REX['ADDON']['plugins']['community'][$plugin] = array(); } // Property fuer das Plugin setzen $REX['ADDON']['plugins']['community'][$plugin][$property] = $value; }
/** * Schreibt Addoneigenschaften in die Datei include/addons.inc.php * * @param array Array mit den Namen der Addons aus dem Verzeichnis addons/ * * @return TRUE bei Erfolg, sonst FALSE */ function rex_generateAddons($ADDONS) { global $REX; natsort($ADDONS); $content = ''; foreach ($ADDONS as $addon) { if (!OOAddon::isInstalled($addon)) { OOAddon::setProperty($addon, 'install', 0); } if (!OOAddon::isActivated($addon)) { OOAddon::setProperty($addon, 'status', 0); } foreach (array('install', 'status') as $prop) { $content .= sprintf("\$REX['ADDON']['%s']['%s'] = '%d';\n", $prop, $addon, OOAddon::getProperty($addon, $prop)); } $content .= "\n"; } // Da dieser Funktion öfter pro request aufgerufen werden kann, // hier die caches löschen clearstatcache(); $file = $REX['INCLUDE_PATH'] . '/addons.inc.php'; if (rex_replace_dynamic_contents($file, $content) === false) { return 'Datei "' . $file . '" hat keine Schreibrechte'; } return true; }
<?php /** @var i18n $I18N */ $content = ''; $settings = rex_post('settings', array(array('backups', 'bool', false), array('api_login', 'string'), array('api_key', 'string')), null); if (is_array($settings)) { $settingsContent = "<?php\n\n"; foreach ($settings as $key => $value) { $settingsContent .= "\$REX['ADDON'][" . var_export($key, true) . "]['install'] = " . var_export($value, true) . ";\n"; OOAddon::setProperty('install', $key, $value); } if (rex_file::put(rex_path::addonData('install', 'settings.inc.php'), $settingsContent)) { echo rex_info($I18N->msg('install_settings_saved')); } else { echo rex_warning($I18N->msg('install_settings_not_saved')); } rex_install_webservice::deleteCache(); } $content .= ' <div class="rex-addon-output"> <h2 class="rex-hl2">' . $I18N->msg('install_subpage_settings') . '</h2> <div class="rex-form"> <form action="index.php?page=install&subpage=settings" method="post"> <fieldset class="rex-form-col-1"> <legend>' . $I18N->msg('install_settings_general') . '</legend> <div class="rex-form-wrapper">'; $content .= ' <div class="rex-form-row"> <p class="rex-form-col-a rex-form-checkbox rex-form-label-right">