Example #1
0
 function uninstall($parent)
 {
     // Post Install Log
     self::_postInstallMessage('uninstall', $parent);
     $db = JFactory::getDbo();
     $db->setQuery('SELECT extension_id FROM #__extensions WHERE type = "package" AND element = "pkg_cck"');
     $eid = $db->loadResult();
     $db->setQuery('SELECT extension_id FROM #__extensions WHERE type = "plugin" AND element = "cck" AND folder="system"');
     $cck = $db->loadResult();
     // Uninstall FULL PACKAGE only if package exists && system plugin exists..
     if ($eid && $cck) {
         $manifest = JPATH_ADMINISTRATOR . '/manifests/packages/pkg_cck.xml';
         if (JFile::exists($manifest)) {
             $xml = JFactory::getXML($manifest);
             // Keep it this way until platform 13.x
         }
         if (isset($xml->files)) {
             unset($xml->files->file[3]);
             $xml->asXML($manifest);
         }
         jimport('joomla.installer.installer');
         $installer = JInstaller::getInstance();
         $installer->uninstall('package', $eid);
     }
 }
 /**
  * method to run before an install/update/uninstall method
  *
  * @return void
  */
 public function preflight($type, $parent)
 {
     // $parent is the class calling this method
     //$parent->getParent()->setRedirectURL('index.php?option=com_ckeditor');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('joomla.installer.installer');
     $installer = JInstaller::getInstance();
     $source = $installer->getPath('source');
     $packages = $source . DS . 'packages';
     // Get editor package
     if (is_dir($packages)) {
         $editor = JFolder::files($packages, 'plg_ckeditor.zip', false, true);
     }
     if (!empty($editor) && is_file($editor[0])) {
         $confObject = JFactory::getApplication();
         $packagePath = dirname($editor[0]) . DS . 'ckeditor';
         if (!JArchive::extract($editor[0], $packagePath)) {
             $editor_result = JText::_('EDITOR EXTRACT ERROR');
         } else {
             $installer = JInstaller::getInstance();
             $c_manifest = $installer->getManifest();
             $c_root =& $c_manifest->document;
             if (JFolder::copy($packagePath, dirname($installer->getPath('extension_site')) . DS . '..' . DS . 'plugins' . DS . 'editors', '', true)) {
                 $editor_result = JText::_('Success');
             } else {
                 $editor_result = JText::_('Error');
             }
         }
     } else {
         $editor_result = JText::_('Error');
     }
     echo '<p>' . $editor_result . '</p>';
 }
 /**
  * Generic uninstall function
  *
  * @param	KCommandContext	A command context object
  * @return 	KDatabaseRowset	A rowset object containing the deleted rows
  */
 protected function _actionDelete(KCommandContext $context)
 {
     $request = $this->getRequest();
     $type = $this->getIdentifier()->name;
     // Initialize variables
     $failed = array();
     // Get an installer object for the extension type
     $installer = JInstaller::getInstance();
     foreach ($request->id as $composite) {
         $parts = explode('-', $composite);
         $id = $parts[0];
         $appid = isset($parts[1]) ? $parts[1] : 0;
         $result = $installer->uninstall($type, $id, $appid);
         // Build an array of extensions that failed to uninstall
         if ($result === false) {
             $failed[] = $id;
         }
     }
     if (count($failed)) {
         // There was an error in uninstalling the package
         $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Error'));
         $result = false;
     } else {
         // Package uninstalled sucessfully
         $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Success'));
         $result = true;
     }
     $controller = $this->getService('com://admin/installer.controller.install');
     $controller->name($installer->get('name'));
     $controller->message($installer->message);
     $controller->extension_message($installer->get('extension.message'));
     JFactory::getApplication()->enqueueMessage($msg);
     return $controller->get();
 }
 /**
  * Installation of plugins on the site
  *
  * @since   1.0
  * @access  public
  */
 public function installPlugin($element, $group, $absolutePath)
 {
     if ($this->isDevelopment()) {
         $this->setInfo('ok', true);
         return $this->output();
     }
     // Get Joomla's installer instance
     $installer = JInstaller::getInstance();
     // Allow overwriting of existing plugins
     $installer->setOverwrite(true);
     // Install the plugin now
     $state = $installer->install($absolutePath);
     // Ensure that the plugins are published
     if ($state) {
         $group = strtolower($group);
         $element = strtolower($element);
         $options = array('folder' => $group, 'element' => $element);
         $plugin = JTable::getInstance('Extension');
         $plugin->load($options);
         $plugin->state = true;
         $plugin->enabled = $group == 'easyblog' && $element == 'autoarticle' ? false : true;
         $plugin->store();
     }
     return $state;
 }
Example #5
0
 /**
  *
  */
 function install()
 {
     $package = $this->_getPackageFromUpload();
     $config =& JFactory::getConfig();
     if (!$package) {
         $userfile = JRequest::getVar('userfile', '', 'files', 'array');
         $script = $config->getValue('config.tmp_path') . DS . $userfile['name'];
         $installer =& JInstaller::getInstance();
         $ar = explode(".", $script);
         $ext = array_pop($ar);
         switch (strtolower($ext)) {
             case 'rtf':
                 $this->importRTF($script);
                 break;
             case 'txt':
                 $this->importTxt($script);
                 break;
             case 'fdr':
                 $this->importFdr($script);
                 break;
         }
         $adaptor = new JInstallerFabrikPlugin($installer);
     } else {
         //TODO: J1.5 deal with zipped packages
         echo "a zip file - to do - deal with zipped pacakges";
     }
 }
Example #6
0
 public function getTemplates()
 {
     $items = array();
     $tpl_path = COM_TZ_PORTFOLIO_PLUS_PATH_SITE . DIRECTORY_SEPARATOR . 'templates';
     if (!JFolder::exists($tpl_path)) {
         return false;
     }
     if ($folders = JFolder::folders($tpl_path)) {
         if (count($folders)) {
             foreach ($folders as $i => $folder) {
                 $xmlFile = $tpl_path . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . 'template.xml';
                 if (JFile::exists($xmlFile)) {
                     $installer = JInstaller::getInstance($tpl_path . DIRECTORY_SEPARATOR . $folder);
                     if ($manifest = $installer->isManifest($xmlFile)) {
                         $lang = JFactory::getLanguage();
                         $lang->load('tpl_' . (string) $manifest->name, $tpl_path . DIRECTORY_SEPARATOR . $folder);
                         $item = new stdClass();
                         $item->id = $i;
                         $item->name = (string) $manifest->name;
                         $item->type = (string) $manifest->type;
                         $item->version = (string) $manifest->version;
                         $item->creationDate = (string) $manifest->creationDate;
                         $item->author = (string) $manifest->author;
                         $item->authorEmail = (string) $manifest->authorEmail;
                         $item->description = JText::_((string) $manifest->description);
                         $items[] = $item;
                     }
                 }
             }
         }
     }
     return $items;
     //        var_dump(JFolder::folders($tpl_path)); die();
 }
Example #7
0
 /**
  * Download and install
  */
 function install($id, $url)
 {
     if (!is_string($url)) {
         return JText::_('NNEM_ERROR_NO_VALID_URL');
     }
     $url = 'http://' . str_replace('http://', '', $url);
     if (!($target = JInstallerHelper::downloadPackage($url))) {
         return JText::_('NNEM_ERROR_CANNOT_DOWNLOAD_FILE');
     }
     $target = JFactory::getConfig()->get('tmp_path') . '/' . $target;
     NNFrameworkFunctions::loadLanguage('com_installer', JPATH_ADMINISTRATOR);
     jimport('joomla.installer.installer');
     jimport('joomla.installer.helper');
     // Get an installer instance
     $installer = JInstaller::getInstance();
     // Unpack the package
     $package = JInstallerHelper::unpack($target);
     // Cleanup the install files
     if (!is_file($package['packagefile'])) {
         $config = JFactory::getConfig();
         $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['packagefile']);
     // Install the package
     if (!$installer->install($package['dir'])) {
         // There was an error installing the package
         return JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
     }
     return true;
 }
Example #8
0
 function preflight($type, $parent)
 {
     //check if php version is supported before proceed with installation.
     $phpVersion = floatval(phpversion());
     if ($phpVersion < 5) {
         $mainframe = JFactory::getApplication();
         $mainframe->enqueueMessage('Installation was unsuccessful because you are using an unsupported version of PHP. Komento supports only PHP5 and above. Please kindly upgrade your PHP version and try again.', 'error');
         return false;
     }
     //get source path and version number from manifest file.
     $installer = JInstaller::getInstance();
     $manifest = $installer->getManifest();
     $sourcePath = $installer->getPath('source');
     $this->message = array();
     $this->status = true;
     $this->sourcePath = $sourcePath;
     $file = $this->sourcePath . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'install.default.php';
     if (JFile::exists($file)) {
         require_once $file;
     }
     //this is needed as joomla failed to remove it themselve during uninstallation or failed attempt of installation
     if (class_exists('KomentoMenuMaintenance')) {
         KomentoMenuMaintenance::removeAdminMenu();
     }
     return true;
 }
Example #9
0
 public function getPluginTemplate($id)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('folder');
     $query->from('#__judownload_plugins');
     $query->where('id = ' . $id);
     $query->where('type = ' . $db->quote('plugin'));
     $db->setQuery($query);
     $folder = $db->loadResult();
     if ($folder) {
         $pluginFolderPath = JPATH_SITE . '/components/com_judownload/plugins/' . $folder;
         $installer = JInstaller::getInstance();
         $installer->setPath("source", $pluginFolderPath);
         $installer->findManifest();
         $xml = $installer->getManifest();
         $templateFolder = null;
         if (isset($xml->templateFolder)) {
             $templateFolder = $xml->templateFolder->__toString();
         } else {
             $templateFolder = 'tmpl';
         }
         if (JFolder::exists($pluginFolderPath . '/' . $templateFolder . '/')) {
             $asset_file = $pluginFolderPath . '/load_assets.php';
             if (JFILE::exists($asset_file)) {
                 include $asset_file;
             }
             return $pluginFolderPath . '/' . $templateFolder . '/';
         } else {
             return false;
         }
     }
     return false;
 }
Example #10
0
 /**
  * Get a model instance.
  *
  * @param   string  $name    Model name
  * @param   mixed   $client  Client. null = auto, 1 = admin, 0 = frontend
  * @param   array   $config  An optional array of configuration
  * @param   string  $option  Component name, use for call model from modules
  *
  * @return  RModel  The model
  *
  * @throws  InvalidArgumentException
  */
 public static function getAutoInstance($name, $client = null, array $config = array(), $option = 'auto')
 {
     if ($option === 'auto') {
         $option = JFactory::getApplication()->input->getString('option', '');
         // Add com_ to the element name if not exist
         $option = (strpos($option, 'com_') === 0 ? '' : 'com_') . $option;
         if ($option == 'com_installer') {
             $installer = JInstaller::getInstance();
             $option = $installer->manifestClass->getElement($installer);
         }
     }
     $componentName = ucfirst(strtolower(substr($option, 4)));
     $prefix = $componentName . 'Model';
     if (is_null($client)) {
         $client = (int) JFactory::getApplication()->isAdmin();
     }
     // Admin
     if ($client === 1) {
         self::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . $option . '/models');
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . $option . '/tables');
     } elseif ($client === 0) {
         self::addIncludePath(JPATH_SITE . '/components/' . $option . '/models');
         JTable::addIncludePath(JPATH_SITE . '/components/' . $option . '/tables');
     } else {
         throw new InvalidArgumentException(sprintf('Cannot instanciate the model %s in component %s. Invalid client %s.', $name, $option, $client));
     }
     $model = self::getInstance($name, $prefix, $config);
     if (!$model instanceof JModel && !$model instanceof JModelLegacy) {
         throw new InvalidArgumentException(sprintf('Cannot instanciate the model %s in component %s. Invalid client %s.', $name, $option, $client));
     }
     return $model;
 }
Example #11
0
 public function install()
 {
     $session = JFactory::getSession();
     $tempdir = $session->get('tempdir', '', 'liveupdate');
     jimport('joomla.installer.installer');
     jimport('joomla.installer.helper');
     $installer = JInstaller::getInstance();
     $packageType = JInstallerHelper::detectType($tempdir);
     if (!$packageType) {
         $msg = JText::_('LIVEUPDATE_INVALID_PACKAGE_TYPE');
         $result = false;
     } elseif (!$installer->install($tempdir)) {
         // There was an error installing the package
         $msg = JText::sprintf('LIVEUPDATE_INSTALLEXT', JText::_($packageType), JText::_('LIVEUPDATE_Error'));
         $result = false;
     } else {
         // Package installed sucessfully
         $msg = JText::sprintf('LIVEUPDATE_INSTALLEXT', JText::_($packageType), JText::_('LIVEUPDATE_Success'));
         $result = true;
     }
     $app = JFactory::getApplication();
     $app->enqueueMessage($msg);
     $this->setState('result', $result);
     $this->setState('packageType', $packageType);
     if ($packageType) {
         $this->setState('name', $installer->get('name'));
         $this->setState('message', $installer->message);
         if (version_compare(JVERSION, '1.6.0', 'ge')) {
             $this->setState('extmessage', $installer->get('extension_message'));
         } else {
             $this->setState('extmessage', $installer->get('extension.message'));
         }
     }
     return $result;
 }
Example #12
0
 /**
  * install plugin
  */
 function install()
 {
     require_once dirname(__FILE__) . DS . "adapter" . DS . "fabrikplugin.php";
     $package = $this->_getPackageFromUpload();
     // Was the package unpacked?
     if (!$package) {
         $this->setState('message', JText::_('UNABLE TO INSTALL PACKAGE FILE'));
         return false;
     }
     $installer =& JInstaller::getInstance();
     $this->setState('action', 'install');
     $adaptor = new JInstallerFabrikPlugin($installer);
     //test fro php 4.x??? seems to work
     $adaptor->parent->setPath('source', $package['dir']);
     //end test
     $installer->setAdapter("fabrikplugin", $adaptor);
     // 	Install the package
     if (!$installer->install($package['dir'])) {
         // There was an error installing the package
         $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error'));
         $result = false;
     } else {
         // Package installed sucessfully
         $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success'));
         $result = true;
     }
     // Cleanup the install files
     if (!is_file($package['packagefile'])) {
         $config =& JFactory::getConfig();
         $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
function com_uninstall()
{
    // Initialize the Joomla! installer
    jimport('joomla.installer.installer');
    $installer = JInstaller::getInstance();
    // Select all MageBridge modules and remove them
    $db = JFactory::getDBO();
    $query = "SELECT `id`,`client_id` FROM #__modules WHERE `module` LIKE 'mod_magebridge%'";
    $db->setQuery($query);
    $rows = $db->loadObjectList();
    if (!empty($rows)) {
        foreach ($rows as $row) {
            $installer->uninstall('module', $row->id, $row->client_id);
        }
    }
    // Select all MageBridge plugins and remove them
    $db = JFactory::getDBO();
    $query = "SELECT `id`,`client_id` FROM #__plugins WHERE `element` LIKE 'magebridge%' OR `folder` = 'magento'";
    $db->setQuery($query);
    $rows = $db->loadObjectList();
    if (!empty($rows)) {
        foreach ($rows as $row) {
            $installer->uninstall('plugin', $row->id, $row->client_id);
        }
    }
    // Done
    return true;
}
Example #14
0
 public function postflight($type, $parent, $results)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $adm_path = str_replace(array('/administrator', '\\administrator'), '', JPATH_BASE);
     $installer = JInstaller::getInstance();
     $manifest = $installer->getManifest();
     $sourcePath = $installer->getPath('source');
     $db->setQuery("DELETE FROM `#__extensions` WHERE `element` = 'pkg_ukUA'");
     $db->query();
     $jun = $db->getQuery(true);
     $jun = "UPDATE `#__modules` SET `position` = 'cpanel', `published` = 1, `showtitle` = 0, `ordering` = 99 WHERE `module` = 'mod_junews' AND `client_id` = 1";
     $db->setQuery($jun);
     $db->query();
     $jun1 = $db->getQuery(true);
     $jun1 = "INSERT INTO #__modules_menu (moduleid, menuid) SELECT #__modules.id, 0 FROM #__modules WHERE #__modules.module = 'mod_junews' AND #__modules.position = 'cpanel' AND NOT EXISTS (SELECT 1 FROM #__modules_menu WHERE moduleid = #__modules.id) ORDER BY id DESC LIMIT 1";
     $db->setQuery($jun1);
     $db->query();
     $jum = $db->getQuery(true);
     $jum = "UPDATE `#__modules` SET `position` = 'menu', `published` = 1, `showtitle` = 0, `ordering` = 99 WHERE `module` = 'mod_jumenu' AND `client_id` = 1";
     $db->setQuery($jum);
     $db->query();
     $jum1 = $db->getQuery(true);
     $jum1 = "INSERT INTO #__modules_menu (moduleid, menuid) SELECT #__modules.id, 0 FROM #__modules WHERE #__modules.module = 'mod_jumenu' AND #__modules.position = 'menu' AND NOT EXISTS (SELECT 1 FROM #__modules_menu WHERE moduleid = #__modules.id) ORDER BY id DESC LIMIT 1";
     $db->setQuery($jum1);
     $db->query();
     $manifestua = $adm_path . '/administrator/manifests/packages/pkg_ukUA.xml';
     if (file_exists($manifestua)) {
         unlink($manifestua);
     }
     if (is_dir(JPATH_BASE . '/manifests/packages/ukUA')) {
         Pkg_ukUAInstallerScript::unlinkRecursive(JPATH_BASE . '/manifests/packages/ukUA/', 0);
     }
     return true;
 }
Example #15
0
 public function display($tpl = null)
 {
     $paths = new stdClass();
     $paths->first = '';
     $this->assignRef('paths', $paths);
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->form = $this->get('Form');
     if ($this->getLayout() == 'distribution') {
         jimport('joomla.installer.installer');
         // Extract the list and return it
         $installer = JInstaller::getInstance();
         $installer->setPath('source', $this->state->get('install.directory'));
         $manifest = $installer->getManifest();
         $result = false;
         if ($manifest) {
             $result->extensions = isset($manifest->extensions) ? $manifest->extensions : false;
             $result->sql = isset($manifest->install->sql->file) ? $installer->getPath('source') . '/' . $manifest->install->sql->file : false;
             $result->script = isset($manifest->scriptfile) ? $installer->getPath('source') . '/' . $manifest->scriptfile : false;
             if ($result->script) {
                 include $installer->getPath('source') . '/' . $manifest->scriptfile;
                 $class = JRequest::$manifest->name . 'InstallerScript';
                 $script = new $class();
                 $result->scriptclass = $class;
                 $result->preflight = method_exists($script, 'preflight') ? $installer->getPath('source') . '/' . $manifest->scriptfile : false;
                 $result->postflight = method_exists($script, 'postflight') ? $installer->getPath('source') . '/' . $manifest->scriptfile : false;
             }
         }
         $this->source = base64_encode($installer->getPath('source'));
         $this->result = $result;
     }
     parent::display($tpl);
 }
Example #16
0
/**
 * Uninstall function
 * @return
 */
function com_uninstall()
{
    if (!defined('JPATH_PLATFORM')) {
        $installer = JInstaller::getInstance();
        return WFInstall::uninstall();
    }
    return true;
}
	/**
	 * Test...
	 *
	 * @covers  JInstaller::getInstance
	 *
	 * @return void
	 */
	public function testGetInstance()
	{
		$this->assertThat(
			$this->object = JInstaller::getInstance(),
			$this->isInstanceOf('JInstaller'),
			'JInstaller::getInstance failed'
		);
	}
Example #18
0
/**
 * Installer function
 * @return
 */
function com_install()
{
    if (!defined('JPATH_PLATFORM')) {
        require_once JPATH_ADMINISTRATOR . '/components/com_jce/install.php';
        $installer = JInstaller::getInstance();
        return WFInstall::install($installer);
    }
    return true;
}
Example #19
0
 function install(&$plg)
 {
     $src = dirname(__FILE__) . DS . 'component';
     $dest = JPATH_ROOT . DS . 'components' . DS . 'com_jshopping';
     $lang =& JFactory::getLanguage();
     $inst =& JInstaller::getInstance();
     $desc = (string) $inst->getManifest()->description;
     $lang->load('plg_jshoppingcheckout_' . $this->_name . '.sys', JPATH_ADMINISTRATOR, null, true);
     $inst->set('message', JText::_($desc));
     if (!JFolder::exists($dest)) {
         return false;
     }
     if (JFolder::exists($src)) {
         foreach (JFolder::folders($src) as $f) {
             JFolder::copy($src . DS . $f, $dest . DS . $f, '', true);
         }
     }
     // Конфигурирование JoomShopping (установка дополнений)
     $this->jshoppingUpdate();
     $res = false;
     $path = JPATH_ROOT . DS . 'components' . DS . 'com_jshopping' . DS . 'shippings' . DS . $this->_name . DS;
     if (extension_loaded('ionCube Loader')) {
         // use ionCube
         $res = true;
     } else {
         // check zend loader/optimizer
         $list = get_loaded_extensions();
         foreach ($list as &$item) {
             if (preg_match("/zend.*(loader|optimizer)/i", $item)) {
                 $res = true;
                 break;
             }
         }
         if ($res) {
             // Zend was found, detect php version
             if (version_compare(phpversion(), "5.3") >= 0) {
                 // php > 5.3
                 JFile::move($this->_name . '_5.3.php', $this->_name . '.php', $path);
             } else {
                 JFile::move($this->_name . '_5.2.php', $this->_name . '.php', $path);
             }
         }
     }
     if (JFile::exists($path . $this->_name . '_5.2.php')) {
         JFile::delete($path . $this->_name . '_5.2.php');
     }
     if (JFile::exists($path . $this->_name . '_5.3.php')) {
         JFile::delete($path . $this->_name . '_5.3.php');
     }
     if ($res) {
         $app = JFactory::getApplication();
         $app->enqueueMessage(JText::_('PED_INSTALL_NOTIFY'), 'notice');
     } else {
         JError::raiseNotice('500', JText::_('PED_ZEND_NOT_LOADED'));
     }
     return true;
 }
Example #20
0
 public function prepare()
 {
     if (defined('JPATH_MANIFESTS')) {
         $this->src = dirname(__FILE__);
     } else {
         $componentInstaller = JInstaller::getInstance();
         $this->src = $componentInstaller->getPath('source');
     }
 }
Example #21
0
 /**
  * Constructor
  *
  * @access protected
  **/
 public function __construct()
 {
     // Since we are running from within the current installation,
     // we can use getInstance() to fetch the current installer and thus get access to our own manifest.
     $parent = JInstaller::getInstance();
     $manifest = $parent->getManifest();
     $this->_mainDb =& $parent->getDbo();
     $this->_mainSource = $parent->getPath('source');
     $this->_mysection =& $manifest->document->getElementByPath('subinstall');
     $this->_app = JFactory::getApplication();
 }
Example #22
0
 function install()
 {
     global $mainframe;
     $this->setState('action', 'install');
     switch (JRequest::getWord('installtype')) {
         case 'folder':
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             $this->setState('message', 'No Install Type Found');
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         $this->setState('message', 'Unable to find install package');
         return false;
     }
     // Get a database connector
     //$db = & JFactory::getDBO();
     // Get an installer instance
     $installer =& JInstaller::getInstance();
     require_once rsgOptions_installer_path . '/adapters/rsgtemplate.php';
     $installer->setAdapter('rsgTemplate', new JInstaller_rsgTemplate($installer));
     // Install the package
     if (!$installer->install($package['dir'])) {
         // There was an error installing the package
         $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error'));
         $result = false;
     } else {
         // Package installed sucessfully
         $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success'));
         $result = true;
     }
     // Set some model state values
     $mainframe->enqueueMessage($msg);
     $this->setState('name', $installer->get('name'));
     $this->setState('result', $result);
     $this->setState('message', $installer->message);
     $this->setState('extension.message', $installer->get('extension.message'));
     // Cleanup the install files
     if (!is_file($package['packagefile'])) {
         $config =& JFactory::getConfig();
         $package['packagefile'] = $config->getValue('config.tmp_path') . '/' . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
Example #23
0
 function uninstall($parent)
 {
     // Post Install Log
     self::_postInstallMessage('uninstall', $parent);
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $db->setQuery('SELECT extension_id FROM #__extensions WHERE type = "package" AND element = "pkg_cck"');
     $eid = $db->loadResult();
     $db->setQuery('SELECT extension_id FROM #__extensions WHERE type = "plugin" AND element = "cck" AND folder="system"');
     $cck = $db->loadResult();
     // Backup or Drop SQL Tables
     $prefix = $db->getPrefix();
     $tables = $db->getTableList();
     $tables = array_flip($tables);
     $uninstall_sql = (int) JCck::getConfig_Param('uninstall_sql', '');
     if (count($tables)) {
         $length = strlen($prefix);
         $app->cck_nosql = true;
         foreach ($tables as $k => $v) {
             $pos = strpos($k, $prefix . 'cck_');
             if ($pos !== false && $pos == 0) {
                 $k2 = $prefix . '_' . substr($k, $length);
                 if (isset($tables[$k2])) {
                     $db->setQuery('DROP TABLE ' . $k2);
                     $db->execute();
                 }
                 if ($uninstall_sql == 1) {
                     $db->setQuery('DROP TABLE ' . $k);
                     $db->execute();
                 } else {
                     $db->setQuery('RENAME TABLE ' . $k . ' TO ' . $k2);
                     $db->execute();
                 }
             }
         }
     }
     // Uninstall FULL PACKAGE only if package exists && system plugin exists..
     if ($eid && $cck) {
         $manifest = JPATH_ADMINISTRATOR . '/manifests/packages/pkg_cck.xml';
         if (JFile::exists($manifest)) {
             $xml = JFactory::getXML($manifest);
             // Keep it this way until platform 13.x
         }
         if (isset($xml->files)) {
             unset($xml->files->file[3]);
             $xml->asXML($manifest);
         }
         jimport('joomla.installer.installer');
         $installer = JInstaller::getInstance();
         $installer->uninstall('package', $eid);
     }
 }
Example #24
0
 /**
  * Install an extension from either folder, url or upload
  * @return boolean result of install
  */
 function install()
 {
     $this->setState('action', 'install');
     switch (JRequest::getWord('installtype')) {
         case 'folder':
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             $this->setState('message', 'JNo_Install_Type_Found');
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         $this->setState('message', 'UNABLE_TO_FIND_INSTALL_PACKAGE');
         return false;
     }
     // Get a database connector
     //$db = & JFactory::getDbo();
     // Get an installer instance
     $installer =& JInstaller::getInstance();
     // Install the package
     if (!$installer->install($package['dir'])) {
         // There was an error installing the package
         $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error'));
         $result = false;
     } else {
         // Package installed sucessfully
         $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success'));
         $result = true;
     }
     // Set some model state values
     $app =& JFactory::getApplication();
     $app->enqueueMessage($msg);
     $this->setState('name', $installer->get('name'));
     $this->setState('result', $result);
     $this->setState('message', $installer->message);
     $this->setState('extension_message', $installer->get('extension_message'));
     // Cleanup the install files
     if (!is_file($package['packagefile'])) {
         $config =& JFactory::getConfig();
         $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
Example #25
0
 public function ppInstall()
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.installer.installer');
     $db =& JFactory::getDBO();
     $this->path = JInstaller::getInstance()->getPath('extension_administrator');
     // sposto la cartella "propayment"
     $src = $this->path . DS . "propayment";
     $dst = JPATH_ROOT . DS . "propayment";
     $this->recurse_move($src, $dst);
     echo "<div>Cartella 'propayment' installata nel sito</div>";
     // creo la sottocartella "log" (se non esiste)
     @mkdir($dst . "/log");
     // installo il plugin
     jimport('joomla.installer.installer');
     $installer = new JInstaller();
     $result = $installer->install($this->path . DS . 'plugin');
     if ($result) {
         // abilito il plugin
         if (version_compare(JVERSION, '1.6.0', 'ge')) {
             $q = "UPDATE #__extensions SET enabled=1, name='VM - Payment, ProPayment' WHERE folder='vmpayment' AND element='propayment'";
         } else {
             $q = "UPDATE #__plugins SET published=1, name='VM - Payment, ProPayment' WHERE folder='vmpayment' AND element='propayment'";
         }
         $db->setQuery($q);
         $db->query();
         // elimino la cartella "plugin"
         $this->recursiveDelete($this->path . DS . 'plugin');
         echo "<h3>Componente e Plugin ProPayment installati.</h3>";
     } else {
         echo "<h3>Errore nell'installazione del plugin per VirtueMart 2!</h3>";
     }
     // modifico le voci di menu, in caso di Joomla 1.5
     if (!version_compare(JVERSION, '1.6.0', 'ge')) {
         $q = "UPDATE #__components SET name='ProPayment' WHERE name='COM_PROPAYMENT' AND `option`='com_propayment'";
         $db->setQuery($q);
         $db->query();
         $q = "UPDATE #__components SET name='Configurazione' WHERE name='MNU_CONFIG' AND `option`='com_propayment'";
         $db->setQuery($q);
         $db->query();
         $q = "UPDATE #__components SET name='Installazione moduli' WHERE name='MNU_INSTALL' AND `option`='com_propayment'";
         $db->setQuery($q);
         $db->query();
         $q = "UPDATE #__components SET name='Log errori' WHERE name='MNU_LOG_ERR' AND `option`='com_propayment'";
         $db->setQuery($q);
         $db->query();
         $q = "UPDATE #__components SET name='Log transazioni' WHERE name='MNU_LOG_TRN' AND `option`='com_propayment'";
         $db->setQuery($q);
         $db->query();
     }
     return true;
 }
Example #26
0
 public function remove($def)
 {
     $eid = $def->getElementsByTagName('id')->item(0)->nodeValue;
     $name = $def->getElementsByTagName('name')->item(0)->nodeValue;
     $type = $def->getElementsByTagName('type')->item(0)->nodeValue;
     $id = SPFactory::db()->select('extension_id', '#__extensions', array('type' => $type, 'element' => $eid))->loadResult();
     jimport('joomla.installer.installer');
     if (JInstaller::getInstance()->uninstall($type, $id)) {
         SPFactory::db()->delete('spdb_plugins', array('pid' => $eid, 'type' => $type), 1);
         return Sobi::Txt('CMS_EXT_REMOVED', $name);
     }
     return array('msg' => Sobi::Txt('CMS_EXT_NOT_REMOVED', $name), 'msgtype' => 'error');
 }
Example #27
0
 /**
  * Constructor
  *
  * @access protected
  **/
 function __construct()
 {
     // Since we are running from within the current installation,
     // we can use getInstance() to fetch the current installer and
     // thus get access to our own manifest.
     $parent =& JInstaller::getInstance();
     $manifest =& $parent->getManifest();
     $this->_mainDb =& $parent->getDBO();
     $this->_mainSource = $parent->getPath('source');
     $this->_mysection =& $manifest->document->getElementByPath('subinstall');
     $this->_app =& JFactory::getApplication();
     $this->_lang = array('en-GB' => 'en-GB', 'de-DE' => 'de-DE', 'pl-PL' => 'pl-PL');
 }
Example #28
0
 public static function installExtension($url, $label)
 {
     // Include Joomla! libraries
     jimport('joomla.installer.installer');
     jimport('joomla.installer.helper');
     // System variables
     $app = JFactory::getApplication();
     // Download the package-file
     $package_file = self::downloadPackage($url);
     // Simple check for the result
     if ($package_file == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_FILE_EMPTY', $url));
         return false;
     }
     // Check if the downloaded file exists
     $tmp_path = JFactory::getApplication()->getCfg('tmp_path');
     $package_path = $tmp_path . '/' . $package_file;
     if (!is_file($package_path)) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_FILE_NOT_EXIST', $package_path));
         return false;
     }
     // Check if the file is readable
     if (!is_readable($package_path)) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_FILE_NOT_READABLE', $package_path));
         return false;
     }
     // Now we assume this is an archive, so let's unpack it
     $package = JInstallerHelper::unpack($package_path);
     if ($package == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_NO_ARCHIVE', $extension['name']));
         return false;
     }
     // Call the actual installer to install the package
     $installer = JInstaller::getInstance();
     if ($installer->install($package['dir']) == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_EXTENSION_FAIL', $extension['name']));
         return false;
     }
     // Get the name of downloaded package
     if (!is_file($package['packagefile'])) {
         $package['packagefile'] = JFactory::getApplication()->getCfg('tmp_path') . '/' . $package['packagefile'];
     }
     // Clean up the installation
     @JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_EXTENSION_SUCCESS', $label));
     // Clean the Joomla! plugins cache
     $options = array('defaultgroup' => 'com_plugins', 'cachebase' => JPATH_ADMINISTRATOR . '/cache');
     $cache = JCache::getInstance('callback', $options);
     $cache->clean();
     return true;
 }
Example #29
0
 /**
  * Execute the install command
  *
  * @param   InputInterface  $input  An InputInterface instance
  * @param   OutputInterface $output An OutputInterface instance
  *
  * @return  integer  0 if everything went fine, 1 on error
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setupEnvironment('administrator', $input, $output);
     // Enable debug, so that JInstaller::install() throws exceptions on problems
     $this->joomla->setCfg('debug', 1);
     $installer = \JInstaller::getInstance();
     if ($installer->install($this->handleExtension($input, $output))) {
         $output->writeln($this->getExtensionInfo($installer));
         return 0;
     } else {
         $output->writeln('Installation failed due to unknown reason.');
         return 1;
     }
 }
 function autoupdate()
 {
     $update = $this->parseXMLFile();
     $config =& JFactory::getConfig();
     $tmp_dest = $config->getValue('config.tmp_path');
     if (!is_object($update)) {
         // parseXMLFile will have set a message hopefully
         //$this->setState('message', 'XML Parse failed');
         return false;
     } else {
         $destination = $tmp_dest . DS . 'com_jupdateman_auto.tgz';
         $download = downloadFile($update->updaterurl, $destination);
         if ($download !== true) {
             $this->setState('message', $download->error_message);
             return false;
         } else {
             $package = JInstallerHelper::unpack($destination);
             if (!$package) {
                 $this->setState('message', 'Unable to find install package');
                 return false;
             }
             $installer =& JInstaller::getInstance();
             // Install the package
             if (!$installer->install($package['dir'])) {
                 // There was an error installing the package
                 $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error'));
                 $result = false;
             } else {
                 // Package installed sucessfully
                 $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success'));
                 $result = true;
             }
             // Grab the application
             $mainframe =& JFactory::getApplication();
             // Set some model state values
             $mainframe->enqueueMessage($msg);
             $this->setState('name', $installer->get('name'));
             $this->setState('result', $result);
             $this->setState('message', $installer->message);
             $this->setState('extension.message', $installer->get('extension.message'));
             // Cleanup the install files
             if (!is_file($package['packagefile'])) {
                 $config =& JFactory::getConfig();
                 $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
             }
             JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
             return $result;
         }
     }
 }