public static function isInstalledSource($element, $type = 'component', $folder = '') { if (!VMMigrateHelperDatabase::isValidConnection()) { return false; } if (!VMMigrateHelperDatabase::isValidPrefix()) { return false; } $source_db = VMMigrateHelperDatabase::getSourceDb(); $params = JComponentHelper::getParams('com_vmmigrate'); $params->get('joomla_version', '1.5'); $joomla_version_src = self::getJoomlaVersionSource(); //Test if the extension is installed on the source website $query = $source_db->getQuery(true); if (version_compare($joomla_version_src, '1.6', 'ge')) { $query->select('extension_id')->from('#__extensions')->where("element = " . $source_db->q($element))->where("type = " . $source_db->q($type)); } else { switch ($type) { case 'plugin': $query->select('id')->from('#__plugins')->where("element = " . $source_db->q($element)); if ($folder) { $query->where("folder = " . $source_db->q($folder)); } break; case 'module': $query->select('id')->from('#__modules')->where("module = " . $source_db->q($element)); break; case 'component': default: $query->select('id')->from('#__components')->where($source_db->qn('option') . " = " . $source_db->q($element)); } } $source_db->setQuery($query); $extension_id = $source_db->loadResult(); if ($extension_id) { return true; } else { return false; } }
public static function isValidPrefix() { try { $source_db = VMMigrateHelperDatabase::getSourceDb(); $query = $source_db->getQuery(true); //$query->select('count(*)')->from('#__components'); $query->select('count(*)')->from('#__users'); $source_db->setQuery($query); $found_extensions = $source_db->loadResult(); if ($found_extensions) { return true; } else { return false; } } catch (Exception $e) { return false; } }