Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow commercial (for a fee) components to use the Joomla! extensions update feature [Tracker 32684] #2508

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1 +1,2 @@
# Placeholder file for database changes for version 3.2.1
ALTER TABLE `#__update_sites` ADD COLUMN `extra_query` VARCHAR(1000) DEFAULT '';
ALTER TABLE `#__updates` ADD COLUMN `extra_query` VARCHAR(1000) DEFAULT '';
@@ -1 +1,2 @@
# Placeholder file for database changes for version 3.2.1
ALTER TABLE "#__update_sites" ADD COLUMN "extra_query" varchar(1000) DEFAULT '';
ALTER TABLE "#__updates" ADD COLUMN "extra_query" varchar(1000) DEFAULT '';
@@ -1 +1,2 @@
# Placeholder file for database changes for version 3.2.1
ALTER TABLE [#__update_sites] ADD [extra_query] [nvarchar](1000) NULL DEFAULT '';
ALTER TABLE [#__updates] ADD [extra_query] [nvarchar](1000) NULL DEFAULT '';
16 changes: 16 additions & 0 deletions administrator/components/com_installer/models/update.php
Expand Up @@ -237,6 +237,7 @@ public function update($uids)
$instance = JTable::getInstance('update');
$instance->load($uid);
$update->loadFromXML($instance->detailsurl);
$update->set('extra_query', $instance->extra_query);

// Install sets state and enqueues messages
$res = $this->install($update);
Expand Down Expand Up @@ -268,6 +269,21 @@ private function install($update)
if (isset($update->get('downloadurl')->_data))
{
$url = $update->downloadurl->_data;

$extra_query = $update->get('extra_query');
if ($extra_query)
{
if (strpos($url, '?') === false)
{
$url .= '?';
}
else
{
$url .= '&';
}

$url .= $extra_query;
}
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions installation/sql/mysql/joomla.sql
Expand Up @@ -1759,6 +1759,7 @@ CREATE TABLE IF NOT EXISTS `#__updates` (
`data` text NOT NULL,
`detailsurl` text NOT NULL,
`infourl` text NOT NULL,
`extra_query` VARCHAR(1000) DEFAULT '',
PRIMARY KEY (`update_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Available Updates';

Expand All @@ -1775,6 +1776,7 @@ CREATE TABLE IF NOT EXISTS `#__update_sites` (
`location` text NOT NULL,
`enabled` int(11) DEFAULT 0,
`last_check_timestamp` bigint(20) DEFAULT 0,
`extra_query` VARCHAR(1000) DEFAULT '',
PRIMARY KEY (`update_site_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Update Sites';

Expand Down
2 changes: 2 additions & 0 deletions installation/sql/postgresql/joomla.sql
Expand Up @@ -1685,6 +1685,7 @@ CREATE TABLE "#__updates" (
"data" text DEFAULT '' NOT NULL,
"detailsurl" text NOT NULL,
"infourl" text NOT NULL,
"extra_query" varchar(1000) DEFAULT '',
PRIMARY KEY ("update_id")
);

Expand All @@ -1700,6 +1701,7 @@ CREATE TABLE "#__update_sites" (
"location" text NOT NULL,
"enabled" bigint DEFAULT 0,
"last_check_timestamp" bigint DEFAULT 0,
"extra_query" varchar(1000) DEFAULT '',
PRIMARY KEY ("update_site_id")
);

Expand Down
2 changes: 2 additions & 0 deletions installation/sql/sqlazure/joomla.sql
Expand Up @@ -2732,6 +2732,7 @@ CREATE TABLE [#__update_sites](
[location] [nvarchar](max) NOT NULL,
[enabled] [int] NULL DEFAULT 0,
[last_check_timestamp] [int] NULL DEFAULT 0,
[extra_query] [nvarchar](1000) NULL DEFAULT '',
CONSTRAINT [PK_#__update_sites_update_site_id] PRIMARY KEY CLUSTERED
(
[update_site_id] ASC
Expand Down Expand Up @@ -2786,6 +2787,7 @@ CREATE TABLE [#__updates](
[data] [nvarchar](max) NOT NULL DEFAULT '',
[detailsurl] [nvarchar](max) NOT NULL,
[infourl] [nvarchar](max) NOT NULL,
[extra_query] [nvarchar](1000) NULL DEFAULT '',
CONSTRAINT [PK_#__updates_update_id] PRIMARY KEY CLUSTERED
(
[update_id] ASC
Expand Down
8 changes: 8 additions & 0 deletions libraries/joomla/updater/update.php
Expand Up @@ -138,6 +138,14 @@ class JUpdate extends JObject
*/
protected $targetplatform;

/**
* Extra query for download URLs
*
* @var string
* @since 13.1
*/
protected $extra_query;

/**
* Resource handle for the XML Parser
*
Expand Down
7 changes: 5 additions & 2 deletions libraries/joomla/updater/updater.php
Expand Up @@ -77,11 +77,11 @@ public function findUpdates($eid = 0, $cacheTimeout = 0)
// Push it into an array
if (!is_array($eid))
{
$query = 'SELECT DISTINCT update_site_id, type, location, last_check_timestamp FROM #__update_sites WHERE enabled = 1';
$query = 'SELECT DISTINCT update_site_id, type, location, last_check_timestamp, extra_query FROM #__update_sites WHERE enabled = 1';
}
else
{
$query = 'SELECT DISTINCT update_site_id, type, location, last_check_timestamp FROM #__update_sites' .
$query = 'SELECT DISTINCT update_site_id, type, location, last_check_timestamp, extra_query FROM #__update_sites' .
' WHERE update_site_id IN' .
' (SELECT update_site_id FROM #__update_sites_extensions WHERE extension_id IN (' . implode(',', $eid) . '))';
}
Expand Down Expand Up @@ -116,11 +116,13 @@ public function findUpdates($eid = 0, $cacheTimeout = 0)
$results = JArrayHelper::arrayUnique(array_merge($results, $update_result['update_sites']));
$result_count = count($results);
}

if (array_key_exists('updates', $update_result) && count($update_result['updates']))
{
for ($k = 0, $count = count($update_result['updates']); $k < $count; $k++)
{
$current_update = &$update_result['updates'][$k];
$current_update->extra_query = $result['extra_query'];
$update = JTable::getInstance('update');
$extension = JTable::getInstance('extension');
$uid = $update
Expand All @@ -140,6 +142,7 @@ public function findUpdates($eid = 0, $cacheTimeout = 0)
'folder' => strtolower($current_update->get('folder'))
)
);

if (!$uid)
{
// Set the extension id
Expand Down