?

User tests: Successful: Unsuccessful:

avatar shumisha
shumisha
15 Jan 2014

Similar to recent feature proposal for the 3.x branch (#2769), here is a proposal to allow the Joomla! updater to process paid-for extensions updates, that may require various types of credentials to be passed along the file download process.

This is implemented by simply firing an event, so the changes are minimal, about 4 lines added to one file. Extensions maybe implement event handler to append credentials to the download urls or add authorization request headers as they see fit.

A sample plugin for extensions using the Akeeba Release system is attached to the Joomlacode tracker item below,a s it can't be attached here.

Joomlacode feature tracker item: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33133&start=0

avatar shumisha shumisha - open - 15 Jan 2014
avatar shumisha
shumisha - comment - 15 Jan 2014

For information, here is the code for the Akeeba Release system sample plugin:

<?php
/**
 * Sample plugin to update a paid-for extension
 * released using Akeeba Release System
 *
 * @copyright   Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

/**
 * Handle commercial extension update authorization
 *
 * @package     MyPackage
 * @subpackage  MyPackage.update
 * @since       2.5
 */
class PlgInstallerSamplears extends JPlugin
{
    /**
     * @var    String  base update url, to decide whether to process the event or not
     * @since  2.5
     */
    private $baseUrl = 'http://update.mysite.com/subscribers/com_myextension';

    /**
     * @var    String  your extension identifier, to retrieve its params
     * @since  2.5
     */
    private $extension = 'com_my_extension';

    /**
     * Handle adding credentials to package download request
     *
     * @param   string  $url        url from which package is going to be downloaded
     * @param   array   $headers    headers to be sent along the download request (key => value format)
     *
     * @return  boolean true if credentials have been added to request or not our business, false otherwise (credentials not set by user)
     *
     * @since   2.5
     */
    public function onInstallerBeforePackageDownload(&$url, &$headers)
    {
        // are we trying to update our extension?
        if (strpos($url, $this->baseUrl) !== 0)
        {
            return true;
        }

        // fetch download id from extension parameters, or
        // wherever you want to store them
        // Get the component information from the #__extensions table
        JLoader::import('joomla.application.component.helper');
        $component = JComponentHelper::getComponent($this->extension);

        // assuming the download id provided by user is stored in component params
        // under the "update_credentials_download_id" key
        $downloadId = $component->params->get('update_credentials_download_id', '');

        // bind credentials to request by appending it to the download url
        if (!empty($downloadId))
        {
            $separator = strpos($url, '?') !== false ? '&' : '?';
            $url .= $separator . 'dlid=' . $downloadId;
        }
        return true;
    }
}
avatar mbabker mbabker - close - 22 Feb 2014
avatar mbabker mbabker - reference | - 22 Feb 14
avatar mbabker mbabker - merge - 22 Feb 2014
avatar mbabker mbabker - change - 22 Feb 2014
Title
Improved Joomla! extensions update handling of paid for extensions to Joomla 2.5.x 
Improved Joomla! extensions update handling of paid for extensions to Joomla 2.5.x
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-02-22 19:21:12
avatar mbabker mbabker - close - 22 Feb 2014

Add a Comment

Login with GitHub to post a comment