/** * Called before any type of action * * @param string $route Which action is happening (install|uninstall|discover_install) * @param JAdapterInstance $adapter The object responsible for running this script * * @return boolean True on success */ function preflight($route, JAdapterInstance $adapter) { if ($adapter instanceof JInstallerAdapterComponent) { $this->installPlugins($adapter->get('parent')->get('paths')); } elseif ($adapter instanceof JInstallerComponent) { $this->installPlugins($adapter->get('parent')->get('_paths')); } // Installing component manifest file version $this->release = $adapter->get('manifest')->version; // Show the essential information at the install/update back-end echo '<h3>Installing SobiPro version ' . $this->release . ' ...'; }
/** * Constructor * * @param JAdapterInstance $adapter The object responsable for running this script */ public function __construct(JAdapterInstance $adapter) { $this->status = new stdClass(); $this->status->fixTableVisforms = array(); $this->status->modules = array(); $this->status->plugins = array(); $this->status->tables = array(); $this->status->folders = array(); $this->status->component = array(); $this->status->messages = array(); $this->release = $adapter->get("manifest")->version; $this->minimum_joomla_release = $adapter->get("manifest")->attributes()->version; $this->oldRelease = ""; // Log to a specific text file. JLog::addLogger(array('text_file' => 'visforms_update.php', 'text_entry_format' => '{PRIORITY} {MESSAGE}', 'logger' => 'FormattedtextVisforms'), JLog::ALL, array('com_visforms')); }
/** * Called after any type of action * * @param string $route Which action is happening (install|uninstall|discover_install) * @param jadapterinstance $adapter The object responsible for running this script * * @return boolean True on success */ public function postflight($route, JAdapterInstance $adapter) { if (strtolower($route) == 'install') { // Get the XML manifest data $manifest = $adapter->get('manifest'); // Set the module params PFInstallerHelper::setModuleParams($manifest); } return true; }
/** * Called after any type of action * * @param string $route Which action is happening (install|uninstall|discover_install) * @param jadapterinstance $adapter The object responsible for running this script * * @return boolean True on success */ public function postflight($route, JAdapterInstance $adapter) { if (strtolower($route) == 'install') { $element = $adapter->get('element'); // Restore assets from backup PFInstallerHelper::restoreAssets($element); // Make the admin component menu item a child of com_projectfork PFInstallerHelper::setComponentMenuItem($element); // Create a menu item in the projectfork site menu $com = JComponentHelper::getComponent($element); $eid = is_object($com) && isset($com->id) ? $com->id : 0; if ($eid) { $item = array(); $item['title'] = 'Designs'; $item['alias'] = 'designs'; $item['link'] = 'index.php?option=' . $element . '&view=designs'; $item['component_id'] = $eid; PFInstallerHelper::addMenuItem($item); } } if (strtolower($route) == 'update') { $element = $adapter->get('element'); // Make the admin component menu item a child of com_projectfork PFInstallerHelper::setComponentMenuItem($element); // Delete duplicate top-level admin menu entry if it exists $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('id')->from('#__menu')->where('level = 1')->where('menutype = ' . $db->quote('main'))->where('link = "index.php?option=' . $element . '&view=designs"'); $db->setQuery($query); $item_id = (int) $db->loadResult(); if ($item_id) { $menu = JTable::getInstance('menu'); $menu->delete($item_id); } } if (in_array(strtolower($route), array('install', 'update'))) { $this->installPlugins($adapter); } return true; }
/** * Called after any type of action * * @param string $route Which action is happening (install|uninstall|discover_install) * @param jadapterinstance $adapter The object responsible for running this script * * @return boolean True on success */ public function postflight($route, JAdapterInstance $adapter) { $action = strtolower($route); if ($action == 'install') { // Get the XML manifest data $manifest = $adapter->get('manifest'); // Get plugin published state $name = $manifest->name; $state = isset($manifest->published) ? (int) $manifest->published : 0; if ($state) { PFInstallerHelper::publishPlugin($name, $state); } } // Move CLI scripts to cli folder if ($action == 'install' || $action == 'update') { $cli_j2_source = JPATH_SITE . '/plugins/content/pfnotifications/pfnotifications_j2.php'; $cli_j2_dest = JPATH_SITE . '/cli/pfnotifications_j2.php'; $cli_j3_source = JPATH_SITE . '/plugins/content/pfnotifications/pfnotifications_j3.php'; $cli_j3_dest = JPATH_SITE . '/cli/pfnotifications_j3.php'; if (file_exists($cli_j2_source)) { if (file_exists($cli_j2_dest)) { if (JFile::delete($cli_j2_dest)) { JFile::copy($cli_j2_source, $cli_j2_dest); } } else { JFile::copy($cli_j2_source, $cli_j2_dest); } } if (file_exists($cli_j3_source)) { if (file_exists($cli_j3_dest)) { if (JFile::delete($cli_j3_dest)) { JFile::copy($cli_j3_source, $cli_j3_dest); } } else { JFile::copy($cli_j3_source, $cli_j3_dest); } } } // Remove CLI scripts if ($action == 'uninstall') { $cli_j2_dest = JPATH_SITE . '/cli/pfnotifications_j2.php'; $cli_j3_dest = JPATH_SITE . '/cli/pfnotifications_j3.php'; if (file_exists($cli_j2_dest)) { JFile::delete($cli_j2_dest); } if (file_exists($cli_j3_dest)) { JFile::delete($cli_j3_dest); } } return true; }
/** * Called after any type of action * * @param string $route Which action is happening (install|uninstall|discover_install) * @param jadapterinstance $adapter The object responsible for running this script * * @return boolean True on success */ public function postflight($route, JAdapterInstance $adapter) { if (strtolower($route) == 'install' || strtolower($route) == 'update') { // Get the XML manifest data $manifest = $adapter->get('manifest'); // Get plugin published state $name = $manifest->name; $state = isset($manifest->published) ? (int) $manifest->published : 0; if ($state) { PFInstallerHelper::publishPlugin($name, $state); } } return true; }
/** * Called before any type of action * * @param string $route Which action is happening (install|uninstall|discover_install) * @param jadapterinstance $adapter The object responsible for running this script * * @return boolean True on success */ public function preflight($route, JAdapterInstance $adapter) { // Joomla version check if (!version_compare(JVERSION, '2.5.5', 'ge')) { $adapter->get('parent')->abort('Unsupported version! Projectfork requires Joomla 2.5.5 or newer.'); return false; } // Memory Check if (file_exists(dirname(__FILE__) . '/memcheck.php')) { require_once dirname(__FILE__) . '/memcheck.php'; $mem = new pkg_projectforkMemory(); $check = $mem->check(); if ($check !== true) { $msg = 'Not enough memory available: Missing ' . $check . 'k. ' . 'You can delete the "memcheck.php" file from this install package to disable the memory check and try again.'; $adapter->get('parent')->abort($msg); return false; } } if (JDEBUG) { JProfiler::getInstance('Application')->mark('before' . ucfirst($route) . 'Projectfork'); } return true; }
/** * Called on uninstallation * * @param jadapterinstance $adapter The object responsible for running this script */ public function uninstall(JAdapterInstance $adapter) { // Skip this step if the user is removing the entire projectfork package if ($this->isRemovingAll()) { return true; } $element = $adapter->get('element'); $asset = JTable::getInstance('Asset'); // Backup any assets for another component that might take over if ($asset->loadByName($element)) { $asset->name = $asset->name . '_bak'; $asset->store(); } return true; }
/** * Called after any type of action. * * @param string $route Which action is happening (install|uninstall|discover_install). * @param JAdapterInstance $adapter The object responsible for running this script. * * @return boolean True on success. * * @since 3.1 */ public function postflight($route, JAdapterInstance $adapter) { // Initialiase variables. $db = JFactory::getDbo(); $query = $db->getQuery(true); // Create the base update statement. $query->update($db->quoteName('#__extensions'))->set($db->quoteName('enabled') . ' = ' . $db->quote('1'))->where($db->quoteName('name') . ' = ' . $db->quote($adapter->get('name'))); // Set the query and execute the update. $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); return false; } }
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) * @param jadapterinstance $adapter The object responsible for running this script * * @return boolean True on success */ public function postflight($route, JAdapterInstance $adapter) { $src = JPATH_SITE . "/plugins/system/pftaskexpirynotifier/cron_pf_notifier.php"; $dest = JPATH_SITE . "/cli/cron_pf_notifier.php"; if (strtolower($route) == 'install') { // Get the XML manifest data $manifest = $adapter->get('manifest'); // Get plugin published state $name = $manifest->name; $state = isset($manifest->published) ? (int) $manifest->published : 0; if (!$state) { $state = 1; $this->_publishPlugin($name, $state); } //let's move the cron file into Joomla's cli directory. JFile::move($src, $dest); } return true; }
/** * * 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); } } } }
/** * 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) { $app = JFactory::getApplication(); $install_jdom = false; $remove_jdom = false; $manifest = $adapter->get('manifest'); $old_params = $this->old_params; $parent = $adapter->get('parent'); $paths = $parent->get('paths'); if (!$paths) { $paths = $parent->get('_paths'); } //Legacy 2.5 $src = $paths['source'] . DS . 'jdom'; $dest = JPATH_SITE . DS . 'libraries' . DS . 'jdom'; $params = array(); $params['update'] = '1'; switch ($route) { case 'install': $params = array(); $params['update'] = '1'; $params['jdomversion'] = $manifest->jdomversion; // clean installation $install_jdom = true; // enable plugin self::enablePlugin(); break; case 'uninstall': // remove the jdom library folder $remove_jdom = true; break; case 'update': switch (intVal($old_params['update'])) { case 0: break; case 2: $vers_compare = version_compare($manifest->jdomversion, $old_params['jdomversion']); if ($vers_compare > 0) { // clean update jdom folder $remove_jdom = true; $install_jdom = true; } elseif ($vers_compare < 0) { $params['jdomversion'] = $old_params['jdomversion']; } break; case 1: default: // clean update jdom folder $remove_jdom = true; $install_jdom = true; $params['jdomversion'] = $manifest->jdomversion; break; } break; default: break; } // remove JDOM if ($remove_jdom and file_exists($dest)) { if (JFolder::delete($dest)) { $app->enqueueMessage(JText::_("PLG_JDOM_SUCCESSFULL_REMOVED")); } else { $app->enqueueMessage(JText::_("PLG_JDOM_ERROR_REMOVED"), 'error'); } } // install JDOM if ($install_jdom) { if (JFolder::copy($src, $dest, '', true)) { $app->enqueueMessage(JText::sprintf('PLG_JDOM_SUCCESSFULL_INSTALLATION', $params['jdomversion'])); self::setParams($params); } else { $app->enqueueMessage(JText::_("PLG_JDOM_ERROR_INSTALLATION"), 'error'); } } }
/** * Method for checking compatibility installation environment * * @param JAdapterInstance $adapter The object responsible for running this script. * * @return boolean True if the installation environment is compatible * * @since 0.1.0 */ private function _checkCompatible($route, JAdapterInstance $adapter) { // Get the application. $this->_release = (string) $adapter->get('manifest')->version; $min_version = (string) $adapter->get('manifest')->attributes()->version; $jversion = new JVersion(); if (version_compare($jversion->getShortVersion(), $min_version, 'lt')) { JFactory::getApplication()->enquequeMessage(JText::sprintf('PLG_SYSTEM_EXTRAFIELDS_VERSION_UNSUPPORTED', $this->_extension, $this->_release, $min_version), 'error'); return false; } // Storing old release number for process in postflight. if ($route == 'update') { $oldRelease = $this->_getParam('version'); if (version_compare($this->_release, $oldRelease, 'lt')) { JFactory::getApplication()->enquequeMessage(JText::sprintf('PLG_SYSTEM_EXTRAFIELDS_UPDATE_UNSUPPORTED', $this->_extension, $oldRelease, $this->_release), 'error'); return false; } } return true; }
/** * 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; }