Changeset 3242

Show
Ignore:
Timestamp:
11/28/06 18:14:17 (5 years ago)
Author:
gregmac
Message:

Modules confirm page now checks for dependencies before actually running actions

Files:

Legend:

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

    r3239 r3242  
    295295     
    296296    $actionstext = array(); 
     297    $errorstext = array(); 
    297298    foreach ($moduleaction as $module => $action) {  
    298299      $text = false; 
     
    300301        case 'upgrade': 
    301302          if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
    302             $actionstext[] = sprintf(_("%s %s will be upgraded to online verison %s"), $modules[$module]['name'], $modules[$module]['dbversion'], $modules_online[$module]['version']); 
     303            if (is_array($errors = module_checkdepends($modules_online[$module]))) { 
     304              $errorstext[] = sprintf(_("%s cannot be upgraded: %s Please correct this error first."),   
     305                                      $modules[$module]['name'], 
     306                                      '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); 
     307            } else { 
     308              $actionstext[] = sprintf(_("%s %s will be upgraded to online verison %s"), $modules[$module]['name'], $modules[$module]['dbversion'], $modules_online[$module]['version']); 
     309               
     310            } 
    303311          } 
    304312        break; 
    305313        case 'downloadinstall': 
    306314          if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
    307             $actionstext[] =  sprintf(_("%s %s will be downloaded and installed"), $modules[$module]['name'], $modules[$module]['version']); 
     315            if (is_array($errors = module_checkdepends($modules_online[$module]))) { 
     316              $errorstext[] = sprintf(_("%s cannot be installed: %s Please correct this error first."),   
     317                                      $modules[$module]['name'], 
     318                                      '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); 
     319            } else { 
     320              $actionstext[] =  sprintf(_("%s %s will be downloaded and installed"), $modules[$module]['name'], $modules_online[$module]['version']); 
     321            } 
    308322          } 
    309323        break; 
    310324        case 'install': 
    311325          if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
    312             if ($modules[$module]['status'] == MODULE_STATUS_NEEDUPGRADE) { 
    313               $actionstext[] =  sprintf(_("%s %s will be upgraded to %s"), $modules[$module]['name'], $modules[$module]['dbversion'], $modules[$module]['version']); 
    314             } else { 
    315               $actionstext[] =  sprintf(_("%s %s will be installed and enabled"), $modules[$module]['name'], $modules[$module]['version']); 
     326            if (is_array($errors = module_checkdepends($modules[$module]))) { 
     327              $errorstext[] = sprintf((($modules[$module]['status'] == MODULE_STATUS_NEEDUPGRADE) ?  _("%s cannot be upgraded: %s Please correct this error first.") : _("%s cannot be installed: %s Please correct this error first.") ),   
     328                                      $modules[$module]['name'], 
     329                                      '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); 
     330            } else { 
     331              if ($modules[$module]['status'] == MODULE_STATUS_NEEDUPGRADE) { 
     332                $actionstext[] =  sprintf(_("%s %s will be upgraded to %s"), $modules[$module]['name'], $modules[$module]['dbversion'], $modules[$module]['version']); 
     333              } else { 
     334                $actionstext[] =  sprintf(_("%s %s will be installed and enabled"), $modules[$module]['name'], $modules[$module]['version']); 
     335              } 
    316336            } 
    317337          } 
    318338        break; 
    319339        case 'enable': 
    320           $actionstext[] =  sprintf(_("%s %s will be enabled"), $modules[$module]['name'], $modules[$module]['dbversion']); 
     340          if (is_array($errors = module_checkdepends($modules[$module]))) { 
     341            $errorstext[] = sprintf(_("%s cannot be enabled: %s Please correct this error first."),   
     342                                    $modules[$module]['name'], 
     343                                    '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); 
     344          } else { 
     345            $actionstext[] =  sprintf(_("%s %s will be enabled"), $modules[$module]['name'], $modules[$module]['dbversion']); 
     346          } 
    321347        break; 
    322348        case 'disable': 
    323           $actionstext[] =  sprintf(_("%s %s will be disabled"), $modules[$module]['name'], $modules[$module]['dbversion']); 
     349          if (is_array($errors = module_reversedepends($modules[$module]))) { 
     350            $errorstext[] = sprintf(_("%s cannot be disabled because the following modules depend on it: %s Please correct this error first."),   
     351                                    $modules[$module]['name'], 
     352                                    '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); 
     353          } else { 
     354            $actionstext[] =  sprintf(_("%s %s will be disabled"), $modules[$module]['name'], $modules[$module]['dbversion']); 
     355          } 
    324356        break; 
    325357        case 'uninstall': 
    326358          if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
    327             $actionstext[] =  sprintf(_("%s %s will be uninstalled"), $modules[$module]['name'], $modules[$module]['dbversion']); 
     359            if (is_array($errors = module_reversedepends($modules[$module]))) { 
     360              $errorstext[] = sprintf(_("%s cannot be uninstalled because the following modules depend on it: %s Please correct this error first."),   
     361                                      $modules[$module]['name'], 
     362                                      '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); 
     363            } else { 
     364              $actionstext[] =  sprintf(_("%s %s will be uninstalled"), $modules[$module]['name'], $modules[$module]['dbversion']); 
     365            } 
    328366          } 
    329367        break; 
     
    332370    } 
    333371     
    334     if (count($actionstext) > 0) { 
     372    if (count($errorstext) > 0) { 
     373      echo "<h4>"._("Errors with selection:")."</h4>\n"; 
     374      echo "<ul>\n"; 
     375      foreach ($errorstext as $text) { 
     376        echo "\t<li>".$text."</li>\n"; 
     377      } 
     378      echo "</ul>"; 
     379 
     380    } else if (count($actionstext) > 0) { 
    335381      echo "<h4>"._("Please confirm the following actions:")."</h4>\n"; 
    336382      echo "<ul>\n";