Changeset 8846 for freepbx

Show
Ignore:
Timestamp:
02/17/10 15:15:05 (3 years ago)
Author:
p_lindheimer
Message:

closes #4052 add option to force reinstall or downgrade modules

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.7/amp_conf/htdocs/admin/page.modules.php

    r8766 r8846  
    206206       
    207207      switch ($action) { 
     208        case 'force_upgrade': 
    208209        case 'upgrade': 
    209210        case 'downloadinstall': 
     
    305306     
    306307    $actionstext = array(); 
     308    $force_actionstext = array(); 
    307309    $errorstext = array(); 
    308310    foreach ($moduleaction as $module => $action) {  
     
    317319      switch ($action) { 
    318320        case 'upgrade': 
     321        case 'force_upgrade': 
    319322          if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
    320323            if (is_array($errors = module_checkdepends($modules_online[$module]))) { 
     
    324327                                      '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); 
    325328            } else { 
    326               $actionstext[] = sprintf(_("%s %s will be upgraded to online version %s"), $modules[$module]['name'], $modules[$module]['dbversion'], $modules_online[$module]['version']); 
     329              switch ( version_compare_freepbx($modules[$module]['dbversion'], $modules_online[$module]['version'])) { 
     330              case '-1': 
     331                $actionstext[] = sprintf(_("%s %s will be upgraded to online version %s"), $modules[$module]['name'], $modules[$module]['dbversion'], $modules_online[$module]['version']); 
     332                break; 
     333              case '0': 
     334                $force_actionstext[] = sprintf(_("%s %s will be re-installed to online version %s"), $modules[$module]['name'], $modules[$module]['dbversion'], $modules_online[$module]['version']); 
     335                break; 
     336              default: 
     337                $force_actionstext[] = sprintf(_("%s %s will be downgraded to online version %s"), $modules[$module]['name'], $modules[$module]['dbversion'], $modules_online[$module]['version']); 
     338              } 
    327339            } 
    328340          } 
     
    408420      echo "</ul>"; 
    409421    }  
    410    if (count($actionstext) > 0) { 
     422    if (count($actionstext) > 0 || count($force_actionstext) > 0) { 
    411423      if (count($errorstext) > 0) { 
    412424        echo "<h4>"._("You may confirm the remaining selection and then try the again for the listed issues once the required dependencies have been met:")."</h4>\n"; 
     
    414426        echo "<h4>"._("Please confirm the following actions:")."</h4>\n"; 
    415427      } 
    416       echo "<ul>\n"; 
    417       foreach ($actionstext as $text) { 
    418         echo "\t<li>".$text."</li>\n"; 
    419       } 
    420       echo "</ul>"; 
     428      if (count($actionstext)) { 
     429        echo "<h5>"._("Upgrades, installs, enables and disables:")."</h5>\n"; 
     430        echo "<ul>\n"; 
     431        foreach ($actionstext as $text) { 
     432          echo "\t<li>".$text."</li>\n"; 
     433        } 
     434        echo "</ul>"; 
     435      } 
     436      if (count($force_actionstext)) { 
     437        echo "<h5>"._("Forced downgrades and re-installs:")."</h5>\n"; 
     438        echo "<ul>\n"; 
     439        foreach ($force_actionstext as $text) { 
     440          echo "\t<li>".$text."</li>\n"; 
     441        } 
     442        echo "</ul>"; 
     443      } 
    421444      echo "\t<input type=\"button\" value=\""._("Confirm")."\" name=\"process\" onclick=\"process_module_actions(moduleActions);\" />"; 
    422445    } else { 
     
    698721          if (isset($modules_online[$name]['version'])) { 
    699722            $vercomp = version_compare_freepbx($modules_local[$name]['version'], $modules_online[$name]['version']); 
    700             if ($vercomp < 0) { 
    701             if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     723            if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     724              if ($vercomp < 0) { 
    702725                echo '<input type="radio" id="upgrade_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="upgrade" /> '. 
    703726                   '<label for="upgrade_'.prep_id($name).'">'.sprintf(_('Download and Upgrade to %s'), $modules_online[$name]['version']).'</label> <br />'; 
    704               } 
     727              } else { 
     728                $force_msg = ($vercomp == 0 ? sprintf(_('Force Download and Install %s'), $modules_online[$name]['version']) : sprintf(_('Force Download and Downgrade to %s'), $modules_online[$name]['version'])); 
     729                echo '<input type="radio" id="force_upgrade_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="force_upgrade" /> '. 
     730                   '<label for="force_upgrade_'.prep_id($name).'">'.$force_msg.'</label> <br />'; 
     731              } 
    705732            } 
    706733          }