Changeset 5068

Show
Ignore:
Timestamp:
09/19/07 21:01:45 (1 year ago)
Author:
gregmac
Message:

Remove hardcoding of module admin, add module-builtin.xml file (related to #2335)
Add handlers for "builtin" module to module API functions.

Files:

Legend:

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

    r4993 r5068  
    104104$active_modules = module_getinfo(false, MODULE_STATUS_ENABLED); 
    105105 
    106 // initialize menu with module admin 
    107 $fpbx_menu = array( 
    108         'modules1' => array('display'=>'modules', 'type'=>'tool', 'category' => 'Admin', 'name' => 'Module Admin', 'sort' => -9), 
    109         'modules2' => array('display'=>'modules', 'type'=>'setup', 'category' => 'Admin', 'name' => 'Module Admin', 'sort' => -9), 
    110 ); 
     106$fpbx_menu = array(); 
     107 
    111108 
    112109// pointer to current item in $fpbx_menu, if applicable 
    113110$cur_menuitem = null; 
    114111 
    115 // handler just to check hardcoded fpbx_menu items to see whats being displayed 
    116 //   For non-hardcoded modules we check this below while looping through $active_modules. 
    117 //   These are separate to avoid looping through $active_modules and then $fpbX_menu 
    118 foreach ($fpbx_menu as $itemKey => $item) { 
    119         if ($item['display'] == $display) { 
    120                 $cur_menuitem =& $fpbx_menu[$itemKey]; 
    121         } 
    122 } 
    123  
    124 // include any module global functions 
    125112// add module sections to $fpbx_menu 
    126113$types = array(); 
     
    246233$module_page = ""; 
    247234$module_file = ""; 
     235 
     236 
     237 
     238// hack to have our default display handler show the "welcome" view  
     239// Note: this probably isn't REALLY needed if there is no menu item for "Welcome".. 
     240// but it doesn't really hurt, and it provides a handler in case some page links 
     241// to "?display=index" 
     242if (($display == 'index') && ($cur_menuitem['module']['rawname'] == 'builtin')) { 
     243        $display = ''; 
     244} 
     245 
     246 
    248247 
    249248// show the appropriate page 
  • freepbx/trunk/amp_conf/htdocs/admin/functions.inc.php

    r5026 r5068  
    18931893                $sql = 'SELECT * FROM modules WHERE modulename = "'.$module.'"'; 
    18941894        } else { 
    1895                 // get info on all modules 
     1895                // initialize list with "builtin" module 
     1896                $module_list = array('builtin'); 
     1897 
     1898                // read modules dir for module names 
    18961899                $dir = opendir($amp_conf['AMPWEBROOT'].'/admin/modules'); 
    18971900                while ($file = readdir($dir)) { 
    18981901                        if (($file != ".") && ($file != "..") && ($file != "CVS") &&  
    18991902                            ($file != ".svn") && ($file != "_cache") &&  
    1900                                 is_dir($amp_conf['AMPWEBROOT'].'/admin/modules/'.$file)) { 
    1901                                  
    1902                                 $xml = _module_readxml($file); 
    1903                                 if (!is_null($xml)) { 
    1904                                         $modules[$file] = $xml; 
    1905                                         // if status is anything else, it will be updated below when we read the db 
    1906                                         $modules[$file]['status'] = MODULE_STATUS_NOTINSTALLED; 
    1907                                 } 
    1908                         } 
    1909                 } 
    1910                  
     1903                            is_dir($amp_conf['AMPWEBROOT'].'/admin/modules/'.$file)) { 
     1904                                $module_list[] = $file; 
     1905                        } 
     1906                } 
     1907 
     1908                // read the xml for each 
     1909                foreach ($module_list as $file) { 
     1910                        $xml = _module_readxml($file); 
     1911                        if (!is_null($xml)) { 
     1912                                $modules[$file] = $xml; 
     1913                                // if status is anything else, it will be updated below when we read the db 
     1914                                $modules[$file]['status'] = MODULE_STATUS_NOTINSTALLED; 
     1915                        } 
     1916                } 
     1917                closedir($dir); 
     1918 
    19111919                // query to get everything 
    19121920                $sql = 'SELECT * FROM modules'; 
     
    19431951                } 
    19441952        } 
     1953 
     1954        // "builtin" module is always enabled 
     1955        $modules['builtin']['status'] = MODULE_STATUS_ENABLED; 
    19451956         
    19461957        if ($status !== false) { 
     
    22472258                return array(_("Module not found in repository")); 
    22482259        } 
    2249  
     2260         
    22502261        $file = basename($res['location']); 
    22512262        $filename = $amp_conf['AMPWEBROOT']."/admin/modules/_cache/".$file; 
     
    26802691function _module_readxml($modulename) { 
    26812692        global $amp_conf; 
    2682         $dir = $amp_conf['AMPWEBROOT'].'/admin/modules/'.$modulename; 
    2683         if (is_dir($dir) && file_exists($dir.'/module.xml')) { 
    2684                 $data = file_get_contents($dir.'/module.xml'); 
     2693        switch ($modulename) { 
     2694                case 'builtin': // special handling 
     2695                        $dir = $amp_conf['AMPWEBROOT']; 
     2696                        $xmlfile = $dir.'/admin/module-builtin.xml'; 
     2697                break; 
     2698                default: 
     2699                        $dir = $amp_conf['AMPWEBROOT'].'/admin/modules/'.$modulename; 
     2700                        $xmlfile = $dir.'/module.xml'; 
     2701                break; 
     2702        } 
     2703 
     2704        if (file_exists($xmlfile)) { 
     2705                $data = file_get_contents($xmlfile); 
    26852706                //$parser = new xml2ModuleArray($data); 
    26862707                //$xmlarray = $parser->parseModulesXML($data); 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads