/** * Makes sure that the Professional release can be updated using Joomla!'s * own update system. THIS IS AN AKEEBA ORIGINAL! */ public function applyJoomlaExtensionUpdateChanges($isPro = -1) { $ret = true; // Don';'t bother if this is not Joomla! 1.7+ if (!version_compare(JVERSION, '1.7.0', 'ge')) { return $ret; } // Do we have Admin Tools Professional? if ($isPro === -1) { $isPro = AKEEBA_PRO; } // Action parameters $action = 'none'; // What to do: none, update, create, delete $purgeUpdates = false; // Should I purge existing updates? $fetchUpdates = false; // Should I fetch new udpater // Init $db = $this->getDbo(); // Figure out the correct XML update stream URL if ($isPro) { $update_url = 'https://www.akeebabackup.com/index.php?option=com_ars&view=update&task=stream&format=xml&id=6'; JLoader::import('joomla.application.component.helper'); $params = JComponentHelper::getParams('com_akeeba'); if (version_compare(JVERSION, '3.0', 'ge')) { $dlid = $params->get('update_dlid', ''); } else { $dlid = $params->getValue('update_dlid', ''); } if (!preg_match('/^[0-9a-f]{32}$/i', $dlid)) { $ret = false; $dlid = ''; } if ($dlid) { $dlid = $dlid; $url = $update_url . '&dlid=' . $dlid . '/extension.xml'; } else { $url = ''; } } else { $url = 'http://cdn.akeebabackup.com/updates/atcore.xml'; } // Get the extension ID $extensionID = JComponentHelper::getComponent('com_akeeba')->id; // Get the update site record $query = $db->getQuery(true)->select(array($db->qn('us') . '.*'))->from($db->qn('#__update_sites_extensions') . ' AS ' . $db->qn('map'))->innerJoin($db->qn('#__update_sites') . ' AS ' . $db->qn('us') . ' ON (' . $db->qn('us') . '.' . $db->qn('update_site_id') . ' = ' . $db->qn('map') . '.' . $db->qn('update_site_id') . ')')->where($db->qn('map') . '.' . $db->qn('extension_id') . ' = ' . $db->q($extensionID)); $db->setQuery($query); $update_site = $db->loadObject(); // Decide on the course of action to take if ($url) { if (!is_object($update_site)) { $action = 'create'; $fetchUpdates = true; } else { $action = $update_site->location != $url ? 'update' : 'none'; $purgeUpdates = $action == 'update'; $fetchUpdates = $action == 'update'; } } else { // Disable the update site for Akeeba Backup if (!is_object($update_site)) { $action = 'none'; } else { $action = 'delete'; $purgeUpdates = true; } } switch ($action) { case 'none': // No change break; case 'create': case 'update': // Remove old update site $query = $db->getQuery(true)->delete($db->qn('#__update_sites'))->where($db->qn('name') . ' = ' . $db->q('Akeeba Backup updates')); $db->setQuery($query); $db->execute(); // Create new update site $oUpdateSite = (object) array('name' => 'Akeeba Backup updates', 'type' => 'extension', 'location' => $url, 'enabled' => 1, 'last_check_timestamp' => 0); $db->insertObject('#__update_sites', $oUpdateSite); // Get the update site ID $usID = $db->insertid(); // Delete existing #__update_sites_extensions records $query = $db->getQuery(true)->delete($db->qn('#__update_sites_extensions'))->where($db->qn('extension_id') . ' = ' . $db->q($extensionID)); $db->setQuery($query); $db->execute(); // Create new #__update_sites_extensions record $oUpdateSitesExtensions = (object) array('update_site_id' => $usID, 'extension_id' => $extensionID); $db->insertObject('#__update_sites_extensions', $oUpdateSitesExtensions); break; case 'delete': // Remove update sites $query = $db->getQuery(true)->delete($db->qn('#__update_sites'))->where($db->qn('update_site_id') . ' = ' . $db->q($update_site->update_site_id)); $db->setQuery($query); $db->execute(); // Delete existing #__update_sites_extensions records $query = $db->getQuery(true)->delete($db->qn('#__update_sites_extensions'))->where($db->qn('extension_id') . ' = ' . $db->q($extensionID)); $db->setQuery($query); $db->execute(); break; } // Do I have to purge updates? if ($purgeUpdates) { $query = $db->getQuery(true)->delete($db->qn('#__updates'))->where($db->qn('element') . ' = ' . $db->q('com_akeeba')); $db->setQuery($query); $db->execute(); } // Do I have to fetch updates? if ($fetchUpdates) { JLoader::import('joomla.update.update'); $x = new JUpdater(); $x->findUpdates($extensionID); } return $ret; }