function installExtensions($mainmsg) { jimport('joomla.installer.helper'); jimport('joomla.installer.installer'); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); $db =& JFactory::getDBO(); $installer = new JInstaller(); // $installer->_overwrite = true; $pkg_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomailermailchimpintegration' . DS . 'extensions' . DS; $pkgs = array('com_joomailermailchimpsignup.zip' => 'Joomlamailer Signup component', 'plg_joomailermailchimpsignup.zip' => 'Joomlamailer Signup plugin', 'mod_mailchimpsignup.zip' => 'MailChimp Signup', 'mod_mailchimpstats.zip' => 'MailChimp Admin Stats', 'plg_fmsts.zip' => 'MailChimp STS plugin', 'plg_joomlamailer_JomSocial.zip' => 'JomSocial plugin', 'plg_joomlamailer_CommunityBuilder.zip' => 'CommunityBuilder plugin'); $mainframe =& JFactory::getApplication(); foreach ($pkgs as $pkg => $pkgname) { if ($pkg == 'plg_joomlamailer_CommunityBuilder.zip') { $cbinstaller = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_comprofiler' . DS . 'library' . DS . 'cb' . DS . 'cb.installer.php'; if (JFile::exists($cbinstaller)) { require_once $cbinstaller; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin.class.php'; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin.foundation.php'; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_comprofiler' . DS . 'library' . DS . 'cb' . DS . 'cb.database.php'; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_comprofiler' . DS . 'comprofiler.class.php'; $installer = new cbInstallerPlugin(); $installer->installArchive($pkg_path . $pkg); $installer->extractArchive(); if ($installer->install()) { $query = "UPDATE #__comprofiler_plugin SET `published` = '1' WHERE `folder` = 'plug_joomlamailercbsignup'"; $db->setQuery($query); $db->query(); } } } else { $package = JInstallerHelper::unpack($pkg_path . $pkg); if ($installer->install($package['dir'])) { $msg = 1; $msgtext = "{$pkgname} successfully installed."; } else { $msg = 0; $msgtext = "ERROR: Could not install the {$pkgname}. Please install manually."; } if (!$msg) { $mainframe->redirect('index.php', $msgtext . "\n" . $mainmsg); } else { if ($pkg == 'com_joomailermailchimpsignup.zip') { // remove signup component from backend menu if (version_compare(JVERSION, '1.6.0', 'ge')) { $query = "DELETE FROM #__menu WHERE `title` = 'com_joomailermailchimpsignup';"; $db->setQuery($query); $db->query(); } } else { if ($pkg == 'mod_mailchimpstats.zip') { $query = "UPDATE #__modules SET published = '1', position = 'cpanel', ordering = '-1' WHERE `module` = 'mod_mailchimpstats'"; $db->setQuery($query); $db->query(); if (version_compare(JVERSION, '1.6.0', 'ge')) { $query = "SELECT id FROM #__modules WHERE `module` = 'mod_mailchimpstats'"; $db->setQuery($query); $moduleID = $db->loadResult(); $query = "INSERT INTO #__modules_menu (moduleid, menuid) VALUES ('" . $moduleID . "', '0')"; $db->setQuery($query); $db->query(); } } else { if ($pkg == 'plg_joomlamailer_JomSocial.zip') { if (version_compare(JVERSION, '1.6.0', 'ge')) { $query = "UPDATE #__extensions SET `enabled` = '1' WHERE `element` = 'joomlamailer' AND `folder` = 'community'"; } else { $query = "UPDATE #__plugins SET `published` = '1' WHERE `element` = 'joomlamailer' AND `folder` = 'community'"; } $db->setQuery($query); $db->query(); } } } } } } $path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomailermailchimpintegration' . DS . 'extensions'; if (JFolder::exists($path)) { JFolder::delete($path); } }