Changeset 4357

Show
Ignore:
Timestamp:
07/11/07 21:40:54 (6 years ago)
Author:
gregmac
Message:

Fix bugs in module version dependency checking

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.3/amp_conf/htdocs/admin/functions.inc.php

    r4353 r4357  
    473473  return array('engine'=>'ERROR-UNSUPPORTED-ENGINE-'.$amp_conf['AMPENGINE'], 'version'=>'0', 'additional' => '0'); 
    474474} 
     475 
     476 
     477/* verison_compare that works with freePBX version numbers 
     478 */ 
     479function version_compare_freepbx($version1, $version2, $op = null) { 
     480        $version1 = str_replace("rc","RC", strtolower($version1)); 
     481        $version2 = str_replace("rc","RC", strtolower($version2)); 
     482    if (!is_null($op)) { 
     483      return version_compare($version1, $version2, $op); 
     484    } else { 
     485      return version_compare($version1, $version2); 
     486    } 
     487} 
     488 
    475489 
    476490/* queries database using PEAR. 
     
    16301644            if (preg_match('/^(lt|le|gt|ge|==|=|eq|!=|ne)?\s*(\d*[beta|alpha|rc|RC]?\d+(\.[^\.]+)*)$/i', $value, $matches)) { 
    16311645              // matches[1] = operator, [2] = version 
    1632               $ver = getversion(); 
     1646              $installed_ver = getversion(); 
    16331647              $operator = (!empty($matches[1]) ? $matches[1] : 'ge'); // default to >= 
    1634               if (version_compare($matches[2], $ver, $operator) ) { 
    1635                 $errors[] = _module_comparison_error_message('FreePBX', $matches[2], $ver, $operator); 
     1648              $compare_ver = $matches[2]; 
     1649              if (version_compare_freepbx($installed_ver, $compare_ver, $operator) ) { 
     1650                // version is good 
     1651              } else { 
     1652                $errors[] = _module_comparison_error_message('FreePBX', $compare_ver, $installed_ver, $operator); 
    16361653              } 
    16371654            } 
     
    16471664                    if (!empty($matches[4])) { 
    16481665                      // also doing version checking 
     1666                      $installed_ver = $modules[$matches[1]]['dbversion']; 
     1667                      $compare_ver = $matches[4]; 
    16491668                      $operator = (!empty($matches[3]) ? $matches[3] : 'ge'); // default to >= 
    1650                       if (version_compare($matches[4], $modules[$matches[1]]['dbversion'], $operator) ) { 
    1651                         $errors[] = _module_comparison_error_message($matches[1].' module', $matches[4], $modules[$matches[1]]['dbversion'], $operator); 
     1669                       
     1670                      if (version_compare_freepbx($installed_ver, $compare_ver, $operator) ) { 
     1671                        // version is good 
     1672                      } else { 
     1673                        $errors[] = _module_comparison_error_message($matches[1].' module', $compare_ver, $installed_ver, $operator); 
    16521674                      } 
    16531675                    }