Update: Version 1.0.2
Update: Version 1.0.1
Update: Version 1.0.0
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
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.
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.
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?
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.)
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+
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.
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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.