mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 18:18:46 +02:00
🎨 N°3566 Hub connector : code format
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
/**
|
||||
* Collect the configuration information to be posted to the hub
|
||||
*
|
||||
*
|
||||
* @return string[][]
|
||||
*/
|
||||
|
||||
@@ -104,17 +104,18 @@
|
||||
* Return a cleaned (i.e.
|
||||
* properly truncated) versin number from
|
||||
* a very long version number like "7.0.18-0unbuntu0-16.04.1"
|
||||
*
|
||||
*
|
||||
* @param string $sString
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function CleanVersionNumber($sString)
|
||||
{
|
||||
$aMatches = array();
|
||||
if (preg_match("|^([0-9\\.]+)-|", $sString, $aMatches))
|
||||
{
|
||||
if (preg_match("|^([0-9\\.]+)-|", $sString, $aMatches)) {
|
||||
return $aMatches[1];
|
||||
}
|
||||
|
||||
return $sString;
|
||||
}
|
||||
|
||||
@@ -123,260 +124,234 @@ function collect_configuration()
|
||||
$aConfiguration = array(
|
||||
'php' => array(),
|
||||
'mysql' => array(),
|
||||
'apache' => array()
|
||||
'apache' => array(),
|
||||
);
|
||||
|
||||
|
||||
// Database information
|
||||
$m_oMysqli = CMDBSource::GetMysqli();
|
||||
$aConfiguration['database_settings']['server'] = (string) $m_oMysqli->server_version;
|
||||
$aConfiguration['database_settings']['client'] = (string) $m_oMysqli->client_version;
|
||||
|
||||
$aConfiguration['database_settings']['server'] = (string)$m_oMysqli->server_version;
|
||||
$aConfiguration['database_settings']['client'] = (string)$m_oMysqli->client_version;
|
||||
|
||||
/** @var mysqli_result $resultSet */
|
||||
$result = CMDBSource::Query('SHOW VARIABLES LIKE "%max_allowed_packet%"');
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$row = $result->fetch_object();
|
||||
$aConfiguration['database_settings']['max_allowed_packet'] = (string) $row->Value;
|
||||
$aConfiguration['database_settings']['max_allowed_packet'] = (string)$row->Value;
|
||||
}
|
||||
|
||||
|
||||
/** @var mysqli_result $resultSet */
|
||||
$result = CMDBSource::Query('SHOW VARIABLES LIKE "%version_comment%"');
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$row = $result->fetch_object();
|
||||
if (preg_match('/mariadb/i', $row->Value))
|
||||
{
|
||||
if (preg_match('/mariadb/i', $row->Value)) {
|
||||
$aConfiguration['database_name'] = 'MariaDB';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Web server information
|
||||
if (function_exists('apache_get_version'))
|
||||
{
|
||||
if (function_exists('apache_get_version')) {
|
||||
$aConfiguration['web_server_name'] = 'apache';
|
||||
$aConfiguration['web_server_version'] = apache_get_version();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// The format of the variable $_SERVER["SERVER_SOFTWARE"] seems to be the following:
|
||||
// PHP 7 FPM with Apache on Ubuntu: "Apache/2.4.18 (Ubuntu)"
|
||||
// IIS 7.5 on Windows 7: "Microsoft-IIS/7.5"
|
||||
// Nginx with PHP FPM on Ubuntu: "nginx/1.10.0"
|
||||
$aConfiguration['web_server_name'] = substr($_SERVER["SERVER_SOFTWARE"], 0, strpos($_SERVER["SERVER_SOFTWARE"], '/'));
|
||||
$sWebServerVersion = trim(substr($_SERVER["SERVER_SOFTWARE"], 1+strpos($_SERVER["SERVER_SOFTWARE"], '/')));
|
||||
if ($sWebServerVersion == '')
|
||||
{
|
||||
$sWebServerVersion = trim(substr($_SERVER["SERVER_SOFTWARE"], 1 + strpos($_SERVER["SERVER_SOFTWARE"], '/')));
|
||||
if ($sWebServerVersion == '') {
|
||||
$sWebServerVersion = 'Unknown';
|
||||
}
|
||||
$aConfiguration['web_server_version'] = $sWebServerVersion;
|
||||
}
|
||||
|
||||
|
||||
// PHP extensions
|
||||
if (!MetaModel::GetConfig()->GetModuleSetting('itop-hub-connector', 'php_extensions_enable', true))
|
||||
{
|
||||
if (!MetaModel::GetConfig()->GetModuleSetting('itop-hub-connector', 'php_extensions_enable', true)) {
|
||||
$aConfiguration['php_extensions'] = array();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (get_loaded_extensions() as $extension)
|
||||
{
|
||||
} else {
|
||||
foreach (get_loaded_extensions() as $extension) {
|
||||
$aConfiguration['php_extensions'][$extension] = $extension;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Collect some PHP settings having a known impact on iTop
|
||||
$aIniGet = MetaModel::GetConfig()->GetModuleSetting('itop-hub-connector', 'php_settings_array', array()); // by default, on the time of the writting, it values are : array('post_max_size', 'upload_max_filesize', 'apc.enabled', 'timezone', 'memory_limit', 'max_execution_time');
|
||||
$aConfiguration['php_settings'] = array();
|
||||
foreach ($aIniGet as $iniGet)
|
||||
{
|
||||
$aConfiguration['php_settings'][$iniGet] = (string) ini_get($iniGet);
|
||||
foreach ($aIniGet as $iniGet) {
|
||||
$aConfiguration['php_settings'][$iniGet] = (string)ini_get($iniGet);
|
||||
}
|
||||
|
||||
|
||||
// iTop modules
|
||||
$oConfig = MetaModel::GetConfig();
|
||||
$sLatestInstallationDate = CMDBSource::QueryToScalar("SELECT max(installed) FROM ".$oConfig->Get('db_subname')."priv_module_install");
|
||||
// Get the latest installed modules, without the "root" ones (iTop version and datamodel version)
|
||||
$aInstalledModules = CMDBSource::QueryToArray("SELECT * FROM ".$oConfig->Get('db_subname')."priv_module_install WHERE installed = '".$sLatestInstallationDate."' AND parent_id != 0");
|
||||
|
||||
foreach ($aInstalledModules as $aDBInfo)
|
||||
{
|
||||
|
||||
foreach ($aInstalledModules as $aDBInfo) {
|
||||
$aConfiguration['itop_modules'][$aDBInfo['name']] = $aDBInfo['version'];
|
||||
}
|
||||
|
||||
|
||||
// iTop Installation Options, i.e. "Extensions"
|
||||
$oExtensionMap = new iTopExtensionsMap();
|
||||
$oExtensionMap->LoadChoicesFromDatabase($oConfig);
|
||||
$aConfiguration['itop_extensions'] = array();
|
||||
foreach ($oExtensionMap->GetChoices() as $oExtension)
|
||||
{
|
||||
switch ($oExtension->sSource)
|
||||
{
|
||||
foreach ($oExtensionMap->GetChoices() as $oExtension) {
|
||||
switch ($oExtension->sSource) {
|
||||
case iTopExtension::SOURCE_MANUAL:
|
||||
case iTopExtension::SOURCE_REMOTE:
|
||||
$aConfiguration['itop_extensions'][$oExtension->sCode] = array(
|
||||
'label' => $oExtension->sLabel,
|
||||
'value' => $oExtension->sInstalledVersion
|
||||
);
|
||||
break;
|
||||
|
||||
$aConfiguration['itop_extensions'][$oExtension->sCode] = array(
|
||||
'label' => $oExtension->sLabel,
|
||||
'value' => $oExtension->sInstalledVersion,
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
$aConfiguration['itop_installation_options'][$oExtension->sCode] = array(
|
||||
'label' => $oExtension->sLabel,
|
||||
'value' => true
|
||||
);
|
||||
$aConfiguration['itop_installation_options'][$oExtension->sCode] = array(
|
||||
'label' => $oExtension->sLabel,
|
||||
'value' => true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $aConfiguration;
|
||||
}
|
||||
|
||||
function MakeDataToPost($sTargetRoute)
|
||||
{
|
||||
if (MetaModel::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
if (MetaModel::GetConfig()->Get('demo_mode')) {
|
||||
// Don't expose such information in demo mode
|
||||
$aDataToPost = array('disabled' => true, 'reason' => 'demo_mode');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$aConfiguration = collect_configuration();
|
||||
|
||||
|
||||
$aDataToPost = array(
|
||||
'itop_hub_target_route' => $sTargetRoute,
|
||||
'itop_stack' => array(
|
||||
"uuidBdd" => (string) trim(DBProperty::GetProperty('database_uuid', ''), '{}'), // TODO check if empty and... regenerate a new UUID ??
|
||||
"uuidFile" => (string) trim(@file_get_contents(APPROOT."data/instance.txt"), "{} \n"), // TODO check if empty and... regenerate a new UUID ??
|
||||
'instance_friendly_name' => (string) $_SERVER['SERVER_NAME'],
|
||||
'instance_host' => (string) utils::GetAbsoluteUrlAppRoot(),
|
||||
'application_name' => (string) ITOP_APPLICATION,
|
||||
'application_version' => (string) ITOP_VERSION,
|
||||
'application_version_full' => (string) Dict::Format('UI:iTopVersion:Long', ITOP_APPLICATION, ITOP_VERSION, ITOP_REVISION, ITOP_BUILD_DATE),
|
||||
'itop_user_id' => (string) (UserRights::GetUserId()===null) ? "1" : UserRights::GetUserId(),
|
||||
'itop_user_lang' => (string) UserRights::GetUserLanguage(),
|
||||
'itop_modules' => (object) $aConfiguration['itop_modules'],
|
||||
'itop_extensions' => (object) $aConfiguration['itop_extensions'],
|
||||
'itop_installation_options' => (object) $aConfiguration['itop_installation_options']
|
||||
"uuidBdd" => (string)trim(DBProperty::GetProperty('database_uuid', ''), '{}'), // TODO check if empty and... regenerate a new UUID ??
|
||||
"uuidFile" => (string)trim(@file_get_contents(APPROOT."data/instance.txt"), "{} \n"), // TODO check if empty and... regenerate a new UUID ??
|
||||
'instance_friendly_name' => (string)$_SERVER['SERVER_NAME'],
|
||||
'instance_host' => (string)utils::GetAbsoluteUrlAppRoot(),
|
||||
'application_name' => (string)ITOP_APPLICATION,
|
||||
'application_version' => (string)ITOP_VERSION,
|
||||
'application_version_full' => (string)Dict::Format('UI:iTopVersion:Long', ITOP_APPLICATION, ITOP_VERSION, ITOP_REVISION, ITOP_BUILD_DATE),
|
||||
'itop_user_id' => (string)(UserRights::GetUserId() === null) ? "1" : UserRights::GetUserId(),
|
||||
'itop_user_lang' => (string)UserRights::GetUserLanguage(),
|
||||
'itop_modules' => (object)$aConfiguration['itop_modules'],
|
||||
'itop_extensions' => (object)$aConfiguration['itop_extensions'],
|
||||
'itop_installation_options' => (object)$aConfiguration['itop_installation_options'],
|
||||
),
|
||||
'server_stack' => array(
|
||||
'os_name' => (string) PHP_OS,
|
||||
'web_server_name' => (string) $aConfiguration['web_server_name'],
|
||||
'web_server_version' => (string) $aConfiguration['web_server_version'],
|
||||
'database_name' => (string) isset($aConfiguration['database_name']) ? $aConfiguration['database_name'] : 'MySQL', // if we do not detect MariaDB, we assume this is mysql
|
||||
'database_version' => (string) CMDBSource::GetDBVersion(),
|
||||
'database_settings' => (object) $aConfiguration['database_settings'],
|
||||
'php_version' => (string) CleanVersionNumber(phpversion()),
|
||||
'php_settings' => (object) $aConfiguration['php_settings'],
|
||||
'php_extensions' => (object) $aConfiguration['php_extensions']
|
||||
)
|
||||
'os_name' => (string)PHP_OS,
|
||||
'web_server_name' => (string)$aConfiguration['web_server_name'],
|
||||
'web_server_version' => (string)$aConfiguration['web_server_version'],
|
||||
'database_name' => (string)isset($aConfiguration['database_name']) ? $aConfiguration['database_name'] : 'MySQL', // if we do not detect MariaDB, we assume this is mysql
|
||||
'database_version' => (string)CMDBSource::GetDBVersion(),
|
||||
'database_settings' => (object)$aConfiguration['database_settings'],
|
||||
'php_version' => (string)CleanVersionNumber(phpversion()),
|
||||
'php_settings' => (object)$aConfiguration['php_settings'],
|
||||
'php_extensions' => (object)$aConfiguration['php_extensions'],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $aDataToPost;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
require_once (APPROOT.'/application/application.inc.php');
|
||||
require_once (APPROOT.'/application/itopwebpage.class.inc.php');
|
||||
require_once (APPROOT.'/setup/extensionsmap.class.inc.php');
|
||||
require_once ('hubconnectorpage.class.inc.php');
|
||||
|
||||
require_once (APPROOT.'/application/startup.inc.php');
|
||||
|
||||
try {
|
||||
require_once(APPROOT.'/application/application.inc.php');
|
||||
require_once(APPROOT.'/application/itopwebpage.class.inc.php');
|
||||
require_once(APPROOT.'/setup/extensionsmap.class.inc.php');
|
||||
require_once('hubconnectorpage.class.inc.php');
|
||||
|
||||
require_once(APPROOT.'/application/startup.inc.php');
|
||||
|
||||
$sTargetRoute = utils::ReadParam('target', ''); // ||browse_extensions|deploy_extensions|
|
||||
|
||||
if ($sTargetRoute != 'inform_after_setup')
|
||||
{
|
||||
require_once (APPROOT.'/application/loginwebpage.class.inc.php');
|
||||
|
||||
if ($sTargetRoute != 'inform_after_setup') {
|
||||
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
|
||||
LoginWebPage::DoLoginEx(null, true /* $bMustBeAdmin */); // Check user rights and prompt if needed
|
||||
}
|
||||
|
||||
|
||||
$sHubUrlStateless = MetaModel::GetModuleSetting('itop-hub-connector', 'url').MetaModel::GetModuleSetting('itop-hub-connector', 'route_landing_stateless');
|
||||
$sHubUrl = MetaModel::GetModuleSetting('itop-hub-connector', 'url').MetaModel::GetModuleSetting('itop-hub-connector', 'route_landing');
|
||||
|
||||
|
||||
// Display... or not... the page
|
||||
|
||||
switch ($sTargetRoute)
|
||||
{
|
||||
|
||||
switch ($sTargetRoute) {
|
||||
case 'inform_after_setup':
|
||||
// Hidden IFRAME at the end of the setup
|
||||
require_once (APPROOT.'/application/ajaxwebpage.class.inc.php');
|
||||
$oPage = new NiceWebPage('');
|
||||
$aDataToPost = MakeDataToPost($sTargetRoute);
|
||||
$oPage->add('<form id="hub_launch_form" action="'.$sHubUrlStateless.'" method="post">');
|
||||
$oPage->add('<input type="hidden" name="json" value="'.htmlentities(json_encode($aDataToPost), ENT_QUOTES, 'UTF-8').'">');
|
||||
$oPage->add_ready_script('$("#hub_launch_form").submit();');
|
||||
break;
|
||||
|
||||
// Hidden IFRAME at the end of the setup
|
||||
require_once(APPROOT.'/application/ajaxwebpage.class.inc.php');
|
||||
$oPage = new NiceWebPage('');
|
||||
$aDataToPost = MakeDataToPost($sTargetRoute);
|
||||
$oPage->add('<form id="hub_launch_form" action="'.$sHubUrlStateless.'" method="post">');
|
||||
$oPage->add('<input type="hidden" name="json" value="'.htmlentities(json_encode($aDataToPost), ENT_QUOTES, 'UTF-8').'">');
|
||||
$oPage->add_ready_script('$("#hub_launch_form").submit();');
|
||||
break;
|
||||
|
||||
default:
|
||||
// All other cases, special "Hub like" web page
|
||||
if ($sTargetRoute == 'view_dashboard')
|
||||
{
|
||||
$sTitle = Dict::S('Menu:iTopHub:Register');
|
||||
$sLabel = Dict::S('Menu:iTopHub:Register+');
|
||||
$sText = Dict::S('Menu:iTopHub:Register:Description');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sTitle = Dict::S('Menu:iTopHub:BrowseExtensions');
|
||||
$sLabel = Dict::S('Menu:iTopHub:BrowseExtensions+');
|
||||
$sText = Dict::S('Menu:iTopHub:BrowseExtensions:Description');
|
||||
}
|
||||
$sLogoUrl = utils::GetAbsoluteUrlModulesRoot().'/itop-hub-connector/images/itophub-logo.svg';
|
||||
$sArrowUrl = utils::GetAbsoluteUrlModulesRoot().'/itop-hub-connector/images/white-arrow-right.svg';
|
||||
$sCloseUrl = utils::GetAbsoluteUrlModulesRoot().'/itop-hub-connector/images/black-close.svg';
|
||||
|
||||
$oPage = new HubConnectorPage(Dict::S('iTopHub:Connect'));
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlModulesRoot().'itop-hub-connector/js/hub.js');
|
||||
$oPage->add_linked_stylesheet('../css/font-combodo/font-combodo.css');
|
||||
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlModulesRoot().'itop-hub-connector/css/hub.css');
|
||||
|
||||
$aDataToPost = MakeDataToPost($sTargetRoute);
|
||||
|
||||
if (MetaModel::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
$oPage->add("<div class=\"header_message message_info\">Sorry, iTop is in <b>demonstration mode</b>: the connection to iTop Hub is disabled.</div>");
|
||||
}
|
||||
|
||||
$oPage->add('<div id="hub_top_banner"></div>');
|
||||
$oPage->add('<div id="hub_launch_content">');
|
||||
$oPage->add('<div id="hub_launch_container">');
|
||||
$oPage->add('<div id="hub_launch_image">');
|
||||
$oPage->add(file_get_contents(__DIR__.'/images/rocket.svg'));
|
||||
$oPage->add('</div>');
|
||||
$oPage->add('<h1><img src="'.$sLogoUrl.'"><span>'.$sTitle.'</span></h1>');
|
||||
$oPage->add($sText);
|
||||
$oPage->add('<p><button type="button" id="CancelBtn" title="Go back to iTop"><img src="'.$sCloseUrl.'"><span>'.Dict::S('iTopHub:CloseBtn').'</span></button><span class="horiz-spacer"> </span><button class="positive" type="button" id="GoToHubBtn" title="'.Dict::S('iTopHub:GoBtn:Tooltip').'"><span>'.Dict::S('iTopHub:GoBtn').'</span><img src="'.$sArrowUrl.'"></button></p>');
|
||||
$sFormTarget = appUserPreferences::GetPref('itophub_open_in_new_window', 1) ? 'target="_blank"' : '';
|
||||
$oPage->add('<form '.$sFormTarget.' id="hub_launch_form" action="'.$sHubUrl.'" method="post">');
|
||||
$oPage->add('<input type="hidden" name="json" value="'.htmlentities(json_encode($aDataToPost), ENT_QUOTES, 'UTF-8').'">');
|
||||
|
||||
// $sNewWindowChecked = appUserPreferences::GetPref('itophub_open_in_new_window', 1) == 1 ? 'checked' : '';
|
||||
// $oPage->add('<p><input type="checkbox" class="userpref" id="itophub_open_in_new_window" '.$sNewWindowChecked.'><label for="itophub_open_in_new_window">'.Dict::S('iTopHub:OpenInNewWindow').'</label><br/>');
|
||||
|
||||
// Beware the combination auto-submit and open in new window (cf above) is blocked by (some) browsers (namely Chrome)
|
||||
$sAutoSubmitChecked = appUserPreferences::GetPref('itophub_auto_submit', 0)==1 ? 'checked' : '';
|
||||
$oPage->add('<input type="checkbox" class="userpref" id="itophub_auto_submit" '.$sAutoSubmitChecked.'><label for="itophub_auto_submit">'.Dict::S('iTopHub:AutoSubmit').'</label></p>');
|
||||
$oPage->add('</form>');
|
||||
$oPage->add('<div style="clear:both"></div>');
|
||||
$oPage->add('</div>');
|
||||
$oPage->add('</div>');
|
||||
|
||||
$oPage->add_ready_script('$(".userpref").on("click", function() { var value = $(this).prop("checked") ? 1 : 0; var code = $(this).attr("id"); SetUserPreference(code, value, true); });');
|
||||
if (MetaModel::GetConfig()->Get('demo_mode'))
|
||||
{
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
// All other cases, special "Hub like" web page
|
||||
if ($sTargetRoute == 'view_dashboard') {
|
||||
$sTitle = Dict::S('Menu:iTopHub:Register');
|
||||
$sLabel = Dict::S('Menu:iTopHub:Register+');
|
||||
$sText = Dict::S('Menu:iTopHub:Register:Description');
|
||||
} else {
|
||||
$sTitle = Dict::S('Menu:iTopHub:BrowseExtensions');
|
||||
$sLabel = Dict::S('Menu:iTopHub:BrowseExtensions+');
|
||||
$sText = Dict::S('Menu:iTopHub:BrowseExtensions:Description');
|
||||
}
|
||||
$sLogoUrl = utils::GetAbsoluteUrlModulesRoot().'/itop-hub-connector/images/itophub-logo.svg';
|
||||
$sArrowUrl = utils::GetAbsoluteUrlModulesRoot().'/itop-hub-connector/images/white-arrow-right.svg';
|
||||
$sCloseUrl = utils::GetAbsoluteUrlModulesRoot().'/itop-hub-connector/images/black-close.svg';
|
||||
|
||||
$oPage = new HubConnectorPage(Dict::S('iTopHub:Connect'));
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlModulesRoot().'itop-hub-connector/js/hub.js');
|
||||
$oPage->add_linked_stylesheet('../css/font-combodo/font-combodo.css');
|
||||
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlModulesRoot().'itop-hub-connector/css/hub.css');
|
||||
|
||||
$aDataToPost = MakeDataToPost($sTargetRoute);
|
||||
|
||||
if (MetaModel::GetConfig()->Get('demo_mode')) {
|
||||
$oPage->add("<div class=\"header_message message_info\">Sorry, iTop is in <b>demonstration mode</b>: the connection to iTop Hub is disabled.</div>");
|
||||
}
|
||||
|
||||
$oPage->add('<div id="hub_top_banner"></div>');
|
||||
$oPage->add('<div id="hub_launch_content">');
|
||||
$oPage->add('<div id="hub_launch_container">');
|
||||
$oPage->add('<div id="hub_launch_image">');
|
||||
$oPage->add(file_get_contents(__DIR__.'/images/rocket.svg'));
|
||||
$oPage->add('</div>');
|
||||
$oPage->add('<h1><img src="'.$sLogoUrl.'"><span>'.$sTitle.'</span></h1>');
|
||||
$oPage->add($sText);
|
||||
$oPage->add('<p><button type="button" id="CancelBtn" title="Go back to iTop"><img src="'.$sCloseUrl.'"><span>'.Dict::S('iTopHub:CloseBtn').'</span></button><span class="horiz-spacer"> </span><button class="positive" type="button" id="GoToHubBtn" title="'.Dict::S('iTopHub:GoBtn:Tooltip').'"><span>'.Dict::S('iTopHub:GoBtn').'</span><img src="'.$sArrowUrl.'"></button></p>');
|
||||
$sFormTarget = appUserPreferences::GetPref('itophub_open_in_new_window', 1) ? 'target="_blank"' : '';
|
||||
$oPage->add('<form '.$sFormTarget.' id="hub_launch_form" action="'.$sHubUrl.'" method="post">');
|
||||
$oPage->add('<input type="hidden" name="json" value="'.htmlentities(json_encode($aDataToPost), ENT_QUOTES, 'UTF-8').'">');
|
||||
|
||||
// $sNewWindowChecked = appUserPreferences::GetPref('itophub_open_in_new_window', 1) == 1 ? 'checked' : '';
|
||||
// $oPage->add('<p><input type="checkbox" class="userpref" id="itophub_open_in_new_window" '.$sNewWindowChecked.'><label for="itophub_open_in_new_window">'.Dict::S('iTopHub:OpenInNewWindow').'</label><br/>');
|
||||
|
||||
// Beware the combination auto-submit and open in new window (cf above) is blocked by (some) browsers (namely Chrome)
|
||||
$sAutoSubmitChecked = appUserPreferences::GetPref('itophub_auto_submit', 0) == 1 ? 'checked' : '';
|
||||
$oPage->add('<input type="checkbox" class="userpref" id="itophub_auto_submit" '.$sAutoSubmitChecked.'><label for="itophub_auto_submit">'.Dict::S('iTopHub:AutoSubmit').'</label></p>');
|
||||
$oPage->add('</form>');
|
||||
$oPage->add('<div style="clear:both"></div>');
|
||||
$oPage->add('</div>');
|
||||
$oPage->add('</div>');
|
||||
|
||||
$oPage->add_ready_script('$(".userpref").on("click", function() { var value = $(this).prop("checked") ? 1 : 0; var code = $(this).attr("id"); SetUserPreference(code, value, true); });');
|
||||
if (MetaModel::GetConfig()->Get('demo_mode')) {
|
||||
$oPage->add_ready_script(
|
||||
<<<JS
|
||||
$("#GoToHubBtn").prop('disabled', true);
|
||||
$("#itophub_auto_submit").prop('disabled', true).prop('checked', false);
|
||||
$("#CancelBtn").on("click", function() {
|
||||
window.history.back();
|
||||
});
|
||||
EOF
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
JS
|
||||
);
|
||||
} else {
|
||||
$oPage->add_ready_script(
|
||||
<<<JS
|
||||
$("#GoToHubBtn").on("click", function() {
|
||||
$(this).prop('disabled', true);
|
||||
$("#hub_launch_image").addClass("animate");
|
||||
@@ -393,38 +368,33 @@ $("#GoToHubBtn").on("click", function() {
|
||||
$("#CancelBtn").on("click", function() {
|
||||
window.history.back();
|
||||
});
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
if (appUserPreferences::GetPref('itophub_auto_submit', 0) == 1)
|
||||
{
|
||||
$oPage->add_ready_script('$("#GoToHubBtn").trigger("click");');
|
||||
}
|
||||
|
||||
if (utils::ReadParam('show-json', false))
|
||||
{
|
||||
$oPage->add('<h1>DEBUG : json</h1>');
|
||||
$oPage->add('<pre class="wizContainer">'.json_encode($aDataToPost, JSON_PRETTY_PRINT).'</pre>');
|
||||
}
|
||||
JS
|
||||
);
|
||||
}
|
||||
|
||||
if (appUserPreferences::GetPref('itophub_auto_submit', 0) == 1) {
|
||||
$oPage->add_ready_script('$("#GoToHubBtn").trigger("click");');
|
||||
}
|
||||
|
||||
if (utils::ReadParam('show-json', false)) {
|
||||
$oPage->add('<h1>DEBUG : json</h1>');
|
||||
$oPage->add('<pre class="wizContainer">'.json_encode($aDataToPost, JSON_PRETTY_PRINT).'</pre>');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$oPage->output();
|
||||
}
|
||||
catch (CoreException $e)
|
||||
{
|
||||
require_once (APPROOT.'/setup/setuppage.class.inc.php');
|
||||
catch (CoreException $e) {
|
||||
require_once(APPROOT.'/setup/setuppage.class.inc.php');
|
||||
$oP = new ErrorPage(Dict::S('UI:PageTitle:FatalError'));
|
||||
$oP->add("<h1>".Dict::S('UI:FatalErrorMessage')."</h1>\n");
|
||||
$oP->error(Dict::Format('UI:Error_Details', $e->getHtmlDesc()));
|
||||
$oP->output();
|
||||
|
||||
if (MetaModel::IsLogEnabledIssue())
|
||||
{
|
||||
if (MetaModel::IsValidClass('EventIssue'))
|
||||
{
|
||||
|
||||
if (MetaModel::IsLogEnabledIssue()) {
|
||||
if (MetaModel::IsValidClass('EventIssue')) {
|
||||
$oLog = new EventIssue();
|
||||
|
||||
|
||||
$oLog->Set('message', $e->getMessage());
|
||||
$oLog->Set('userinfo', '');
|
||||
$oLog->Set('issue', $e->GetIssue());
|
||||
@@ -433,27 +403,24 @@ catch (CoreException $e)
|
||||
$oLog->Set('data', $e->getContextData());
|
||||
$oLog->DBInsertNoReload();
|
||||
}
|
||||
|
||||
|
||||
IssueLog::Error($e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
// For debugging only
|
||||
// throw $e;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
require_once (APPROOT.'/setup/setuppage.class.inc.php');
|
||||
catch (Exception $e) {
|
||||
require_once(APPROOT.'/setup/setuppage.class.inc.php');
|
||||
$oP = new ErrorPage(Dict::S('UI:PageTitle:FatalError'));
|
||||
$oP->add("<h1>".Dict::S('UI:FatalErrorMessage')."</h1>\n");
|
||||
$oP->error(Dict::Format('UI:Error_Details', $e->getMessage()));
|
||||
$oP->output();
|
||||
|
||||
if (MetaModel::IsLogEnabledIssue())
|
||||
{
|
||||
if (MetaModel::IsValidClass('EventIssue'))
|
||||
{
|
||||
|
||||
if (MetaModel::IsLogEnabledIssue()) {
|
||||
if (MetaModel::IsValidClass('EventIssue')) {
|
||||
$oLog = new EventIssue();
|
||||
|
||||
|
||||
$oLog->Set('message', $e->getMessage());
|
||||
$oLog->Set('userinfo', '');
|
||||
$oLog->Set('issue', 'PHP Exception');
|
||||
@@ -462,7 +429,7 @@ catch (Exception $e)
|
||||
$oLog->Set('data', array());
|
||||
$oLog->DBInsertNoReload();
|
||||
}
|
||||
|
||||
|
||||
IssueLog::Error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
require_once ('../approot.inc.php');
|
||||
require_once (APPROOT.'/application/application.inc.php');
|
||||
require_once (APPROOT.'/application/itopwebpage.class.inc.php');
|
||||
require_once (APPROOT.'setup/extensionsmap.class.inc.php');
|
||||
require_once('../approot.inc.php');
|
||||
require_once(APPROOT.'/application/application.inc.php');
|
||||
require_once(APPROOT.'/application/itopwebpage.class.inc.php');
|
||||
require_once(APPROOT.'setup/extensionsmap.class.inc.php');
|
||||
|
||||
require_once (APPROOT.'/application/startup.inc.php');
|
||||
require_once(APPROOT.'/application/startup.inc.php');
|
||||
|
||||
require_once (APPROOT.'/application/loginwebpage.class.inc.php');
|
||||
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
|
||||
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
|
||||
|
||||
$oAppContext = new ApplicationContext();
|
||||
@@ -35,12 +35,9 @@ $oPage->SetBreadCrumbEntry('ui-hub-myextensions', Dict::S('Menu:iTopHub:MyExtens
|
||||
function DisplayExtensionInfo(Webpage $oPage, iTopExtension $oExtension)
|
||||
{
|
||||
$oPage->add('<li>');
|
||||
if ($oExtension->sInstalledVersion == '')
|
||||
{
|
||||
if ($oExtension->sInstalledVersion == '') {
|
||||
$oPage->add('<b>'.$oExtension->sLabel.'</b> '.Dict::Format('UI:About:Extension_Version', $oExtension->sVersion).' <span class="extension-source">'.Dict::S('iTopHub:ExtensionNotInstalled').'</span>');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$oPage->add('<b>'.$oExtension->sLabel.'</b> '.Dict::Format('UI:About:Extension_Version', $oExtension->sInstalledVersion));
|
||||
}
|
||||
$oPage->add('<p style="margin-top: 0.25em;">'.$oExtension->sDescription.'</p>');
|
||||
@@ -48,29 +45,25 @@ function DisplayExtensionInfo(Webpage $oPage, iTopExtension $oExtension)
|
||||
}
|
||||
|
||||
// Main program
|
||||
try
|
||||
{
|
||||
try {
|
||||
$oExtensionsMap = new iTopExtensionsMap();
|
||||
$oExtensionsMap->LoadChoicesFromDatabase(MetaModel::GetConfig());
|
||||
|
||||
|
||||
$oPage->add('<h1>'.Dict::S('iTopHub:InstalledExtensions').'</h1>');
|
||||
|
||||
|
||||
$oPage->add('<fieldset>');
|
||||
$oPage->add('<legend>'.Dict::S('iTopHub:ExtensionCategory:Remote').'</legend>');
|
||||
$oPage->p(Dict::S('iTopHub:ExtensionCategory:Remote+'));
|
||||
$oPage->add('<ul style="margin: 0;">');
|
||||
$iCount = 0;
|
||||
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension)
|
||||
{
|
||||
if ($oExtension->sSource == iTopExtension::SOURCE_REMOTE)
|
||||
{
|
||||
$iCount++ ;
|
||||
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) {
|
||||
if ($oExtension->sSource == iTopExtension::SOURCE_REMOTE) {
|
||||
$iCount++;
|
||||
DisplayExtensionInfo($oPage, $oExtension);
|
||||
}
|
||||
}
|
||||
$oPage->add('</ul>');
|
||||
if ($iCount == 0)
|
||||
{
|
||||
if ($iCount == 0) {
|
||||
$oPage->p(Dict::S('iTopHub:NoExtensionInThisCategory'));
|
||||
}
|
||||
$oPage->add('</fieldset>');
|
||||
@@ -79,45 +72,39 @@ try
|
||||
|
||||
// Display the section about "manually deployed" extensions, only if there are some already
|
||||
$iCount = 0;
|
||||
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension)
|
||||
{
|
||||
if ($oExtension->sSource == iTopExtension::SOURCE_MANUAL)
|
||||
{
|
||||
$iCount++ ;
|
||||
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) {
|
||||
if ($oExtension->sSource == iTopExtension::SOURCE_MANUAL) {
|
||||
$iCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($iCount > 0)
|
||||
{
|
||||
|
||||
if ($iCount > 0) {
|
||||
$oPage->add('<fieldset>');
|
||||
$oPage->add('<legend>'.Dict::S('iTopHub:ExtensionCategory:Manual').'</legend>');
|
||||
$oPage->p(Dict::Format('iTopHub:ExtensionCategory:Manual+', '<span title="'.(APPROOT.'extensions').'" id="extension-dir-path">"extensions"</span>'));
|
||||
$oPage->add('<ul style="margin: 0;">');
|
||||
$iCount = 0;
|
||||
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension)
|
||||
{
|
||||
if ($oExtension->sSource == iTopExtension::SOURCE_MANUAL)
|
||||
{
|
||||
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) {
|
||||
if ($oExtension->sSource == iTopExtension::SOURCE_MANUAL) {
|
||||
DisplayExtensionInfo($oPage, $oExtension);
|
||||
}
|
||||
}
|
||||
$oPage->add('</ul>');
|
||||
}
|
||||
|
||||
|
||||
$oPage->add('</fieldset>');
|
||||
$sExtensionsDirTooltip = json_encode(APPROOT.'extensions');
|
||||
$oPage->add_style(
|
||||
<<<EOF
|
||||
<<<CSS
|
||||
#extension-dir-path {
|
||||
display: inline-block;
|
||||
border-bottom: 1px #999 dashed;
|
||||
cursor: help;
|
||||
}
|
||||
EOF
|
||||
CSS
|
||||
);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
catch (Exception $e) {
|
||||
$oPage->p('<b>'.Dict::Format('UI:Error_Details', $e->getMessage()).'</b>');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user