Merge branch 'ent-1668-update-manager' into 'develop'

UM register, UM newsletter flow improved

See merge request artica/pandorafms!2463
This commit is contained in:
Daniel Rodriguez 2019-05-29 11:55:34 +02:00
commit ee7cd68d39
3 changed files with 152 additions and 72 deletions

View File

@ -140,7 +140,7 @@ $registration = isset($config['pandora_uid']) !== true
|| $config['pandora_uid'] == '';
if ($initial) {
if ($initial && users_is_admin()) {
// Show all forms in order.
// 1- Ask for email, timezone, etc. Fullfill alerts and user mail.
config_wiz_modal(
@ -150,7 +150,7 @@ if ($initial) {
);
}
if ($registration) {
if ($registration && users_is_admin()) {
// Prepare registration wizard, not launch. leave control to flow.
registration_wiz_modal(
false,

View File

@ -1,18 +1,36 @@
<?php
/**
* Update manager client options.
*
* @category Update Manager
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Begin.
global $config;
require_once __DIR__.'/../../include/functions_users.php';
check_login();
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
@ -27,12 +45,38 @@ $action_update_url_update_manager = (bool) get_parameter(
0
);
if (users_is_admin()) {
$update_manager_disconnect = get_parameter(
'um_disconnect_console',
0
);
if ($update_manager_disconnect) {
config_update_value(
'pandora_uid',
'OFFLINE'
);
}
}
if (!$action_update_url_update_manager) {
$url_update_manager = get_parameter('url_update_manager', $config['url_update_manager']);
$update_manager_proxy_server = get_parameter('update_manager_proxy_server', $config['update_manager_proxy_server']);
$update_manager_proxy_port = get_parameter('update_manager_proxy_port', $config['update_manager_proxy_port']);
$update_manager_proxy_user = get_parameter('update_manager_proxy_user', $config['update_manager_proxy_user']);
$update_manager_proxy_password = get_parameter('update_manager_proxy_password', $config['update_manager_proxy_password']);
$update_manager_proxy_server = get_parameter(
'update_manager_proxy_server',
$config['update_manager_proxy_server']
);
$update_manager_proxy_port = get_parameter(
'update_manager_proxy_port',
$config['update_manager_proxy_port']
);
$update_manager_proxy_user = get_parameter(
'update_manager_proxy_user',
$config['update_manager_proxy_user']
);
$update_manager_proxy_password = get_parameter(
'update_manager_proxy_password',
$config['update_manager_proxy_password']
);
if ($action_update_url_update_manager) {
@ -69,7 +113,10 @@ if (!$action_update_url_update_manager) {
}
if ($result && license_free()) {
$result = config_update_value('identification_reminder', $identification_reminder);
$result = config_update_value(
'identification_reminder',
$identification_reminder
);
}
ui_print_result_message(
@ -189,11 +236,26 @@ $table->data[4][1] = html_print_input_password(
true
);
$table->data[5][0] = __('Registration ID:');
$table->data[5][1] = '<i>'.$config['pandora_uid'].'</i>';
if (update_manager_verify_registration() === true && users_is_admin()) {
$table->data[6][0] = __('Cancel registration:');
$table->data[6][1] = '<a href="';
$table->data[6][1] .= ui_get_full_url(
'index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=setup&um_disconnect_console=1'
);
$table->data[6][1] .= '" onclick="if(confirm(\'Are you sure?\')) {return true;} else { return false; }">'.__('Unregister').'</a>';
}
if (license_free()) {
$config['identification_reminder'] = isset($config['identification_reminder']) ? $config['identification_reminder'] : 1;
$table->data[6][0] = __('Pandora FMS community reminder').ui_print_help_tip(__('Every 8 days, a message is displayed to admin users to remember to register this Pandora instance'), true);
$table->data[6][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 1, '', $config['identification_reminder'], true).'&nbsp;&nbsp;';
$table->data[6][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 0, '', $config['identification_reminder'], true);
$table->data[7][0] = __('Pandora FMS community reminder').ui_print_help_tip(__('Every 8 days, a message is displayed to admin users to remember to register this Pandora instance'), true);
$table->data[7][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 1, '', $config['identification_reminder'], true).'&nbsp;&nbsp;';
$table->data[7][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button('identification_reminder', 0, '', $config['identification_reminder'], true);
}
html_print_input_hidden('action_update_url_update_manager', 1);

View File

@ -865,50 +865,63 @@ function show_newsletter_wizard() {
var language = $("#language").val();
var email_identification = $("#text-email-newsletter").val();
jQuery.post (
"ajax.php",
{
"page": "general/register",
"register_newsletter": 1,
"email": email_identification
},
function (data) {
cl = '';
msg = 'no response';
try {
json = JSON.parse(data);
cl = json.status
msg = json.message;
} catch (error) {
msg = 'Failed: ' + error;
cl = 'error';
}
if (!cl || cl == 'error') {
cl = 'error';
} else {
// Success.
}
$('#news_result_content').html(msg);
$('#news_result').addClass(cl);
$('#news_result').dialog({
buttons: {
'Ok': function() {
$(this).dialog('close');
$("#newsletter_wizard").dialog('close');
<?php
if (isset($callback) && $callback != '') {
echo $callback;
}
?>
}
if (email_identification == '') {
msg = '<?php echo __('You must specify an email'); ?>';
$('#news_result_content').html(msg);
$('#news_result').dialog({
buttons: {
'Ok': function() {
$(this).dialog('close');
}
});
}
);
}
});
} else {
jQuery.post (
"ajax.php",
{
"page": "general/register",
"register_newsletter": 1,
"email": email_identification
},
function (data) {
cl = '';
msg = 'no response';
try {
json = JSON.parse(data);
cl = json.status
msg = json.message;
} catch (error) {
msg = 'Failed: ' + error;
cl = 'error';
}
if (!cl || cl == 'error') {
cl = 'error';
} else {
// Success.
}
$('#news_result_content').html(msg);
$('#news_result').addClass(cl);
$('#news_result').dialog({
buttons: {
'Ok': function() {
$(this).dialog('close');
$("#newsletter_wizard").dialog('close');
<?php
if (isset($callback) && $callback != '') {
echo $callback;
}
?>
}
}
});
}
);
}
}
});
}
@ -1570,15 +1583,20 @@ function update_manager_register_instance()
global $config;
$email = db_get_value('email', 'tusuario', 'id_user', $config['id_user']);
$um_config_values = update_manager_get_config_values();
$params = [
'language' => $config['language'],
'timezone' => $config['timezone'],
'email' => $email,
'license' => db_get_value_filter(
'value',
'tupdate_settings',
['key' => 'customer_key']
),
'action' => 'newest_package',
'license' => $um_config_values['license'],
'limit_count' => $um_config_values['limit_count'],
'current_package' => $um_config_values['current_update'],
'version' => $um_config_values['version'],
'build' => $um_config_values['build'],
'puid' => $um_config_values['puid'],
'email' => $email,
'language' => $config['language'],
'timezone' => $config['timezone'],
];
$result = update_manager_curl_request('new_register', $params);