Ignore:
Timestamp:
Feb 13, 2009, 2:02:20 PM (16 years ago)
Author:
rvelices
Message:

merge r3136 from trunk

  • 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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/admin/include/functions_upgrade.php

    r3046 r3137  
    186186  }
    187187}
     188
     189/**
     190 * which upgrades are available ?
     191 *
     192 * @return array
     193 */
     194function get_available_upgrade_ids()
     195{
     196  $upgrades_path = PHPWG_ROOT_PATH.'install/db';
     197
     198  $available_upgrade_ids = array();
     199
     200  if ($contents = opendir($upgrades_path))
     201  {
     202    while (($node = readdir($contents)) !== false)
     203    {
     204      if (is_file($upgrades_path.'/'.$node)
     205          and preg_match('/^(.*?)-database\.php$/', $node, $match))
     206      {
     207        array_push($available_upgrade_ids, $match[1]);
     208      }
     209    }
     210  }
     211  natcasesort($available_upgrade_ids);
     212
     213  return $available_upgrade_ids;
     214}
     215
     216
     217/**
     218 * returns true if there are available upgrade files
     219 */
     220function check_upgrade_feed()
     221{
     222  // retrieve already applied upgrades
     223  $query = '
     224SELECT id
     225  FROM '.UPGRADE_TABLE.'
     226;';
     227  $applied = array_from_query($query, 'id');
     228
     229  // retrieve existing upgrades
     230  $existing = get_available_upgrade_ids();
     231
     232  // which upgrades need to be applied?
     233  return (count(array_diff($existing, $applied)) > 0);
     234}
     235
    188236?>
Note: See TracChangeset for help on using the changeset viewer.