| 1 |
<?php /* $Id: page.modules.php 5520 2007-12-16 20:21:55Z p_lindheimer $ */ |
|---|
| 2 |
|
|---|
| 3 |
/** Controls if online module and install/uninstall options are available. |
|---|
| 4 |
* This is meant for when using external packaging systems (eg, deb or rpm) to manage |
|---|
| 5 |
* modules. Package mantainers should set AMPEXTERNPACKAGES to true in /etc/amportal.conf. |
|---|
| 6 |
* Optionally, the other way is to remove the below lines, and instead just define |
|---|
| 7 |
* EXTERNAL_PACKAGE_MANAGEMENT as 1. This prevents changing the setting from amportal.conf. |
|---|
| 8 |
*/ |
|---|
| 9 |
if (!isset($amp_conf['AMPEXTERNPACKAGES']) || ($amp_conf['AMPEXTERNPACKAGES'] != 'true')) { |
|---|
| 10 |
define('EXTERNAL_PACKAGE_MANAGEMENT', 0); |
|---|
| 11 |
} else { |
|---|
| 12 |
define('EXTERNAL_PACKAGE_MANAGEMENT', 1); |
|---|
| 13 |
} |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
$extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:''; |
|---|
| 17 |
// can't go online if external management is on |
|---|
| 18 |
$online = (isset($_REQUEST['online']) && !EXTERNAL_PACKAGE_MANAGEMENT) ? $_REQUEST['online'] : false; |
|---|
| 19 |
// fix php errors from undefined variable. Not sure if we can just change the reference below to use |
|---|
| 20 |
// online since it changes values so just setting to what we decided it is here. |
|---|
| 21 |
$_REQUEST['online'] = $online ? 1 : 0; |
|---|
| 22 |
$moduleaction = isset($_REQUEST['moduleaction'])?$_REQUEST['moduleaction']:false; |
|---|
| 23 |
/* |
|---|
| 24 |
moduleaction is an array with the key as the module name, and possible values: |
|---|
| 25 |
|
|---|
| 26 |
downloadinstall - download and install (used when a module is not locally installed) |
|---|
| 27 |
upgrade - download and install (used when a module is locally installed) |
|---|
| 28 |
install - install/upgrade locally available module |
|---|
| 29 |
enable - enable local module |
|---|
| 30 |
disable - disable local module |
|---|
| 31 |
uninstall - uninstall local module |
|---|
| 32 |
*/ |
|---|
| 33 |
|
|---|
| 34 |
$freepbx_version = get_framework_version(); |
|---|
| 35 |
$freepbx_version = $freepbx_version ? $freepbx_version : getversion(); |
|---|
| 36 |
$freepbx_help_url = "http://www.freepbx.org/freepbx-help-system?freepbx_version=".urlencode($freepbx_version); |
|---|
| 37 |
|
|---|
| 38 |
function pageReload(){ |
|---|
| 39 |
return ""; |
|---|
| 40 |
//return "<script language=\"Javascript\">document.location='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&foo=".rand()."'</script>"; |
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
if (!$quietmode) { |
|---|
| 45 |
?> |
|---|
| 46 |
<script type="text/javascript" src="common/tabber-minimized.js"></script> |
|---|
| 47 |
<script type="text/javascript"> |
|---|
| 48 |
function toggleInfoPane(pane) { |
|---|
| 49 |
var style = document.getElementById(pane).style; |
|---|
| 50 |
if (style.display == 'none' || style.display == '') { |
|---|
| 51 |
style.display = 'block'; |
|---|
| 52 |
} else { |
|---|
| 53 |
style.display = 'none'; |
|---|
| 54 |
} |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
function check_upgrade_all() { |
|---|
| 58 |
var re = /^moduleaction\[([a-z0-9_\-]+)\]$/; |
|---|
| 59 |
for(i=0; i<document.modulesGUI.elements.length; i++) { |
|---|
| 60 |
if (document.modulesGUI.elements[i].value == 'upgrade' || document.modulesGUI.elements[i].value == 'install' ) { |
|---|
| 61 |
if (match = document.modulesGUI.elements[i].name.match(re)) { |
|---|
| 62 |
// check the box |
|---|
| 63 |
document.modulesGUI.elements[i].checked = true; |
|---|
| 64 |
// expand info pane |
|---|
| 65 |
document.getElementById('infopane_'+match[1]).style.display = 'block'; |
|---|
| 66 |
} |
|---|
| 67 |
} |
|---|
| 68 |
} |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
function check_download_all() { |
|---|
| 72 |
var re = /^moduleaction\[([a-z0-9_\-]+)\]$/; |
|---|
| 73 |
for(i=0; i<document.modulesGUI.elements.length; i++) { |
|---|
| 74 |
if (document.modulesGUI.elements[i].value == 'downloadinstall') { |
|---|
| 75 |
if (match = document.modulesGUI.elements[i].name.match(re)) { |
|---|
| 76 |
// check the box |
|---|
| 77 |
document.modulesGUI.elements[i].checked = true; |
|---|
| 78 |
// expand info pane |
|---|
| 79 |
document.getElementById('infopane_'+match[1]).style.display = 'block'; |
|---|
| 80 |
} |
|---|
| 81 |
} |
|---|
| 82 |
} |
|---|
| 83 |
} |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
function showhide_upgrades() { |
|---|
| 87 |
var upgradesonly = document.getElementById('show_upgradable_only').checked; |
|---|
| 88 |
|
|---|
| 89 |
var module_re = /^module_([a-z0-9_]+)$/; // regex to match a module element id |
|---|
| 90 |
var cat_re = /^category_([a-zA-Z0-9_]+)$/; // regex to match a category element id |
|---|
| 91 |
|
|---|
| 92 |
var elements = document.getElementById('modulelist').getElementsByTagName('li'); |
|---|
| 93 |
|
|---|
| 94 |
// loop through all modules, check if there is an upgrade_<module> radio box |
|---|
| 95 |
for(i=0; i<elements.length; i++) { |
|---|
| 96 |
if (match = elements[i].id.match(module_re)) { |
|---|
| 97 |
if (!document.getElementById('upgrade_'+match[1])) { |
|---|
| 98 |
// not upgradable |
|---|
| 99 |
document.getElementById('module_'+match[1]).style.display = upgradesonly ? 'none' : 'block'; |
|---|
| 100 |
} |
|---|
| 101 |
} |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
// hide category headings that don't have any visible modules |
|---|
| 107 |
|
|---|
| 108 |
var elements = document.getElementById('modulelist').getElementsByTagName('div'); |
|---|
| 109 |
// loop through category items |
|---|
| 110 |
for(i=0; i<elements.length; i++) { |
|---|
| 111 |
if (elements[i].id.match(cat_re)) { |
|---|
| 112 |
var subelements = elements[i].getElementsByTagName('li'); |
|---|
| 113 |
var display = false; |
|---|
| 114 |
for(j=0; j<subelements.length; j++) { |
|---|
| 115 |
// loop through children <li>'s, find names that are module element id's |
|---|
| 116 |
if (subelements[j].id.match(module_re) && subelements[j].style.display != 'none') { |
|---|
| 117 |
// if at least one is visible, we're displaying this element |
|---|
| 118 |
display = true; |
|---|
| 119 |
break; // no need to go further |
|---|
| 120 |
} |
|---|
| 121 |
} |
|---|
| 122 |
|
|---|
| 123 |
document.getElementById(elements[i].id).style.display = display ? 'block' : 'none'; |
|---|
| 124 |
} |
|---|
| 125 |
} |
|---|
| 126 |
|
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
function process_module_actions(actions) { |
|---|
| 130 |
freepbx_modal_show('moduleBox'); |
|---|
| 131 |
urlStr = "config.php?type=tool&display=modules&extdisplay=process&quietmode=1"; |
|---|
| 132 |
for (var i in actions) { |
|---|
| 133 |
urlStr += "&moduleaction["+i+"]="+actions[i]; |
|---|
| 134 |
} |
|---|
| 135 |
$('#moduleBox').html('<iframe src="'+urlStr+'"></iframe>'); |
|---|
| 136 |
} |
|---|
| 137 |
function close_module_actions(goback) { |
|---|
| 138 |
//freepbx_modal_close('moduleBox'); |
|---|
| 139 |
freepbx_modal_hide('moduleBox'); |
|---|
| 140 |
if (goback) { |
|---|
| 141 |
location.href = 'config.php?display=modules&type=tool&online=<?php echo ($_REQUEST['online']?1:0); ?>'; |
|---|
| 142 |
} |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
</script> |
|---|
| 146 |
<?php |
|---|
| 147 |
|
|---|
| 148 |
echo "<h2>" . _CORE_MOD_ADMIN . "</h2>"; |
|---|
| 149 |
} else { |
|---|
| 150 |
// $quietmode==true |
|---|
| 151 |
?> |
|---|
| 152 |
<html><head> |
|---|
| 153 |
<link href="common/mainstyle.css" rel="stylesheet" type="text/css" /> |
|---|
| 154 |
</head><body> |
|---|
| 155 |
<?php |
|---|
| 156 |
} |
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
$modules_local = module_getinfo(); |
|---|
| 160 |
|
|---|
| 161 |
if ($online) { |
|---|
| 162 |
$modules_online = module_getonlinexml(false); |
|---|
| 163 |
|
|---|
| 164 |
// $module_getonlinexml_error is a global set by module_getonlinexml() |
|---|
| 165 |
if ($module_getonlinexml_error) { |
|---|
| 166 |
echo "<div class=\"warning\"><p>".sprintf(_CORE_ERR_CONNECT_ONLINE, "mirror.freepbx.org")."</p></div><br />"; |
|---|
| 167 |
$online = false; |
|---|
| 168 |
unset($modules_online); |
|---|
| 169 |
} else if (!is_array($modules_online)) { |
|---|
| 170 |
echo "<div class=\"warning\"><p>".sprintf(_CORE_ERR_RETRIEVE_MODULES, "mirror.freepbx.org")."</p></div><br />"; |
|---|
| 171 |
$online = false; |
|---|
| 172 |
unset($modules_online); |
|---|
| 173 |
} else { |
|---|
| 174 |
// combine online and local modules |
|---|
| 175 |
$modules = $modules_online; |
|---|
| 176 |
foreach (array_keys($modules) as $name) { |
|---|
| 177 |
if (isset($modules_local[$name])) { |
|---|
| 178 |
// combine in any other values in _local that aren't in _online |
|---|
| 179 |
$modules[$name] += $modules_local[$name]; |
|---|
| 180 |
|
|---|
| 181 |
// explicitly override these values with the _local ones |
|---|
| 182 |
// - should never come from _online anyways, but this is just to be sure |
|---|
| 183 |
$modules[$name]['status'] = $modules_local[$name]['status']; |
|---|
| 184 |
$modules[$name]['dbversion'] = isset($modules_local[$name]['dbversion'])?$modules_local[$name]['dbversion']:''; |
|---|
| 185 |
} else { |
|---|
| 186 |
// not local, so it's not installed |
|---|
| 187 |
$modules[$name]['status'] = MODULE_STATUS_NOTINSTALLED; |
|---|
| 188 |
} |
|---|
| 189 |
} |
|---|
| 190 |
// add any remaining local-only modules |
|---|
| 191 |
$modules += $modules_local; |
|---|
| 192 |
|
|---|
| 193 |
// use online categories |
|---|
| 194 |
foreach (array_keys($modules) as $modname) { |
|---|
| 195 |
if (isset($modules_online[$modname]['category'])) { |
|---|
| 196 |
$modules[$modname]['category'] = $modules_online[$modname]['category']; |
|---|
| 197 |
} |
|---|
| 198 |
} |
|---|
| 199 |
} |
|---|
| 200 |
} |
|---|
| 201 |
|
|---|
| 202 |
if (!isset($modules)) { |
|---|
| 203 |
$modules = & $modules_local; |
|---|
| 204 |
} |
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
function category_sort_callback($a, $b) { |
|---|
| 208 |
// sort by category.. |
|---|
| 209 |
$catcomp = strcmp($a['category'], $b['category']); |
|---|
| 210 |
if ($catcomp == 0) { |
|---|
| 211 |
// .. then by name |
|---|
| 212 |
return strcmp($a['name'], $b['name']); |
|---|
| 213 |
} else |
|---|
| 214 |
return $catcomp; |
|---|
| 215 |
} |
|---|
| 216 |
|
|---|
| 217 |
/** preps a string to use as an HTML id element |
|---|
| 218 |
*/ |
|---|
| 219 |
function prep_id($name) { |
|---|
| 220 |
return preg_replace("/[^a-z0-9-]/i", "_", $name); |
|---|
| 221 |
} |
|---|
| 222 |
|
|---|
| 223 |
/** Progress callback used by module_download() |
|---|
| 224 |
*/ |
|---|
| 225 |
function download_progress($action, $params) { |
|---|
| 226 |
switch ($action) { |
|---|
| 227 |
case 'untar': |
|---|
| 228 |
echo '<script type="text/javascript"> |
|---|
| 229 |
var txt = document.createTextNode("'._CORE_UNTARRING.'"); |
|---|
| 230 |
var br = document.createElement(\'br\'); |
|---|
| 231 |
document.getElementById(\'moduleprogress\').appendChild(br); |
|---|
| 232 |
document.getElementById(\'moduleprogress\').appendChild(txt); |
|---|
| 233 |
</script>'; |
|---|
| 234 |
flush(); |
|---|
| 235 |
break; |
|---|
| 236 |
case 'downloading': |
|---|
| 237 |
if ($params['total']==0) { |
|---|
| 238 |
$progress = $params['read'].' of '.$params['total'].' (0%)'; |
|---|
| 239 |
} else { |
|---|
| 240 |
$progress = $params['read'].' of '.$params['total'].' ('.round($params['read']/$params['total']*100).'%)'; |
|---|
| 241 |
} |
|---|
| 242 |
echo '<script type="text/javascript"> |
|---|
| 243 |
document.getElementById(\'downloadprogress_'.$params['module'].'\').innerHTML = \''.$progress.'\'; |
|---|
| 244 |
</script>'; |
|---|
| 245 |
flush(); |
|---|
| 246 |
break; |
|---|
| 247 |
case 'done'; |
|---|
| 248 |
echo '<script type="text/javascript"> |
|---|
| 249 |
var txt = document.createTextNode("'._CORE_DONE.'"); |
|---|
| 250 |
var br = document.createElement(\'br\'); |
|---|
| 251 |
document.getElementById(\'moduleprogress\').appendChild(txt); |
|---|
| 252 |
document.getElementById(\'moduleprogress\').appendChild(br); |
|---|
| 253 |
</script>'; |
|---|
| 254 |
flush(); |
|---|
| 255 |
break; |
|---|
| 256 |
} |
|---|
| 257 |
} |
|---|
| 258 |
|
|---|
| 259 |
/* enable_option($module_name, $option) |
|---|
| 260 |
This function will return false if the particular option, which is a module xml tag, |
|---|
| 261 |
is set to 'no'. It also provides for some hardcoded overrides on critical modules to |
|---|
| 262 |
keep people from editing the xml themselves and then breaking their the system. |
|---|
| 263 |
*/ |
|---|
| 264 |
function enable_option($module_name, $option) { |
|---|
| 265 |
global $modules; |
|---|
| 266 |
|
|---|
| 267 |
$enable=true; |
|---|
| 268 |
$override = array('core' => array('candisable' => 'no', |
|---|
| 269 |
'canuninstall' => 'no', |
|---|
| 270 |
), |
|---|
| 271 |
'framework' => array('candisable' => 'no', |
|---|
| 272 |
'canuninstall' => 'no', |
|---|
| 273 |
), |
|---|
| 274 |
); |
|---|
| 275 |
|
|---|
| 276 |
if (isset($modules[$module_name][$option]) && strtolower(trim($modules[$module_name][$option])) == 'no') { |
|---|
| 277 |
$enable=false; |
|---|
| 278 |
} |
|---|
| 279 |
if (isset($override[$module_name][$option]) && strtolower(trim($override[$module_name][$option])) == 'no') { |
|---|
| 280 |
$enable=false; |
|---|
| 281 |
} |
|---|
| 282 |
|
|---|
| 283 |
return $enable; |
|---|
| 284 |
} |
|---|
| 285 |
|
|---|
| 286 |
//-------------------------------------------------------------------------------------------------------- |
|---|
| 287 |
switch ($extdisplay) { // process, confirm, or nothing |
|---|
| 288 |
case 'process': |
|---|
| 289 |
echo "<div id=\"moduleBoxContents\">"; |
|---|
| 290 |
echo "<h4>"._CORE_MODULES_ACTION."</h4>\n"; |
|---|
| 291 |
|
|---|
| 292 |
echo "<div id=\"moduleprogress\">"; |
|---|
| 293 |
|
|---|
| 294 |
// stop output buffering, and send output |
|---|
| 295 |
@ ob_end_flush(); |
|---|
| 296 |
|
|---|
| 297 |
flush(); |
|---|
| 298 |
foreach ($moduleaction as $modulename => $action) { |
|---|
| 299 |
$didsomething = true; // set to false in default clause of switch() below.. |
|---|
| 300 |
|
|---|
| 301 |
switch ($action) { |
|---|
| 302 |
case 'upgrade': |
|---|
| 303 |
case 'downloadinstall': |
|---|
| 304 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 305 |
echo sprintf(_CORE_DOWNLOADING, $modulename).' <span id="downloadprogress_'.$modulename.'"></span>'; |
|---|
| 306 |
if (is_array($errors = module_download($modulename, false, 'download_progress'))) { |
|---|
| 307 |
echo '<span class="error">'.sprintf(_CORE_ERR_DOWNLADING,$modulename).': '; |
|---|
| 308 |
echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; |
|---|
| 309 |
echo '</span>'; |
|---|
| 310 |
} else { |
|---|
| 311 |
|
|---|
| 312 |
if (is_array($errors = module_install($modulename))) { |
|---|
| 313 |
echo '<span class="error">'.sprintf(_CORE_ERR_INSTALLING,$modulename).': '; |
|---|
| 314 |
echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; |
|---|
| 315 |
echo '</span>'; |
|---|
| 316 |
} else { |
|---|
| 317 |
echo '<span class="success">'.sprintf(_CORE_INSTALLED_OK,$modulename).'</span>'; |
|---|
| 318 |
} |
|---|
| 319 |
} |
|---|
| 320 |
} |
|---|
| 321 |
break; |
|---|
| 322 |
case 'install': |
|---|
| 323 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 324 |
if (is_array($errors = module_install($modulename))) { |
|---|
| 325 |
echo '<span class="error">'.sprintf(_CORE_ERR_INSTALLING,$modulename).': '; |
|---|
| 326 |
echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; |
|---|
| 327 |
echo '</span>'; |
|---|
| 328 |
} else { |
|---|
| 329 |
echo '<span class="success">'.sprintf(_CORE_INSTALLED_OK,$modulename).'</span>'; |
|---|
| 330 |
} |
|---|
| 331 |
} |
|---|
| 332 |
break; |
|---|
| 333 |
case 'enable': |
|---|
| 334 |
if (is_array($errors = module_enable($modulename))) { |
|---|
| 335 |
echo '<span class="error">'.sprintf(_CORE_ERR_ENABLING,$modulename).': '; |
|---|
| 336 |
echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; |
|---|
| 337 |
echo '</span>'; |
|---|
| 338 |
} else { |
|---|
| 339 |
echo '<span class="success">'.sprintf(_CORE_ENABLED_OK,$modulename).'</span>'; |
|---|
| 340 |
} |
|---|
| 341 |
break; |
|---|
| 342 |
case 'disable': |
|---|
| 343 |
if (is_array($errors = module_disable($modulename))) { |
|---|
| 344 |
echo '<span class="error">'.sprintf(_CORE_ERR_DISABLING,$modulename).': '; |
|---|
| 345 |
echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; |
|---|
| 346 |
echo '</span>'; |
|---|
| 347 |
} else { |
|---|
| 348 |
echo '<span class="success">'.sprintf(_CORE_DISABLED_OK,$modulename).'</span>'; |
|---|
| 349 |
} |
|---|
| 350 |
break; |
|---|
| 351 |
case 'uninstall': |
|---|
| 352 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 353 |
if (is_array($errors = module_uninstall($modulename))) { |
|---|
| 354 |
echo '<span class="error">'.sprintf(_CORE_ERR_UNINSTALLING,$modulename).': '; |
|---|
| 355 |
echo '<ul><li>'.implode('</li><li>',$errors).'</li></ul>'; |
|---|
| 356 |
echo '</span>'; |
|---|
| 357 |
} else { |
|---|
| 358 |
echo '<span class="success">'.sprintf(_CORE_UNINSTALLED_OK,$modulename).'</span>'; |
|---|
| 359 |
} |
|---|
| 360 |
} |
|---|
| 361 |
break; |
|---|
| 362 |
default: |
|---|
| 363 |
// just so we don't send an <hr> and flush() |
|---|
| 364 |
$didsomething = false; |
|---|
| 365 |
} |
|---|
| 366 |
|
|---|
| 367 |
if ($didsomething) { |
|---|
| 368 |
echo "<hr /><br />"; |
|---|
| 369 |
flush(); |
|---|
| 370 |
} |
|---|
| 371 |
} |
|---|
| 372 |
echo "</div>"; |
|---|
| 373 |
if ($quietmode) { |
|---|
| 374 |
echo "\t<a href=\"#\" onclick=\"parent.close_module_actions(true);\" />"._GLOBAL_RETURN."</a>"; |
|---|
| 375 |
} else { |
|---|
| 376 |
echo "\t<input type=\"button\" value=\""._GLOBAL_RETURN."\" onclick=\"location.href = 'config.php?display=modules&type=tool&online=".($_REQUEST['online']?1:0)."';\" />"; |
|---|
| 377 |
echo "</div>"; |
|---|
| 378 |
} |
|---|
| 379 |
break; |
|---|
| 380 |
case 'confirm': |
|---|
| 381 |
ksort($moduleaction); |
|---|
| 382 |
|
|---|
| 383 |
echo "<form name=\"modulesGUI\" action=\"config.php\" method=\"post\">"; |
|---|
| 384 |
echo "<input type=\"hidden\" name=\"display\" value=\"".$display."\" />"; |
|---|
| 385 |
echo "<input type=\"hidden\" name=\"type\" value=\"".$type."\" />"; |
|---|
| 386 |
echo "<input type=\"hidden\" name=\"online\" value=\"".$online."\" />"; |
|---|
| 387 |
echo "<input type=\"hidden\" name=\"extdisplay\" value=\"process\" />"; |
|---|
| 388 |
|
|---|
| 389 |
echo "\t<script type=\"text/javascript\"> var moduleActions = new Array(); </script>\n"; |
|---|
| 390 |
|
|---|
| 391 |
$actionstext = array(); |
|---|
| 392 |
$errorstext = array(); |
|---|
| 393 |
foreach ($moduleaction as $module => $action) { |
|---|
| 394 |
$text = false; |
|---|
| 395 |
$skipaction = false; |
|---|
| 396 |
|
|---|
| 397 |
// make sure name is set. This is a problem for broken modules |
|---|
| 398 |
if (!isset($modules[$module]['name'])) { |
|---|
| 399 |
$modules[$module]['name'] = $module; |
|---|
| 400 |
} |
|---|
| 401 |
|
|---|
| 402 |
switch ($action) { |
|---|
| 403 |
case 'upgrade': |
|---|
| 404 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 405 |
if (is_array($errors = module_checkdepends($modules_online[$module]))) { |
|---|
| 406 |
$skipaction = true; |
|---|
| 407 |
$errorstext[] = sprintf(_CORE_ERR_UPGRADE, |
|---|
| 408 |
$modules[$module]['name'], |
|---|
| 409 |
'<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); |
|---|
| 410 |
} else { |
|---|
| 411 |
$actionstext[] = sprintf(_CORE_UPGRADE, $modules[$module]['name'], $modules[$module]['dbversion'], $modules_online[$module]['version']); |
|---|
| 412 |
} |
|---|
| 413 |
} |
|---|
| 414 |
break; |
|---|
| 415 |
case 'downloadinstall': |
|---|
| 416 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 417 |
if (is_array($errors = module_checkdepends($modules_online[$module]))) { |
|---|
| 418 |
$skipaction = true; |
|---|
| 419 |
$errorstext[] = sprintf(_CORE_ERR_CANNOT_INSTALL, |
|---|
| 420 |
$modules[$module]['name'], |
|---|
| 421 |
'<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); |
|---|
| 422 |
} else { |
|---|
| 423 |
$actionstext[] = sprintf(_CORE_WILL_DOWNLOAD_INSTALL, $modules[$module]['name'], $modules_online[$module]['version']); |
|---|
| 424 |
} |
|---|
| 425 |
} |
|---|
| 426 |
break; |
|---|
| 427 |
case 'install': |
|---|
| 428 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 429 |
if (is_array($errors = module_checkdepends($modules[$module]))) { |
|---|
| 430 |
$skipaction = true; |
|---|
| 431 |
$errorstext[] = sprintf((($modules[$module]['status'] == MODULE_STATUS_NEEDUPGRADE) ? _CORE_ERR_UPGRADE : _CORE_ERR_CANNOT_INSTALL), |
|---|
| 432 |
$modules[$module]['name'], |
|---|
| 433 |
'<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); |
|---|
| 434 |
} else { |
|---|
| 435 |
if ($modules[$module]['status'] == MODULE_STATUS_NEEDUPGRADE) { |
|---|
| 436 |
$actionstext[] = sprintf(_CORE_UPGRADED, $modules[$module]['name'], $modules[$module]['dbversion'], $modules[$module]['version']); |
|---|
| 437 |
} else { |
|---|
| 438 |
$actionstext[] = sprintf(_CORE_INSTALL_ENABLE, $modules[$module]['name'], $modules[$module]['version']); |
|---|
| 439 |
} |
|---|
| 440 |
} |
|---|
| 441 |
} |
|---|
| 442 |
break; |
|---|
| 443 |
case 'enable': |
|---|
| 444 |
if (is_array($errors = module_checkdepends($modules[$module]))) { |
|---|
| 445 |
$skipaction = true; |
|---|
| 446 |
$errorstext[] = sprintf(_CORE_ERR_ENABLE, |
|---|
| 447 |
$modules[$module]['name'], |
|---|
| 448 |
'<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); |
|---|
| 449 |
} else { |
|---|
| 450 |
$actionstext[] = sprintf(_CORE_WILL_ENABLE, $modules[$module]['name'], $modules[$module]['dbversion']); |
|---|
| 451 |
} |
|---|
| 452 |
break; |
|---|
| 453 |
case 'disable': |
|---|
| 454 |
if (is_array($errors = module_reversedepends($modules[$module]))) { |
|---|
| 455 |
$skipaction = true; |
|---|
| 456 |
$errorstext[] = sprintf(_CORE_ERR_CANNOT_BE_DISABLED, |
|---|
| 457 |
$modules[$module]['name'], |
|---|
| 458 |
'<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); |
|---|
| 459 |
} else { |
|---|
| 460 |
$actionstext[] = sprintf(_CORE_WILL_BE_DISABLED, $modules[$module]['name'], $modules[$module]['dbversion']); |
|---|
| 461 |
} |
|---|
| 462 |
break; |
|---|
| 463 |
case 'uninstall': |
|---|
| 464 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 465 |
if (is_array($errors = module_reversedepends($modules[$module]))) { |
|---|
| 466 |
$skipaction = true; |
|---|
| 467 |
$errorstext[] = sprintf(_CORE_ERR_CANNOT_UNINSTALL, |
|---|
| 468 |
$modules[$module]['name'], |
|---|
| 469 |
'<ul><li>'.implode('</li><li>',$errors).'</li></ul>'); |
|---|
| 470 |
} else { |
|---|
| 471 |
$actionstext[] = sprintf(_CORE_WILL_BE_UNINSTALLED, $modules[$module]['name'], $modules[$module]['dbversion']); |
|---|
| 472 |
} |
|---|
| 473 |
} |
|---|
| 474 |
break; |
|---|
| 475 |
} |
|---|
| 476 |
|
|---|
| 477 |
// If error above we skip this action so we can proceed with the others |
|---|
| 478 |
// |
|---|
| 479 |
if (!$skipaction) { //TODO |
|---|
| 480 |
echo "\t<script type=\"text/javascript\"> moduleActions['".$module."'] = '".$action."'; </script>\n"; |
|---|
| 481 |
} |
|---|
| 482 |
} |
|---|
| 483 |
|
|---|
| 484 |
// Write out the erros, if there are additional actions that can be accomplished list those next with the choice to |
|---|
| 485 |
// process which will ignore the ones with errors but process the rest. |
|---|
| 486 |
// |
|---|
| 487 |
if (count($errorstext) > 0) { |
|---|
| 488 |
echo "<h4>"._CORE_ERR_SELECTION."</h4>\n"; |
|---|
| 489 |
echo "<ul>\n"; |
|---|
| 490 |
foreach ($errorstext as $text) { |
|---|
| 491 |
echo "\t<li>".$text."</li>\n"; |
|---|
| 492 |
} |
|---|
| 493 |
echo "</ul>"; |
|---|
| 494 |
} |
|---|
| 495 |
if (count($actionstext) > 0) { |
|---|
| 496 |
if (count($errorstext) > 0) { |
|---|
| 497 |
echo "<h4>"._CORE_CONFIRM_REMAINING."</h4>\n"; |
|---|
| 498 |
} else { |
|---|
| 499 |
echo "<h4>"._CORE_CONFIRM."</h4>\n"; |
|---|
| 500 |
} |
|---|
| 501 |
echo "<ul>\n"; |
|---|
| 502 |
foreach ($actionstext as $text) { |
|---|
| 503 |
echo "\t<li>".$text."</li>\n"; |
|---|
| 504 |
} |
|---|
| 505 |
echo "</ul>"; |
|---|
| 506 |
echo "\t<input type=\"button\" value=\"Confirm\" name=\"process\" onclick=\"process_module_actions(moduleActions);\" />"; |
|---|
| 507 |
} else { |
|---|
| 508 |
echo "<h4>"._CORE_NO_ACTIONS_PERFORM."</h4>\n"; |
|---|
| 509 |
echo "<p>"._CORE_SELECT_ACTION."</p>"; |
|---|
| 510 |
} |
|---|
| 511 |
echo "\t<input type=\"button\" value=\""._GLOBAL_CANCEL."\" onclick=\"location.href = 'config.php?display=modules&type=tool&online=".($_REQUEST['online']?1:0)."';\" />"; |
|---|
| 512 |
echo "</form>"; |
|---|
| 513 |
|
|---|
| 514 |
break; |
|---|
| 515 |
case 'upload': |
|---|
| 516 |
// display links |
|---|
| 517 |
echo "<a href='config.php?display=modules&type=tool'>"._CORE_MANAGE_LOCAL."</a>\n"; |
|---|
| 518 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 519 |
echo " | <a class='info' href='config.php?display=modules&type=tool&online=1'>"._CORE_CHECK_ONLINE."<span>"._CORE_PRIVACY."</span></a>\n"; |
|---|
| 520 |
} |
|---|
| 521 |
|
|---|
| 522 |
if (isset($_FILES['uploadmod']) && !empty($_FILES['uploadmod']['name'])) { |
|---|
| 523 |
// display upload link, only if they did upload something |
|---|
| 524 |
echo " | <a href='config.php?display=modules&type=tool&extdisplay=upload'>"._CORE_UPLOAD_MODULE."</a><br />\n"; |
|---|
| 525 |
|
|---|
| 526 |
$res = module_handleupload($_FILES['uploadmod']); |
|---|
| 527 |
if (is_array($res)) { |
|---|
| 528 |
|
|---|
| 529 |
echo '<div class="error"><p>'; |
|---|
| 530 |
echo sprintf(_CORE_ERR_UPLOAD, |
|---|
| 531 |
'<ul><li>'.implode('</li><li>',$res).'</li></ul>'); |
|---|
| 532 |
echo sprintf(_CORE_ERR_FIX_PROBLEM, |
|---|
| 533 |
"<a href='config.php?display=modules&type=tool'>"._CORE_TRY_AGAIN."</a>"); |
|---|
| 534 |
echo "</p></div>\n"; |
|---|
| 535 |
} else { |
|---|
| 536 |
|
|---|
| 537 |
echo "<p>".sprintf(_CORE_MODULE_UPLOAD_OK, |
|---|
| 538 |
"<a href='config.php?display=modules&type=tool'>"._CORE_LOCAL_MODULE_ADMINISTRATION."</a>") |
|---|
| 539 |
."</p>\n"; |
|---|
| 540 |
} |
|---|
| 541 |
|
|---|
| 542 |
} else { |
|---|
| 543 |
echo "<p>"._CORE_UPLOAD_FILE."</p>\n"; |
|---|
| 544 |
|
|---|
| 545 |
echo "<form name=\"modulesGUI-upload\" action=\"config.php\" method=\"post\" enctype=\"multipart/form-data\">"; |
|---|
| 546 |
echo "<input type=\"hidden\" name=\"display\" value=\"".$display."\" />"; |
|---|
| 547 |
echo "<input type=\"hidden\" name=\"type\" value=\"".$type."\" />"; |
|---|
| 548 |
echo "<input type=\"hidden\" name=\"extdisplay\" value=\"upload\" />"; |
|---|
| 549 |
|
|---|
| 550 |
echo "<input type=\"file\" name=\"uploadmod\" /> "; |
|---|
| 551 |
echo " <input type=\"submit\" value=\"Upload\" />"; |
|---|
| 552 |
echo "</form>"; |
|---|
| 553 |
} |
|---|
| 554 |
|
|---|
| 555 |
break; |
|---|
| 556 |
case 'online': |
|---|
| 557 |
default: |
|---|
| 558 |
|
|---|
| 559 |
uasort($modules, 'category_sort_callback'); |
|---|
| 560 |
|
|---|
| 561 |
if ($online) { |
|---|
| 562 |
//echo "<a href='config.php?display=modules&type=tool&extdisplay=local'>"._("Terminate Connection to Online Module Repository")."</a><br />\n"; |
|---|
| 563 |
//echo "<a href='config.php?display=modules&type=tool&extdisplay=online&refresh=true'>"._("Force Refresh of Local Module Cache")."</a>\n"; |
|---|
| 564 |
|
|---|
| 565 |
// Check for annoucements such as security advisories, required updates, etc. |
|---|
| 566 |
// |
|---|
| 567 |
$announcements = module_get_annoucements(); |
|---|
| 568 |
if (isset($announcements) && !empty($announcements)) { |
|---|
| 569 |
echo "<div class='announcements'>$announcements</div>"; |
|---|
| 570 |
} |
|---|
| 571 |
|
|---|
| 572 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 573 |
echo "<a href='config.php?display=modules&type=tool&online=0'>"._CORE_MANAGE_LOCAL."</a>\n"; |
|---|
| 574 |
echo "<input type=\"checkbox\" id=\"show_upgradable_only\" onclick=\"showhide_upgrades();\" /><label for=\"show_upgradable_only\">"._CORE_SHOW_UPGRADES."</label>"; |
|---|
| 575 |
} |
|---|
| 576 |
} else { |
|---|
| 577 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 578 |
echo "<a class='info' href='config.php?display=modules&type=tool&online=1'>"._CORE_CHECK_ONLINE."<span>"._CORE_PRIVACY."</span></a>\n"; |
|---|
| 579 |
} |
|---|
| 580 |
echo " | <a href='config.php?display=modules&type=tool&extdisplay=upload'>"._CORE_UPLOAD_MODULE."</a><br />\n"; |
|---|
| 581 |
} |
|---|
| 582 |
|
|---|
| 583 |
echo "<form name=\"modulesGUI\" action=\"config.php\" method=\"post\">"; |
|---|
| 584 |
echo "<input type=\"hidden\" name=\"display\" value=\"".$display."\" />"; |
|---|
| 585 |
echo "<input type=\"hidden\" name=\"type\" value=\"".$type."\" />"; |
|---|
| 586 |
echo "<input type=\"hidden\" name=\"online\" value=\"".$online."\" />"; |
|---|
| 587 |
echo "<input type=\"hidden\" name=\"extdisplay\" value=\"confirm\" />"; |
|---|
| 588 |
|
|---|
| 589 |
echo "<div class=\"modulebuttons\">"; |
|---|
| 590 |
if ($online) { |
|---|
| 591 |
echo "\t<a href=\"javascript:void(null);\" onclick=\"check_download_all();\">"._CORE_DOWNLOAD_ALL."</a>"; |
|---|
| 592 |
echo "\t<a href=\"javascript:void(null);\" onclick=\"check_upgrade_all();\">"._CORE_UPGRADE_ALL."</a>"; |
|---|
| 593 |
} |
|---|
| 594 |
echo "\t<input type=\"reset\" value=\""._CORE_RESET."\" />"; |
|---|
| 595 |
echo "\t<input type=\"submit\" value=\""._CORE_PROCESS."\" name=\"process\" />"; |
|---|
| 596 |
echo "</div>"; |
|---|
| 597 |
|
|---|
| 598 |
echo "<div id=\"modulelist\">\n"; |
|---|
| 599 |
|
|---|
| 600 |
echo "\t<div id=\"modulelist-header\">"; |
|---|
| 601 |
echo "\t\t<span class=\"modulename\">"._CORE_MODULE."</span>\n"; |
|---|
| 602 |
echo "\t\t<span class=\"moduletype\">"._CORE_TYPE."</span>\n"; |
|---|
| 603 |
echo "\t\t<span class=\"moduleversion\">"._CORE_VERSION."</span>\n"; |
|---|
| 604 |
echo "\t\t<span class=\"clear\"> </span>\n"; |
|---|
| 605 |
echo "\t</div>"; |
|---|
| 606 |
|
|---|
| 607 |
$category = false; |
|---|
| 608 |
$numdisplayed = 0; |
|---|
| 609 |
foreach (array_keys($modules) as $name) { |
|---|
| 610 |
|
|---|
| 611 |
$numdisplayed++; |
|---|
| 612 |
|
|---|
| 613 |
if ($category !== $modules[$name]['category']) { |
|---|
| 614 |
// show category header |
|---|
| 615 |
|
|---|
| 616 |
if ($category !== false) { |
|---|
| 617 |
// not the first one, so end the previous blocks |
|---|
| 618 |
echo "\t</ul></div>\n"; |
|---|
| 619 |
} |
|---|
| 620 |
|
|---|
| 621 |
// start a new category header, and associated html blocks |
|---|
| 622 |
$category = $modules[$name]['category']; |
|---|
| 623 |
echo "\t<div class=\"category\" id=\"category_".prep_id($category)."\"><h3>"._($category)."</h3>\n"; |
|---|
| 624 |
echo "\t<ul>"; |
|---|
| 625 |
} |
|---|
| 626 |
|
|---|
| 627 |
echo "\t\t<li id=\"module_".prep_id($name)."\">\n"; |
|---|
| 628 |
|
|---|
| 629 |
// ---- module header |
|---|
| 630 |
echo "\t\t<div class=\"moduleheader\" onclick=\"toggleInfoPane('infopane_".prep_id($name)."');\" >\n"; |
|---|
| 631 |
echo "\t\t\t<span class=\"modulename\"><a href=\"javascript:void(null);\">".(!empty($modules[$name]['name']) ? $modules[$name]['name'] : $name)."</a></span>\n"; |
|---|
| 632 |
echo "\t\t\t<span class=\"moduletype\">".$modules[$name]['type']."</span>\n"; |
|---|
| 633 |
echo "\t\t\t<span class=\"moduleversion\">".(isset($modules[$name]['dbversion'])?$modules[$name]['dbversion']:' ')."</span>\n"; |
|---|
| 634 |
|
|---|
| 635 |
echo "\t\t\t<span class=\"modulestatus\">"; |
|---|
| 636 |
switch ($modules[$name]['status']) { |
|---|
| 637 |
case MODULE_STATUS_NOTINSTALLED: |
|---|
| 638 |
if (isset($modules_local[$name])) { |
|---|
| 639 |
echo '<span class="alert">'._CORE_NOT_INSTALL_LOCAL_AVAIL.'</span>'; |
|---|
| 640 |
} else { |
|---|
| 641 |
echo sprintf(_CORE_NOT_INSTALL_ONLINE_AVAIL, $modules_online[$name]['version']); |
|---|
| 642 |
} |
|---|
| 643 |
break; |
|---|
| 644 |
case MODULE_STATUS_DISABLED: |
|---|
| 645 |
if (isset($modules_online[$name]['version'])) { |
|---|
| 646 |
$vercomp = version_compare_freepbx($modules_local[$name]['version'], $modules_online[$name]['version']); |
|---|
| 647 |
if ($vercomp < 0) { |
|---|
| 648 |
echo '<span class="alert">'.sprintf(_CORE_DISABLED_ONLINE_AVAIL,$modules_online[$name]['version']).'</span>'; |
|---|
| 649 |
} else if ($vercomp > 0) { |
|---|
| 650 |
echo sprintf(_CORE_DISABLED_NEWER_THAN_ONLINE, $modules_online[$name]['version']); |
|---|
| 651 |
} else { |
|---|
| 652 |
echo _CORE_DISABLED_UPTODATE; |
|---|
| 653 |
} |
|---|
| 654 |
} else { |
|---|
| 655 |
echo _CORE_DISABLED; |
|---|
| 656 |
} |
|---|
| 657 |
break; |
|---|
| 658 |
case MODULE_STATUS_NEEDUPGRADE: |
|---|
| 659 |
echo '<span class="alert">'.sprintf(_CORE_DISABLED_PENDING_UPDATE,$modules_local[$name]['version']).'</span>'; |
|---|
| 660 |
break; |
|---|
| 661 |
case MODULE_STATUS_BROKEN: |
|---|
| 662 |
echo '<span class="alert">'._CORE_BROKEN.'</span>'; |
|---|
| 663 |
break; |
|---|
| 664 |
default: |
|---|
| 665 |
// check for online upgrade |
|---|
| 666 |
if (isset($modules_online[$name]['version'])) { |
|---|
| 667 |
$vercomp = version_compare_freepbx($modules_local[$name]['version'], $modules_online[$name]['version']); |
|---|
| 668 |
if ($vercomp < 0) { |
|---|
| 669 |
echo '<span class="alert">'.sprintf(_CORE_ONLINE_AVAILABLE, $modules_online[$name]['version']).'</span>'; |
|---|
| 670 |
} else if ($vercomp > 0) { |
|---|
| 671 |
echo sprintf(_CORE_NEWER_THAN_ONLINE,$modules_online[$name]['version']); |
|---|
| 672 |
} else { |
|---|
| 673 |
echo _CORE_ENABLED_UPTODATE; |
|---|
| 674 |
} |
|---|
| 675 |
} else if (isset($modules_online)) { |
|---|
| 676 |
// we're connected to online, but didn't find this module |
|---|
| 677 |
echo _CORE_ENABLED_NOT_AVAIL_ONLINE; |
|---|
| 678 |
} else { |
|---|
| 679 |
echo _CORE_ENABLED; |
|---|
| 680 |
} |
|---|
| 681 |
break; |
|---|
| 682 |
} |
|---|
| 683 |
echo "</span>\n"; |
|---|
| 684 |
|
|---|
| 685 |
|
|---|
| 686 |
echo "\t\t\t<span class=\"clear\"> </span>\n"; |
|---|
| 687 |
echo "\t\t</div>\n"; |
|---|
| 688 |
|
|---|
| 689 |
// ---- end of module header |
|---|
| 690 |
|
|---|
| 691 |
|
|---|
| 692 |
// ---- drop-down tab box thingy: |
|---|
| 693 |
|
|---|
| 694 |
echo "\t\t<div class=\"moduleinfopane\" id=\"infopane_".prep_id($name)."\" >\n"; |
|---|
| 695 |
echo "\t\t\t<div class=\"tabber\">\n"; |
|---|
| 696 |
|
|---|
| 697 |
if (isset($modules_online[$name]['attention']) && !empty($modules_online[$name]['attention'])) { |
|---|
| 698 |
echo "\t\t\t\t<div class=\"tabbertab\" title=\""._CORE_ATTENTION."\">\n"; |
|---|
| 699 |
echo nl2br($modules_online[$name]['attention']); |
|---|
| 700 |
echo "\t\t\t\t</div>\n"; |
|---|
| 701 |
} |
|---|
| 702 |
|
|---|
| 703 |
echo "\t\t\t\t<div class=\"tabbertab actiontab\" title=\""._CORE_ACTION."\">\n"; |
|---|
| 704 |
|
|---|
| 705 |
echo '<input type="radio" checked="CHECKED" id="noaction_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="0" /> '. |
|---|
| 706 |
'<label for="noaction_'.prep_id($name).'">'._CORE_NO_ACTION.'</label> <br />'; |
|---|
| 707 |
switch ($modules[$name]['status']) { |
|---|
| 708 |
|
|---|
| 709 |
case MODULE_STATUS_NOTINSTALLED: |
|---|
| 710 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 711 |
if (isset($modules_local[$name])) { |
|---|
| 712 |
echo '<input type="radio" id="install_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="install" /> '. |
|---|
| 713 |
'<label for="install_'.prep_id($name).'">'._CORE_INSTALL.'</label> <br />'; |
|---|
| 714 |
} else { |
|---|
| 715 |
echo '<input type="radio" id="upgrade_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="downloadinstall" /> '. |
|---|
| 716 |
'<label for="upgrade_'.prep_id($name).'">'._CORE_DOWNLOAD_INSTALL.'</label> <br />'; |
|---|
| 717 |
} |
|---|
| 718 |
} |
|---|
| 719 |
break; |
|---|
| 720 |
case MODULE_STATUS_DISABLED: |
|---|
| 721 |
echo '<input type="radio" id="enable_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="enable" /> '. |
|---|
| 722 |
'<label for="enable_'.prep_id($name).'">'._CORE_ENABLE.'</label> <br />'; |
|---|
| 723 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 724 |
echo '<input type="radio" id="uninstall_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="uninstall" /> '. |
|---|
| 725 |
'<label for="uninstall_'.prep_id($name).'">'._CORE_UNINSTALL.'</label> <br />'; |
|---|
| 726 |
if (isset($modules_online[$name]['version'])) { |
|---|
| 727 |
$vercomp = version_compare_freepbx($modules_local[$name]['version'], $modules_online[$name]['version']); |
|---|
| 728 |
if ($vercomp < 0) { |
|---|
| 729 |
echo '<input type="radio" id="upgrade_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="upgrade" /> '. |
|---|
| 730 |
'<label for="upgrade_'.prep_id($name).'">'.sprintf(_CORE_DOWNLOAD_UPGRADE_ENABLE,$modules_online[$name]['version']).'</label> <br />'; |
|---|
| 731 |
} |
|---|
| 732 |
} |
|---|
| 733 |
} |
|---|
| 734 |
break; |
|---|
| 735 |
case MODULE_STATUS_NEEDUPGRADE: |
|---|
| 736 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 737 |
echo '<input type="radio" id="install_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="install" /> '. |
|---|
| 738 |
'<label for="install_'.prep_id($name).'">'.sprintf(_CORE_UPGRADE_ENABLE,$modules_local[$name]['version']).'</label> <br />'; |
|---|
| 739 |
echo '<input type="radio" id="uninstall_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="uninstall" /> '. |
|---|
| 740 |
'<label for="uninstall_'.prep_id($name).'">'._CORE_UNINSTALL.'</label> <br />'; |
|---|
| 741 |
} |
|---|
| 742 |
break; |
|---|
| 743 |
case MODULE_STATUS_BROKEN: |
|---|
| 744 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 745 |
echo '<input type="radio" id="install_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="install" /> '. |
|---|
| 746 |
'<label for="install_'.prep_id($name).'">'._CORE_INSTALL.'</label> <br />'; |
|---|
| 747 |
echo '<input type="radio" id="uninstall_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="uninstall" /> '. |
|---|
| 748 |
'<label for="uninstall_'.prep_id($name).'">'._CORE_UNINSTALL.'</label> <br />'; |
|---|
| 749 |
} |
|---|
| 750 |
break; |
|---|
| 751 |
default: |
|---|
| 752 |
// check for online upgrade |
|---|
| 753 |
if (isset($modules_online[$name]['version'])) { |
|---|
| 754 |
$vercomp = version_compare_freepbx($modules_local[$name]['version'], $modules_online[$name]['version']); |
|---|
| 755 |
if ($vercomp < 0) { |
|---|
| 756 |
if (!EXTERNAL_PACKAGE_MANAGEMENT) { |
|---|
| 757 |
echo '<input type="radio" id="upgrade_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="upgrade" /> '. |
|---|
| 758 |
'<label for="upgrade_'.prep_id($name).'">'.sprintf(_CORE_DOWNLOAD_UPGRADE, $modules_online[$name]['version']).'</label> <br />'; |
|---|
| 759 |
} |
|---|
| 760 |
} |
|---|
| 761 |
} |
|---|
| 762 |
if (enable_option($name,'candisable')) { |
|---|
| 763 |
echo '<input type="radio" id="disable_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="disable" /> '. |
|---|
| 764 |
'<label for="disable_'.prep_id($name).'">'._CORE_DISABLE.'</label> <br />'; |
|---|
| 765 |
} |
|---|
| 766 |
if (!EXTERNAL_PACKAGE_MANAGEMENT && enable_option($name,'canuninstall')) { |
|---|
| 767 |
echo '<input type="radio" id="uninstall_'.prep_id($name).'" name="moduleaction['.prep_id($name).']" value="uninstall" /> '. |
|---|
| 768 |
'<label for="uninstall_'.prep_id($name).'">'._CORE_UNINSTALL.'</label> <br />'; |
|---|
| 769 |
} |
|---|
| 770 |
break; |
|---|
| 771 |
} |
|---|
| 772 |
echo "\t\t\t\t</div>\n"; |
|---|
| 773 |
|
|---|
| 774 |
echo "\t\t\t\t<div class=\"tabbertab\" title=\""._CORE_DESCRIPTION."\">\n"; |
|---|
| 775 |
if (isset($modules[$name]['description']) && !empty($modules[$name]['description'])) { |
|---|
| 776 |
echo "<h5>".sprintf(_CORE_DESCRIPTION_VERSION,$modules[$name]['version'])."</h5>"; |
|---|
| 777 |
echo nl2br($modules[$name]['description']); |
|---|
| 778 |
} else { |
|---|
| 779 |
echo _CORE_NO_DESCRIPTION; |
|---|
| 780 |
} |
|---|
| 781 |
if (isset($modules[$name]['info']) && !empty($modules[$name]['info'])) { |
|---|
| 782 |
echo '<p>'._CORE_MORE_INFO.': <a href="'.$modules[$name]['info'].'" target="_new">'.$modules[$name]['info'].'</a></p>'; |
|---|
| 783 |
} else { |
|---|
| 784 |
echo '<p>'._CORE_MORE_INFO.': <a href="'."$freepbx_help_url&freepbx_module=".urlencode($name).'" target="help">Get help for '.$modules[$name]['name'].'</a></p>'; |
|---|
| 785 |
} |
|---|
| 786 |
echo "\t\t\t\t</div>\n"; |
|---|
| 787 |
|
|---|
| 788 |
if (isset($modules[$name]['changelog']) && !empty($modules[$name]['changelog'])) { |
|---|
| 789 |
echo "\t\t\t\t<div class=\"tabbertab\" title=\""._CORE_CHANGELOG."\">\n"; |
|---|
| 790 |
echo "<h5>".sprintf(_CORE_CHANGELOG_VERSION, $modules[$name]['version'])."</h5>"; |
|---|
| 791 |
// convert "1.x.x:" and "*1.x.x*" into bold, and do nl2br |
|---|
| 792 |
$changelog = nl2br($modules[$name]['changelog']); |
|---|
| 793 |
$changelog = preg_replace('/(\d+(\.\d+)+):/', '<strong>$0</strong>', $changelog); |
|---|
| 794 |
$changelog = preg_replace('/\*(\d+(\.\d+)+)\*/', '<strong>$1:</strong>', $changelog); |
|---|
| 795 |
echo $changelog; |
|---|
| 796 |
echo "\t\t\t\t</div>\n"; |
|---|
| 797 |
} |
|---|
| 798 |
|
|---|
| 799 |
if (isset($amp_conf['DEVEL']) && $amp_conf['DEVEL'] == 'true') { |
|---|
| 800 |
echo "\t\t\t\t<div class=\"tabbertab\" title=\""._CORE_DEBUG."\">\n"; |
|---|
| 801 |
echo "\t\t\t\t<h5>".$name."</h5><pre>\n"; |
|---|
| 802 |
print_r($modules_local[$name]); |
|---|
| 803 |
echo "</pre>"; |
|---|
| 804 |
if (isset($modules_online)) { |
|---|
| 805 |
echo "\t\t\t\t<h5>Online info</h5><pre>\n"; |
|---|
| 806 |
print_r($modules_online[$name]); |
|---|
| 807 |
echo "</pre>\n"; |
|---|
| 808 |
} |
|---|
| 809 |
echo "\t\t\t\t<h5>combined</h5><pre>\n"; |
|---|
| 810 |
print_r($modules[$name]); |
|---|
| 811 |
echo "</pre>\n"; |
|---|
| 812 |
echo "\t\t\t\t</div>\n"; |
|---|
| 813 |
} |
|---|
| 814 |
|
|---|
| 815 |
echo "\t\t\t</div>\n"; |
|---|
| 816 |
echo "\t\t</div>\n"; |
|---|
| 817 |
|
|---|
| 818 |
// ---- end of drop-down tab box |
|---|
| 819 |
|
|---|
| 820 |
echo "\t\t</li>\n"; |
|---|
| 821 |
} |
|---|
| 822 |
|
|---|
| 823 |
if ($numdisplayed == 0) { |
|---|
| 824 |
if (isset($modules_online) && count($modules_online) > 0) { |
|---|
| 825 |
echo _CORE_ALL_MODULES_UP_TO_DATE; |
|---|
| 826 |
} else { |
|---|
| 827 |
echo _CORE_NO_MODULES_DISPLAY; |
|---|
| 828 |
} |
|---|
| 829 |
} |
|---|
| 830 |
|
|---|
| 831 |
echo "\t</ul></div>\n"; |
|---|
| 832 |
echo "</div>"; |
|---|
| 833 |
|
|---|
| 834 |
echo "<div class=\"modulebuttons\">"; |
|---|
| 835 |
if ($online) { |
|---|
| 836 |
echo "\t<a href=\"javascript:void(null);\" onclick=\"check_download_all();\">"._CORE_DOWNLOAD_ALL."</a>"; |
|---|
| 837 |
echo "\t<a href=\"javascript:void(null);\" onclick=\"check_upgrade_all();\">"._CORE_UPGRADE_ALL."</a>"; |
|---|
| 838 |
} |
|---|
| 839 |
echo "\t<input type=\"reset\" value=\""._CORE_RESET."\" />"; |
|---|
| 840 |
echo "\t<input type=\"submit\" value=\""._CORE_PROCESS."\" name=\"process\" />"; |
|---|
| 841 |
echo "</div>"; |
|---|
| 842 |
|
|---|
| 843 |
echo "</form>"; |
|---|
| 844 |
break; |
|---|
| 845 |
} |
|---|
| 846 |
|
|---|
| 847 |
if ($quietmode) { |
|---|
| 848 |
echo '</body></html>'; |
|---|
| 849 |
} |
|---|
| 850 |
|
|---|
| 851 |
?> |
|---|