-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added autoupdater package (no build yet)
- Loading branch information
Showing
4 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<?php | ||
/** | ||
* PHP Version 5.3 | ||
* | ||
* @package Shmanic.Scripts | ||
* @author Shaun Maunder <shaun@shmanic.com> | ||
* | ||
* @copyright Copyright (C) 2011-2013 Shaun Maunder. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('JPATH_PLATFORM') or die; | ||
|
||
/** | ||
* Installer script for pkg_autoupdater. | ||
* This package is only used to update all the packages through Joomla's | ||
* auto updater. | ||
* | ||
* @package Shmanic.Scripts | ||
* @since 2.0 | ||
*/ | ||
class Pkg_ShautoupdaterInstallerScript | ||
{ | ||
/** | ||
* Minimum PHP version to install this extension. | ||
* | ||
* @var string | ||
* @since 2.0 | ||
*/ | ||
const MIN_PHP_VERSION = '5.3.0'; | ||
|
||
/** | ||
* Method to run before an install/update/uninstall method. | ||
* | ||
* @param string $type Type of change (install, update or discover_install). | ||
* @param object $parent Object of class calling this method. | ||
* | ||
* @return boolean False to abort installation. | ||
* | ||
* @since 2.0 | ||
*/ | ||
public function preflight($type, $parent) | ||
{ | ||
// Check the PHP version is at least at 5.3.0 | ||
if (version_compare(PHP_VERSION, self::MIN_PHP_VERSION, '<')) | ||
{ | ||
JFactory::getApplication()->enqueueMessage( | ||
JText::sprintf('PKG_SHAUTOUPDATER_PREFLIGHT_PHP_VERSION', PHP_VERSION, self::MIN_PHP_VERSION), | ||
'error' | ||
); | ||
|
||
return false; | ||
} | ||
|
||
if ($type == 'install' || $type == 'update') | ||
{ | ||
$db = JFactory::getDbo(); | ||
$query = $db->getQuery(true); | ||
|
||
$query->select($db->quoteName('element')) | ||
->select($db->quoteName('name')) | ||
->select($db->quoteName('type')) | ||
->from($db->quoteName('#__extensions')); | ||
|
||
try | ||
{ | ||
$list = $db->setQuery($query)->loadAssocList('name'); | ||
|
||
/* | ||
* Check all files that were packaged in this auto updater with that | ||
* of currently installed Joomla extensions. If extension is installed | ||
* then add to the update list. | ||
*/ | ||
foreach ($parent->manifest->autoupdates->file as $file) | ||
{ | ||
$type = (string) $file->attributes()->type; | ||
$name = (string) $file->attributes()->id; | ||
|
||
if (isset($list[$name]) && $list[$name]['type'] == $type) | ||
{ | ||
// This extension is installed so add it to the update list | ||
$parent->manifest->files->addChild('file', (string) $file); | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
catch (Exception $e) | ||
{ | ||
JFactory::getApplication()->enqueueMessage( | ||
$e->getMessage(), | ||
'error' | ||
); | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Method to run after an install/update/uninstall method. | ||
* Removes this autoupdator package from the Joomla database. | ||
* | ||
* @param string $type Type of change (install, update or discover_install). | ||
* @param object $parent Object of class calling this method. | ||
* @param array $results Array of extension results. | ||
* | ||
* @return void | ||
* | ||
* @since 2.0 | ||
*/ | ||
public function postflight($type, $parent, $results = array()) | ||
{ | ||
if ($type == 'install' || $type == 'update') | ||
{ | ||
$db = JFactory::getDbo(); | ||
|
||
$db->setQuery( | ||
$db->getQuery(true) | ||
->delete('#__extensions') | ||
->where($db->quoteName('name') . ' = ' . $db->quote('shautoupdater')) | ||
) | ||
->execute(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<extension type="package" version="2.5" method="upgrade"> | ||
<name>pkg_shautoupdater</name> | ||
<packagename>shautoupdater</packagename> | ||
<version>2.0.1.9</version> | ||
<authorEmail>shaun@shmanic.com</authorEmail> | ||
<authorUrl>www.shmanic.com</authorUrl> | ||
<author>Shaun Maunder</author> | ||
<packagerurl>http://www.shmanic.com/tool/jmapmyldap/file.php?name=pkg_ldap_sso_core.zip</packagerurl> | ||
<buildDate>Fri Apr 11 22:28:03 2014</buildDate> | ||
<description>PKG_SHAUTOUPDATER_DESCRIPTION</description> | ||
<scriptfile>shautoupdater_install.php</scriptfile> | ||
<autoupdates> | ||
<!-- Order matters!!! --> | ||
<file type="package" id="shplatform">pkg_shplatform.zip</file> | ||
<file type="package" id="ldap_sso_core">pkg_ldap_sso_core.zip</file> | ||
<file type="package" id="ldap_plugins">pkg_ldap_plugins.zip</file> | ||
</autoupdates> | ||
<files /> | ||
<languages> | ||
<language tag="en-GB">language/en-GB/en-GB.pkg_shautoupdater.ini</language> | ||
<language tag="en-GB">language/en-GB/en-GB.pkg_shautoupdater.sys.ini</language> | ||
</languages> | ||
</extension> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
; Shmanic Auto Updater Package en-GB Translations | ||
; Copyright (C) 2011-2013 Shaun Maunder. All rights reserved. | ||
; License GNU General Public License version 2 or later; see LICENSE.txt | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PKG_SHAUTOUPDATER="Shmanic Auto Updater Package" | ||
PKG_SHAUTOUPDATER_DESCRIPTION="Auto Updater package to update all Shmanic extensions." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
; Shmanic Auto Updater Package en-GB Translations | ||
; Copyright (C) 2011-2013 Shaun Maunder. All rights reserved. | ||
; License GNU General Public License version 2 or later; see LICENSE.txt | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PKG_SHAUTOUPDATER="Shmanic Auto Updater Package" | ||
|
||
PKG_SHAUTOUPDATER_PREFLIGHT_PHP_VERSION="This server is running PHP %1$s, this extension requires at least PHP %2$s. Aborting installation." | ||
|
||
PKG_SHAUTOUPDATER_DESCRIPTION="Auto Updater package to update all Shmanic extensions." |