Changeset 1388

Show
Ignore:
Timestamp:
04/07/06 18:48:18 (7 years ago)
Author:
rcourtna
Message:

modules now use module.xml, not module.ini!!

Files:

Legend:

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

    r1377 r1388  
    8181        $display=''; 
    8282} 
     83 
     84// if we are looking at tools, then show module admin 
     85if ($_REQUEST['type'] == "tool") { 
    8386  $amp_sections = array( 
    8487    'modules'=>_("Module Admin") 
    8588  ); 
     89} 
    8690 
    8791/* 
  • freepbx/trunk/amp_conf/htdocs/admin/functions.inc.php

    r1386 r1388  
    149149*/ 
    150150 
     151/* 
    151152function find_allmodules() { 
    152153  global $db; 
     
    193194  } 
    194195  return $mod; 
     196} */ 
     197 
     198 
     199/* look for all modules in modules dir. 
     200** returns array: 
     201** array['module']['displayName'] 
     202** array['module']['version'] 
     203** array['module']['type'] 
     204** array['module']['status'] 
     205** array['module']['items'][array(items)] 
     206** Use find_modules() to return only specific type or status 
     207*/ 
     208function find_allmodules() { 
     209  global $db; 
     210  global $amp_conf; 
     211  $dir = opendir($amp_conf['AMPWEBROOT'].'/admin/modules'); 
     212  $data = "<xml>"; 
     213  //loop through each module directory, ensure there is a module.ini file 
     214  while ($file = readdir($dir)) { 
     215    if (($file != ".") && ($file != "..") && ($file != "CVS") && ($file != ".svn") && is_dir($amp_conf['AMPWEBROOT'].'/admin/modules/'.$file) && is_file($amp_conf['AMPWEBROOT'].'/admin/modules/'.$file.'/module.ini')) { 
     216      //open module.xml and read contents 
     217      if(is_file($amp_conf['AMPWEBROOT'].'/admin/modules/'.$file.'/module.xml')){ 
     218        $data .=file_get_contents($amp_conf['AMPWEBROOT'].'/admin/modules/'.$file.'/module.xml'); 
     219         
     220      } 
     221    } 
     222  } 
     223  $data .= "</xml>"; 
     224  $parser = new xml2ModuleArray($data); 
     225  $xmlarray = $parser->parseModulesXML($data); 
     226   
     227  // determine details about this module from database 
     228  // modulename should match the directory name 
     229  $sql = "SELECT * FROM modules"; 
     230  $results = $db->getAll($sql,DB_FETCHMODE_ASSOC); 
     231  if(DB::IsError($results)) { 
     232    die($results->getMessage()); 
     233  } 
     234   
     235  if (is_array($results)) { 
     236    foreach($results as $result) { 
     237        /*  
     238        set status key based on results 
     239        -1=broken (in table, not not on filesystem) 
     240        0 or null=not installed 
     241        1=disabled 
     242        2=enabled 
     243        */ 
     244        if(is_array($xmlarray[ $result['modulename'] ])) { 
     245          if ($result['enabled'] != 0) 
     246            $xmlarray[ $result['modulename'] ]["status"] = 2; 
     247          else 
     248            $xmlarray[ $result['modulename'] ]["status"] = 1; 
     249        } else { 
     250          $xmlarray[ $result['modulename'] ]["status"] = -1; 
     251        } 
     252           
     253    } 
     254  } 
     255 
     256  //echo "<pre>"; print_r($xmlarray); echo "</pre>"; 
     257  return $xmlarray; 
    195258} 
    196259 
     
    803866      // loop through each modules's tags 
    804867      foreach($module['children'] as $modTags) { 
    805  
    806868          if(is_array($modTags['children'])) { 
    807869            $$modTags['name'] = $modTags['children']; 
    808870            // loop if there are children (menuitems and requirements) 
    809871            foreach($modTags['children'] as $subTag) { 
    810               $subTags[$subTag['name']] = $subTag['tagData']; 
     872              $subTags[strtolower($subTag['name'])] = $subTag['tagData']; 
    811873            } 
    812874            $$modTags['name'] = $subTags; 
     
    828890      $arrModules[$RAWNAME]['items'] = $MENUITEMS; 
    829891      $arrModules[$RAWNAME]['requirements'] = $REQUIREMENTS; 
    830        
     892      //print_r($arrModules); 
    831893      //unset our variables 
    832894      unset($NAME); 
  • freepbx/trunk/amp_conf/htdocs/admin/page.modules.php

    r1373 r1388  
    1919    case "enable": 
    2020      enableModule($_POST['modname']); 
    21       echo "<script language=\"Javascript\">document.location='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."'</script>"; 
     21      echo "<script language=\"Javascript\">document.location='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&foo=1'</script>"; 
    2222    break; 
    2323    case "disable": 
    2424      disableModule($_POST['modname']); 
    25       echo "<script language=\"Javascript\">document.location='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."'</script>"; 
     25      echo "<script language=\"Javascript\">document.location='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&foo=2'</script>"; 
     26    break; 
     27    case "delete": 
     28      deleteModule($_POST['modname']); 
     29      //echo "<script language=\"Javascript\">document.location='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."'</script>"; 
    2630    break; 
    2731    case "download": 
     
    120124        $action .= "<input type=\"submit\" name=\"submit\" value=\""._("Disable")."\">"; 
    121125        $action .= "</form>"; 
     126      } else if($mod['status'] == -1){ 
     127        $status = _("Broken"); 
     128        //disable form 
     129        $action = "<form method=\"POST\" action=\"{$_SERVER['REQUEST_URI']}\" style=display:inline>"; 
     130        $action .= "<input type=\"hidden\" name=\"modname\" value=\"{$key}\">"; 
     131        $action .= "<input type=\"hidden\" name=\"modaction\" value=\"delete\">"; 
     132        $action .= "<input type=\"submit\" name=\"submit\" value=\""._("Delete")."\">"; 
     133        $action .= "</form>"; 
    122134      } 
    123135       
     
    248260function runModuleSQL($moddir,$type){ 
    249261  global $db; 
     262  global $amp_conf; 
    250263  $data=''; 
     264  // if there is an sql file, run it 
    251265  if (is_file("modules/{$moddir}/{$type}.sql")) { 
    252266    // run sql script 
     
    267281    return true; 
    268282  } 
    269     return true; 
     283  // if there is a php file, run it 
     284  if (is_file("modules/{$moddir}/{$type}.php")) { 
     285    include("modules/{$moddir}/{$type}.php"); 
     286  } 
     287  return true; 
    270288} 
    271289 
     
    319337  global $db; 
    320338  $sql = "UPDATE modules SET enabled = 0 WHERE modulename = '{$modname}'"; 
     339  $results = $db->query($sql); 
     340  if(DB::IsError($results)) { 
     341    die($results->getMessage()); 
     342  } 
     343} 
     344 
     345function deleteModule($modname) { 
     346  global $db; 
     347  $sql = "DELETE FROM modules WHERE modulename = '{$modname}' LIMIT 1"; 
    321348  $results = $db->query($sql); 
    322349  if(DB::IsError($results)) {