Changeset 3390
- Timestamp:
- 12/20/06 10:09:10 (6 years ago)
- Files:
-
- freepbx/branches/2.2 (modified) (1 prop)
- freepbx/branches/2.2/amp_conf/htdocs/admin/functions.inc.php (modified) (2 diffs)
- freepbx/branches/2.2/amp_conf/htdocs/admin/page.modules.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/branches/2.2
- Property svnmerge-integrated changed from /freepbx/trunk:1-3224,3231,3245-3246,3300-3302,3312,3315,3336,3338,3341-3347,3349,3351,3353,3367-3368,3370,3372-3373 to /freepbx/trunk:1-3224,3231,3245-3246,3300-3302,3312,3315,3336,3338,3341-3347,3349,3351,3353,3367-3368,3370,3372-3373,3388
freepbx/branches/2.2/amp_conf/htdocs/admin/functions.inc.php
r3376 r3390 1091 1091 /** Get the latest module.xml file for this freePBX version. 1092 1092 * Caches in the database for 5 mintues. 1093 * If $module is specified, only returns the data for that module 1093 * If $module is specified, only returns the data for that module. 1094 * If the module is not found (or none are available for whatever reason), 1095 * then null is returned. 1096 * 1097 * Sets the global variable $module_getonlinexml_error to true if an error 1098 * occured getting the module from the repository, false if no error occured, 1099 * or null if the repository wasn't checked. Note that this may change in the 1100 * future if we decide we need to return more error codes, but as long as it's 1101 * a php zero-value (false, null, 0, etc) then no error happened. 1094 1102 */ 1095 1103 function module_getonlinexml($module = false) { // was getModuleXml() 1096 1104 global $amp_conf; 1105 1106 global $module_getonlinexml_error; // okay, yeah, this sucks, but there's no other good way to do it without breaking BC 1107 $module_getonlinexml_error = null; 1108 1097 1109 //this should be in an upgrade file ... putting here for now. 1098 1110 sql('CREATE TABLE IF NOT EXISTS module_xml (time INT NOT NULL , data BLOB NOT NULL) TYPE = MYISAM ;'); 1099 1111 1100 1112 $result = sql('SELECT * FROM module_xml','getRow',DB_FETCHMODE_ASSOC); 1113 $data = $result['data']; 1114 1101 1115 // if the epoch in the db is more than 2 hours old, or the xml is less than 100 bytes, then regrab xml 1102 1116 // Changed to 5 minutes while not in release. Change back for released version. … … 1117 1131 } 1118 1132 //$fn = "/usr/src/freepbx-modules/modules.xml"; 1119 $data = file_get_contents($fn); 1120 // remove the old xml 1121 sql('DELETE FROM module_xml'); 1122 // update the db with the new xml 1123 $data4sql = addslashes($data); 1124 sql('INSERT INTO module_xml (time,data) VALUES ('.time().',"'.$data4sql.'")'); 1125 } else { 1126 // echo "using cache"; 1127 $data = $result['data']; 1128 } 1133 $data = @ file_get_contents($fn); 1134 $module_getonlinexml_error = empty($data); 1135 1136 if (!empty($data)) { 1137 // remove the old xml 1138 sql('DELETE FROM module_xml'); 1139 // update the db with the new xml 1140 $data4sql = addslashes($data); 1141 sql('INSERT INTO module_xml (time,data) VALUES ('.time().',"'.$data4sql.'")'); 1142 } 1143 } 1144 1145 if (empty($data)) { 1146 // no data, probably couldn't connect online, and nothing cached 1147 return null; 1148 } 1149 1129 1150 //echo time() - $result['time']; 1130 1151 $parser = new xml2ModuleArray($data); freepbx/branches/2.2/amp_conf/htdocs/admin/page.modules.php
r3352 r3390 129 129 130 130 if ($online) { 131 $modules_online = module_getonlinexml(); 132 133 // combine online and local modules 134 $modules = $modules_online; 135 foreach (array_keys($modules) as $name) { 136 if (isset($modules_local[$name])) { 137 // combine in any other values in _local that aren't in _online 138 $modules[$name] += $modules_local[$name]; 139 140 // explicitly override these values with the _local ones 141 // - should never come from _online anyways, but this is just to be sure 142 $modules[$name]['status'] = $modules_local[$name]['status']; 143 $modules[$name]['dbversion'] = $modules_local[$name]['dbversion']; 144 } else { 145 // not local, so it's not installed 146 $modules[$name]['status'] = MODULE_STATUS_NOTINSTALLED; 131 $modules_online = module_getonlinexml(false, $connect_error); 132 133 // $module_getonlinexml_error is a global set by module_getonlinexml() 134 if ($module_getonlinexml_error) { 135 echo "<div class=\"warning\"><p>".sprintf(_("Warning: Cannot connect to online repository (%s). Online modules are not available."), "mirror.freepbx.org")."</p></div><br />"; 136 $online = false; 137 unset($modules_online); 138 } else { 139 140 // combine online and local modules 141 $modules = $modules_online; 142 foreach (array_keys($modules) as $name) { 143 if (isset($modules_local[$name])) { 144 // combine in any other values in _local that aren't in _online 145 $modules[$name] += $modules_local[$name]; 146 147 // explicitly override these values with the _local ones 148 // - should never come from _online anyways, but this is just to be sure 149 $modules[$name]['status'] = $modules_local[$name]['status']; 150 $modules[$name]['dbversion'] = $modules_local[$name]['dbversion']; 151 } else { 152 // not local, so it's not installed 153 $modules[$name]['status'] = MODULE_STATUS_NOTINSTALLED; 154 } 155 } 156 // add any remaining local-only modules 157 $modules += $modules_local; 158 159 // use online categories 160 foreach (array_keys($modules) as $modname) { 161 if (isset($modules_online[$modname]['category'])) { 162 $modules[$modname]['category'] = $modules_online[$modname]['category']; 163 } 147 164 } 148 165 } 149 // add any remaining local-only modules 150 $modules += $modules_local; 151 152 // use online categories 153 foreach (array_keys($modules) as $modname) { 154 if (isset($modules_online[$modname]['category'])) { 155 $modules[$modname]['category'] = $modules_online[$modname]['category']; 156 } 157 } 158 } else { 166 } 167 168 if (!isset($modules)) { 159 169 $modules = & $modules_local; 160 170 }
