diff options
author | rvelices <rv-github@modusoptimus.com> | 2009-02-13 13:01:03 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2009-02-13 13:01:03 +0000 |
commit | 601134c57e736e4639d0c105c7948279d9563813 (patch) | |
tree | 7bfc44db1c9e336596c5b7324d9a491c8afa5c87 /admin/include/functions_upgrade.php | |
parent | d4914a344708d4020f7cee561e41503896da5260 (diff) |
- moved check upgrade feed code to admin/include/functions_upgrade.php
- refactored some code (shorter and somehow faster - but nothing revolutionary)
- decrease lost space in permalinks.tpl and hard coded column width (was illisible)
git-svn-id: http://piwigo.org/svn/trunk@3136 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/include/functions_upgrade.php | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/admin/include/functions_upgrade.php b/admin/include/functions_upgrade.php index d7c1a4e96..3181946eb 100644 --- a/admin/include/functions_upgrade.php +++ b/admin/include/functions_upgrade.php @@ -185,4 +185,52 @@ WHERE '.$conf['user_fields']['username'].'="'.$username.'" define('PHPWG_IN_UPGRADE', true); } } -?> + +/** + * which upgrades are available ? + * + * @return array + */ +function get_available_upgrade_ids() +{ + $upgrades_path = PHPWG_ROOT_PATH.'install/db'; + + $available_upgrade_ids = array(); + + if ($contents = opendir($upgrades_path)) + { + while (($node = readdir($contents)) !== false) + { + if (is_file($upgrades_path.'/'.$node) + and preg_match('/^(.*?)-database\.php$/', $node, $match)) + { + array_push($available_upgrade_ids, $match[1]); + } + } + } + natcasesort($available_upgrade_ids); + + return $available_upgrade_ids; +} + + +/** + * returns true if there are available upgrade files + */ +function check_upgrade_feed() +{ + // retrieve already applied upgrades + $query = ' +SELECT id + FROM '.UPGRADE_TABLE.' +;'; + $applied = array_from_query($query, 'id'); + + // retrieve existing upgrades + $existing = get_available_upgrade_ids(); + + // which upgrades need to be applied? + return (count(array_diff($existing, $applied)) > 0); +} + +?>
\ No newline at end of file |