Changeset 6574

Show
Ignore:
Timestamp:
09/04/08 18:26:41 (3 months ago)
Author:
p_lindheimer
Message:

no changes, just re-organized to move all functions to the bottom

Files:

Legend:

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

    r6525 r6574  
    1313} 
    1414 
    15  
    1615$extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:''; 
     16 
    1717// can't go online if external management is on 
    1818$online = (isset($_REQUEST['online']) && !EXTERNAL_PACKAGE_MANAGEMENT) ? $_REQUEST['online'] : false; 
     19 
    1920// fix php errors from undefined variable. Not sure if we can just change the reference below to use 
    2021// online since it changes values so just setting to what we decided it is here. 
    2122$_REQUEST['online'] = $online ? 1 : 0; 
     23 
    2224$moduleaction = isset($_REQUEST['moduleaction'])?$_REQUEST['moduleaction']:false; 
    2325/* 
     
    3638$freepbx_help_url = "http://www.freepbx.org/freepbx-help-system?freepbx_version=".urlencode($freepbx_version); 
    3739 
    38 function pageReload(){ 
    39 return ""; 
    40         //return "<script language=\"Javascript\">document.location='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&foo=".rand()."'</script>"; 
    41 } 
    42  
    43  
    4440if (!$quietmode) { 
    4541        ?> 
     
    5450                } 
    5551        } 
    56  
    5752        function check_upgrade_all() { 
    5853                var re = /^moduleaction\[([a-z0-9_\-]+)\]$/; 
     
    6863                } 
    6964        } 
    70  
    7165        function check_download_all() { 
    7266                var re = /^moduleaction\[([a-z0-9_\-]+)\]$/; 
     
    8276                } 
    8377        } 
    84  
    85  
    8678        function showhide_upgrades() { 
    8779                var upgradesonly = document.getElementById('show_upgradable_only').checked; 
    88                  
    8980                var module_re = /^module_([a-z0-9_]+)$/;   // regex to match a module element id 
    9081                var cat_re = /^category_([a-zA-Z0-9_]+)$/; // regex to match a category element id 
    91  
    9282                var elements = document.getElementById('modulelist').getElementsByTagName('li'); 
    93  
    9483                // loop through all modules, check if there is an upgrade_<module> radio box  
    9584                for(i=0; i<elements.length; i++) { 
     
    10190                        } 
    10291                } 
    103                  
    104                  
    105                  
    10692                // hide category headings that don't have any visible modules 
    107                  
    10893                var elements = document.getElementById('modulelist').getElementsByTagName('div'); 
    10994                // loop through category items 
     
    120105                                        } 
    121106                                } 
    122                                  
    123107                                document.getElementById(elements[i].id).style.display = display ? 'block' : 'none'; 
    124108                        } 
    125109                } 
    126                  
    127         } 
    128  
     110        } 
    129111        function process_module_actions(actions) { 
    130112                freepbx_modal_show('moduleBox'); 
     
    142124                } 
    143125        } 
    144  
    145126        </script> 
    146127        <?php 
     
    155136        <?php 
    156137} 
    157  
    158138 
    159139$modules_local = module_getinfo(false,false,true); 
     
    204184} 
    205185 
     186//-------------------------------------------------------------------------------------------------------- 
     187switch ($extdisplay) {  // process, confirm, or nothing 
     188        case 'process': 
     189                echo "<div id=\"moduleBoxContents\">"; 
     190                echo "<h4>"._("Please wait while module actions are performed")."</h4>\n"; 
     191                echo "<div id=\"moduleprogress\">"; 
     192 
     193                // stop output buffering, and send output 
     194                @ ob_end_flush(); 
     195                flush(); 
     196                foreach ($moduleaction as $modulename => $action) {      
     197                        $didsomething = true; // set to false in default clause of switch() below.. 
     198                         
     199                        switch ($action) { 
     200                                case 'upgrade': 
     201                                case 'downloadinstall': 
     202                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     203                                                echo sprintf(_('Downloading %s'), $modulename).' <span id="downloadprogress_'.$modulename.'"></span>'; 
     204                                                if (is_array($errors = module_download($modulename, false, 'download_progress'))) { 
     205                                                        echo '<span class="error">'.sprintf(_("Error(s) downloading %s"),$modulename).': '; 
     206                                                        echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; 
     207                                                        echo '</span>'; 
     208                                                } else { 
     209                                                        if (is_array($errors = module_install($modulename))) { 
     210                                                                echo '<span class="error">'.sprintf(_("Error(s) installing %s"),$modulename).': '; 
     211                                                                echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; 
     212                                                                echo '</span>'; 
     213                                                        } else { 
     214                                                                echo '<span class="success">'.sprintf(_("%s installed successfully"),$modulename).'</span>'; 
     215                                                        } 
     216                                                } 
     217                                        } 
     218                                break; 
     219                                case 'install': 
     220                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     221                                                if (is_array($errors = module_install($modulename))) { 
     222                                                        echo '<span class="error">'.sprintf(_("Error(s) installing %s"),$modulename).': '; 
     223                                                        echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; 
     224                                                        echo '</span>'; 
     225                                                } else { 
     226                                                        echo '<span class="success">'.sprintf(_("%s installed successfully"),$modulename).'</span>'; 
     227                                                } 
     228                                        } 
     229                                break; 
     230                                case 'enable': 
     231                                        if (is_array($errors = module_enable($modulename))) { 
     232                                                echo '<span class="error">'.sprintf(_("Error(s) enabling %s"),$modulename).': '; 
     233                                                echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; 
     234                                                echo '</span>'; 
     235                                        } else { 
     236                                                echo '<span class="success">'.sprintf(_("%s enabled successfully"),$modulename).'</span>'; 
     237                                        } 
     238                                break; 
     239                                case 'disable': 
     240                                        if (is_array($errors = module_disable($modulename))) { 
     241                                                echo '<span class="error">'.sprintf(_("Error(s) disabling %s"),$modulename).': '; 
     242                                                echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; 
     243                                                echo '</span>'; 
     244                                        } else { 
     245                                                echo '<span class="success">'.sprintf(_("%s disabled successfully"),$modulename).'</span>'; 
     246                                        } 
     247                                break; 
     248                                case 'uninstall': 
     249                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     250                                                if (is_array($errors = module_uninstall($modulename))) { 
     251                                                        echo '<span class="error">'.sprintf(_("Error(s) uninstalling %s"),$modulename).': '; 
     252                                                        echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; 
     253                                                        echo '</span>'; 
     254                                                } else { 
     255                                                        echo '<span class="success">'.sprintf(_("%s uninstalled successfully"),$modulename).'</span>'; 
     256                                                } 
     257                                        } 
     258                                break; 
     259                                default: 
     260                                        // just so we don't send an <hr> and flush() 
     261                                        $didsomething = false; 
     262                        } 
     263                         
     264                        if ($didsomething) { 
     265                                echo "<hr /><br />"; 
     266                                flush(); 
     267                        } 
     268                } 
     269                echo "</div>"; 
     270                if ($quietmode) { 
     271                        echo "\t<a href=\"#\" onclick=\"parent.close_module_actions(true);\" />"._("Return")."</a>"; 
     272                } else { 
     273                        echo "\t<input type=\"button\" value=\""._("Return")."\" onclick=\"location.href = 'config.php?display=modules&amp;type=tool&amp;online=".($_REQUEST['online']?1:0)."';\" />"; 
     274                echo "</div>"; 
     275                } 
     276        break; 
     277        case 'confirm': 
     278                ksort($moduleaction); 
     279                 
     280                echo "<form name=\"modulesGUI\" action=\"config.php\" method=\"post\">"; 
     281                echo "<input type=\"hidden\" name=\"display\" value=\"".$display."\" />"; 
     282                echo "<input type=\"hidden\" name=\"type\" value=\"".$type."\" />"; 
     283                echo "<input type=\"hidden\" name=\"online\" value=\"".$online."\" />"; 
     284                echo "<input type=\"hidden\" name=\"extdisplay\" value=\"process\" />"; 
     285                 
     286                echo "\t<script type=\"text/javascript\"> var moduleActions = new Array(); </script>\n"; 
     287                 
     288                $actionstext = array(); 
     289                $errorstext = array(); 
     290                foreach ($moduleaction as $module => $action) {  
     291                        $text = false; 
     292                        $skipaction = false; 
     293 
     294                        // make sure name is set. This is a problem for broken modules 
     295                        if (!isset($modules[$module]['name'])) { 
     296                                $modules[$module]['name'] = $module; 
     297                        } 
     298                         
     299                        switch ($action) { 
     300                                case 'upgrade': 
     301                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     302                                                if (is_array($errors = module_checkdepends($modules_online[$module]))) { 
     303                                                        $skipaction = true; 
     304                                                        $errorstext[] = sprintf(_("%s cannot be upgraded: %s Please try again after the dependencies have been installed."),   
     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 version %s"), $modules[$module]['name'], $modules[$module]['dbversion'], $modules_online[$module]['version']); 
     309                                                } 
     310                                        } 
     311                                break; 
     312                                case 'downloadinstall': 
     313                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     314                                                if (is_array($errors = module_checkdepends($modules_online[$module]))) { 
     315                                                        $skipaction = true; 
     316                                                        $errorstext[] = sprintf(_("%s cannot be installed: %s Please try again after the dependencies have been installed."),   
     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                                                } 
     322                                        } 
     323                                break; 
     324                                case 'install': 
     325                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     326                                                if (is_array($errors = module_checkdepends($modules[$module]))) { 
     327                                                        $skipaction = true; 
     328                                                        $errorstext[] = sprintf((($modules[$module]['status'] == MODULE_STATUS_NEEDUPGRADE) ?  _("%s cannot be upgraded: %s Please try again after the dependencies have been installed.") : _("%s cannot be installed: %s Please try again after the dependencies have been installed.") ),   
     329                                                                                $modules[$module]['name'], 
     330                                                                                '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); 
     331                                                } else { 
     332                                                        if ($modules[$module]['status'] == MODULE_STATUS_NEEDUPGRADE) { 
     333                                                                $actionstext[] =  sprintf(_("%s %s will be upgraded to %s"), $modules[$module]['name'], $modules[$module]['dbversion'], $modules[$module]['version']); 
     334                                                        } else { 
     335                                                                $actionstext[] =  sprintf(_("%s %s will be installed and enabled"), $modules[$module]['name'], $modules[$module]['version']); 
     336                                                        } 
     337                                                } 
     338                                        } 
     339                                break; 
     340                                case 'enable': 
     341                                        if (is_array($errors = module_checkdepends($modules[$module]))) { 
     342                                                $skipaction = true; 
     343                                                $errorstext[] = sprintf(_("%s cannot be enabled: %s Please try again after the dependencies have been installed."),   
     344                                                                        $modules[$module]['name'], 
     345                                                                        '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); 
     346                                        } else { 
     347                                                $actionstext[] =  sprintf(_("%s %s will be enabled"), $modules[$module]['name'], $modules[$module]['dbversion']); 
     348                                        } 
     349                                break; 
     350                                case 'disable': 
     351                                        if (is_array($errors = module_reversedepends($modules[$module]))) { 
     352                                                $skipaction = true; 
     353                                                $errorstext[] = sprintf(_("%s cannot be disabled because the following modules depend on it: %s Please disable those modules first then try again."),   
     354                                                                        $modules[$module]['name'], 
     355                                                                        '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); 
     356                                        } else { 
     357                                                $actionstext[] =  sprintf(_("%s %s will be disabled"), $modules[$module]['name'], $modules[$module]['dbversion']); 
     358                                        } 
     359                                break; 
     360                                case 'uninstall': 
     361                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     362                                                if (is_array($errors = module_reversedepends($modules[$module]))) { 
     363                                                        $skipaction = true; 
     364                                                        $errorstext[] = sprintf(_("%s cannot be uninstalled because the following modules depend on it: %s Please disable those modules first then try again."),   
     365                                                                                $modules[$module]['name'], 
     366                                                                                '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); 
     367                                                } else { 
     368                                                        $actionstext[] =  sprintf(_("%s %s will be uninstalled"), $modules[$module]['name'], $modules[$module]['dbversion']); 
     369                                                } 
     370                                        } 
     371                                break; 
     372                        } 
     373 
     374                        // If error above we skip this action so we can proceed with the others 
     375                        // 
     376                        if (!$skipaction) { //TODO 
     377                                echo "\t<script type=\"text/javascript\"> moduleActions['".$module."'] = '".$action."'; </script>\n"; 
     378                        } 
     379                } 
     380                 
     381                // Write out the erros, if there are additional actions that can be accomplished list those next with the choice to 
     382                // process which will ignore the ones with errors but process the rest. 
     383                // 
     384                if (count($errorstext) > 0) { 
     385                        echo "<h4>"._("Errors with selection:")."</h4>\n"; 
     386                        echo "<ul>\n"; 
     387                        foreach ($errorstext as $text) { 
     388                                echo "\t<li>".$text."</li>\n"; 
     389                        } 
     390                        echo "</ul>"; 
     391                }  
     392                if (count($actionstext) > 0) { 
     393                        if (count($errorstext) > 0) { 
     394                                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"; 
     395                        } else { 
     396                                echo "<h4>"._("Please confirm the following actions:")."</h4>\n"; 
     397                        } 
     398                        echo "<ul>\n"; 
     399                        foreach ($actionstext as $text) { 
     400                                echo "\t<li>".$text."</li>\n"; 
     401                        } 
     402                        echo "</ul>"; 
     403                        echo "\t<input type=\"button\" value=\"Confirm\" name=\"process\" onclick=\"process_module_actions(moduleActions);\" />"; 
     404                } else { 
     405                        echo "<h4>"._("No actions to perform")."</h4>\n"; 
     406                        echo "<p>"._("Please select at least one action to perform by clicking on the module, and selecting an action on the \"Action\" tab.")."</p>"; 
     407                } 
     408                echo "\t<input type=\"button\" value=\""._("Cancel")."\" onclick=\"location.href = 'config.php?display=modules&amp;type=tool&amp;online=".($_REQUEST['online']?1:0)."';\" />"; 
     409                echo "</form>"; 
     410                 
     411        break; 
     412        case 'upload': 
     413                // display links 
     414                echo "<a href='config.php?display=modules&amp;type=tool'>"._("Manage local modules")."</a>\n"; 
     415                if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     416                        echo " | <a class='info' href='config.php?display=modules&amp;type=tool&amp;online=1'>"._("Check for updates online")."<span>"._("Checking for updates will transmit your FreePBX and Asterisk version numbers along with a unique but random identifier. This is used to provide proper update information and track version usage to focus development and maintenance efforts. No private information is transmitted.")."</span></a>\n"; 
     417                } 
     418                                 
     419                if (isset($_FILES['uploadmod']) && !empty($_FILES['uploadmod']['name'])) { 
     420                        // display upload link, only if they did upload something 
     421                        echo " | <a href='config.php?display=modules&amp;type=tool&amp;extdisplay=upload'>"._("Upload module")."</a><br />\n"; 
     422                         
     423                        $res = module_handleupload($_FILES['uploadmod']); 
     424                        if (is_array($res)) { 
     425                                 
     426                                echo '<div class="error"><p>'; 
     427                                echo sprintf(_('The following error(s) occurred processing the uploaded file: %s'),  
     428                                     '<ul><li>'.implode('</li><li>',$res).'</li></ul>'); 
     429                                echo sprintf(_('You should fix the problem or select another file and %s.'),  
     430                                     "<a href='config.php?display=modules&amp;type=tool'>"._("try again")."</a>"); 
     431                                echo "</p></div>\n"; 
     432                        } else { 
     433                                 
     434                                echo "<p>".sprintf(_("Module uploaded successfully. You need to enable the module using %s to make it available."), 
     435                                     "<a href='config.php?display=modules&amp;type=tool'>"._("local module administration")."</a>") 
     436                                         ."</p>\n"; 
     437                        } 
     438                         
     439                } else { 
     440                        echo "<p>"._('You can upload a tar gzip file containing a FreePBX module from your local system. If a module with the same name already exists, it will be overwritten.')."</p>\n"; 
     441                 
     442                        echo "<form name=\"modulesGUI-upload\" action=\"config.php\" method=\"post\" enctype=\"multipart/form-data\">"; 
     443                        echo "<input type=\"hidden\" name=\"display\" value=\"".$display."\" />"; 
     444                        echo "<input type=\"hidden\" name=\"type\" value=\"".$type."\" />"; 
     445                        echo "<input type=\"hidden\" name=\"extdisplay\" value=\"upload\" />"; 
     446                        echo "<input type=\"file\" name=\"uploadmod\" /> "; 
     447                        echo "&nbsp;&nbsp; <input type=\"submit\" value=\"Upload\" />"; 
     448                        echo "</form>"; 
     449                } 
     450                 
     451        break; 
     452        case 'online': 
     453        default: 
     454                 
     455                uasort($modules, 'category_sort_callback'); 
     456                 
     457                if ($online) { 
     458                        // Check for annoucements such as security advisories, required updates, etc. 
     459                        // 
     460                        $announcements = module_get_annoucements(); 
     461                        if (isset($announcements) && !empty($announcements)) { 
     462                                echo "<div class='announcements'>$announcements</div>"; 
     463                        } 
     464                         
     465                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     466                                echo "<a href='config.php?display=modules&amp;type=tool&amp;online=0'>"._("Manage local modules")."</a>\n"; 
     467                                echo "<input type=\"checkbox\" id=\"show_upgradable_only\" onclick=\"showhide_upgrades();\" /><label for=\"show_upgradable_only\">"._("Show only upgradable")."</label>"; 
     468                        } 
     469                } else { 
     470                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     471                                echo "<a class='info' href='config.php?display=modules&amp;type=tool&amp;online=1'>"._("Check for updates online")."<span>"._("Checking for updates will transmit your FreePBX and Asterisk version numbers along with a unique but random identifier. This is used to provide proper update information and track version usage to focus development and maintenance efforts. No private information is transmitted.")."</span></a>\n"; 
     472                        } 
     473                        echo " | <a href='config.php?display=modules&amp;type=tool&amp;extdisplay=upload'>"._("Upload module")."</a><br />\n"; 
     474                } 
     475 
     476                echo "<form name=\"modulesGUI\" action=\"config.php\" method=\"post\">"; 
     477                echo "<input type=\"hidden\" name=\"display\" value=\"".$display."\" />"; 
     478                echo "<input type=\"hidden\" name=\"type\" value=\"".$type."\" />"; 
     479                echo "<input type=\"hidden\" name=\"online\" value=\"".$online."\" />"; 
     480                echo "<input type=\"hidden\" name=\"extdisplay\" value=\"confirm\" />"; 
     481                 
     482                echo "<div class=\"modulebuttons\">"; 
     483                if ($online) { 
     484                        echo "\t<a href=\"javascript:void(null);\" onclick=\"check_download_all();\">"._("Download all")."</a>"; 
     485                        echo "\t<a href=\"javascript:void(null);\" onclick=\"check_upgrade_all();\">"._("Upgrade all")."</a>"; 
     486                } 
     487                echo "\t<input type=\"reset\" value=\""._("Reset")."\" />"; 
     488                echo "\t<input type=\"submit\" value=\""._("Process")."\" name=\"process\" />"; 
     489                echo "</div>"; 
     490 
     491                echo "<div id=\"modulelist\">\n"; 
     492 
     493                echo "\t<div id=\"modulelist-header\">"; 
     494                echo "\t\t<span class=\"modulename\">"._("Module")."</span>\n"; 
     495                echo "\t\t<span class=\"moduletype\">"._("Type")."</span>\n"; 
     496                echo "\t\t<span class=\"moduleversion\">"._("Version")."</span>\n"; 
     497                echo "\t\t<span class=\"clear\">&nbsp;</span>\n"; 
     498                echo "\t</div>"; 
     499 
     500                $category = false; 
     501                $numdisplayed = 0; 
     502                $fd = $amp_conf['ASTETCDIR'].'/freepbx_module_admin.conf'; 
     503                if (file_exists($fd)) { 
     504                        $module_filter = parse_ini_file($fd); 
     505                } else { 
     506                        $module_filter = array(); 
     507                } 
     508                foreach (array_keys($modules) as $name) { 
     509                        if (isset($module_filter[$name]) && strtolower(trim($module_filter[$name])) == 'hidden') { 
     510                                continue; 
     511                        } 
     512                        $numdisplayed++; 
     513                         
     514                        if ($category !== $modules[$name]['category']) { 
     515                                // show category header 
     516                                 
     517                                if ($category !== false) { 
     518                                        // not the first one, so end the previous blocks 
     519                                        echo "\t</ul></div>\n"; 
     520                                } 
     521                                 
     522                                // start a new category header, and associated html blocks 
     523                                $category = $modules[$name]['category']; 
     524                                echo "\t<div class=\"category\" id=\"category_".prep_id($category)."\"><h3>"._($category)."</h3>\n"; 
     525                                echo "\t<ul>"; 
     526                        } 
     527                         
     528                        echo "\t\t<li id=\"module_".prep_id($name)."\">\n"; 
     529                         
     530                        // ---- module header  
     531                        echo "\t\t<div class=\"moduleheader\" onclick=\"toggleInfoPane('infopane_".prep_id($name)."');\" >\n"; 
     532                        echo "\t\t\t<span class=\"modulename\"><a href=\"javascript:void(null);\">".(!empty($modules[$name]['name']) ? $modules[$name]['name'] : $name)."</a></span>\n"; 
     533                        echo "\t\t\t<span class=\"moduletype\">".$modules[$name]['type']."</span>\n"; 
     534                        echo "\t\t\t<span class=\"moduleversion\">".(isset($modules[$name]['dbversion'])?$modules[$name]['dbversion']:'&nbsp;')."</span>\n"; 
     535                         
     536                        echo "\t\t\t<span class=\"modulestatus\">"; 
     537                        switch ($modules[$name]['status']) { 
     538                                case MODULE_STATUS_NOTINSTALLED: 
     539                                        if (isset($modules_local[$name])) { 
     540                                                echo '<span class="notinstalled">'._('Not Installed (Locally available)').'</span>'; 
     541                                        } else { 
     542                                                echo '<span class="notinstalled">'.sprintf(_('Not Installed (Available online: %s)'), $modules_online[$name]['version']).'</span>'; 
     543                                        } 
     544                                break; 
     545                                case MODULE_STATUS_DISABLED: 
     546                                        if (isset($modules_online[$name]['version'])) { 
     547                                                $vercomp = version_compare_freepbx($modules_local[$name]['version'], $modules_online[$name]['version']); 
     548                                                if ($vercomp < 0) { 
     549                                                        echo '<span class="alert">'.sprintf(_('Disabled; Online upgrade available (%s)'),$modules_online[$name]['version']).'</span>'; 
     550                                                } else if ($vercomp > 0) { 
     551                                                        echo sprintf(_('Disabled; Newer than online version (%s)'), $modules_online[$name]['version']); 
     552                                                } else { 
     553                                                        echo _('Disabled; up to date'); 
     554                                                } 
     555                                        } else { 
     556                                                echo 'Disabled'; 
     557                                        } 
     558                                break; 
     559                                case MODULE_STATUS_NEEDUPGRADE: 
     560                                        echo '<span class="alert">'.sprintf(_('Disabled; Pending upgrade to %s'),$modules_local[$name]['version']).'</span>'; 
     561                                break; 
     562                                case MODULE_STATUS_BROKEN: 
     563                                        echo '<span class="alert">'._('Broken').'</span>'; 
     564                                break; 
     565                                default: 
     566                                        // check for online upgrade 
     567                                        if (isset($modules_online[$name]['version'])) { 
     568                                                $vercomp = version_compare_freepbx($modules_local[$name]['version'], $modules_online[$name]['version']); 
     569                                                if ($vercomp < 0) { 
     570                                                        echo '<span class="alert">'.sprintf(_('Online upgrade available (%s)'), $modules_online[$name]['version']).'</span>'; 
     571                                                } else if ($vercomp > 0) { 
     572                                                        echo sprintf(_('Newer than online version (%s)'),$modules_online[$name]['version']); 
     573                                                } else { 
     574                                                        echo _('Enabled and up to date'); 
     575                                                } 
     576                                        } else if (isset($modules_online)) { 
     577                                                // we're connected to online, but didn't find this module 
     578                                                echo _('Enabled; Not available online'); 
     579                                        } else { 
     580                                                echo _('Enabled'); 
     581                                        } 
     582                                break; 
     583                        } 
     584                        echo "</span>\n"; 
     585                         
     586                         
     587                        echo "\t\t\t<span class=\"clear\">&nbsp;</span>\n"; 
     588                        echo "\t\t</div>\n"; 
     589                         
     590                        // ---- end of module header 
     591                         
     592                        // ---- drop-down tab box thingy: 
     593                         
     594                        echo "\t\t<div class=\"moduleinfopane\" id=\"infopane_".prep_id($name)."\" >\n"; 
     595                        echo "\t\t\t<div class=\"tabber\">\n"; 
     596                         
     597                        if (isset($modules_online[$name]['attention']) && !empty($modules_online[$name]['attention'])) { 
     598                                echo "\t\t\t\t<div class=\"tabbertab\" title=\""._("Attention")."\">\n"; 
     599                                echo nl2br($modules_online[$name]['attention']); 
     600                                echo "\t\t\t\t</div>\n"; 
     601                        } 
     602                         
     603                        echo "\t\t\t\t<div class=\"tabbertab actiontab\" title=\""._("Action")."\">\n"; 
     604                         
     605                        echo '<input type="radio" checked="CHECKED" id="noaction_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="0" /> '. 
     606                                 '<label for="noaction_'.prep_id($name).'">'._('No Action').'</label> <br />';   
     607                        switch ($modules[$name]['status']) { 
     608                         
     609                                case MODULE_STATUS_NOTINSTALLED: 
     610                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     611                                                if (isset($modules_local[$name])) { 
     612                                                        echo '<input type="radio" id="install_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="install" /> '. 
     613                                                                 '<label for="install_'.prep_id($name).'">'._('Install').'</label> <br />'; 
     614                                                } else { 
     615                                                        echo '<input type="radio" id="upgrade_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="downloadinstall" /> '. 
     616                                                                 '<label for="upgrade_'.prep_id($name).'">'._('Download and Install').'</label> <br />'; 
     617                                                } 
     618                                        } 
     619                                break; 
     620                                case MODULE_STATUS_DISABLED: 
     621                                        echo '<input type="radio" id="enable_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="enable" /> '. 
     622                                                 '<label for="enable_'.prep_id($name).'">'._('Enable').'</label> <br />'; 
     623                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     624                                                echo '<input type="radio" id="uninstall_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="uninstall" /> '. 
     625                                                         '<label for="uninstall_'.prep_id($name).'">'._('Uninstall').'</label> <br />'; 
     626                                                if (isset($modules_online[$name]['version'])) { 
     627                                                        $vercomp = version_compare_freepbx($modules_local[$name]['version'], $modules_online[$name]['version']); 
     628                                                        if ($vercomp < 0) { 
     629                                                                echo '<input type="radio" id="upgrade_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="upgrade" /> '. 
     630                                                                         '<label for="upgrade_'.prep_id($name).'">'.sprintf(_('Download and Upgrade to %s, and Enable'),$modules_online[$name]['version']).'</label> <br />'; 
     631                                                        } 
     632                                                } 
     633                                        } 
     634                                break; 
     635                                case MODULE_STATUS_NEEDUPGRADE: 
     636                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     637                                                echo '<input type="radio" id="install_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="install" /> '. 
     638                                                         '<label for="install_'.prep_id($name).'">'.sprintf(_('Upgrade to %s and Enable'),$modules_local[$name]['version']).'</label> <br />'; 
     639                                                echo '<input type="radio" id="uninstall_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="uninstall" /> '. 
     640                                                         '<label for="uninstall_'.prep_id($name).'">'._('Uninstall').'</label> <br />'; 
     641                                        } 
     642                                break; 
     643                                case MODULE_STATUS_BROKEN: 
     644                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) { 
     645                                                echo '<input type="radio" id="install_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="install" /> '. 
     646                                                         '<label for="install_'.prep_id($name).'">'._('Install').'</label> <br />'; 
     647                                                echo '<input type="radio" id="uninstall_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="uninstall" /> '. 
     648                                                         '<label for="uninstall_'.prep_id($name).'">'._('Uninstall').'</label> <br />'; 
     649                                        } 
     650                                break; 
     651                                default: 
     652                                        // check for online upgrade 
     653                                        if (isset($modules_online[$name]['version'])) { 
     654                                                $vercomp = version_compare_freepbx($modules_local[$name]['version'], $modules_online[$name]['version']); 
     655                                                if ($vercomp < 0) { 
     656                                                        if (!EXTERNAL_PACKAGE_MANAGEMENT) {