/** * Discovered package installation method * * @param integer $eid Extension ID * * @return boolean True if successful * * @since 3.1 */ public function discover_install($eid = null) { if (!$eid) { $this->abort(JText::_('JLIB_INSTALLER_ABORT_EXTENSIONNOTVALID')); return false; } if (!$this->extension->load($eid)) { $this->abort(JText::_('JLIB_INSTALLER_ABORT_LOAD_DETAILS')); return false; } if ($this->extension->state != -1) { $this->abort(JText::_('JLIB_INSTALLER_ABORT_ALREADYINSTALLED')); return false; } // Load the adapter(s) for the install manifest $type = $this->extension->type; $params = array('extension' => $this->extension, 'route' => 'discover_install'); $adapter = $this->getAdapter($type, $params); if (!is_object($adapter)) { return false; } if (!method_exists($adapter, 'discover_install') || !$adapter->getDiscoverInstallSupported()) { $this->abort(JText::sprintf('JLIB_INSTALLER_ERROR_DISCOVER_INSTALL_UNSUPPORTED', $type)); return false; } // The adapter needs to prepare itself if (method_exists($adapter, 'prepareDiscoverInstall')) { try { $adapter->prepareDiscoverInstall(); } catch (RuntimeException $e) { $this->abort($e->getMessage()); return false; } } // Add the languages from the package itself if (method_exists($adapter, 'loadLanguage')) { $adapter->loadLanguage(); } // Fire the onExtensionBeforeInstall event. JPluginHelper::importPlugin('extension'); $dispatcher = JEventDispatcher::getInstance(); $dispatcher->trigger('onExtensionBeforeInstall', array('method' => 'discover_install', 'type' => $this->extension->get('type'), 'manifest' => null, 'extension' => $this->extension->get('extension_id'))); // Run the install $result = $adapter->discover_install(); // Fire the onExtensionAfterInstall $dispatcher->trigger('onExtensionAfterInstall', array('installer' => clone $this, 'eid' => $result)); if ($result !== false) { // Refresh versionable assets cache JFactory::getApplication()->flushAssets(); return true; } return false; }
/** * Discovered package installation method * * @param integer $eid Extension ID * * @return boolean True if successful * * @since 3.1 */ public function discover_install($eid = null) { if ($eid) { $this->extension = JTable::getInstance('extension'); if (!$this->extension->load($eid)) { $this->abort(JText::_('JLIB_INSTALLER_ABORT_LOAD_DETAILS')); return false; } if ($this->extension->state != -1) { $this->abort(JText::_('JLIB_INSTALLER_ABORT_ALREADYINSTALLED')); return false; } // Lazy load the adapter if (!isset($this->_adapters[$this->extension->type]) || !is_object($this->_adapters[$this->extension->type])) { if (!$this->setAdapter($this->extension->type)) { return false; } } if (is_object($this->_adapters[$this->extension->type])) { if (method_exists($this->_adapters[$this->extension->type], 'discover_install')) { // Add the languages from the package itself if (method_exists($this->_adapters[$this->extension->type], 'loadLanguage')) { $this->_adapters[$this->extension->type]->loadLanguage(); } // Fire the onExtensionBeforeInstall event. JPluginHelper::importPlugin('extension'); $dispatcher = JEventDispatcher::getInstance(); $dispatcher->trigger('onExtensionBeforeInstall', array('method' => 'discover_install', 'type' => $this->extension->get('type'), 'manifest' => null, 'extension' => $this->extension->get('extension_id'))); // Run the install $result = $this->_adapters[$this->extension->type]->discover_install(); // Fire the onExtensionAfterInstall $dispatcher->trigger('onExtensionAfterInstall', array('installer' => clone $this, 'eid' => $result)); if ($result !== false) { // Refresh versionable assets cache JFactory::getApplication()->flushAssets(); return true; } else { return false; } } else { $this->abort(JText::_('JLIB_INSTALLER_ABORT_METHODNOTSUPPORTED')); return false; } } return false; } else { $this->abort(JText::_('JLIB_INSTALLER_ABORT_EXTENSIONNOTVALID')); return false; } }
function discover_install($eid = null) { if ($eid) { $this->extension =& JTable::getInstance('extension'); if (!$this->extension->load($eid)) { $this->abort(JText::_('Failed to load extension details')); return false; } if ($this->extension->state != -1) { $this->abort(JText::_('Extension is already installed')); return false; } // Lazy load the adapter if (!isset($this->_adapters[$this->extension->type]) || !is_object($this->_adapters[$this->extension->type])) { if (!$this->setAdapter($this->extension->type)) { return false; } } if (is_object($this->_adapters[$this->extension->type])) { if (method_exists($this->_adapters[$this->extension->type], 'discover_install')) { // Fire the onBeforeExtensionInstall event. JPluginHelper::importPlugin('installer'); $dispatcher =& JDispatcher::getInstance(); $dispatcher->trigger('onBeforeExtensionInstall', array('method' => 'discover_install', 'type' => $this->extension->get('type'), 'manifest' => null, 'extension' => $this->extension->get('extension_id'))); // Run the install $result = $this->_adapters[$this->extension->type]->discover_install(); // Fire the onAfterExtensionInstall $dispatcher->trigger('onAfterExtensionInstall', array('installer' => clone $this, 'eid' => $result)); if ($result !== false) { return true; } else { return false; } } else { $this->abort(JText::_('Method not supported for this extension type')); return false; } } return false; } else { $this->abort(JText::_('Extension is not a valid')); return false; } }
/** * Extra install operation. * * @param JTableExtension $extension * @return void */ function extra(&$extension) { if (AINSTALLER_J16) { if (isset($extension->enabled)) { $db = JFactory::getDbo(); /* @var $db JDatabaseMySQL */ $db->setQuery('UPDATE `#__modules` SET `published` = ' . (int) $extension->enabled . ' WHERE `module` = ' . $db->Quote($extension->get('element'))); $db->query(); } } }
/** * Global config has been saved. * Check the product key and if it exists create an update site entry * Update server XML manifest generated from update/premium.php * * @param string $option * @param JTableExtension $data */ function onExtensionAfterSave($option, $data) { if ($option !== 'com_config.component') { return; } if ($data->get('name') !== 'com_fabrik') { return; } $props = $data->getProperties(); $params = new JRegistry($props['params']); $productKey = $params->get('fabrik_product_key', ''); if ($productKey === '') { return; } $table = JTable::getInstance('Updatesite'); $table->load(array('name' => 'Fabrik - Premium')); $table->save(array('type' => 'collection', 'name' => 'Fabrik - Premium', 'enabled' => 1, 'location' => 'http://localhost:81/fabrik31x/public_html/update/premium.php?productKey=' . $productKey)); }