mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
some changes in discovery
This commit is contained in:
parent
08e514e12c
commit
457f8e9448
@ -219,7 +219,7 @@ class Applications extends Wizard
|
|||||||
'class' => 'agent_details_line',
|
'class' => 'agent_details_line',
|
||||||
'content' => ui_toggle(
|
'content' => ui_toggle(
|
||||||
Wizard::printBigButtonsList($not_defined_extensions, true),
|
Wizard::printBigButtonsList($not_defined_extensions, true),
|
||||||
'<span class="subsection_header_title">'.__('Not defined applications').'</span>',
|
'<span class="subsection_header_title">'.__('Not installed').'</span>',
|
||||||
'not_defined_apps',
|
'not_defined_apps',
|
||||||
'not_defined_apps',
|
'not_defined_apps',
|
||||||
false,
|
false,
|
||||||
|
@ -239,7 +239,7 @@ class Cloud extends Wizard
|
|||||||
'class' => 'agent_details_line',
|
'class' => 'agent_details_line',
|
||||||
'content' => ui_toggle(
|
'content' => ui_toggle(
|
||||||
Wizard::printBigButtonsList($not_defined_extensions, true),
|
Wizard::printBigButtonsList($not_defined_extensions, true),
|
||||||
'<span class="subsection_header_title">'.__('Not defined applications').'</span>',
|
'<span class="subsection_header_title">'.__('Not installed').'</span>',
|
||||||
'not_defined_apps',
|
'not_defined_apps',
|
||||||
'not_defined_apps',
|
'not_defined_apps',
|
||||||
false,
|
false,
|
||||||
|
@ -142,7 +142,7 @@ class Custom extends Wizard
|
|||||||
'class' => 'agent_details_line',
|
'class' => 'agent_details_line',
|
||||||
'content' => ui_toggle(
|
'content' => ui_toggle(
|
||||||
Wizard::printBigButtonsList($not_defined_extensions, true),
|
Wizard::printBigButtonsList($not_defined_extensions, true),
|
||||||
'<span class="subsection_header_title">'.__('Not defined applications').'</span>',
|
'<span class="subsection_header_title">'.__('Not installed').'</span>',
|
||||||
'not_defined_apps',
|
'not_defined_apps',
|
||||||
'not_defined_apps',
|
'not_defined_apps',
|
||||||
false,
|
false,
|
||||||
|
@ -697,6 +697,9 @@ class ManageExtensions extends HTML
|
|||||||
$order,
|
$order,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$appsMetadata = self::loadDiscoveryAppsMetadata();
|
||||||
|
$flattenMetadata = array_merge(...array_values($appsMetadata));
|
||||||
|
|
||||||
$count = db_get_num_rows($sqlCount);
|
$count = db_get_num_rows($sqlCount);
|
||||||
|
|
||||||
foreach ($data as $key => $row) {
|
foreach ($data as $key => $row) {
|
||||||
@ -705,6 +708,15 @@ class ManageExtensions extends HTML
|
|||||||
$logo = $this->defaultLogo;
|
$logo = $this->defaultLogo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$metadataImage = $flattenMetadata[$row['short_name']]['image'];
|
||||||
|
|
||||||
|
if (isset($metadataImage) === true
|
||||||
|
&& file_exists($config['homedir'].'/images/discovery/'.$metadataImage) === true
|
||||||
|
&& file_exists($this->path.'/'.$row['short_name'].'/logo.png') === false
|
||||||
|
) {
|
||||||
|
$logo = '/images/discovery/'.$metadataImage;
|
||||||
|
}
|
||||||
|
|
||||||
$logo = html_print_image($logo, true, ['style' => 'max-width: 30px; margin-right: 15px;']);
|
$logo = html_print_image($logo, true, ['style' => 'max-width: 30px; margin-right: 15px;']);
|
||||||
$data[$key]['name'] = $logo.io_safe_output($row['name']);
|
$data[$key]['name'] = $logo.io_safe_output($row['name']);
|
||||||
$data[$key]['short_name'] = $row['short_name'];
|
$data[$key]['short_name'] = $row['short_name'];
|
||||||
@ -1490,4 +1502,55 @@ class ManageExtensions extends HTML
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read metadata CSV from system and store data structure in memory.
|
||||||
|
*
|
||||||
|
* @return array Data structure.
|
||||||
|
*/
|
||||||
|
private static function loadDiscoveryAppsMetadata()
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
// Open the CSV file for reading.
|
||||||
|
$fileHandle = fopen($config['homedir'].'/extras/discovery/DiscoveryApps.csv', 'r');
|
||||||
|
|
||||||
|
// Check if the file was opened successfully.
|
||||||
|
if ($fileHandle !== false) {
|
||||||
|
$csvData = [];
|
||||||
|
|
||||||
|
// Loop through each line in the CSV file.
|
||||||
|
while (($data = fgetcsv($fileHandle)) !== false) {
|
||||||
|
$csvData[] = explode(';', $data[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the file handle.
|
||||||
|
fclose($fileHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
$groupedArray = [];
|
||||||
|
|
||||||
|
foreach ($csvData as $item) {
|
||||||
|
$key = $item[2];
|
||||||
|
if (isset($groupedArray[$key]) === false) {
|
||||||
|
$groupedArray[$key] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemShortName = $item[0];
|
||||||
|
unset($item[0]);
|
||||||
|
unset($item[2]);
|
||||||
|
|
||||||
|
$itemIns = [
|
||||||
|
'name' => $item[1],
|
||||||
|
'enterprise' => $item[3],
|
||||||
|
'image' => $item[4],
|
||||||
|
'url' => $item[5],
|
||||||
|
];
|
||||||
|
|
||||||
|
$groupedArray[$key][$itemShortName] = $itemIns;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groupedArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -224,37 +224,32 @@ class ExtensionsDiscovery extends Wizard
|
|||||||
|
|
||||||
// Print JS required for message management.
|
// Print JS required for message management.
|
||||||
echo '<script>
|
echo '<script>
|
||||||
function sanitizeHTML(input) {
|
function showExtensionMsg(msgs, url, title) {
|
||||||
var doc = new DOMParser().parseFromString(input, "text/html");
|
|
||||||
return doc.body.textContent || "";
|
|
||||||
}
|
|
||||||
|
|
||||||
function showExtensionMsg(msgs, url) {
|
|
||||||
var msgs_json = JSON.parse(msgs);
|
var msgs_json = JSON.parse(msgs);
|
||||||
|
|
||||||
var url_str = "";
|
var url_str = "";
|
||||||
if (url != false) {
|
if (url != false) {
|
||||||
url_str = `<a href="${url}">'.__('here').'</a>`;
|
url_str = `<a target="_blank" class="link-important" href="${url}">'.__('here').'</a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
var markup = "<ul>";
|
var markup = "<ul class=\'\'>";
|
||||||
|
|
||||||
if (msgs_json.includes('.NOT_FOUND_MSG.')) {
|
if (msgs_json.includes('.NOT_FOUND_MSG.')) {
|
||||||
markup += "<li>'.__('The required files for the application were not found').'</li>";
|
markup += "<li> '.__('The required files for the application were not found.').'</li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgs_json.includes('.ENTERPRISE_MSG.')) {
|
if (msgs_json.includes('.ENTERPRISE_MSG.')) {
|
||||||
markup += "<li>'.__('This discovery application is for Enterprise customers only').'</li>";
|
markup += "<li> '.__('This discovery application is for Enterprise customers only.').'</li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgs_json.includes('.URL_MSG.')) {
|
if (msgs_json.includes('.URL_MSG.')) {
|
||||||
markup += \'<li>'.__('You can download this application from').' \'+url_str+\'</li>\';
|
markup += \'<li> '.__('You can download this application from').' \'+url_str+\'.</li>\';
|
||||||
}
|
}
|
||||||
|
|
||||||
markup += "</ul>";
|
markup += "</ul>";
|
||||||
|
|
||||||
confirmDialog({
|
confirmDialog({
|
||||||
title: "'.__('Warning').'",
|
title: title,
|
||||||
message: markup,
|
message: markup,
|
||||||
hideOkButton: true,
|
hideOkButton: true,
|
||||||
ok: "'.__('OK').'",
|
ok: "'.__('OK').'",
|
||||||
@ -279,22 +274,26 @@ class ExtensionsDiscovery extends Wizard
|
|||||||
|
|
||||||
$error_msgs = [];
|
$error_msgs = [];
|
||||||
|
|
||||||
|
if (isset($val['image']) === true
|
||||||
|
&& file_exists($config['homedir'].'/images/discovery/'.$val['image']) === true
|
||||||
|
&& file_exists($config['homedir'].$this->path.'/'.$short_name.'/'.$val['image']) === false
|
||||||
|
) {
|
||||||
|
$logo = '/images/discovery/'.$val['image'];
|
||||||
|
}
|
||||||
|
|
||||||
$url = ui_get_full_url(
|
$url = ui_get_full_url(
|
||||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz='.$this->section.'&mode='.$extension['short_name']
|
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz='.$this->section.'&mode='.$extension['short_name']
|
||||||
);
|
);
|
||||||
|
|
||||||
if (self::iniFileExists($short_name) === false) {
|
|
||||||
// Set ghost mode and display not found message if ini file does not exist for extension.
|
|
||||||
$error_msgs[] = NOT_FOUND_MSG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enterprise_installed() === false && ((bool) $val['enterprise'] === true)) {
|
if (enterprise_installed() === false && ((bool) $val['enterprise'] === true)) {
|
||||||
// Display enterprise message if console is open and extension is enterprise.
|
// Display enterprise message if console is open and extension is enterprise.
|
||||||
$error_msgs[] = ENTERPRISE_MSG;
|
$error_msgs[] = ENTERPRISE_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
$url_href = false;
|
$url_href = false;
|
||||||
if (isset($val['url']) === true && $val['url'] !== '') {
|
if (isset($val['url']) === true
|
||||||
|
&& $val['url'] !== ''
|
||||||
|
) {
|
||||||
$url_href = $val['url'];
|
$url_href = $val['url'];
|
||||||
// Display URL message if an URL is defined in the metadata.
|
// Display URL message if an URL is defined in the metadata.
|
||||||
$error_msgs[] = URL_MSG;
|
$error_msgs[] = URL_MSG;
|
||||||
@ -303,7 +302,7 @@ class ExtensionsDiscovery extends Wizard
|
|||||||
if (empty($error_msgs) === false) {
|
if (empty($error_msgs) === false) {
|
||||||
$json_errors = json_encode($error_msgs);
|
$json_errors = json_encode($error_msgs);
|
||||||
// Display messages dialog if there are some.
|
// Display messages dialog if there are some.
|
||||||
$url = 'javascript: showExtensionMsg(\''.$json_errors.'\', \''.$url_href.'\');';
|
$url = 'javascript: showExtensionMsg(\''.$json_errors.'\', \''.$url_href.'\', \''.io_safe_input($val['name']).'\');';
|
||||||
}
|
}
|
||||||
|
|
||||||
$extensions[] = [
|
$extensions[] = [
|
||||||
@ -319,6 +318,7 @@ class ExtensionsDiscovery extends Wizard
|
|||||||
} else {
|
} else {
|
||||||
foreach ($rows as $key => $extension) {
|
foreach ($rows as $key => $extension) {
|
||||||
$error_msgs = [];
|
$error_msgs = [];
|
||||||
|
|
||||||
$logo = $this->path.'/'.$extension['short_name'].'/'.$this->icon;
|
$logo = $this->path.'/'.$extension['short_name'].'/'.$this->icon;
|
||||||
if (file_exists($config['homedir'].$logo) === false) {
|
if (file_exists($config['homedir'].$logo) === false) {
|
||||||
$logo = $this->defaultLogo;
|
$logo = $this->defaultLogo;
|
||||||
@ -331,33 +331,53 @@ class ExtensionsDiscovery extends Wizard
|
|||||||
);
|
);
|
||||||
$url_href = false;
|
$url_href = false;
|
||||||
|
|
||||||
|
$iniFileExists = self::iniFileExists($extension['short_name']);
|
||||||
|
|
||||||
// Access metadata for current extension.
|
// Access metadata for current extension.
|
||||||
if (isset($sectionMetadata[$extension['short_name']]) === true) {
|
if (isset($sectionMetadata[$extension['short_name']]) === true) {
|
||||||
$itemData = $sectionMetadata[$extension['short_name']];
|
$itemData = $sectionMetadata[$extension['short_name']];
|
||||||
$mark_as_enterprise = (bool) $itemData['enterprise'];
|
|
||||||
if (isset($itemData['url']) === true && $itemData['url'] !== '') {
|
if (isset($itemData) === true) {
|
||||||
$url_href = $itemData['url'];
|
if (isset($itemData['image']) === true
|
||||||
// Display URL message if an URL is defined in the metadata.
|
&& file_exists($config['homedir'].'/images/discovery/'.$itemData['image']) === true
|
||||||
$error_msgs[] = URL_MSG;
|
&& file_exists($config['homedir'].$this->path.'/'.$extension['short_name'].'/'.$this->icon) === false
|
||||||
|
) {
|
||||||
|
$logo = '/images/discovery/'.$itemData['image'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$mark_as_enterprise = (bool) $itemData['enterprise'];
|
||||||
|
|
||||||
|
if ($iniFileExists === false
|
||||||
|
&& isset($itemData['url']) === true
|
||||||
|
&& $itemData['url'] !== ''
|
||||||
|
) {
|
||||||
|
$url_href = $itemData['url'];
|
||||||
|
// Display URL message if an URL is defined in the metadata.
|
||||||
|
$error_msgs[] = URL_MSG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enterprise_installed() === false
|
||||||
|
&& (bool) $itemData['enterprise'] === true
|
||||||
|
) {
|
||||||
|
// Set ghost mode and display enterprise message if console is open and extension is enterprise.
|
||||||
|
$error_msgs[] = ENTERPRISE_MSG;
|
||||||
|
$ghostMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemName = $itemData['name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::iniFileExists($extension['short_name']) === false) {
|
if ($iniFileExists === false) {
|
||||||
// Set ghost mode and display not found message if ini file does not exist for extension.
|
// Set ghost mode and display not found message if ini file does not exist for extension.
|
||||||
$error_msgs[] = NOT_FOUND_MSG;
|
$error_msgs[] = NOT_FOUND_MSG;
|
||||||
$ghostMode = true;
|
$ghostMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enterprise_installed() === false && ((bool) $itemData['enterprise'] === true)) {
|
|
||||||
// Set ghost mode and display enterprise message if console is open and extension is enterprise.
|
|
||||||
$error_msgs[] = ENTERPRISE_MSG;
|
|
||||||
$ghostMode = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($error_msgs) === false) {
|
if (empty($error_msgs) === false) {
|
||||||
$json_errors = json_encode($error_msgs);
|
$json_errors = json_encode($error_msgs);
|
||||||
// Display messages dialog if there are some.
|
// Display messages dialog if there are some.
|
||||||
$url = 'javascript: showExtensionMsg(\''.$json_errors.'\', \''.$url_href.'\');';
|
$url = 'javascript: showExtensionMsg(\''.$json_errors.'\', \''.$url_href.'\', \''.io_safe_input($itemName).'\');';
|
||||||
}
|
}
|
||||||
|
|
||||||
$extensions[] = [
|
$extensions[] = [
|
||||||
|
@ -12289,6 +12289,12 @@ div.parent_graph > p.legend_background > table > tbody > tr {
|
|||||||
color: #82b92e;
|
color: #82b92e;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.link-important {
|
||||||
|
color: #82b92e !important;
|
||||||
|
text-decoration: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
.signature a {
|
.signature a {
|
||||||
color: #82b92e;
|
color: #82b92e;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user