예제 #1
0
 /**
  * Describe the SQL scripts that will be used to upgrade KnowledgeTree
  *
  * Return an array of arrays with two components: a string identifier
  * that uniquely describes the step to be taken and a string which is an
  * HTML-formatted description of the step to be taken.  These will be
  * returned in any order - describeUpgrade performs the ordering.
  *
  * @param string Original version (e.g., "1.2.4")
  * @param string Current version (e.g., "2.0.2")
  *
  * @return array Array of SQLUpgradeItem describing steps to be taken
  *
  * STATIC
  */
 public static function getUpgrades($origVersion, $currVersion)
 {
     $dbType = 'mysql';
     $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/';
     $ret = array();
     if (!is_dir($sqlupgradedir)) {
         return false;
     }
     if (!($dh = opendir($sqlupgradedir))) {
         return false;
     }
     while (($file = readdir($dh)) !== false) {
         // Each entry can be a file or a directory
         //
         // A file is legacy before the upgrade system was created, but
         // will be supported anyway.
         //
         // A directory is the end-result version: so, 2.0.5 contains
         // every script that differentiates it from a previous version,
         // say, 2.0.5rc1 or 2.0.4.
         //
         if (in_array($file, array('.', '..', 'CVS'))) {
             continue;
         }
         $fullpath = $sqlupgradedir . $file;
         if (is_file($fullpath)) {
             // Legacy file support, will be in form of
             // 1.2.4-to-2.0.0.sql.
             $details = SQLUpgradeItem::_getDetailsFromFileName($file);
             if ($details) {
                 if (!gte_version($details[0], $origVersion)) {
                     continue;
                 }
                 if (!lte_version($details[1], $currVersion)) {
                     continue;
                 }
                 $ret[] = new SQLUpgradeItem($file);
             }
         }
         if (is_dir($fullpath)) {
             $subdir = $file;
             if (!($subdh = opendir($fullpath))) {
                 continue;
             }
             while (($file = readdir($subdh)) !== false) {
                 $relpath = $subdir . '/' . $file;
                 $details = SQLUpgradeItem::_getDetailsFromFileName($relpath);
                 if ($details) {
                     if (!gte_version($details[0], $origVersion)) {
                         continue;
                     }
                     if (!lte_version($details[1], $currVersion)) {
                         continue;
                     }
                     $ret[] = new SQLUpgradeItem($relpath);
                 }
             }
         }
     }
     closedir($dh);
     return $ret;
 }
예제 #2
0
 function getUpgrades($origVersion, $currVersion)
 {
     $aUpgradeFunctions = new UpgradeFunctions();
     $ret = array();
     foreach ($aUpgradeFunctions->upgrades as $version => $funcs) {
         if (!gte_version($version, $origVersion)) {
             continue;
         }
         if (!lte_version($version, $currVersion)) {
             continue;
         }
         foreach ($funcs as $func) {
             $iPhase = KTUtil::arrayGet($aUpgradeFunctions->phases, $func, 0);
             $iPriority = KTUtil::arrayGet($aUpgradeFunctions->priority, $func, 0);
             $ret[] = new FunctionUpgradeItem($func, $version, $aUpgradeFunctions->descriptions[$func], $iPhase, $iPriority);
         }
     }
     return $ret;
 }