public function install(JAdapterInstance $adapter) { $lib = $adapter->getParent()->getPath('source') . '/library/'; $installer = new JInstaller(); $installer->install($lib); $src = $adapter->getParent()->getPath('source'); foreach ($this->cli as $script) { if (JFile::exists(JPATH_ROOT . '/cli/' . $script)) { JFile::delete(JPATH_ROOT . '/cli/' . $script); } if (JFile::exists($src . '/cli/' . $script)) { JFile::move($src . '/cli/' . $script, JPATH_ROOT . '/cli/' . $script); } } }
public function update(JAdapterInstance $adapter) { $src = $adapter->getParent()->getPath('source'); $site = $adapter->getParent()->getPath('extension_site'); $admin = $adapter->getParent()->getPath('extension_administrator'); $attributes = $adapter->getParent()->get('manifest')->media->attributes(); $attributes = reset($attributes); $extension = \Joomla\Utilities\ArrayHelper::getValue($attributes, 'destination'); $exclude = array(); $exclude[] = $adapter->get('manifest_script'); $exclude[] = JFile::getName($adapter->getParent()->getPath('manifest')); $this->removeRedundantFiles($site, $src . '/site'); $this->removeRedundantFiles($admin, $src . '/admin', $exclude); if ($extension) { $media = JPATH_ROOT . '/media/' . $extension; $this->removeRedundantFiles($media, $src . '/media', $exclude); } }
/** * Called after any type of action * * @param string $route Which action is happening (install|uninstall|discover_install|update) * @param JAdapterInstance $adapter The object responsible for running this script * * @return boolean True on success */ public function postflight($route, JAdapterInstance $adapter) { $parent = $adapter->getParent(); // install update server for new installation or when updating module older than 3.2.4 require_once $parent->getPath('source') . '/helpers/updateserver.php'; $version = $parent->getManifest()->version; $updateServer = new modPWebContactUpdateServer(); // delete old md5 files $updateServer->deleteMd5($parent->getPath('extension_root') . '/form'); // add new md5 file if ($download_id = $updateServer->getMd5($parent->getPath('source'))) { $buffer = ''; JFile::write($parent->getPath('extension_root') . '/form/' . $download_id, $buffer); } $updateServer->add($version, $download_id); }
/** * install all integrated third party plugins and the xmap system plugin * * @param JAdapterInstance $adapter */ public function install(JAdapterInstance $adapter) { $path = $adapter->getParent()->getPath('source'); $folders = JFolder::folders($path . '/plugins/xmap/'); $plugins = array(); foreach ($folders as $component) { $plugins[$component] = $path . '/plugins/xmap/' . $component; } // install each third party plugin if component installed foreach ($plugins as $component => $plugin) { if (JComponentHelper::isInstalled($component)) { $installer = new JInstaller(); $installer->install($plugin); } } // install xmap system plugin // TODO implement plugin features in XmapDisplayerHtml //$installer = new JInstaller; //$installer->install($path . '/plugins/system/xmap/'); }
/** * * install the modules from "modules" folder */ public function installModules(JAdapterInstance &$adapter, $type = "install") { $ds = ""; if (defined("DIRECTORY_SEPARATOR")) { $ds = DIRECTORY_SEPARATOR; } else { $ds = DS; } $manifest = $adapter->get("manifest"); $installer = new JInstaller(); $p_installer = $adapter->getParent(); // Install modules if (is_object($manifest->modules->module)) { foreach ($manifest->modules->module as $module) { $attributes = $module->attributes(); $modulePath = $p_installer->getPath("source") . $ds . $attributes['folder'] . $ds . $attributes['module']; if ($type == "install") { $installer->install($modulePath); } else { $installer->update($modulePath); } } } }
public function uninstall(JAdapterInstance $adapter) { $language = JFactory::getLanguage(); $language->load('com_jvrelatives'); $this->db->setQuery("drop table if exists #__jvrelatives"); $this->db->execute(); $manifest = $adapter->getParent()->manifest; $plugins = $manifest->xpath('plugins/plugin'); if (count($plugins)) { foreach ($plugins as $plugin) { $name = (string) $plugin->attributes()->plugin; $group = (string) $plugin->attributes()->group; $this->i_status->plugins[] = array('name' => $name, 'group' => $group, 'result' => $this->uninstallPlugin($name, $group)); } } $modules = $manifest->xpath('modules/module'); if (count($modules)) { foreach ($modules as $module) { $name = (string) $module->attributes()->module; $client = (string) $module->attributes()->client; $this->i_status->modules[] = array('name' => $name, 'client' => $client, 'result' => $this->uninstallModule($name)); } } if (JFolder::exists(JPATH_ROOT . DS . 'components' . DS . 'com_cobalt')) { try { if (JFolder::exists(JPATH_ROOT . DS . 'components' . DS . 'com_cobalt' . DS . 'fields' . DS . 'jvrelatives')) { JFolder::delete(JPATH_ROOT . DS . 'components' . DS . 'com_cobalt' . DS . 'fields' . DS . 'jvrelatives'); $this->i_status->files[0] = array('name' => 'cobalt field', 'result' => 1); } } catch (Exception $ex) { $this->i_status->files[0] = array('name' => 'cobalt field', 'result' => 0); } } $rows = 0; ?> <h2><?php echo JText::_('COM_JVRELATIVES_REMOVAL_STATUS'); ?> </h2> <table class="adminlist table table-striped"> <thead> <tr> <th class="title" colspan="2"><?php echo JText::_('COM_JVRELATIVES_EXTENSION'); ?> </th> <th width="30%"><?php echo JText::_('COM_JVRELATIVES_STATUS'); ?> </th> </tr> </thead> <tfoot> <tr> <td colspan="3"></td> </tr> </tfoot> <tbody> <tr class="row0"> <td class="key" colspan="2"><?php echo 'JV-Relatives ' . JText::_('COM_JVRELATIVES_COMPONENT'); ?> </td> <td><strong><?php echo JText::_('COM_JVRELATIVES_UNINSTALLED'); ?> </strong></td> </tr> <?php if (count($this->i_status->modules)) { ?> <tr> <th><?php echo JText::_('COM_JVRELATIVES_MODULE'); ?> </th> <th><?php echo JText::_('COM_JVRELATIVES_CLIENT'); ?> </th> <th></th> </tr> <?php foreach ($this->i_status->modules as $module) { ?> <tr class="row<?php echo ++$rows % 2; ?> "> <td class="key"><?php echo $module['name']; ?> </td> <td class="key"><?php echo ucfirst($module['client']); ?> </td> <td><strong><?php echo $module['result'] ? JText::_('COM_JVRELATIVES_UNINSTALLED') : JText::_('COM_JVRELATIVES_NOT_UNINSTALLED'); ?> </strong></td> </tr> <?php } ?> <?php } ?> <?php if (count($this->i_status->plugins)) { ?> <tr> <th><?php echo JText::_('COM_JVRELATIVES_PLUGIN'); ?> </th> <th><?php echo JText::_('COM_JVRELATIVES_GROUP'); ?> </th> <th></th> </tr> <?php foreach ($this->i_status->plugins as $plugin) { ?> <tr class="row<?php echo ++$rows % 2; ?> "> <td class="key"><?php echo ucfirst($plugin['name']); ?> </td> <td class="key"><?php echo ucfirst($plugin['group']); ?> </td> <td><strong><?php echo $plugin['result'] ? JText::_('COM_JVRELATIVES_UNINSTALLED') : JText::_('COM_JVRELATIVES_NOT_UNINSTALLED'); ?> </strong></td> </tr> <?php } ?> <?php } ?> <?php if (count($this->i_status->files)) { ?> <tr> <th><?php echo JText::_('COM_JVRELATIVES_FILE'); ?> </th> <th></th> <th></th> </tr> <?php foreach ($this->i_status->files as $file) { ?> <tr class="row<?php echo ++$rows % 2; ?> "> <td class="key"><?php echo ucfirst($file['name']); ?> </td> <td class="key"></td> <td><strong><?php echo $file['result'] ? JText::_('COM_JVRELATIVES_UNINSTALLED') : JText::_('COM_JVRELATIVES_NOT_UNINSTALLED'); ?> </strong></td> </tr> <?php } ?> <?php } ?> </tbody> </table> <br /><br /> <div class="well"> <?php echo JText::_('COM_JVRELATIVES_UNINSTALL_TEXT_THANKYOU'); ?> </div> <?php }
/** * Called on update * * @access public * @param JAdapterInstance $adapter Installer Component Adapter. * @return void * * @since 1.6 */ public function update(JAdapterInstance $adapter) { $adapter->getParent()->setRedirectURL('index.php?option=com_rtiprint'); }
/** * Installs all dependencies. * * @param JAdapterInstance $parent */ private function installDependencies($parent) { $installed = array(); $installer = new JInstaller(); $installer->setOverwrite(true); $src = $parent->getParent()->getPath('source'); foreach ($this->dependencies as $type => $extension) { foreach ($extension as $name => $params) { $packageZip = $src . '/' . $type . '/' . $name . '.zip'; if (JFile::exists($packageZip)) { if ($package = JInstallerHelper::unpack($packageZip)) { $doInstall = true; $path = $this->getInstalledManifest($type, $name, $params); $oldManifest = null; if (JFile::exists($path)) { $oldManifest = $installer->parseXMLInstallFile($path); } $dir = JArrayHelper::getValue($package, 'dir') . '/'; $path = $this->getExtractedManifest($dir, $type, $name); $newManifest = $installer->parseXMLInstallFile($path); if ($oldManifest) { $oldVersion = JArrayHelper::getValue($oldManifest, 'version'); $newVersion = JArrayHelper::getValue($newManifest, 'version'); if (version_compare($oldVersion, $newVersion, 'ge')) { $doInstall = false; } } $success = true; if ($doInstall) { if ($success = $installer->install($dir)) { $installed[$name] = array('status' => 1); } else { $installed[$name] = array('status' => 0); } } else { $installed[$name] = array('status' => 2); } if ($success) { // post installation configuration. if ($type == 'modules') { $this->configureModule($name, $params); } } JInstallerHelper::cleanupInstall($packageZip, $dir); } } } } return $installed; }
public function install(JAdapterInstance $adapter) { $lib = $adapter->getParent()->getPath('source') . '/library/'; $installer = new JInstaller(); $installer->install($lib); }
/** * Method to run after an install/update/uninstall method. * * @param string $type is the type of change (install, update or discover_install) * @param JAdapterInstance $parent The class calling this method * * @return bool */ public function postflight($type, $parent) { if ('update' != $type) { return true; } $extensionPath = $parent->getParent()->getPath('extension_administrator'); $this->removeObsoleteFiles($extensionPath . '/to-be-removed.txt'); return true; }
public function installExtensions($route, JAdapterInstance $adapter) { JLog::add("*** Try to install extensions ***", JLog::INFO, 'com_visforms'); $db = JFactory::getDbo(); $src = $adapter->getParent()->getPath('source'); $manifest = $adapter->getParent()->manifest; $types = array(array('libraries', 'library'), array('plugins', 'plugin'), array('modules', 'module')); foreach ($types as $type) { $xmldefs = $manifest->xpath($type[0] . '/' . $type[1]); foreach ($xmldefs as $xmldef) { $name = (string) $xmldef->attributes()->{$type}[1]; $newVersion = (string) $xmldef->attributes()->version; $version = ""; $extWhere = $db->quoteName('type') . ' = ' . $db->quote($type[1]) . ' AND ' . $db->quoteName('element') . ' = ' . $db->quote($name); if ($type[1] == 'plugin') { $group = (string) $xmldef->attributes()->group; $path = $src . '/' . $type[0] . '/' . $group; if (JFolder::exists($src . '/' . $type[0] . '/' . $group . '/' . $name)) { $path = $src . '/' . $type[0] . '/' . $group . '/' . $name; } $extWhere .= ' AND ' . $db->quoteName('folder') . ' = ' . $db->quote($group); } if ($type[1] == 'module') { $client = (string) $xmldef->attributes()->client; if (is_null($client)) { $client = 'site'; } if ($client == 'site') { $client_id = 0; } else { $client_id = 1; } $client == 'administrator' ? $path = $src . '/administrator/' . $type[0] . '/' . $name : ($path = $src . '/' . $type[0] . '/' . $name); $extWhere .= ' AND ' . $db->quoteName('client_id') . ' = ' . $db->quote($client_id); } if ($type[1] == 'library') { $path = $src . '/' . $type[0] . '/' . $name; } $query = $db->getQuery(true); $query->select($db->quoteName('extension_id'))->from($db->quoteName('#__extensions'))->where($extWhere); $db->setQuery($query); $extension = array(); try { $extension = $db->loadColumn(); } catch (RuntimeException $e) { $message = JText::sprintf('COM_VISFORMS_UNABLE_TO_GET_EXTENSION_ID', $name) . " " . JText::sprintf('COM_VISFORMS_DB_FUNCTION_FAILED', $e->getMessage()); $this->status->messages[] = array('message' => $message); JLog::add('Unable to get extension_id: ' . $name . ', ' . $e->getMessage(), JLog::ERROR, 'com_visforms'); continue; } $installer = new JInstaller(); if (count($extension)) { //make sure we have got only on id, if not use the first if (is_array($extension)) { $extension = $extension[0]; } //check if we need to update try { $version = $this->getExtensionParam('version', (int) $extension); } catch (RuntimeException $e) { $message = JText::sprintf('COM_VISFORMS_UNABLE_TO_GET_EXTENSION_PARAMS', $name) . " " . JText::sprintf('COM_VISFORMS_DB_FUNCTION_FAILED', $e->getMessage()); $this->status->messages[] = array('message' => $message); JLog::add('Unable to get ' . $type[1] . ' params: ' . $name . ', ' . $e->getMessage(), JLog::ERROR, 'com_visforms'); continue; } if (version_compare($newVersion, $version, 'gt')) { $installationType = "update"; } } else { $installationType = "install"; } if (isset($installationType)) { try { $result = $installer->{$installationType}($path); $resultArray = array('name' => $name, 'result' => $result, 'type' => $installationType); if ($type[1] == "plugin") { $resultArray['group'] = $group; $this->status->plugins[] = $resultArray; //we have to enable the content plugin visforms if ($name == 'visforms') { JLog::add("Try to enable " . $type[1] . " " . $name, JLog::INFO, 'com_visforms'); $this->enableExtension($extWhere); } //enable plugin visform spambotcheck if ($name == 'spambotcheck') { JLog::add("Try to enable " . $type[1] . " " . $name, JLog::INFO, 'com_visforms'); $this->enableExtension($extWhere); } //enable plugin editor-xtd visformfields if ($name == 'visformfields') { JLog::add("Try to enable " . $type[1] . " " . $name, JLog::INFO, 'com_visforms'); $this->enableExtension($extWhere); } } if ($type[1] == "module") { $resultArray['client'] = $client; $this->status->modules[] = $resultArray; } if ($result) { JLog::add($installationType . " of " . $type[1] . ' sucessfully: ' . $name, JLog::INFO, 'com_visforms'); } else { JLog::add($installationType . " of " . $type[1] . ' failed: ' . $name, JLog::ERROR, 'com_visforms'); } } catch (RuntimeException $e) { JLog::add($installationType . " of " . $type[1] . ' failed: ' . $name . ', ' . $e->getMessage(), JLog::ERROR, 'com_visforms'); } unset($installationType); } } } $this->installationResults($route); }
/** * Called before any type of action * * @param string $type Which action is happening (install|uninstall|discover_install|update) * @param JAdapterInstance $parent The object responsible for running this script * * @return boolean True on success */ public function preflight($type, JAdapterInstance $parent) { $app = JFactory::getApplication(); $session = JFactory::getSession(); $jversion = new JVersion(); $this->parentInstaller = $parent->getParent(); // Get component manifest file version $this->release = $parent->get("manifest")->version; $session->set('release', $this->release->__toString(), 'bwpostman'); // Manifest file minimum Joomla version $this->minimum_joomla_release = $parent->get("manifest")->attributes()->version; // abort if the current Joomla release is older if (version_compare($jversion->getShortVersion(), $this->minimum_joomla_release, 'lt')) { $app->enqueueMessage(JText::sprintf('COM_BWPOSTMAN_INSTALL_ERROR_JVERSION', $this->minimum_joomla_release), 'error'); return false; } if (floatval(phpversion()) < 5) { $app->enqueueMessage(JText::_('COM_BWPOSTMAN_USES_PHP5'), 'error'); return false; } // abort if the component being installed is not newer than the currently installed version if ($type == 'update') { $oldRelease = $this->getManifestVar('version'); $app->setUserState('com_bwpostman.update.oldRelease', $oldRelease); if (version_compare($this->release, $oldRelease, 'lt')) { $app->enqueueMessage(JText::sprintf('COM_BWPOSTMAN_INSTALL_ERROR_INCORRECT_VERSION_SEQUENCE', $oldRelease, $this->release), 'error'); return false; } // delete existing files in frontend and backend to prevent conflicts with previous relicts jimport('joomla.filesystem.folder'); $admin_path = JPATH_ADMINISTRATOR . '/components/com_bwpostman'; $site_path = JPATH_SITE . '/components/com_bwpostman'; if (JFolder::exists($admin_path) === true) { JFolder::delete($admin_path); } if (JFolder::exists($site_path) === true) { JFolder::delete($site_path); } } $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->quoteName('params')); $query->from($db->quoteName('#__extensions')); $query->where($db->quoteName('element') . " = " . $db->quote('com_bwpostman')); $db->SetQuery($query); $params_default = $db->loadResult(); $app->setUserState('com_bwpostman.install.params', $params_default); return true; }