Changeset 10950
- Timestamp:
- 01/11/11 17:55:56 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/trunk/amp_conf/htdocs/admin/libraries/module.functions.php
r10865 r10950 135 135 if (count($xmlarray)) { 136 136 foreach ($xmlarray['xml']['module'] as $mod) { 137 $new_modules[$mod['rawname']] = $mod;137 $new_modules[$mod['rawname']] = $mod; 138 138 } 139 139 } … … 148 148 // This will always be the case the first time it is run since the xml is empty. 149 149 // 150 // TODO: if old_modules is empty, should I populate it from getinfo to at find out what151 // is installed or otherwise, just skip it since it is the first time?152 //153 150 $diff_modules = array_diff_assoc($new_modules, $old_modules); 154 151 $cnt = count($diff_modules); 155 152 if ($cnt) { 153 $active_repos = module_get_active_repos(); 156 154 $extext = _("The following new modules are available for download. Click delete icon on the right to remove this notice.")."<br />"; 157 155 foreach ($diff_modules as $mod) { 158 $extext .= $mod['rawname']." (".$mod['version'].")<br />"; 159 } 160 $notifications->add_notice('freepbx', 'NEWMODS', sprintf(_('%s New modules are available'),$cnt), $extext, '', $reset_value, true); 156 // If it's a new module in a repo we are not interested in, then don't send a notification. 157 if (isset($active_repos[$mod['repo']]) && $active_repos[$mod['repo']]) { 158 $extext .= $mod['rawname']." (".$mod['version'].")<br />"; 159 } else { 160 $cnt--; 161 } 162 } 163 if ($cnt) { 164 $notifications->add_notice('freepbx', 'NEWMODS', sprintf(_('%s New modules are available'),$cnt), $extext, '', $reset_value, true); 165 } 161 166 } 162 167 … … 204 209 $notifications->delete('freepbx', 'NEWUPDATES'); 205 210 } 211 } 212 213 function module_get_active_repos() { 214 global $active_repos; 215 if (!isset($active_repos) || !$active_repos) { 216 $repos_serialized = sql("SELECT `data` FROM `module_xml` WHERE `id` = 'repos_serialized'","getOne"); 217 if (isset($repos_serialized) && $repos_serialized) { 218 $active_repos = unserialize($repos_serialized); 219 } else { 220 $active_repos = array('standard' => 1); 221 module_set_active_repos($active_repos); 222 } 223 return $active_repos; 224 } else { 225 return $active_repos; 226 } 227 } 228 229 function module_set_active_repos($repos) { 230 global $active_repos; 231 global $db; 232 $active_repos = $repos; 233 $repos_serialized = $db->escapeSimple(serialize($repos)); 234 sql("REPLACE INTO `module_xml` (`id`, `time`, `data`) VALUES ('repos_serialized', '".time()."','".$repos_serialized."')"); 206 235 } 207 236 … … 257 286 // if status is anything else, it will be updated below when we read the db 258 287 $modules[$file]['status'] = MODULE_STATUS_NOTINSTALLED; 288 // I think this is the source of reading every module from a file. The assumption is all modules 289 // from the online repo will always have a repo defined but local ones may not so we need to define 290 // them here. 291 292 //TODO: should we have a master list of supported repos and validate against that, or do it dynamically 293 // we do with other stuff 294 if (!isset($modules[$file]['repo']) || !$modules[$file]['repo']) { 295 $modules[$file]['repo'] = 'local'; 296 } 259 297 } 260 298 } … … 293 331 // no directory for this db entry 294 332 $modules[ $row['modulename'] ]['status'] = MODULE_STATUS_BROKEN; 333 $modules[ $row['modulename'] ]['repo'] = 'broken'; 295 334 } 296 335 $modules[ $row['modulename'] ]['dbversion'] = $row['version']; freepbx/trunk/amp_conf/htdocs/admin/libraries/modulelist.class.php
r10244 r10950 32 32 function initialize(&$module_list) { 33 33 $this->module_array = $module_list; 34 // strip out extraneous fields (help especially when printing out debugs 35 // 36 foreach ($this->module_array as $mod_key => $mod) { 37 if (isset($mod['changelog'])) { 38 unset($this->module_array[$mod_key]['changelog']); 39 } 40 if (isset($mod['description'])) { 41 unset($this->module_array[$mod_key]['description']); 42 } 43 if (isset($mod['attention'])) { 44 unset($this->module_array[$mod_key]['attention']); 45 } 46 if (isset($mod['publisher'])) { 47 unset($this->module_array[$mod_key]['publisher']); 48 } 49 if (isset($mod['license'])) { 50 unset($this->module_array[$mod_key]['license']); 51 } 52 if (isset($mod['candisable'])) { 53 unset($this->module_array[$mod_key]['candisable']); 54 } 55 if (isset($mod['canuninstall'])) { 56 unset($this->module_array[$mod_key]['canuninstall']); 57 } 58 if (isset($mod['location'])) { 59 unset($this->module_array[$mod_key]['location']); 60 } 61 if (isset($mod['md5sum'])) { 62 unset($this->module_array[$mod_key]['md5sum']); 63 } 64 } 34 65 $module_serialized = $this->_db->escapeSimple(serialize($this->module_array)); 35 66 sql("DELETE FROM `module_xml` WHERE `id` = 'mod_serialized'"); freepbx/trunk/amp_conf/htdocs/admin/page.modules.php
r10944 r10950 16 16 $module_repo = isset($_REQUEST['module_repo'])?htmlentities($_REQUEST['module_repo']):'supported'; 17 17 $repo = "http://mirror.freepbx.org/"; 18 if ($module_repo == "extended") { 19 $repo .= "extended-"; 20 } 21 22 // can't go online if external management is on 23 $online = (isset($_REQUEST['online']) && !EXTERNAL_PACKAGE_MANAGEMENT) ? 1 : 0; 18 19 global $active_repos; 20 if (isset($_REQUEST['check_online'])) { 21 $online = 1; 22 $active_repos = $_REQUEST['active_repos']; 23 module_set_active_repos($active_repos); 24 } else { 25 $online = (isset($_REQUEST['online']) && $_REQUEST['online'] && !EXTERNAL_PACKAGE_MANAGEMENT) ? 1 : 0; 26 $active_repos = module_get_active_repos(); 27 } 24 28 25 29 // fix php errors from undefined variable. Not sure if we can just change the reference below to use … … 132 136 133 137 echo "<h2>" . _("Module Administration") . "</h2>"; 138 //TODO: decide if warnings of any sort need to be given, or just list of repos active? 134 139 if ($module_repo == "extended") { 135 140 echo "<h4 align='center'>"._("NOTICE")."<br />"._("You have accessed the extended repository which includes un-supported and third party modules")."</h4>"; … … 453 458 // display links 454 459 if (!EXTERNAL_PACKAGE_MANAGEMENT) { 455 displayRepoSelect(); 456 } 457 echo "| <a href='config.php?display=modules&type=$type'>"._("Manage local modules")."</a>\n"; 458 if (!EXTERNAL_PACKAGE_MANAGEMENT) { 459 echo " | <a class='info check_updates' href='config.php?display=modules&type=$type&online=1&module_repo=$module_repo'>"._("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"; 460 $disp_buttons[] = 'local'; 461 if (isset($_FILES['uploadmod']) && !empty($_FILES['uploadmod']['name'])) { 462 // display upload button, only if they did upload something 463 $disp_buttons[] = 'upload'; 464 } 465 displayRepoSelect($disp_buttons); 466 } else { 467 echo "<a href='config.php?display=modules&type=$type'>"._("Manage local modules")."</a>\n"; 460 468 } 461 469 462 470 if (isset($_FILES['uploadmod']) && !empty($_FILES['uploadmod']['name'])) { 463 // display upload link, only if they did upload something464 echo " | <a href='config.php?display=modules&type=$type&extdisplay=upload'>"._("Upload module")."</a><br />\n";465 466 471 $res = module_handleupload($_FILES['uploadmod']); 467 472 if (is_array($res)) { … … 512 517 } else { 513 518 if (!EXTERNAL_PACKAGE_MANAGEMENT) { 514 displayRepoSelect( );515 echo " | <a class='info check_updates' href='config.php?display=modules&type=$type&online=1&module_repo=$module_repo'>"._("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";516 }517 echo " | <a href='config.php?display=modules&type=$type&extdisplay=upload'>"._("Upload module")."</a><br />\n";519 displayRepoSelect(array('upload')); 520 } else { 521 echo " | <a href='config.php?display=modules&type=$type&extdisplay=upload'>"._("Upload module")."</a><br />\n"; 522 } 518 523 } 519 524 … … 544 549 545 550 $category = false; 546 $has_extended_modules = false;547 551 $numdisplayed = 0; 548 552 $fd = $amp_conf['ASTETCDIR'].'/freepbx_module_admin.conf'; … … 553 557 } 554 558 foreach (array_keys($modules) as $name) { 555 if (!isset($modules[$name]['category'])) {559 if (!isset($modules[$name]['category'])) { 556 560 $modules[$name]['category'] = _("Broken"); 557 561 $modules[$name]['name'] = $name; 558 }562 } 559 563 if (isset($module_filter[$name]) && strtolower(trim($module_filter[$name])) == 'hidden') { 560 564 continue; 561 565 } 566 567 // Theory: module is not in the defined repos, and since it is not local (meaning we loaded it at some point) then we 568 // don't show it. Exception, if the status is BROKEN then we should show it because it was here once. 569 // 570 if ((!isset($active_repos[$modules[$name]['repo']]) || !$active_repos[$modules[$name]['repo']]) 571 && $modules[$name]['status'] != MODULE_STATUS_BROKEN && !isset($modules_local[$name])) { 572 continue; 573 } 574 562 575 $numdisplayed++; 563 576 … … 603 616 604 617 echo "\t\t\t<span class=\"modulestatus\">"; 605 if (!$has_extended_modules && $category == 'Third Party Addon') { 606 $has_extended_modules = true; 607 } 618 608 619 switch ($modules[$name]['status']) { 609 620 case MODULE_STATUS_NOTINSTALLED: … … 831 842 832 843 echo "</form>"; 833 if ($has_extended_modules) {834 ?>835 <script language="javascript">836 <!-- Begin837 838 $(document).ready(function(){839 $("#module_repo").val('extended');840 $('.check_updates').attr('href','config.php?display=modules&type=<?php echo $type ?>&online=1&module_repo=extended');841 });842 843 // End -->844 </script>845 <?php846 }847 844 break; 848 845 } … … 957 954 } 958 955 959 960 961 function displayRepoSelect() { 962 global $type; 956 function displayRepoSelect($buttons) { 957 global $display, $type, $online, $tabindex; 958 global $active_repos; 959 960 $standard_repo = true; 961 $extended_repo = true; 962 $unsupported_repo = false; 963 $commercial_repo = true; 964 965 $button_display = ''; 966 $href = "config.php?display=$display&type=$type"; 967 $button_template = '<input type="button" value="%s" onclick="location.href=\'%s\';" />'."\n"; 968 969 foreach ($buttons as $button) { 970 switch($button) { 971 case 'local': 972 $button_display .= sprintf($button_template, _("Manage local modules"), $href); 973 break; 974 case 'upload': 975 $button_display .= sprintf($button_template, _("Upload modules"), $href.'&extdisplay=upload'); 976 break; 977 } 978 } 979 980 $tooltip = _("Choose the repositories that you want to check for new modules. Any updates available for modules you have on your system will be detected even if the repository is not checked. If you are installing a new system, you may want to start with the Basic repository and upload all modules, then go back and review the others.").' '; 981 $tooltip .= _(" The modules in the Extended repository are less common and may receive lower levels of support. The Unsupported repository has modules that are not supported by the FreePBX team but may receive some level of support by the authors.").' '; 982 $tooltip .= _("The Commerical reposiotry is reserved for modules that are available for purchase and commercially supported.").' '; 983 $tooltip .= '<br /><br /><small><i>('._("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.").')</i></small>'; 963 984 ?> 964 <select name="module_repo" id="module_repo"> 965 <option value="supported"><?php echo _("Standard Repository") ?></option> 966 <option value="extended"><?php echo _("Extended Repository") ?></option> 967 </select> 968 <script language="javascript"> 969 <!-- Begin 970 971 $(document).ready(function(){ 972 $("#module_repo").change(function(){ 973 $('.check_updates').attr('href','config.php?display=modules&type=<?php echo $type ?>&online=1&module_repo='+this.value); 974 if (this.value == "extended") { 975 alert("<?php echo _("You have selected to access the Extended Repository. This repository contains some Third Party and un-supported modules. Although these modules are believed to work with FreePBX, they are either developed by third parties in conjunction with optional PBX components, or they are not directly sponsored by the core FreePBX team and may not receive the same level of responsiveness to issues as the main code base does.") ?>"); 976 } 977 }); 978 }); 979 980 // End --> 981 </script> 985 <form name="onlineRepo" action="config.php" method="post"> 986 <input type="hidden" name="display" value="<?php echo $display ?>"/> 987 <input type="hidden" name="type" value="<?php echo $type ?>"/> 988 <input type="hidden" name="online" value="<?php echo $online ?>"/> 989 <table width="600px"> 990 <tr> 991 <td> 992 <a href="#" class="info"><?php echo _("Repositories")?><span><?php echo $tooltip ?></span></a> 993 </td><td> 994 <table> 995 <tr> 996 <td width="25%"> 997 <input id="standard_repo" type="checkbox" name="active_repos[standard]" value="1" tabindex="<?php echo ++$tabindex;?>"<?php echo isset($active_repos['standard'])?"checked":""?>/> 998 <label for="active_repos[standard]"><?php echo _("Basic") ?></label> 999 </td> 1000 <td width="25%"> 1001 <input id="extended_repo" type="checkbox" name="active_repos[extended]" value="1" tabindex="<?php echo ++$tabindex;?>"<?php echo isset($active_repos['extended'])?"checked":""?>/> 1002 <label for="active_repos[extended]"><?php echo _("Extended") ?></label> 1003 </td> 1004 <td width="25%"> 1005 <input id="unsupported_repo" type="checkbox" name="active_repos[unsupported]" value="1" tabindex="<?php echo ++$tabindex;?>"<?php echo isset($active_repos['unsupported'])?"checked":""?>/> 1006 <label for="active_repos[unsupported]"><?php echo _("Unsupported") ?></label> 1007 </td> 1008 <td width="25%"> 1009 <input id="commercial_repo" type="checkbox" name="active_repos[commercial]" value="1" tabindex="<?php echo ++$tabindex;?>"<?php echo isset($active_repos['commercial'])?"checked":""?>/> 1010 <label for="active_repos[commercial]"><?php echo _("Commercial") ?></label> 1011 </td> 1012 </tr> 1013 </table> 1014 </td> 1015 </tr> 1016 </table> 1017 <input type="submit" value="<?php echo _("Check Online") ?>" name="check_online" /> 1018 <?php echo $button_display ?> 1019 </form> 982 1020 <?php 983 1021 } 984 985 1022 ?>
