TheTimPlummerJoomlaShowCoverImage 200

Reading the JED meeting minutes, I discovered that there will be a new requirement as of 10th January 2017 that all extensions listed on the JED must use the Joomla Updater. While I support the idea, it struck me that there just isn't any documentation targeted to commercial extension developers. There is some documentation on Deploying an Update Server, and I wrote about Setting up an update server in Chapter 9 of Learning Joomla 3 Extension Development, however this only helps those that are wanting to give away their extension for free.

So the purpose of this article is to explain to commercial extension developers how they can leverage the Joomla Updater in their components, but still limit updates only to customers who have a current subscription.

Since writing this, @ot2sen has brought to my attention an alternative approach which allows you to redirect users with a nice message if they don't enter their download ID in their config.
 

 

My initial assumption is that you already have Akeeba Release Systems installed on your site and are using this to distribute your extensions. I’m also assuming that you are using Akeeba Subscriptions to sell your extension, and that customers are issued with an Akeeba download ID. If there is enough interest, I may write about setting these up, but for now I'll assume that you are capable of reading Nicholas' documentation and figuring out that bit yourself.


Throughout this example, I'm going to use a ficticious component called "Your Component (com_yourcomponent)", so when using this code yourself don't forget to replace COM_YOURCOMPONENT, com_yourcomponent and Your Component with the name of your component.

1. The first step is to add a component option to store the customer’s download ID. Add a field to store the download ID in your config.xml file

/administrator/components/com_yourcomponent/config.xml

 

<field name="downloadid" type="text" default="" size="30"
    label="COM_YOURCOMPONENT_FIELD_DOWNLOADID_LABEL"
    description ="COM_YOURCOMPONENT_FIELD_DOWNLOADID_DESC" />

 

 

2. Next, you need to add the language strings for these options.

/language/en-GB/en-GB.com_yourcomponent.ini

COM_YOURCOMPONENT_FIELD_DOWNLOADID_DESC="Enter your Download ID to enable Updates"
COM_YOURCOMPONENT_FIELD_DOWNLOADID_LABEL="Download ID"

 

3. Add an update server reference in your installation XML file

/administrator/components/com_yourcomponent/com_yourcomponent.xml

Note, the id you select at the end of this url will be determined by the update stream you create in Akeeba Release Systems.

updater1

Note you can add this at the bottom of your installation XML file, just before the closing </extension> tag.

 

<updateservers>    
    <server type="extension" priority="1"
        name="Your Component"><![CDATA[http://www.yourwebsite.com/index.php?option=com_ars&view=update&task=stream&format=xml&id=4]]>
    </server>
</updateservers>

 

 

 4. In the controller for your default view, add the following:

Note, this should probably go in your model instead of the controller as we are dealing with a database call, but for now lets just be lazy. Essentially what we want to do is update the jos_update_sites entry for our extension and include the download id.

 

public function __construct($config = array())
    {
        parent::__construct($config);

        $component = JComponentHelper::getComponent('com_yourcomponent');
        $dlid = $component->params->get('downloadid', '');

        if (empty($dlid)) return;

        $extra_query = "'dlid=$dlid'";

        $db = JFactory::getDbo();
        $query = $db->getQuery(true)
        ->update('#__update_sites')
        ->set('extra_query = '.$extra_query)
        ->where('name = "Your Component"');
        $db->setQuery($query);
        $db->execute();
    }

 

Note the name above should exactly match the name in the updates server section of your installation XML file.

 

That’s all you need to do in the component, the rest of the work is on your site where you have Akeeba Release Systems installed.

 

In the item record for this release in Akeeba Release Systems, make sure you select the appropriate update stream, and which versions of Joomla (Environments) this release is compatible with.

updater2

 

The Joomla updater should now see your extension has a new version available.

updater3

If a user tries to update without a valid download id, they will see an error.

updater4

Assuming user has correct download id entered, and has a valid subscription, then they will be able to update the component.

updater5

 

Leave your comments

Post comment as a guest

0
Your comments are subject to administrator's moderation.
  • No comments found