diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-15 04:41:46 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-15 04:41:46 +0000 |
commit | 54a3c3e7e9e70c4770010e442e95f734200d03f9 (patch) | |
tree | f8e2e7e383523bbf28654ec171e57c841ed1910b /engine/lib/version.php | |
parent | ba331497c03a51ae4b46b387e5f6773620a98cff (diff) | |
download | elgg-54a3c3e7e9e70c4770010e442e95f734200d03f9.tar.gz elgg-54a3c3e7e9e70c4770010e442e95f734200d03f9.tar.bz2 |
Standardized gobs of files.
git-svn-id: http://code.elgg.org/elgg/trunk@3548 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/version.php')
-rw-r--r-- | engine/lib/version.php | 229 |
1 files changed, 109 insertions, 120 deletions
diff --git a/engine/lib/version.php b/engine/lib/version.php index 8251efe67..3728fb8ec 100644 --- a/engine/lib/version.php +++ b/engine/lib/version.php @@ -1,128 +1,117 @@ <?php +/** + * Elgg version library. + * Contains code for handling versioning and upgrades. + * + * @package Elgg + * @subpackage Core + * @link http://elgg.org/ + */ - /** - * Elgg version library. - * Contains code for handling versioning and upgrades. - * - * @package Elgg - * @subpackage Core - - - * @link http://elgg.org/ - */ - - /** - * Run any php upgrade scripts which are required - * - * @param unknown_type $version - */ - function upgrade_code($version) - { - global $CONFIG; - - // Elgg and its database must be installed to upgrade it! - if (!is_db_installed() || !is_installed()) return false; - - $version = (int) $version; - - if ($handle = opendir($CONFIG->path . 'engine/lib/upgrades/')) { - - $upgrades = array(); - - while ($updatefile = readdir($handle)) { - - // Look for upgrades and add to upgrades list - if (!is_dir($CONFIG->path . 'engine/lib/upgrades/' . $updatefile)) { - if (preg_match('/([0-9]*)\.php/',$updatefile,$matches)) { - $core_version = (int) $matches[1]; - if ($core_version > $version) { - $upgrades[] = $updatefile; - } - } - } - - } - - // Sort and execute - asort($upgrades); - if (sizeof($upgrades) > 0) { - foreach($upgrades as $upgrade) { - try { - include($CONFIG->path . 'engine/lib/upgrades/' . $upgrade); - } catch (Exception $e) { - error_log($e->getmessage()); - } - - } - } - - return true; - } - - return false; +/** + * Run any php upgrade scripts which are required + * + * @param unknown_type $version + */ +function upgrade_code($version) { + global $CONFIG; + + // Elgg and its database must be installed to upgrade it! + if (!is_db_installed() || !is_installed()) { + return false; } - /** - * Get the current version information - * - * @param true|false $humanreadable Whether to return a human readable version (default: false) - * @return string|false Depending on success - */ - function get_version($humanreadable = false) { - - global $CONFIG; - if (include($CONFIG->path . "version.php")) { - if (!$humanreadable) return $version; - return $release; + $version = (int) $version; + + if ($handle = opendir($CONFIG->path . 'engine/lib/upgrades/')) { + $upgrades = array(); + + while ($updatefile = readdir($handle)) { + // Look for upgrades and add to upgrades list + if (!is_dir($CONFIG->path . 'engine/lib/upgrades/' . $updatefile)) { + if (preg_match('/([0-9]*)\.php/',$updatefile,$matches)) { + $core_version = (int) $matches[1]; + if ($core_version > $version) { + $upgrades[] = $updatefile; + } + } } - - return false; - } - - /** - * Determines whether or not the database needs to be upgraded. - * - * @return true|false Depending on whether or not the db version matches the code version - */ - function version_upgrade_check() { - - $dbversion = (int) datalist_get('version'); - $version = get_version(); - - if ($version > $dbversion) { - return true; + + // Sort and execute + asort($upgrades); + if (sizeof($upgrades) > 0) { + foreach($upgrades as $upgrade) { + try { + include($CONFIG->path . 'engine/lib/upgrades/' . $upgrade); + } catch (Exception $e) { + error_log($e->getmessage()); + } } - return false; - - } - - /** - * Upgrades Elgg - * - */ - function version_upgrade() { - - $dbversion = (int) datalist_get('version'); - - // Upgrade database - db_upgrade($dbversion); - system_message(elgg_echo('upgrade:db')); - - // Upgrade core - if (upgrade_code($dbversion)) - system_message(elgg_echo('upgrade:core')); - - // Now we trigger an event to give the option for plugins to do something - $upgrade_details = stdClass; - $upgrade_details->from = $dbversion; - $upgrade_details->to = get_version(); - - trigger_elgg_event('upgrade', 'upgrade', $upgrade_details); - - // Update the version - datalist_set('version', get_version()); - } - -?>
\ No newline at end of file + + return true; + } + + return false; +} + +/** + * Get the current version information + * + * @param true|false $humanreadable Whether to return a human readable version (default: false) + * @return string|false Depending on success + */ +function get_version($humanreadable = false) { + global $CONFIG; + + if (include($CONFIG->path . "version.php")) { + if (!$humanreadable) return $version; + return $release; + } + + return false; +} + +/** + * Determines whether or not the database needs to be upgraded. + * + * @return true|false Depending on whether or not the db version matches the code version + */ +function version_upgrade_check() { + $dbversion = (int) datalist_get('version'); + $version = get_version(); + + if ($version > $dbversion) { + return true; + } + + return false; +} + +/** + * Upgrades Elgg + * + */ +function version_upgrade() { + $dbversion = (int) datalist_get('version'); + + // Upgrade database + db_upgrade($dbversion); + system_message(elgg_echo('upgrade:db')); + + // Upgrade core + if (upgrade_code($dbversion)) { + system_message(elgg_echo('upgrade:core')); + } + + // Now we trigger an event to give the option for plugins to do something + $upgrade_details = stdClass; + $upgrade_details->from = $dbversion; + $upgrade_details->to = get_version(); + + trigger_elgg_event('upgrade', 'upgrade', $upgrade_details); + + // Update the version + datalist_set('version', get_version()); +} |