/** * Installs subextensions (modules, plugins) bundled with the main extension * * @param JInstaller $parent * @return JObject The subextension installation status */ private function _installSubextensions($parent) { if (version_compare(JVERSION, '1.6.0', 'ge')) { $src = $parent->getParent()->getPath('source'); } else { $src = $parent->getPath('source'); } $db = JFactory::getDbo(); $status = new JObject(); $status->modules = array(); $status->plugins = array(); $status->adsmanagerfields = array(); $src = str_replace('backend', '', $src); // Modules installation if (count($this->installation_queue['modules'])) { foreach ($this->installation_queue['modules'] as $folder => $modules) { if (count($modules)) { foreach ($modules as $module => $modulePreferences) { // Install the module if (empty($folder)) { $folder = 'site'; } $path = "{$src}/modules/{$folder}/{$module}"; if (!is_dir($path)) { $path = "{$src}/modules/{$folder}/mod_{$module}"; } if (!is_dir($path)) { $path = "{$src}/modules/{$module}"; } if (!is_dir($path)) { $path = "{$src}/modules/mod_{$module}"; } if (!is_dir($path)) { continue; } // Was the module already installed? if (version_compare(JVERSION, '1.6.0', 'ge')) { $sql = $db->getQuery(true)->select('COUNT(*)')->from('#__modules')->where($db->qn('module') . ' = ' . $db->q('mod_' . $module)); $db->setQuery($sql); $count = $db->loadResult(); } else { $count = 1; } $installer = new JInstaller(); $result = $installer->install($path); $status->modules[] = array('name' => 'mod_' . $module, 'client' => $folder, 'result' => $result); // Modify where it's published and its published state if (!$count) { // A. Position and state list($modulePosition, $modulePublished) = $modulePreferences; if ($modulePosition == 'cpanel') { $modulePosition = 'icon'; } if (version_compare(JVERSION, '3.0.2', 'ge')) { if ($modulePosition == "left") { $modulePosition = 'position-7'; } } $sql = $db->getQuery(true)->update($db->qn('#__modules'))->set($db->qn('position') . ' = ' . $db->q($modulePosition))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module)); if ($modulePublished) { $sql->set($db->qn('published') . ' = ' . $db->q('1')); } $db->setQuery($sql); $db->query(); // B. Change the ordering of back-end modules to 1 + max ordering if ($folder == 'admin') { $query = $db->getQuery(true); $query->select('MAX(' . $db->qn('ordering') . ')')->from($db->qn('#__modules'))->where($db->qn('position') . '=' . $db->q($modulePosition)); $db->setQuery($query); $position = $db->loadResult(); $position++; $query = $db->getQuery(true); $query->update($db->qn('#__modules'))->set($db->qn('ordering') . ' = ' . $db->q($position))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module)); $db->setQuery($query); $db->query(); } // C. Link to all pages $query = $db->getQuery(true); $query->select('id')->from($db->qn('#__modules'))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module)); $db->setQuery($query); $moduleid = $db->loadResult(); $query = $db->getQuery(true); $query->select('*')->from($db->qn('#__modules_menu'))->where($db->qn('moduleid') . ' = ' . $db->q($moduleid)); $db->setQuery($query); $assignments = $db->loadObjectList(); $isAssigned = !empty($assignments); if (!$isAssigned) { $o = (object) array('moduleid' => $moduleid, 'menuid' => 0); $db->insertObject('#__modules_menu', $o); } } } } } } if (version_compare(JVERSION, '1.6.0', 'ge')) { $this->installation_queue['plugins']['sh404sefextplugins'] = array('sh404sefextplugincom_adsmanager' => 1); } else { $this->installation_queue['plugins']['sh404sefextplugins'] = array('com_adsmanager' => 1); unset($this->installation_queue['plugins']['xmap']); } // Plugins installation if (count($this->installation_queue['plugins'])) { foreach ($this->installation_queue['plugins'] as $folder => $plugins) { if (count($plugins)) { foreach ($plugins as $plugin => $published) { $path = "{$src}/plugins/{$folder}/{$plugin}"; if (!is_dir($path)) { $path = "{$src}/plugins/{$folder}/plg_{$plugin}"; } if (!is_dir($path)) { $path = "{$src}/plugins/{$plugin}"; } if (!is_dir($path)) { $path = "{$src}/plugins/plg_{$plugin}"; } if (!is_dir($path)) { continue; } // Was the plugin already installed? if (version_compare(JVERSION, '1.6.0', 'ge')) { $query = $db->getQuery(true)->select('COUNT(*)')->from($db->qn('#__extensions'))->where($db->qn('element') . ' = ' . $db->q($plugin))->where($db->qn('folder') . ' = ' . $db->q($folder)); $db->setQuery($query); $count = $db->loadResult(); } else { $count = 1; } $installer = new JInstaller(); $result = $installer->install($path); $status->plugins[] = array('name' => 'plg_' . $plugin, 'group' => $folder, 'result' => $result); if ($published && !$count) { $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q($plugin))->where($db->qn('folder') . ' = ' . $db->q($folder)); $db->setQuery($query); $db->query(); } } } } } // External Plugins installation if (count($this->installation_queue['adsmanagerfields'])) { $path = JPATH_SITE . "/images/com_adsmanager/plugins"; if (file_exists($path)) { foreach ($this->installation_queue['adsmanagerfields'] as $folder => $plugins) { if (count($plugins)) { foreach ($plugins as $plugin) { $destPath = $path . "/" . $folder; $sourcePath = $src . "/adsmanagerfields/" . $folder; if (is_dir($destPath)) { //echo "ok"; $this->rmdir_recurse($destPath); //if (is_dir($destPath)) //echo "ok"; } @mkdir($path); $this->recurse_copy($sourcePath, $destPath); if (file_exists($destPath . '/plug.php')) { include_once $destPath . '/plug.php'; if (isset($plugins[$folder])) { $plugins[$folder]->install(); } } } } $status->adsmanagerfields[] = array('name' => $folder, 'group' => '', 'result' => 'Installed'); } } } // External Plugins installation if (file_exists(JPATH_ROOT . '/components/com_comprofiler/comprofiler.php')) { global $_CB_framework, $mainframe; if (defined('JPATH_ADMINISTRATOR')) { if (!file_exists(JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php')) { echo 'CB not installed!'; return; } include_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php'; } else { if (!file_exists($mainframe->getCfg('absolute_path') . '/administrator/components/com_comprofiler/plugin.foundation.php')) { echo 'CB not installed!'; return; } include_once $mainframe->getCfg('absolute_path') . '/administrator/components/com_comprofiler/plugin.foundation.php'; } cbimport('cb.html'); cbimport('cb.installer'); $installer = new cbInstallerPlugin(); $sourcePath = $src . "/cbplugins/"; if (count($this->installation_queue['cbplugins'])) { foreach ($this->installation_queue['cbplugins'] as $plugin) { if ($installer->install($sourcePath . $plugin . "/")) { $installed = true; } else { $installed = false; } $installer->cleanupInstall(null, $installer->unpackDir()); $status->plugins[] = array('name' => 'CB Plugin ' . ucfirst($plugin), 'group' => '', 'result' => $installed); } } } $app = JFactory::getApplication(); $source = $src . "/langplugins/joomfish"; if (file_exists(JPATH_ROOT . "/administrator/components/com_joomfish/contentelements/")) { JFile::copy($source . "/adsmanager_ads.xml", JPATH_ROOT . "/administrator/components/com_joomfish/contentelements/adsmanager_ads.xml"); JFile::copy($source . "/adsmanager_categories.xml", JPATH_ROOT . "/administrator/components/com_joomfish/contentelements/adsmanager_categories.xml"); JFile::copy($source . "/adsmanager_columns.xml", JPATH_ROOT . "/administrator/components/com_joomfish/contentelements/adsmanager_columns.xml"); JFile::copy($source . "/adsmanager_config.xml", JPATH_ROOT . "/administrator/components/com_joomfish/contentelements/adsmanager_config.xml"); JFile::copy($source . "/adsmanager_fields.xml", JPATH_ROOT . "/administrator/components/com_joomfish/contentelements/adsmanager_fields.xml"); JFile::copy($source . "/adsmanager_field_values.xml", JPATH_ROOT . "/administrator/components/com_joomfish/contentelements/adsmanager_field_values.xml"); $status->plugins[] = array('name' => 'Joomfish XML files', 'group' => '', 'result' => true); } $source = $src . "/langplugins/falang"; if (file_exists(JPATH_ROOT . "/administrator/components/com_falang/contentelements/")) { JFile::copy($source . "/adsmanager_ads.xml", JPATH_ROOT . "/administrator/components/com_falang/contentelements/adsmanager_ads.xml"); JFile::copy($source . "/adsmanager_categories.xml", JPATH_ROOT . "/administrator/components/com_falang/contentelements/adsmanager_categories.xml"); JFile::copy($source . "/adsmanager_columns.xml", JPATH_ROOT . "/administrator/components/com_falang/contentelements/adsmanager_columns.xml"); JFile::copy($source . "/adsmanager_config.xml", JPATH_ROOT . "/administrator/components/com_falang/contentelements/adsmanager_config.xml"); JFile::copy($source . "/adsmanager_fields.xml", JPATH_ROOT . "/administrator/components/com_falang/contentelements/adsmanager_fields.xml"); JFile::copy($source . "/adsmanager_field_values.xml", JPATH_ROOT . "/administrator/components/com_falang/contentelements/adsmanager_field_values.xml"); $status->plugins[] = array('name' => 'Falang XML files', 'group' => '', 'result' => true); } return $status; }
/** * Installs the plugin From URL * * @param string $userfileURL Url * @return boolean Success */ private function installPluginURL($userfileURL) { global $_CB_framework; // Try extending time, as unziping/ftping took already quite some... : @set_time_limit(240); _CBsecureAboveForm('showPlugins'); outputCbTemplate(2); outputCbJs(2); initToolTip(2); $installer = new cbInstallerPlugin(); // Check that the zlib is available if (!extension_loaded('zlib')) { cbInstaller::showInstallMessage(CBTxt::T('The installer cannot continue before zlib is installed'), CBTxt::T('Installer - Error'), false); return false; } if (!$userfileURL) { cbInstaller::showInstallMessage(CBTxt::T('No URL selected'), CBTxt::T('Upload new plugin - error'), false); return false; } cbimport('cb.adminfilesystem'); $adminFS = cbAdminFileSystem::getInstance(); if ($adminFS->isUsingStandardPHP()) { $baseDir = _cbPathName($_CB_framework->getCfg('tmp_path')); } else { $baseDir = $_CB_framework->getCfg('absolute_path') . '/tmp/'; } $userfileName = $baseDir . 'comprofiler_temp.zip'; $msg = ''; $resultdir = $this->uploadFileURL($userfileURL, $userfileName, $msg); if ($resultdir === false) { cbInstaller::showInstallMessage($msg, sprintf(CBTxt::T('Download %s - Download Error'), $userfileURL), false); return false; } if (!$installer->upload($userfileName)) { cbInstaller::showInstallMessage($installer->getError(), sprintf(CBTxt::T('Download %s - Upload Failed'), $userfileURL), false); return false; } $ret = $installer->install(); cbInstaller::showInstallMessage($installer->getError(), sprintf(CBTxt::T('Download %s'), $userfileURL) . ' - ' . ($ret ? CBTxt::T('Success') : CBTxt::T('Failed')), $ret); $installer->cleanupInstall($userfileName, $installer->unpackDir()); return $ret; }
function installPluginURL() { global $_CB_framework; // Try extending time, as unziping/ftping took already quite some... : @set_time_limit(240); _CBsecureAboveForm('showPlugins'); outputCbTemplate(2); outputCbJs(2); initToolTip(2); $option = "com_comprofiler"; $task = "showPlugins"; $client = 0; // echo "installPluginURL"; $installer = new cbInstallerPlugin(); // Check that the zlib is available if (!extension_loaded('zlib')) { cbInstaller::renderInstallMessage(CBTxt::T('The installer cannot continue before zlib is installed'), CBTxt::T('Installer - Error'), $installer->returnTo($option, $task, $client)); exit; } $userfileURL = cbGetParam($_REQUEST, 'userfile', null); if (!$userfileURL) { cbInstaller::renderInstallMessage(CBTxt::T('No URL selected'), CBTxt::T('Upload new plugin - error'), $installer->returnTo($option, $task, $client)); exit; } cbimport('cb.adminfilesystem'); $adminFS = cbAdminFileSystem::getInstance(); if ($adminFS->isUsingStandardPHP()) { $baseDir = _cbPathName($_CB_framework->getCfg('tmp_path')); } else { $baseDir = $_CB_framework->getCfg('absolute_path') . '/tmp/'; } $userfileName = $baseDir . 'comprofiler_temp.zip'; $msg = ''; //echo "step-uploadfile<br />"; $resultdir = uploadFileURL($userfileURL, $userfileName, $msg); if ($resultdir !== false) { //echo "step-upload<br />"; if (!$installer->upload($userfileName)) { cbInstaller::renderInstallMessage($installer->getError(), sprintf(CBTxt::T('Download %s - Upload Failed'), $userfileURL), $installer->returnTo($option, $task, $client)); } //echo "step-install<br />"; $ret = $installer->install(); if ($ret) { cbInstaller::renderInstallMessage($installer->getError(), sprintf(CBTxt::T('Download %s'), $userfileURL) . ' - ' . ($ret ? CBTxt::T('Success') : CBTxt::T('Failed')), $installer->returnTo($option, $task, $client)); } $installer->cleanupInstall($userfileName, $installer->unpackDir()); } else { cbInstaller::renderInstallMessage($msg, sprintf(CBTxt::T('Download %s - Download Error'), $userfileURL), $installer->returnTo($option, $task, $client)); } }