We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

LG Addon Updater - NOW AVAILABLE!!!!

Development and Programming

Leevi Graham's avatar
Leevi Graham
1,143 posts
about 17 years ago
Leevi Graham's avatar Leevi Graham

Update: Version 1.0.2

  • PHP4 fixes Is this an upgrade or a downgrade? 😉

Update: Version 1.0.1

  • Added CP homepage check to reduce object initialisation and hook method calling; basically a speed improvement.

Update: Version 1.0.0

  • Initial Release Grab it from my site

Hey guys,

I have been getting some bug reports about the way each of the extensions checks to see if there is an update available. I had a look at the way I was doing it and figureed it could do with some improvement.

The result: LG Addon Updater.

Bascially this is how it works:

LG Addon Updater is a simple extension that provides two extension hooks to EE developers. The first hook allows you to register a source (a basic xml file) than contains version information about your extensions. The second hook allows you to add the extension to a list of extensions that will be checked against the available sources.

Example:

/**
    * Register a new Addon Source
    *
    * @param    array $sources The existing sources
    * @return   array The new source list
    * @since version 1.0.0
    */
    function lg_addon_update_register_source($sources)
    {
        global $EXT;
        // -- Check if we're not the only one using this hook
        if($EXT->last_call !== FALSE)
            $sources = $EXT->last_call;

        // add a new source
        // must be in the following format:
        /*
        <versions>
            <addon id='LG Addon Updater' version='2.0.0' last_updated="1218852797" docs_url="http://leevigraham.com/" >
        </versions>
        */
        $sources[] = 'http://leevigraham.com/version-check/versions.xml';

        return $sources;
    }


    /**
    * Register a new Addon
    *
    * @param    array $addons The existing sources
    * @return   array The new addon list
    * @since version 1.0.0
    */
    function lg_addon_update_register_addon($addons)
    {
        global $EXT;
        // -- Check if we're not the only one using this hook
        if($EXT->last_call !== FALSE)
            $addons = $EXT->last_call;

        // add a new addon
        // the key must match the id attribute in the source xml
        // the value must be the addons current version
        $addons[LG_AU_addon_id] = $this->version;
        return $addons;
    }

Now on the CP homepage LG Addon Updater checks the addons vs the sources and informs the site admin if any updates are available.

If the user does not have LG Addon Updater installed nothing happens because the hooks are not called. Also the extension can use either CURL or fsockopen() depending on the users setup.

The only issue I have so far is that the extension is using the sessions_end hook whch requires the $SESS object be passed by reference. So PHP5 only for now. If anyone has any ideas on how to tweka that I would greatly appreciate it.

Thoughts?

Grab the extension from my site: LG Addon Updater

       
Ryan M.'s avatar
Ryan M.
1,511 posts
about 17 years ago
Ryan M.'s avatar Ryan M.

You’re ridiculous. In a good way.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
about 17 years ago
Leevi Graham's avatar Leevi Graham

Does that mean your going to incorporate it in to your extensions 😉

       
Ryan M.'s avatar
Ryan M.
1,511 posts
about 17 years ago
Ryan M.'s avatar Ryan M.

Yes, I think this method would reduce a lot of bloat in the current versions of the Extensions. My main questions have to do with the idea of a cache and how often this calls the sources.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
about 17 years ago
Leevi Graham's avatar Leevi Graham

Ah yeah should have mentioned that… Its up to the user to set the cache timeout in the extension settings.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
about 17 years ago
Ryan M.'s avatar Ryan M.

So would I continue to keep update and cache information inside the Extensions themselves, or remove all that and just recommend that the user install the Addon Updater extension and register my extensions in it to receive update notifications?

       
Brandon Kelly's avatar
Brandon Kelly
257 posts
about 17 years ago
Brandon Kelly's avatar Brandon Kelly

Brilliant work, LG. I’m going to incorporate this in the next Playa update.

Just one nit pick: it would be nice if last_updated could be written in EE’s “human readable format”. (I’m not a fan of the Unix timestamp.) And if you ever decide to add any logic based on the attribute, it’s just a $LOC->convert_human_date_to_gmt() away.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
about 17 years ago
Leevi Graham's avatar Leevi Graham
So would I continue to keep update and cache information inside the Extensions themselves, or remove all that and just recommend that the user install the Addon Updater extension and register my extensions in it to receive update notifications?

LG Addon Updater handles all of that for you. You don’t need to cache anything in your extension which means the user only has one setting to change.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
about 17 years ago
Leevi Graham's avatar Leevi Graham
Brilliant work, LG. I’m going to incorporate this in the next Playa update. Just one nit pick: it would be nice if last_updated could be written in EE’s “human readable format”. (I’m not a fan of the Unix timestamp.) And if you ever decide to add any logic based on the attribute, it’s just a $LOC->convert_human_date_to_gmt() away.

Hmm… yeah that sounds like it would be ok. How about I just add a bit of conditional action that checks if the value is an integer?

The reason I went with the timestamp is that you could use a weblog to manage your xml source and just output the last modified date. I also throught there would be less room for error when reading thrid party sources.

On a side not how important do you guys think security is… I know thats a stupid question but at the moment it is possible that someone could register a source file that overwrites an existing one and change the links. How do you think I should handle this?

       
Brandon Kelly's avatar
Brandon Kelly
257 posts
about 17 years ago
Brandon Kelly's avatar Brandon Kelly
Hmm… yeah that sounds like it would be ok. How about I just add a bit of conditional action that checks if the value is an integer?

Perfect.

On a side not how important do you guys think security is… I know thats a stupid question but at the moment it is possible that someone could register a source file that overwrites an existing one and change the links. How do you think I should handle this?

If someone was going to write a malicious EE extension, they could/would do a hell of a lot worse than mess around with this. (Like, you know, drop the DB.)

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
about 17 years ago
Leevi Graham's avatar Leevi Graham

Very good point. However I think there should be some kinda warning when the user clicks the documentation link that takes them to a intermediate page that says they are about to leave the admin.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
about 17 years ago
Leevi Graham's avatar Leevi Graham

From This thread: http://ellislab.com/forums/viewthread/73620/#445507

Wondering if in any of these extensions that use jQuery, there shouldn’t be a further option to use the Google AJAX Libraries API? I’m increasingly interested in the thought of that. I suppose the user could just enter the full script path to the google version in the supplied field? (I just did that with this extension, putting “http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js” in the field for the jQuery script).

How would you feel if I renamed this extension LG Utilities and added an option to include jQuery + jQuery UI on every admin page? I think its something that all EE developers could use now in EE 1.6+

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
about 17 years ago
Leevi Graham's avatar Leevi Graham

Getting close to a stable release now!

I have rebuilt nearly alll of my extensions to make use of this extension.

While I was there I also incorporated the duplicate script checking idea from this thread which greatly speeds up the CP.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
about 17 years ago
Leevi Graham's avatar Leevi Graham

Hey guys,

Just letting you all know that this extension is now available with full documentation over on my site.

Check out LG Addon Updater .. Notify users of ExpressionEngine extension, module and plugin updates.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
about 17 years ago
Ryan M.'s avatar Ryan M.

Thanks, Leevi. I will probably modify all of my work to make use of this extension. (In addition to adding some significant upgrades to one or two of them, thanks to some “suggestions” from you 😊 )

       
1 2 3 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.