$json_array['status'] = true; } header("Content-type: application/json"); echo json_encode($json_array); exit; } $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : ''; global $active_repos; $loc_domain = 'amp'; if (isset($_REQUEST['check_online'])) { $online = 1; $active_repos = $_REQUEST['active_repos']; module_set_active_repos($active_repos); } else { $online = isset($_REQUEST['online']) && $_REQUEST['online'] && !EXTERNAL_PACKAGE_MANAGEMENT ? 1 : 0; $active_repos = module_get_active_repos(); } // fix php errors from undefined variable. Not sure if we can just change the reference below to use // online since it changes values so just setting to what we decided it is here. $moduleaction = isset($_REQUEST['moduleaction']) ? $_REQUEST['moduleaction'] : false; /* moduleaction is an array with the key as the module name, and possible values: downloadinstall - download and install (used when a module is not locally installed) upgrade - download and install (used when a module is locally installed) install - install/upgrade locally available module enable - enable local module disable - disable local module uninstall - uninstall local module */ $freepbx_version = get_framework_version();
/** Determines if there are updates we don't already know about and posts to notification * server about those updates. * */ function module_update_notifications(&$old_xml, &$xmlarray, $passive) { global $db; $notifications =& notifications::create($db); $reset_value = $passive ? 'PASSIVE' : false; $old_parser = new xml2ModuleArray($old_xml); $old_xmlarray = $old_parser->parseAdvanced($old_xml); $new_modules = array(); if (count($xmlarray)) { foreach ($xmlarray['xml']['module'] as $mod) { $new_modules[$mod['rawname']] = $mod; } } $old_modules = array(); if (count($old_xmlarray)) { foreach ($old_xmlarray['xml']['module'] as $mod) { $old_modules[$mod['rawname']] = $mod; } } // If keys (rawnames) are different then there are new modules, create a notification. // This will always be the case the first time it is run since the xml is empty. // $diff_modules = array_diff_key($new_modules, $old_modules); $cnt = count($diff_modules); if ($cnt) { $active_repos = module_get_active_repos(); $extext = _("The following new modules are available for download. Click delete icon on the right to remove this notice.") . "<br />"; foreach ($diff_modules as $modname) { $mod = $new_modules[$modname]; // If it's a new module in a repo we are not interested in, then don't send a notification. if (isset($active_repos[$mod['repo']]) && $active_repos[$mod['repo']]) { $extext .= $mod['rawname'] . " (" . $mod['version'] . ")<br />"; } else { $cnt--; } } if ($cnt) { $notifications->add_notice('freepbx', 'NEWMODS', sprintf(_('%s New modules are available'), $cnt), $extext, '', $reset_value, true); } } // Now check if any of the installed modules need updating // module_upgrade_notifications($new_modules, $reset_value); }