UM notifications MR update
Former-commit-id: d2aad195cb9bab4e1efa504cb4b4a583f262f0e3
This commit is contained in:
parent
6e35f6aec7
commit
53e9113b7e
|
@ -5,4 +5,8 @@ ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM('regex','max_min','max'
|
||||||
|
|
||||||
DELETE FROM `tevent_response` WHERE `name` LIKE 'Create Integria IMS incident from event';
|
DELETE FROM `tevent_response` WHERE `name` LIKE 'Create Integria IMS incident from event';
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="Official communication"), "admin", 1, 0);
|
||||||
|
INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Official communication";
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
|
@ -46,8 +46,35 @@ if (is_ajax()) {
|
||||||
$cancel_newsletter = get_parameter('cancel_newsletter', 0);
|
$cancel_newsletter = get_parameter('cancel_newsletter', 0);
|
||||||
$register_newsletter = get_parameter('register_newsletter', 0);
|
$register_newsletter = get_parameter('register_newsletter', 0);
|
||||||
|
|
||||||
|
// Load wizards.
|
||||||
|
$load_wizards = get_parameter('load_wizards', '');
|
||||||
|
|
||||||
$feedback = [];
|
$feedback = [];
|
||||||
|
|
||||||
|
// Load wizards.
|
||||||
|
if ($load_wizards != '') {
|
||||||
|
switch ($load_wizards) {
|
||||||
|
case 'initial':
|
||||||
|
return config_wiz_modal(false, false);
|
||||||
|
|
||||||
|
case 'registration':
|
||||||
|
return registration_wiz_modal(false, false);
|
||||||
|
|
||||||
|
case 'newsletter':
|
||||||
|
return newsletter_wiz_modal(false, false);
|
||||||
|
|
||||||
|
case 'all':
|
||||||
|
config_wiz_modal(false, false);
|
||||||
|
registration_wiz_modal(false, false);
|
||||||
|
newsletter_wiz_modal(false, false);
|
||||||
|
return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Ignore.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Configuration wizard process.
|
// Configuration wizard process.
|
||||||
if ($configuration_wizard) {
|
if ($configuration_wizard) {
|
||||||
$feedback = config_wiz_process();
|
$feedback = config_wiz_process();
|
||||||
|
@ -122,7 +149,6 @@ if ($initial) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($registration) {
|
if ($registration) {
|
||||||
// Prepare registration wizard, not launch. leave control to flow.
|
// Prepare registration wizard, not launch. leave control to flow.
|
||||||
registration_wiz_modal(
|
registration_wiz_modal(
|
||||||
|
|
|
@ -194,6 +194,22 @@ class ConsoleSupervisor
|
||||||
$this->checkCronRunning();
|
$this->checkCronRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if instance is registered.
|
||||||
|
* NOTIF.UPDATEMANAGER.REGISTRATION
|
||||||
|
*/
|
||||||
|
|
||||||
|
$this->checkUpdateManagerRegistration();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if there're new messages in UM.
|
||||||
|
* NOTIF.UPDATEMANAGER.MESSAGES
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (update_manager_verify_registration()) {
|
||||||
|
$this->getUMMessages();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -571,6 +587,7 @@ class ConsoleSupervisor
|
||||||
case 'NOTIF.UPDATEMANAGER.OPENSETUP':
|
case 'NOTIF.UPDATEMANAGER.OPENSETUP':
|
||||||
case 'NOTIF.UPDATEMANAGER.UPDATE':
|
case 'NOTIF.UPDATEMANAGER.UPDATE':
|
||||||
case 'NOTIF.UPDATEMANAGER.MINOR':
|
case 'NOTIF.UPDATEMANAGER.MINOR':
|
||||||
|
case 'NOTIF.UPDATEMANAGER.MESSAGES':
|
||||||
case 'NOTIF.CRON.CONFIGURED':
|
case 'NOTIF.CRON.CONFIGURED':
|
||||||
default:
|
default:
|
||||||
// NOTIF.SERVER.STATUS.
|
// NOTIF.SERVER.STATUS.
|
||||||
|
@ -1913,25 +1930,15 @@ class ConsoleSupervisor
|
||||||
global $config;
|
global $config;
|
||||||
$login = get_parameter('login', false);
|
$login = get_parameter('login', false);
|
||||||
|
|
||||||
if (license_free() === true
|
if (update_manager_verify_registration() === false) {
|
||||||
&& users_is_admin($config['id_user']) === true
|
$this->notify(
|
||||||
) {
|
[
|
||||||
$login = get_parameter('login', false);
|
'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION',
|
||||||
// Registration advice.
|
'title' => __('This instance is not registered in the Update manager section'),
|
||||||
if ((isset($config['instance_registered']) === true
|
'message' => __('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_register();"> here</a> to start the registration process'),
|
||||||
|| ($config['instance_registered'] != 1)) && ($login === false)
|
'url' => 'javascript: force_run_register();',
|
||||||
) {
|
]
|
||||||
$this->notify(
|
);
|
||||||
[
|
|
||||||
'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION',
|
|
||||||
'title' => __('This instance is not registered in the Update manager section'),
|
|
||||||
'message' => __('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_register();"> here</a> to start the registration process'),
|
|
||||||
'url' => 'javascript: force_run_register();',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION');
|
$this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION');
|
||||||
}
|
}
|
||||||
|
@ -2217,4 +2224,55 @@ class ConsoleSupervisor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for messages.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getUMMessages()
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
include_once $config['homedir'].'/include/functions_update_manager.php';
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'pandora_uid' => $config['pandora_uid'],
|
||||||
|
'timezone' => $config['timezone'],
|
||||||
|
'language' => $config['language'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = update_manager_curl_request('get_messages', $params);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($result['success'] === true) {
|
||||||
|
$messages = json_decode($result['update_message'], true);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
error_log($e->getMessage());
|
||||||
|
};
|
||||||
|
|
||||||
|
if (is_array($messages)) {
|
||||||
|
$source_id = get_notification_source_id(
|
||||||
|
'Official communication'
|
||||||
|
);
|
||||||
|
foreach ($messages as $message) {
|
||||||
|
if (!isset($message['url'])) {
|
||||||
|
// Avoid log messges.
|
||||||
|
$message['url'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->notify(
|
||||||
|
[
|
||||||
|
'type' => 'NOTIF.UPDATEMANAGER.MESSAGES',
|
||||||
|
'title' => $message['subject'],
|
||||||
|
'message' => base64_decode($message['message_html']),
|
||||||
|
'url' => $message['url'],
|
||||||
|
],
|
||||||
|
$source_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Extension to manage a list of gateways and the node address where they should
|
* Update manager client library.
|
||||||
* point to.
|
|
||||||
*
|
*
|
||||||
* @category Functions Update Manager
|
* @category Functions Update Manager
|
||||||
* @package Pandora FMS
|
* @package Pandora FMS
|
||||||
|
|
|
@ -1201,6 +1201,9 @@ if ($config['pure'] == 0) {
|
||||||
// main_pure
|
// main_pure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo '<div id="wiz_container">';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
|
||||||
if ($config['pure'] == 0) {
|
if ($config['pure'] == 0) {
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
@ -1281,13 +1284,49 @@ require 'include/php_to_js_values.php';
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function force_run_register () {
|
function force_run_register () {
|
||||||
run_identification_wizard (1, 0, 0);
|
jQuery.post ("ajax.php",
|
||||||
|
{
|
||||||
|
"page": "general/register",
|
||||||
|
"load_wizards": 'registration'
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
$('#wiz_container').empty ()
|
||||||
|
.html (data);
|
||||||
|
show_registration_wizard();
|
||||||
|
},
|
||||||
|
"html"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function force_run_newsletter () {
|
function force_run_newsletter () {
|
||||||
run_identification_wizard (0, 1, 0);
|
jQuery.post ("ajax.php",
|
||||||
|
{
|
||||||
|
"page": "general/register",
|
||||||
|
"load_wizards": 'newsletter'
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
$('#wiz_container').empty ()
|
||||||
|
.html (data);
|
||||||
|
show_newsletter_wizard ();
|
||||||
|
},
|
||||||
|
"html"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function first_time_identification () {
|
function first_time_identification () {
|
||||||
run_identification_wizard (-1, -1, 1);
|
jQuery.post ("ajax.php",
|
||||||
|
{
|
||||||
|
"page": "general/register",
|
||||||
|
"load_wizards": 'initial'
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
$('#wiz_container').empty ()
|
||||||
|
.html (data);
|
||||||
|
run_configuration_wizard ();
|
||||||
|
},
|
||||||
|
"html"
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var times_fired_register_wizard = 0;
|
var times_fired_register_wizard = 0;
|
||||||
|
|
Loading…
Reference in New Issue