From 1a743640b5b29dab4ceb8106aa1a180a2275b2f0 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 25 May 2016 12:43:49 +0200 Subject: [PATCH 01/20] Added dummy and undesigned identification wizard --- .../general/login_identification_wizard.php | 290 ++++++++++++++++++ pandora_console/general/login_required.php | 185 +++++++++++ .../update_manager/update_manager.setup.php | 14 +- pandora_console/include/functions.php | 14 + pandora_console/include/functions_config.php | 30 ++ pandora_console/index.php | 73 ++++- pandora_console/license.lic | 19 ++ pandora_console/operation/users/user_edit.php | 21 +- 8 files changed, 643 insertions(+), 3 deletions(-) create mode 100644 pandora_console/general/login_identification_wizard.php create mode 100644 pandora_console/general/login_required.php create mode 100644 pandora_console/license.lic diff --git a/pandora_console/general/login_identification_wizard.php b/pandora_console/general/login_identification_wizard.php new file mode 100644 index 0000000000..662f3967c5 --- /dev/null +++ b/pandora_console/general/login_identification_wizard.php @@ -0,0 +1,290 @@ + 1), array('id_user' => $config['id_user'])); + } elseif (!$forced) { + html_debug ('future days'); + db_process_sql_update ('tusuario', array ('lastname' => $future_8_days), array('id_user' => $config['id_user'])); + } + } + + if (!$not_return) { + return; + } +} + +//Check if user is admin +if (!license_free()) return; +if (!users_is_admin ($config['id_user'])) return; + +// Get data to display properly the wizard +$wizard_data = array (); + +$wizard_data['newsletter_subscribed'] = db_get_value ('middlename', 'tusuario', 'id_user', $config['id_user']); +// force_* = 1 -> force show +// force_* = 0 -> force hide +// force_* = -1 -> show or hide depends reminder and timestamp +$wizard_data['force_newsletter'] = get_parameter ('force_newsletter', -1); +$wizard_data['newsletter_reminder'] = db_get_value ('firstname', 'tusuario', 'id_user', $config['id_user']); +$wizard_data['newsletter_reminder_timestamp'] = db_get_value ('lastname', 'tusuario', 'id_user', $config['id_user']); + + +$wizard_data['instance_register'] = $config['instance_registered']; +$wizard_data['force_register'] = get_parameter ('force_register', -1); +$wizard_data['identification_reminder'] = $config['identification_reminder']; +$wizard_data['identification_reminder_timestamp'] = $config['identification_reminder_timestamp']; + +$display_newsletter = display_newsletter ($wizard_data); +$display_register = display_register ($wizard_data); +$display_forced = ($wizard_data['force_newsletter'] != -1) || ($wizard_data['force_register'] != -1); + +// Return if it is fully completed +if ((!$display_register) && (!$display_newsletter)) return; +html_debug ($wizard_data, true); + +$return_button = get_parameter ('return_button', 0) == 1; + +$email = db_get_value ('email', 'tusuario', 'id_user', $config['id_user']); +//Avoid to show default email +if ($email == 'admin@example.com') $email = ''; + +// Prints accept register license +echo '
'; + echo '
'; + echo html_print_image ('images/support.png', true); + echo '
'; + echo '
'; + echo __('KEEP UPDATED!'); + echo '
'; + + echo '
'; + $license_text = file('license.lic'); + $license_text = implode ($license_text); + html_print_textarea ("text-license", 1, 65, $license_text, + 'readonly="readonly"; ', false); + echo '
'; + + echo '
'; + echo '
'; + html_print_submit_button("Finish", 'finish_dialog_button', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok" style="width:100px;"'); + echo '
'; + echo '
'; + html_print_submit_button("Return", 'return_dialog_button', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok" style="width:100px;"'); + echo '
'; + echo '
'; + html_print_checkbox('register', 1, false, false, false, 'cursor: \'pointer\''); + echo ' ' .__("Accept register Pandora") . '
'; + html_print_checkbox('newsletter', 1, false, false, false, 'cursor: \'pointer\''); + echo ' ' .__("Subscribe to newsletter") . ''; + echo "
"; + echo ' '; + //html_print_input_text ('email-newsletter', '', '', 30, 255, false); + html_print_input_text_extended ('email-newsletter', $email, 'text-email-newsletter', '', 30, 255, false, '', array ("style" => "display:none; ")); echo ' '; + echo ' '; + echo '
'; + echo '
'; +echo '
'; + +// Print yes or not dialog +echo '
'; + echo '
'; + echo __("Do you want to continue without any registration") . "?"; + echo '
'; + echo '
'; + html_print_submit_button("No", 'no_registration', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok" style="width:100px;"'); + echo '
'; + echo '
'; + html_print_submit_button("Yes", 'yes_registration', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok" style="width:100px;"'); + echo '
'; +echo '
'; +?> + + diff --git a/pandora_console/general/login_required.php b/pandora_console/general/login_required.php new file mode 100644 index 0000000000..df2bd630ef --- /dev/null +++ b/pandora_console/general/login_required.php @@ -0,0 +1,185 @@ + $email), array('id_user' => $config['id_user'])); + + config_update_value ('initial_wizard', 1); + + } + + return; +} + +$email = db_get_value ('email', 'tusuario', 'id_user', $config['id_user']); +//Avoid to show default email +if ($email == 'admin@example.com') $email = ''; + +// Prints first step pandora registration +echo ''; + +?> + + diff --git a/pandora_console/godmode/update_manager/update_manager.setup.php b/pandora_console/godmode/update_manager/update_manager.setup.php index 0fdabc9188..216311790a 100644 --- a/pandora_console/godmode/update_manager/update_manager.setup.php +++ b/pandora_console/godmode/update_manager/update_manager.setup.php @@ -37,6 +37,8 @@ $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']); +$identification_reminder = get_parameter('identification_reminder', + $config['identification_reminder']); if ($action_update_url_update_manager) { @@ -54,7 +56,9 @@ if ($action_update_url_update_manager) { if ($result) $result = config_update_value('update_manager_proxy_password', $update_manager_proxy_password); - + if ($result) + $result = config_update_value('identification_reminder', + $identification_reminder); ui_print_result_message($result, __('Succesful Update the url config vars.'), __('Unsuccesful Update the url config vars.')); @@ -88,6 +92,14 @@ $table->data[4][0] = __('Proxy password:'); $table->data[4][1] = html_print_input_password('update_manager_proxy_password', $update_manager_proxy_password, __('Proxy password'), 40, 60, true); +if (license_free()) { + $config["identification_reminder"] = isset($config["identification_reminder"]) ? $config["identification_reminder"] : 1; + $table->data[6][0] = __('Remember registration to admins') . + ui_print_help_tip(__('Every 8 days, a message is displayed to admin to remember Pandora is not registered'), true); + $table->data[6][1] = __('Yes').'   '.html_print_radio_button ('identification_reminder', 1, '', $config["identification_reminder"], true).'  '; + $table->data[6][1] .= __('No').'   '.html_print_radio_button ('identification_reminder', 0, '', $config["identification_reminder"], true); +} + html_print_input_hidden('action_update_url_update_manager', 1); html_print_table($table); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index d7b027bef2..facc8489ce 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1195,6 +1195,20 @@ function enterprise_installed() { return $return; } +/** + * Check if the license is PANDORA-FREE. + * + * @return boolean. + */ +function license_free() { + $return = true; + + $pandora_license = db_get_value ('value', 'tupdate_settings', '`key`', 'customer_key'); + if ($pandora_license !== 'PANDORA-FREE') $return = false; + + return $return; +} + /** * TODO: Document enterprise functions */ diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index ce619227e1..e4a22899cd 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1435,6 +1435,18 @@ function config_process_config () { config_update_value ('max_file_size', "2M"); } + if (!isset ($config["initial_wizard"])) { + config_update_value ('initial_wizard', 0); + } + + if (!isset ($config["identification_reminder"])) { + config_update_value ('identification_reminder', 1); + } + + if (!isset ($config["instance_registered"])) { + config_update_value ('instance_registered', 0); + } + /* Finally, check if any value was overwritten in a form */ @@ -1611,6 +1623,24 @@ function config_check () { __("Variable disable_functions containts functions system() or exec(), in PHP configuration file (php.ini)"). '

' . __('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), __("Problems with disable functions in PHP.INI")); } + + if (license_free() && users_is_admin($config['id_user'])) { + //Newsletter advice + $newsletter = db_get_value ('middlename', 'tusuario', 'id_user', $config['id_user']); + if ($newsletter != 1) { + set_pandora_error_for_header( + __('Click HERE to init the newsletter subscription process'), + __("Missing user in newsletter")); + } + + //Registration advice + if (!isset ($config['instance_registered']) || ($config['instance_registered'] != 1)) { + set_pandora_error_for_header( + __('Click HERE to init the registration process'), + __("This PandoraFMS instance is not registered")); + } + } + } function config_return_in_bytes($val) { diff --git a/pandora_console/index.php b/pandora_console/index.php index 9a8bfa9b87..be76bdd9f3 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -78,6 +78,7 @@ if(session_id() == '') { session_start (); } require_once ("include/config.php"); +require_once ("include/functions_config.php"); // If metaconsole activated, redirect to it @@ -596,12 +597,19 @@ if ($old_global_counter_chat != $now_global_counter_chat) { $_SESSION['new_chat'] = true; } +if ($config['initial_wizard'] != 1) { + include_once ("general/login_required.php"); +} if (get_parameter ('login', 0) !== 0) { // Display news dialog include_once("general/news_dialog.php"); // Display login help info dialog // If it's configured to not skip this + + if ($config['initial_wizard'] == 1) { + include_once("general/login_identification_wizard.php"); + } if (!isset($config['skip_login_help_dialog']) || $config['skip_login_help_dialog'] == 0) { @@ -773,7 +781,6 @@ else { echo ""; // main_pure } - if ($config["pure"] == 0) { echo ''; //container div echo '
'; @@ -824,6 +831,70 @@ require('include/php_to_js_values.php'); }; })(); + function force_run_register () { + run_identification_wizard (1, 0, 0); + } + function force_run_newsletter () { + run_identification_wizard (0, 1, 0); + } + function first_time_identification () { + run_identification_wizard (-1, -1, 1); + } + var times_fired_register_wizard = 0; + function run_identification_wizard (register, newsletter , return_button) { + + if (times_fired_register_wizard) { + console.log ("only open"); + $(".ui-dialog-titlebar-close").show(); + + //Reset some values + $("#label-email-newsletter").hide(); + $("#text-email-newsletter").hide(); + $("#required-email-newsletter").hide(); + $("#checkbox-register").removeAttr('checked'); + $("#checkbox-newsletter").removeAttr('checked'); + + // Hide or show parts + if (register == 1) { + $("#checkbox-register").show(); + $("#label-register").show (); + } + if (register == 0) { + $("#checkbox-register").attr ('style', 'display: none !important'); + $("#label-register").hide (); + } + if (newsletter == 1) { + $("#checkbox-newsletter").show(); + $("#label-newsletter").show (); + } + if (newsletter == 0) { + $("#checkbox-newsletter").attr ('style', 'display: none !important'); + $("#label-newsletter").hide (); + } + $("#login_accept_register").dialog('open'); + } + else { + console.log ("ajax open wizard"); + $(".ui-dialog-titlebar-close").show(); + $("#container").append('
'); + jQuery.get ("ajax.php", + {"page": "general/login_identification_wizard", + "not_return": 1, + "force_register": register, + "force_newsletter": newsletter, + "return_button": return_button}, + function (data) { + $(".id_wizard").hide () + .empty () + .append (data); + }, + "html" + ); + } + times_fired_register_wizard++; + return false; + } + //Dynamically assign footer position and width. function adjustFooter() { /* diff --git a/pandora_console/license.lic b/pandora_console/license.lic new file mode 100644 index 0000000000..a367bfc87b --- /dev/null +++ b/pandora_console/license.lic @@ -0,0 +1,19 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis malesuada ante et nibh bibendum vehicula sed a nulla. Vivamus volutpat elit dictum dui mollis lacinia. Cras ac nibh cursus dui dignissim faucibus. Vivamus felis nisi, vulputate eget ipsum ac, tristique volutpat nisi. Curabitur lacinia maximus purus, a gravida purus tempor at. Nullam nec metus quis ligula laoreet consectetur vitae ut massa. Ut commodo nunc in pellentesque imperdiet. Nam justo ex, eleifend sed justo in, rhoncus auctor ex. Nullam commodo nulla in sodales faucibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; + +Proin suscipit a quam sed auctor. Fusce commodo, ex vitae congue molestie, lacus leo maximus risus, quis lobortis sem lacus in velit. Sed a egestas nisi. Aenean nec gravida enim, id venenatis enim. Nunc imperdiet porttitor posuere. Nunc tempor at quam ut suscipit. Aenean at bibendum erat, nec pretium sem. Etiam congue eu risus et accumsan. Ut viverra nisl augue, in rutrum nibh tincidunt sit amet. Nunc ac felis auctor, interdum nibh ac, gravida eros. In lacinia, metus pharetra maximus ultricies, diam risus ultrices enim, in posuere nibh nulla a libero. Aenean cursus interdum metus id bibendum. + +Proin vulputate leo sed iaculis ultricies. Nunc et dapibus libero. Aenean vitae mauris sit amet nisl fringilla elementum. Maecenas iaculis ipsum vitae enim vulputate, aliquam sodales dui iaculis. Sed elementum urna at lectus consequat, sed vestibulum arcu mollis. Sed non magna malesuada, condimentum elit et, feugiat ante. Pellentesque a consectetur eros. Fusce aliquet sit amet sem ac fringilla. Praesent sagittis convallis tincidunt. Aliquam et pellentesque neque. Sed consectetur, neque sollicitudin feugiat tincidunt, libero odio tempus ligula, mollis fringilla dui mauris nec sem. Pellentesque pulvinar mauris ac enim consequat, vel pulvinar neque imperdiet. + +Vivamus varius consequat lacus. Sed gravida est a molestie congue. In iaculis lacus magna, a malesuada enim finibus at. Nullam auctor nunc vitae diam vestibulum convallis. Curabitur gravida, metus nec sodales ultrices, leo libero consectetur orci, at rhoncus turpis tortor eget felis. Fusce tempor, leo sed rutrum rhoncus, nisl augue pellentesque purus, et facilisis leo nisi non leo. Nam sed congue erat, vitae sagittis orci. Integer luctus nibh arcu, eu viverra est mollis ac. Sed in tempor dui. Proin a pretium nisi. Sed felis neque, mattis eu nisi fermentum, efficitur semper nulla. Quisque lacinia tellus et odio aliquet eleifend. + +Aliquam gravida ligula in massa blandit, eu semper magna vulputate. Suspendisse potenti. In vitae fringilla metus. Mauris iaculis, ex non condimentum semper, felis lectus rhoncus quam, at consectetur turpis sem vitae sem. Quisque sed turpis diam. In a nunc faucibus, accumsan tellus ut, rhoncus elit. Nulla consequat magna non massa cursus pulvinar. + +Etiam tincidunt sed odio sit amet placerat. Duis mattis dui a placerat aliquet. Etiam finibus orci nec mi dignissim euismod. Suspendisse ac metus sit amet ex lobortis iaculis at vel eros. In finibus lectus non interdum sagittis. Nulla non efficitur odio. Aliquam tempus sagittis gravida. Nam vel magna et leo molestie faucibus a sit amet ipsum. Duis ultricies, enim et rhoncus maximus, est ipsum ornare arcu, ut tempus diam lacus ac dolor. + +In vel condimentum lacus, elementum sodales magna. Etiam porta, neque ac sodales tincidunt, diam mi semper quam, a molestie massa ligula eget ligula. Praesent et sodales enim. Donec in ultrices enim. Etiam dapibus, sem at faucibus vehicula, metus ipsum tempus dolor, id tincidunt neque erat vel nulla. Sed in justo eu ipsum accumsan tempor. Vestibulum blandit metus quam, ac condimentum magna vehicula nec. Integer sagittis ante non sapien efficitur porttitor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum ut justo volutpat, venenatis nisi quis, imperdiet lorem. Quisque nec justo id urna convallis rutrum sit amet vitae quam. Nullam scelerisque, sem et egestas bibendum, ipsum nunc lacinia orci, et feugiat ex purus vitae magna. + +Quisque suscipit auctor nisi, nec mattis nisi cursus a. Proin nec turpis ut libero condimentum aliquam eget eleifend arcu. Aliquam commodo sed ante in efficitur. Fusce sollicitudin sit amet felis at ultricies. Praesent pulvinar aliquam malesuada. Praesent vel dolor feugiat, eleifend metus in, molestie arcu. Nunc efficitur, orci eget tristique congue, metus arcu tempor sapien, non ultricies mauris massa vel mauris. Praesent tristique ornare felis, a laoreet tellus varius pharetra. Phasellus ex eros, faucibus quis orci laoreet, commodo mattis magna. Morbi nec nisl finibus, vulputate erat et, fringilla justo. + +Suspendisse semper scelerisque mi, vel faucibus ante hendrerit non. Praesent auctor quam at purus elementum, venenatis faucibus erat mollis. Morbi consequat eu mi a imperdiet. Sed volutpat nunc eget euismod condimentum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus cursus, enim in eleifend egestas, nunc libero congue dui, eget vehicula nulla erat eu nisl. Pellentesque ipsum velit, condimentum non risus nec, hendrerit accumsan arcu. Praesent maximus, augue et tristique rhoncus, est tortor ullamcorper nisl, ut pharetra elit lectus ac nulla. Sed ultricies dignissim arcu. In consequat lectus a aliquet sagittis. Curabitur sit amet arcu ante. Etiam finibus velit tellus, sed consectetur felis euismod nec. Etiam a dui sed sem iaculis molestie. Duis auctor augue nec condimentum cursus. Aliquam volutpat erat urna, eget accumsan tellus dictum tincidunt. Proin nec convallis lorem. + +Donec pulvinar interdum odio. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vestibulum fermentum gravida purus, et dictum elit fermentum id. Sed elementum, neque lobortis consequat sodales, nisi diam efficitur lectus, et blandit enim justo non tortor. Maecenas lacus libero, efficitur ut commodo sit amet, vulputate in felis. Nulla in ullamcorper turpis, vel pellentesque urna. In tempus, nulla eget laoreet maximus, urna velit porttitor est, sed egestas lectus dui vel lectus. Fusce et dictum nibh, iaculis rutrum enim. Vestibulum in consequat augue. Phasellus at sem eget diam suscipit scelerisque nec et justo. Aliquam erat volutpat. diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index dfc713e1bd..918082ea31 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -102,6 +102,7 @@ if (isset ($_GET["modified"]) && !$view_mode) { $upd_info["language"] = get_parameter_post ("language", $user_info["language"]); $upd_info["id_skin"] = get_parameter ("skin", $user_info["id_skin"]); $upd_info["block_size"] = get_parameter ("block_size", $config["block_size"]); + $upd_info["firstname"] = get_parameter ("newsletter_reminder", $user_info["first_name"]); $default_block_size = get_parameter ("default_block_size", 0); if($default_block_size) { $upd_info["block_size"] = 0; @@ -355,7 +356,25 @@ if ($double_auth_enabled) { } // Dialog $data[0] .= "
"; -$table->colspan[count($table->data)][0] = 3; + +// Newsletter +if (license_free()) { + $data[1] = __('Newsletter Subscribed'); + $data[1] .= $jump . ui_print_help_tip(__('Subs news'), true); + if ($user_info["middlename"]) { + $data[1] .= $jump . __('You are subscribed to PandoraFMS newsletter'); + } + else { + $data[1] .= $jump . __('Click HERE to init the newsletter subscription process'); + } + + $data[2] = __('Newsletter Reminder'); + $data[2] .= ui_print_help_tip(__('Remind news'), true); + if ($user_info["firstname"] != 0) $user_info["firstname"] = 1; + $data[2] .= html_print_checkbox('newsletter_reminder', 1, $user_info["firstname"], true); +} else { + $table->colspan[count($table->data)][0] = 3; +} $table->rowclass[] = ''; $table->rowstyle[] = 'font-weight: bold;'; $table->data[] = $data; From 92c5751bbb4ba4d38262c70f47ce88052417fd83 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 25 May 2016 13:03:19 +0200 Subject: [PATCH 02/20] Minor type fix --- pandora_console/general/login_identification_wizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/general/login_identification_wizard.php b/pandora_console/general/login_identification_wizard.php index 662f3967c5..b08c9a9990 100644 --- a/pandora_console/general/login_identification_wizard.php +++ b/pandora_console/general/login_identification_wizard.php @@ -91,7 +91,7 @@ $wizard_data['newsletter_reminder'] = db_get_value ('firstname', 'tusuario', 'id $wizard_data['newsletter_reminder_timestamp'] = db_get_value ('lastname', 'tusuario', 'id_user', $config['id_user']); -$wizard_data['instance_register'] = $config['instance_registered']; +$wizard_data['instance_registered'] = $config['instance_registered']; $wizard_data['force_register'] = get_parameter ('force_register', -1); $wizard_data['identification_reminder'] = $config['identification_reminder']; $wizard_data['identification_reminder_timestamp'] = $config['identification_reminder_timestamp']; From fb9010675f4422a01ba394646d2ec5343007608b Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 26 May 2016 15:03:00 +0200 Subject: [PATCH 03/20] Added first version of update manager messages --- .../update_manager.messages.php | 231 ++++++++++++++++++ .../godmode/update_manager/update_manager.php | 12 +- .../include/functions_update_manager.php | 27 ++ pandora_console/include/styles/pandora.css | 8 + 4 files changed, 277 insertions(+), 1 deletion(-) create mode 100644 pandora_console/godmode/update_manager/update_manager.messages.php diff --git a/pandora_console/godmode/update_manager/update_manager.messages.php b/pandora_console/godmode/update_manager/update_manager.messages.php new file mode 100644 index 0000000000..aef074e5ae --- /dev/null +++ b/pandora_console/godmode/update_manager/update_manager.messages.php @@ -0,0 +1,231 @@ + $message_id) { + + update_manger_set_read_message ($message_id, 0); + } +} + +if ($delete_action !== false) { + + $selected = get_parameter ('select_multiple', false); + foreach ($selected as $k => $message_id) { + + db_process_sql_delete ('tupdate', array('svn_version' => $message_id)); + } + +} + +// Get all messages +$sql = 'SELECT data, svn_version, filename, data_rollback, description FROM tupdate'; +$um_messages = array (); +$um_messages = db_get_all_rows_sql ($sql); + +echo '
'; + +html_print_input_hidden ('tab', 'messages'); +echo '
'; +html_print_submit_button (__('Delete'), 'delete_button', false, + 'class="sub upd"'); +echo '
'; + +echo '
'; +html_print_submit_button (__('Mark as not read'), 'not_read_button', false, + 'class="sub upd"'); +echo '
'; + +$table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox data'; + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->head = array (); + $table->data = array (); + $table->align = array (); + $table->size = array (); + $table->id = 'um_messages_table'; + + $table->align[0] = "left"; + $table->align[1] = "left"; + $table->align[2] = "left"; + $table->align[3] = "left"; + $table->align[4] = "left"; + + $table->size[0] = "20px"; + $table->size[1] = "100px"; + $table->size[3] = "80px"; + $table->size[4] = "60px"; + + $table->head[0] = __('Message Id'); + $table->head[1] = __('Expiration date'); + $table->head[2] = __('Subject'); + $table->head[3] = html_print_checkbox_extended('all_selection[]', 0, false, false, '', '', true); + + $i = 0; + foreach ($um_messages as $message) { + $data[0] = $message['svn_version']; + + $data[1] = $message['filename']; + + $data[2] = $message['description']; + + //~ $delete_link = 'index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=messages&delete_single=1&message_id=' . $message['svn_version']; + $data[3] = html_print_checkbox_extended('select_multiple[]', $message['svn_version'], false, false, '', 'class="check_selection"', true); + + + // Change row class if message is read or not by this user + if (update_manger_get_read_message ($message['svn_version'], $message['data_rollback'])) { + $table->rowclass[count($table->data)] = "um_read_message"; + + } else { + $table->rowclass[count($table->data)] = "um_not_read_message"; + + } + array_push ($table->data, $data); + + // Insert an empty row too. Here the message will be displayed + $empty[0] = ""; + $table->colspan[count($table->data)][0] = 4; + $table->cellclass[count($table->data)][0] = "um_message_" . $i; + $table->cellstyle[count($table->data)][0] = "display: none;"; + array_push ($table->data, $empty); + + $i++; + } +html_print_table($table); + +echo '
'; +html_print_submit_button (__('Delete'), 'delete_button', false, + 'class="sub upd"'); +echo '
'; + +echo '
'; +html_print_submit_button (__('Mark as not read'), 'not_read_button', false, + 'class="sub upd"'); +echo '
'; +echo '
'; +?> + + diff --git a/pandora_console/godmode/update_manager/update_manager.php b/pandora_console/godmode/update_manager/update_manager.php index 4659550a4e..27590bc011 100644 --- a/pandora_console/godmode/update_manager/update_manager.php +++ b/pandora_console/godmode/update_manager/update_manager.php @@ -40,7 +40,11 @@ $buttons = array( 'online' => array( 'active' => ($tab == 'online') ? true : false, 'text' => '' . - html_print_image("images/op_gis.png", true, array ("title" => __('Online update manager'))) .'') + html_print_image("images/op_gis.png", true, array ("title" => __('Online update manager'))) .''), + 'messages' => array( + 'active' => ($tab == 'messages') ? true : false, + 'text' => '' . + html_print_image("images/hourglass.png", true, array ("title" => __('Update manager messages'))) .'') ); switch ($tab) { @@ -53,6 +57,9 @@ switch ($tab) { case 'online': $title = __('Update manager » Online'); break; + case 'messages': + $title = __('Update manager » Messages'); + break; } ui_print_page_header($title, @@ -65,6 +72,9 @@ switch ($tab) { case 'offline': require($config['homedir'] . "/godmode/update_manager/update_manager.offline.php"); break; + case 'messages': + require($config['homedir'] . "/godmode/update_manager/update_manager.messages.php"); + break; case 'online': default: require($config['homedir'] . "/godmode/update_manager/update_manager.online.php"); diff --git a/pandora_console/include/functions_update_manager.php b/pandora_console/include/functions_update_manager.php index 7064ef1fe7..720ccb897a 100755 --- a/pandora_console/include/functions_update_manager.php +++ b/pandora_console/include/functions_update_manager.php @@ -522,4 +522,31 @@ function update_manager_get_current_package() { return $current_update; } + +// Set the read or not read status message of current user +function update_manger_set_read_message ($message_id, $status) { + global $config; + + $rollback = db_get_value('data_rollback', 'tupdate', 'svn_version', $message_id); + $users_read = json_decode ($rollback, true); + $users_read[$config['id_user']] = $status; + + $rollback = json_encode ($users_read); + db_process_sql_update('tupdate', array('data_rollback' => $rollback), array('svn_version' => $message_id)); +} + +// Get the read or not read status message +function update_manger_get_read_message ($message_id, $rollback = false) { + global $config; + + if ($rollback === false) { + $rollback = db_get_value('data_rollback', 'tupdate', 'svn_version', $message_id); + } + $users_read = json_decode ($rollback, true); + + if (isset ($users_read[$config['id_user']]) && ($users_read[$config['id_user']] == 1)) { + return true; + } + return false; +} ?> diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 3444356aa4..78dd1c06d3 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -3087,6 +3087,14 @@ table#policy_modules td * { margin-left: 3%; } +.um_not_read_message{ + font-weight: 900; +} +.um_read_message{ + font-weight: 500; + color: #bbbbbb; +} + /* The items with the class 'spinner' will rotate */ /* Not supported on IE9 and below */ .spinner { From 62aab34c8f44be6b19682683642193227adcfdd8 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 26 May 2016 15:53:31 +0200 Subject: [PATCH 04/20] Added header link to UM messages --- pandora_console/general/header.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index d868827229..e1f24ea701 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -72,6 +72,21 @@ config_check(); $table->styleTable = 'margin: auto; margin-top: 0px;'; $table->rowclass[0] = ''; + //UM messages + if (is_user_admin ($config['id_user'])) { + include_once ("include/functions_update_manager.php"); + $sql = 'SELECT COUNT(*) FROM tupdate WHERE data_rollback LIKE \'%"' . $config['id_user'] . '":1%\''; + $number_read_messages = (int) db_get_sql ($sql); + $sql = 'SELECT COUNT(*) FROM tupdate'; + $number_total_messages = (int) db_get_sql ($sql); + $number_unread_messages = $number_total_messages - $number_read_messages; + if ($number_unread_messages > 0) { + $um_messages = html_print_image("images/header_email.png", true, + array("alt" => 'cross', "class" => 'bot', 'title' => __('UM messages').': ' . $number_unread_messages . '/' . $number_total_messages)); + $table->data[0]['um'] = '' . $um_messages . ""; + } + } + // Search bar $search_bar = '
'; if (!isset($config['search_keywords'])) { From 5740aa3be75f5ccb3bdc176a77eabca208e3f257 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 26 May 2016 16:52:47 +0200 Subject: [PATCH 05/20] Added pagination to update manager messages --- pandora_console/general/header.php | 8 +- .../update_manager.messages.php | 173 ++++++++++-------- .../include/functions_update_manager.php | 17 ++ 3 files changed, 112 insertions(+), 86 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index e1f24ea701..60cf5992ab 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -75,14 +75,10 @@ config_check(); //UM messages if (is_user_admin ($config['id_user'])) { include_once ("include/functions_update_manager.php"); - $sql = 'SELECT COUNT(*) FROM tupdate WHERE data_rollback LIKE \'%"' . $config['id_user'] . '":1%\''; - $number_read_messages = (int) db_get_sql ($sql); - $sql = 'SELECT COUNT(*) FROM tupdate'; - $number_total_messages = (int) db_get_sql ($sql); - $number_unread_messages = $number_total_messages - $number_read_messages; + $number_unread_messages = update_manager_get_unread_messages (); if ($number_unread_messages > 0) { $um_messages = html_print_image("images/header_email.png", true, - array("alt" => 'cross', "class" => 'bot', 'title' => __('UM messages').': ' . $number_unread_messages . '/' . $number_total_messages)); + array("alt" => 'cross', "class" => 'bot', 'title' => __('UM unread messages').': ' . $number_unread_messages)); $table->data[0]['um'] = '' . $um_messages . ""; } } diff --git a/pandora_console/godmode/update_manager/update_manager.messages.php b/pandora_console/godmode/update_manager/update_manager.messages.php index aef074e5ae..47e4f7755d 100644 --- a/pandora_console/godmode/update_manager/update_manager.messages.php +++ b/pandora_console/godmode/update_manager/update_manager.messages.php @@ -66,94 +66,107 @@ if ($delete_action !== false) { } -// Get all messages -$sql = 'SELECT data, svn_version, filename, data_rollback, description FROM tupdate'; -$um_messages = array (); -$um_messages = db_get_all_rows_sql ($sql); +$offset = (int) get_parameter ('offset', 0); -echo ''; +$total_messages = update_manager_get_total_messages (); +if ($total_messages){ -html_print_input_hidden ('tab', 'messages'); -echo '
'; -html_print_submit_button (__('Delete'), 'delete_button', false, - 'class="sub upd"'); -echo '
'; + // Get all messages + $sql = 'SELECT data, svn_version, filename, data_rollback, description FROM tupdate LIMIT ' . $offset . ',' . $config['block_size']; + $um_messages = array (); + $um_messages = db_get_all_rows_sql ($sql); -echo '
'; -html_print_submit_button (__('Mark as not read'), 'not_read_button', false, - 'class="sub upd"'); -echo '
'; + echo ''; -$table = new stdClass(); - $table->width = '100%'; - $table->class = 'databox data'; - $table->cellpadding = 4; - $table->cellspacing = 4; - $table->head = array (); - $table->data = array (); - $table->align = array (); - $table->size = array (); - $table->id = 'um_messages_table'; - - $table->align[0] = "left"; - $table->align[1] = "left"; - $table->align[2] = "left"; - $table->align[3] = "left"; - $table->align[4] = "left"; - - $table->size[0] = "20px"; - $table->size[1] = "100px"; - $table->size[3] = "80px"; - $table->size[4] = "60px"; - - $table->head[0] = __('Message Id'); - $table->head[1] = __('Expiration date'); - $table->head[2] = __('Subject'); - $table->head[3] = html_print_checkbox_extended('all_selection[]', 0, false, false, '', '', true); + html_print_input_hidden ('tab', 'messages'); + html_print_input_hidden ('offset', $offset); + echo '
'; + html_print_submit_button (__('Delete'), 'delete_button', false, + 'class="sub upd"'); + echo '
'; - $i = 0; - foreach ($um_messages as $message) { - $data[0] = $message['svn_version']; - - $data[1] = $message['filename']; - - $data[2] = $message['description']; - - //~ $delete_link = 'index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=messages&delete_single=1&message_id=' . $message['svn_version']; - $data[3] = html_print_checkbox_extended('select_multiple[]', $message['svn_version'], false, false, '', 'class="check_selection"', true); - - - // Change row class if message is read or not by this user - if (update_manger_get_read_message ($message['svn_version'], $message['data_rollback'])) { - $table->rowclass[count($table->data)] = "um_read_message"; - - } else { - $table->rowclass[count($table->data)] = "um_not_read_message"; - - } - array_push ($table->data, $data); - - // Insert an empty row too. Here the message will be displayed - $empty[0] = ""; - $table->colspan[count($table->data)][0] = 4; - $table->cellclass[count($table->data)][0] = "um_message_" . $i; - $table->cellstyle[count($table->data)][0] = "display: none;"; - array_push ($table->data, $empty); - - $i++; + echo '
'; + html_print_submit_button (__('Mark as not read'), 'not_read_button', false, + 'class="sub upd"'); + echo '
'; + + if ($total_messages > $config['block_size']) { + ui_pagination (update_manager_get_total_messages (), false, 0); } -html_print_table($table); -echo '
'; -html_print_submit_button (__('Delete'), 'delete_button', false, - 'class="sub upd"'); -echo '
'; + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox data'; + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->head = array (); + $table->data = array (); + $table->align = array (); + $table->size = array (); + $table->id = 'um_messages_table'; + + $table->align[0] = "left"; + $table->align[1] = "left"; + $table->align[2] = "left"; + $table->align[3] = "left"; + $table->align[4] = "left"; + + $table->size[0] = "20px"; + $table->size[1] = "100px"; + $table->size[3] = "80px"; + $table->size[4] = "60px"; + + $table->head[0] = __('Message Id'); + $table->head[1] = __('Expiration date'); + $table->head[2] = __('Subject'); + $table->head[3] = html_print_checkbox_extended('all_selection[]', 0, false, false, '', '', true); -echo '
'; -html_print_submit_button (__('Mark as not read'), 'not_read_button', false, - 'class="sub upd"'); -echo '
'; -echo ''; + $i = 0; + foreach ($um_messages as $message) { + $data[0] = $message['svn_version']; + + $data[1] = $message['filename']; + + $data[2] = $message['description']; + + //~ $delete_link = 'index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=messages&delete_single=1&message_id=' . $message['svn_version']; + $data[3] = html_print_checkbox_extended('select_multiple[]', $message['svn_version'], false, false, '', 'class="check_selection"', true); + + + // Change row class if message is read or not by this user + if (update_manger_get_read_message ($message['svn_version'], $message['data_rollback'])) { + $table->rowclass[count($table->data)] = "um_read_message"; + + } else { + $table->rowclass[count($table->data)] = "um_not_read_message"; + + } + array_push ($table->data, $data); + + // Insert an empty row too. Here the message will be displayed + $empty[0] = ""; + $table->colspan[count($table->data)][0] = 4; + $table->cellclass[count($table->data)][0] = "um_message_" . $i; + $table->cellstyle[count($table->data)][0] = "display: none;"; + array_push ($table->data, $empty); + + $i++; + } + html_print_table($table); + + echo '
'; + html_print_submit_button (__('Delete'), 'delete_button', false, + 'class="sub upd"'); + echo '
'; + + echo '
'; + html_print_submit_button (__('Mark as not read'), 'not_read_button', false, + 'class="sub upd"'); + echo '
'; + echo ''; +} else { + ui_print_info_message ( array ( 'no_close' => true, 'message' => __('There is not any update manager messages.') ) ); +} ?> + + + diff --git a/pandora_console/godmode/update_manager/update_manager.messages.php b/pandora_console/godmode/update_manager/update_manager.messages.php index 2bd2ef5859..e4f6d3a3ac 100644 --- a/pandora_console/godmode/update_manager/update_manager.messages.php +++ b/pandora_console/godmode/update_manager/update_manager.messages.php @@ -39,6 +39,7 @@ if (is_ajax()) { if ($not_read_single) { $message_id = get_parameter ('message_id', 0); update_manger_set_read_message ($message_id, 1); + update_manager_remote_read_messages ($message_id); } return; @@ -74,6 +75,7 @@ if ($total_messages){ // Get all messages $sql = 'SELECT data, svn_version, filename, data_rollback, db_field_value FROM tupdate '; $sql .= 'WHERE description NOT LIKE \'%"' . $config['id_user'] . '":1%\' '; + $sql .= 'OR description IS NULL '; $sql .= 'LIMIT ' . $offset . ',' . $config['block_size']; $um_messages = array (); $um_messages = db_get_all_rows_sql ($sql); @@ -84,12 +86,12 @@ if ($total_messages){ html_print_input_hidden ('offset', $offset); echo '
'; html_print_submit_button (__('Delete'), 'delete_button', false, - 'class="sub upd"'); + 'class="sub delete"'); echo '
'; echo '
'; html_print_submit_button (__('Mark as not read'), 'not_read_button', false, - 'class="sub upd"'); + 'class="sub wand"'); echo '
'; if ($total_messages > $config['block_size']) { @@ -113,26 +115,32 @@ if ($total_messages){ $table->align[3] = "left"; $table->align[4] = "left"; - $table->size[0] = "20px"; + $table->size[0] = "30px"; $table->size[1] = "100px"; $table->size[3] = "80px"; $table->size[4] = "60px"; - $table->head[0] = __('Message Id'); - $table->head[1] = __('Expiration date'); + $table->style[0] = "padding-left: 20px"; + + $table->head[0] = html_print_checkbox_extended('all_selection[]', 0, false, false, '', '', true); + $table->head[1] = __('Message Id'); $table->head[2] = __('Subject'); - $table->head[3] = html_print_checkbox_extended('all_selection[]', 0, false, false, '', '', true); + $table->head[3] = __('Expiration date'); + $i = 0; foreach ($um_messages as $message) { - $data[0] = $message['svn_version']; + $data[0] = html_print_checkbox_extended('select_multiple[]', $message['svn_version'], false, false, '', 'class="check_selection"', true); + $table->cellclass[count($table->data)][0] = 'um_individual_check'; - $data[1] = $message['filename']; + $data[1] = $message['svn_version']; + $table->cellclass[count($table->data)][1] = 'um_individual_info'; $data[2] = $message['db_field_value']; + $table->cellclass[count($table->data)][2] = 'um_individual_subject'; - //~ $delete_link = 'index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=messages&delete_single=1&message_id=' . $message['svn_version']; - $data[3] = html_print_checkbox_extended('select_multiple[]', $message['svn_version'], false, false, '', 'class="check_selection"', true); + $data[3] = $message['filename']; + $table->cellclass[count($table->data)][3] = 'um_individual_info'; // Change row class if message is read or not by this user @@ -156,14 +164,14 @@ if ($total_messages){ } html_print_table($table); - echo '
'; + echo '
'; html_print_submit_button (__('Delete'), 'delete_button', false, - 'class="sub upd"'); + 'class="sub delete"'); echo '
'; - echo '
'; + echo '
'; html_print_submit_button (__('Mark as not read'), 'not_read_button', false, - 'class="sub upd"'); + 'class="sub wand"'); echo '
'; echo ''; } else { @@ -176,8 +184,10 @@ if ($total_messages){ $("#checkbox-all_selection").click( function() { if ($("#checkbox-all_selection").is(':checked')) { $(".check_selection").prop('checked', true); + $(".check_selection").parent().parent().css('background', "#FFFFEE"); } else { $(".check_selection").prop('checked', false); + $(".check_selection").parent().parent().css('background', "inherit"); } }); @@ -194,14 +204,14 @@ if ($total_messages){ var column = raw_position.replace(/.*-/ig, ""); // Delete and mark as not read column will do not open the message - if (column > 2) return; + if (column == 0) return; if (row%2 == 0) { // Clicking a tittle // Class where object will be displayed var current_class = ".um_message_" + row/2; - var message_id = $("#"+target).parent().find(":first-child").html(); + var message_id = $("#"+target).parent().find(":nth-child(2)").html(); var div_id = 'um_individual_message' + row/2; // Get the message via Ajax (only if it is not checked now @@ -230,17 +240,77 @@ if ($total_messages){ "message_id": message_id}, function (data) {} ); - $("#"+target).parent().find(".um_not_read_message").attr('class', 'um_read_message'); + + $("#"+target).parent().children().each(function(){ + var full_class = $(this).attr('class'); + console.log ("current_class: " + full_class); + full_class = full_class.replace (/um_not_read_message/g, "um_read_message"); + console.log ("modified_class: " + full_class); + $(this).attr('class', full_class); + }); } } // Display message $(current_class).toggle (); - } else { - // Clicking a message - $(".um_message_" + Math.floor(row/2)).hide(); } }); + + $(".check_selection").click(function (event) { + console.log(event.target.id); + if ($("#" + event.target.id).is(':checked')) { + $("#" + event.target.id).parent().parent().css('background', "#FFFFEE"); + } else { + $("#" + event.target.id).parent().parent().css('background', 'inherit'); + } + }); + + $(".um_individual_info, .um_individual_subject").hover( + function () { + $(this).parent().css('background', '#EFFFEF'); + }, + function () { + if ($(this).parent().find(":first-child").is(':checked')) { + $(this).parent().css('background', "#FFFFEE"); + } else { + $(this).parent().css('background', 'inherit'); + } + } + ); + + + diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index f3187aa7b0..24d79353f6 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -201,6 +201,8 @@ function config_update_config () { $error_update[] = __('Allow create planned downtimes in the past'); if (!config_update_value ('limit_parameters_massive', get_parameter('limit_parameters_massive'))) $error_update[] = __('Limit parameters massive'); + if (!config_update_value ('identification_reminder', get_parameter('identification_reminder'))) + $error_update[] = __('Identification_reminder'); break; case 'enterprise': if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { @@ -1464,7 +1466,7 @@ function config_check () { //Registration advice if (!isset ($config['instance_registered']) || ($config['instance_registered'] != 1)) { set_pandora_error_for_header( - __('Click HERE to init the registration process'), + __('Click here to init the registration process'), __("This PandoraFMS instance is not registered")); } @@ -1472,7 +1474,7 @@ function config_check () { $newsletter = db_get_value ('middlename', 'tusuario', 'id_user', $config['id_user']); if ($newsletter != 1) { set_pandora_error_for_header( - __('Click HERE to init the newsletter subscription process'), + __('Click here to init the newsletter subscription process'), __("Missing user in newsletter")); } } diff --git a/pandora_console/include/functions_update_manager.php b/pandora_console/include/functions_update_manager.php index b31666f851..abb4cb14bf 100755 --- a/pandora_console/include/functions_update_manager.php +++ b/pandora_console/include/functions_update_manager.php @@ -383,11 +383,9 @@ function update_manager_curl_request ($action, $additional_params = false) { 'build' => $um_config_values['build'] ); if ($additional_params !== false) { - html_debug ($additional_params, true); $params = array_merge ($params, $additional_params); } $params['action'] = $action; - html_debug ($params, true); $curlObj = curl_init(); curl_setopt($curlObj, CURLOPT_URL, $config['url_update_manager']); @@ -454,38 +452,30 @@ function update_manager_curl_request ($action, $additional_params = false) { } -function update_manager_insert_newsletter () { +function update_manager_insert_newsletter ($email) { global $config; - $email = db_get_value ('email', 'tusuario', 'id_user', $config['id_user']); + if ($email === '') return false; + $params = array( 'email' => $email, 'language' => $config['language'] ); - //For to test in the shell ????????????????? - /* - wget https://artica.es/pandoraupdate6/server.php -O- --no-check-certificate --post-data "action=new_newsletter&email=m@d.com&language=es" - */ - $result = update_manager_curl_request ('new_newsletter', $params); if (!$result['success']) { - html_debug ("FAIL update_manager_insert_newsletter", true); - html_debug ($result, true); - return ($result['update_message']); + return false; } - switch ($resul['http_status']) { + switch ($result['http_status']) { case 200: - //SUCESS - break; - case 201: //provisional - //EMAIL ON DB - break; + $message = json_decode($result['update_message'], true); + if ($message['success'] == 1) return true; + return false; default: - //FAILS + return false; break; } } @@ -496,39 +486,38 @@ function update_manager_register_instance () { $email = db_get_value ('email', 'tusuario', 'id_user', $config['id_user']); $params = array( 'language' => $config['language'], - 'timezone' => $config['timezone'] + 'timezone' => $config['timezone'], + 'email' => $email ); - //For to test in the shell ?????????????? - /* - wget https://artica.es/pandoraupdate6/server.php -O- --no-check-certificate --post-data "action=new_instance&language=es&timezone=Europe/Berlin" - */ - - $result = update_manager_curl_request ('new_instance', $params); + $result = update_manager_curl_request ('new_register', $params); if (!$result['success']) { - html_debug ("FAIL update_manager_register_instance", true); - html_debug ($result, true); - return ($result['update_message']); + return false; } - switch ($resul['http_status']) { + switch ($result['http_status']) { case 200: - //SUCESS //Retrieve the PUID - $update_message = json_decode($result['update_message'], true); - $puid = $update_message[0]['pandora_uid']; - config_update_value ('pandora_uid', $puid); - - //The tupdate table is reused to display messages. A specific entry to tupdate_package is required. - //Then, this tupdate_package id is saved in tconfig - db_process_sql_insert ('tupdate_package', array ('description' => '__UMMESSAGES__')); - $id_um_package_messages = db_get_value('id', 'tupdate_package', 'description', '__UMMESSAGES__'); - config_update_config ('id_um_package_messages', $id_um_package_messages); + $message = json_decode($result['update_message'], true); + if ($message['success'] == 1) { + $puid = $message['pandora_uid']; + config_update_value ('pandora_uid', $puid); + + //The tupdate table is reused to display messages. A specific entry to tupdate_package is required. + //Then, this tupdate_package id is saved in tconfig + db_process_sql_insert ('tupdate_package', array ('description' => '__UMMESSAGES__')); + $id_um_package_messages = db_get_value('id', 'tupdate_package', 'description', '__UMMESSAGES__'); + config_update_value ('id_um_package_messages', $id_um_package_messages); + return true; + } else { + return false; + } break; default: - //FAILS + return false; + break; } } @@ -537,56 +526,66 @@ function update_manager_download_messages () { // TODO: Delete old messages - $email = db_get_value ('email', 'tusuario', 'id_user', $config['id_user']); $params = array( - 'pandora_uid' => $config['puid'] - ); + 'pandora_uid' => $config['pandora_uid'] + ); //For to test in the shell ?????????????? /* wget https://artica.es/pandoraupdate6/server.php -O- --no-check-certificate --post-data "action=download_messages&language=es&timezone=Europe/Berlin" */ - $result = update_manager_curl_request ('download_messages', $params); + $result = update_manager_curl_request ('get_messages', $params); + + //Do not ask in next 2 hours + config_update_value ('last_um_check', time() + 2 * SECONDS_1HOUR); if (!$result['success']) { - //Do not ask in next 2 hours - //~ html_debug ("FAIL update_manager_download_messages", true); - //~ html_debug ($result, true); - config_update_value ('last_um_check', time() + 2 * SECONDS_1HOUR); return ($result['update_message']); } - switch ($resul['http_status']) { + switch ($result['http_status']) { case 200: - //SUCESS + $message = json_decode($result['update_message'], true); + + if ($message['success'] == 1) { + foreach ($message['messages'] as $single_message) { + // Convert subject -> db_field_value; message_html -> data; expiration -> filename; message_id -> svn_version + $single_message['db_field_value'] = $single_message['subject']; + unset ($single_message['subject']); + $single_message['data'] = $single_message['message_html']; + unset ($single_message['message_html']); + $single_message['filename'] = $single_message['expiration']; + unset ($single_message['expiration']); + $single_message['svn_version'] = $single_message['message_id']; + unset ($single_message['message_id']); + + // Add common tconfig id_update_package + $single_message['id_update_package'] = $config['id_um_package_messages']; + + $result = db_process_sql_insert('tupdate', $single_message); + } + } break; default: - } - - //Do not ask in next 2 hours - config_update_value ('last_um_check', time() + 2 * SECONDS_1HOUR); - //FAILS + break; + } } function update_manager_remote_read_messages ($id_message) { global $config; - $email = db_get_value ('email', 'tusuario', 'id_user', $config['id_user']); $params = array( - 'pandora_uid' => $config['puid'], - 'id_message' => $id_message + 'pandora_uid' => $config['pandora_uid'], + 'message_id' => $id_message ); - //For to test in the shell ?????????????? - /* - wget https://artica.es/pandoraupdate6/server.php -O- --no-check-certificate --post-data "action=download_messages&language=es&timezone=Europe/Berlin" - */ + $result = update_manager_curl_request ('mark_as_read', $params); - $result = update_manager_curl_request ('read_message', $params); + //if (!$result['success']) { + // html_debug ($result['update_message'], true); + //} - html_debug ("Update_manager_read_messages", true); - html_debug ($result, true); return $result['success']; } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 78dd1c06d3..3444356aa4 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -3087,14 +3087,6 @@ table#policy_modules td * { margin-left: 3%; } -.um_not_read_message{ - font-weight: 900; -} -.um_read_message{ - font-weight: 500; - color: #bbbbbb; -} - /* The items with the class 'spinner' will rotate */ /* Not supported on IE9 and below */ .spinner { diff --git a/pandora_console/index.php b/pandora_console/index.php index be76bdd9f3..4a4e9cc723 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -528,6 +528,14 @@ clear_pandora_error_for_header(); $config['logged'] = false; extensions_load_extensions ($process_login); + +// Check for update manager messages +if ($config['last_um_check'] > (time() + 2 * SECONDS_1HOUR)) { + require_once("include/functions_update_manager.php"); + + update_manager_download_messages (); +} + if ($process_login) { /* Call all extensions login function */ extensions_call_login_function (); @@ -615,7 +623,6 @@ if (get_parameter ('login', 0) !== 0) { include_once("general/login_help_dialog.php"); } - } // Header diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 918082ea31..445371443c 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -362,10 +362,10 @@ if (license_free()) { $data[1] = __('Newsletter Subscribed'); $data[1] .= $jump . ui_print_help_tip(__('Subs news'), true); if ($user_info["middlename"]) { - $data[1] .= $jump . __('You are subscribed to PandoraFMS newsletter'); + $data[1] .= $jump . '' . __('You are subscribed to PandoraFMS newsletter') . ""; } else { - $data[1] .= $jump . __('Click HERE to init the newsletter subscription process'); + $data[1] .= $jump . '' . __('Click here to init the newsletter subscription process') . ""; } $data[2] = __('Newsletter Reminder'); From 60df86a8d4f154d69ddbb9fe2f78cf20275ee840 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 8 Jun 2016 18:32:15 +0200 Subject: [PATCH 11/20] Added feedback message when subscription and register --- .../general/login_identification_wizard.php | 59 ++++++++++++++++++- .../include/functions_update_manager.php | 23 ++++---- 2 files changed, 66 insertions(+), 16 deletions(-) diff --git a/pandora_console/general/login_identification_wizard.php b/pandora_console/general/login_identification_wizard.php index 2b86481b51..a2b916c29c 100644 --- a/pandora_console/general/login_identification_wizard.php +++ b/pandora_console/general/login_identification_wizard.php @@ -55,12 +55,18 @@ if (is_ajax()) { $newsletter = get_parameter ('newsletter', 0); $forced = get_parameter ('forced', 0); $future_8_days = time() + 8 * SECONDS_1DAY; + $ui_feedback = array('status' => true, 'message' => ''); if ($register_pandora) { // Pandora register update - if (update_manager_register_instance ()) { + $um_message = update_manager_register_instance (); + $ui_feedback['message'] .= $um_message['message'] . '

'; + if ($um_message['success']) { config_update_value ('instance_registered', 1); + $ui_feedback['status'] = true && $ui_feedback['status']; + } else { + $ui_feedback['status'] = false; } } elseif (!$forced) { config_update_value ('identification_reminder_timestamp', $future_8_days); @@ -70,12 +76,21 @@ if (is_ajax()) { // Pandora newsletter update $email = get_parameter ('email', ''); - if (update_manager_insert_newsletter ($email)){ + $um_message = update_manager_insert_newsletter ($email); + $ui_feedback['message'] .= $um_message['message']; + if ($um_message['success']) { db_process_sql_update ('tusuario', array ('middlename' => 1), array('id_user' => $config['id_user'])); + $ui_feedback['status'] = true && $ui_feedback['status']; + } else { + $ui_feedback['status'] = false; } } elseif (!$forced) { db_process_sql_update ('tusuario', array ('lastname' => $future_8_days), array('id_user' => $config['id_user'])); } + + // Form answer JSON + $ui_feedback['status'] = $ui_feedback['status'] ? 1 : 0; + echo io_json_mb_encode($ui_feedback); } if (!$not_return) { @@ -170,6 +185,14 @@ echo '
'; echo '
'; + +// Print feedback user dialog +echo '
'; + echo '
'; + echo html_print_image ('images/support.png', true); + echo '
'; + echo '
'; +echo '
'; ?> diff --git a/pandora_console/general/login_identification_wizard.php b/pandora_console/general/login_identification_wizard.php index 69e8e5a888..e6a2d3790a 100644 --- a/pandora_console/general/login_identification_wizard.php +++ b/pandora_console/general/login_identification_wizard.php @@ -124,7 +124,7 @@ $display_register = display_register ($wizard_data); $display_forced = ($wizard_data['force_newsletter'] != -1) || ($wizard_data['force_register'] != -1); // Return if it is fully completed -if ((!$display_register) && (!$display_newsletter)) return; +if ((!$display_register) && (!$display_newsletter)) return false; $return_button = get_parameter ('return_button', 0) == 1; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 24d79353f6..dd31ae027c 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1463,18 +1463,19 @@ function config_check () { if (license_free() && users_is_admin($config['id_user'])) { + $login = get_parameter ('login', false); //Registration advice - if (!isset ($config['instance_registered']) || ($config['instance_registered'] != 1)) { + if ((!isset ($config['instance_registered']) || ($config['instance_registered'] != 1)) && ($login === false)) { set_pandora_error_for_header( - __('Click here to init the registration process'), - __("This PandoraFMS instance is not registered")); + __('Click here to start the registration process'), + __("This instance is not registered in the Update manager")); } //Newsletter advice $newsletter = db_get_value ('middlename', 'tusuario', 'id_user', $config['id_user']); - if ($newsletter != 1) { + if ($newsletter != 1 && $login === false) { set_pandora_error_for_header( - __('Click here to init the newsletter subscription process'), + __('Click here to start the newsletter subscription process'), __("Missing user in newsletter")); } } diff --git a/pandora_console/index.php b/pandora_console/index.php index 4a4e9cc723..ef03f6542b 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -530,7 +530,7 @@ $config['logged'] = false; extensions_load_extensions ($process_login); // Check for update manager messages -if ($config['last_um_check'] > (time() + 2 * SECONDS_1HOUR)) { +if (license_free() && is_user_admin ($config['id_user']) && $config['last_um_check'] > (time() + 2 * SECONDS_1HOUR)) { require_once("include/functions_update_manager.php"); update_manager_download_messages (); @@ -605,7 +605,12 @@ if ($old_global_counter_chat != $now_global_counter_chat) { $_SESSION['new_chat'] = true; } -if ($config['initial_wizard'] != 1) { +// Pop-ups display order: +// 1) login_required (timezone and email) +// 2) identification (newsletter and register) +// 3) last_message (update manager message popup +// 4) login_help (online help, enterpirse version, forums, documentation) +if (!isset($config['initial_wizard']) || $config['initial_wizard'] != 1) { include_once ("general/login_required.php"); } if (get_parameter ('login', 0) !== 0) { @@ -614,13 +619,17 @@ if (get_parameter ('login', 0) !== 0) { // Display login help info dialog // If it's configured to not skip this - - if ($config['initial_wizard'] == 1) { - include_once("general/login_identification_wizard.php"); + $display_previous_popup = false; + if (license_free() && is_user_admin ($config['id_user']) && $config['initial_wizard'] == 1) { + $display_previous_popup = include_once("general/login_identification_wizard.php"); + if ($display_previous_popup === false) { + $display_previous_popup = include_once("general/last_message.php"); + } } - if (!isset($config['skip_login_help_dialog']) || - $config['skip_login_help_dialog'] == 0) { - + if ((!isset($config['skip_login_help_dialog']) || $config['skip_login_help_dialog'] == 0) && + $display_previous_popup === false && + $config['initial_wizard'] == 1) { + include_once("general/login_help_dialog.php"); } } @@ -881,7 +890,7 @@ require('include/php_to_js_values.php'); $("#login_accept_register").dialog('open'); } else { - console.log ("ajax open wizard"); + $(".ui-dialog-titlebar-close").show(); $("#container").append('
'); jQuery.get ("ajax.php", From a93a6befeecd646af49b4275f8a8a2cd46b653cb Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 13 Jun 2016 17:31:17 +0200 Subject: [PATCH 18/20] Removed some unwanted traces --- pandora_console/general/login_identification_wizard.php | 1 - pandora_console/general/login_required.php | 2 +- .../godmode/update_manager/update_manager.messages.php | 4 +--- pandora_console/index.php | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pandora_console/general/login_identification_wizard.php b/pandora_console/general/login_identification_wizard.php index e6a2d3790a..501bdd05df 100644 --- a/pandora_console/general/login_identification_wizard.php +++ b/pandora_console/general/login_identification_wizard.php @@ -38,7 +38,6 @@ function display_newsletter ($data) { if (!isset ($data['newsletter_reminder_timestamp'])) return true; if (!is_numeric ($data['newsletter_reminder_timestamp'])) return true; if ($data['newsletter_reminder_timestamp'] < time()) return true; - else {html_debug ($data['newsletter_reminder_timestamp'] . "<<-data", true);} return false; } diff --git a/pandora_console/general/login_required.php b/pandora_console/general/login_required.php index df2bd630ef..054b299982 100644 --- a/pandora_console/general/login_required.php +++ b/pandora_console/general/login_required.php @@ -120,7 +120,7 @@ echo '
'; //HELPER FUNCTIONS function show_timezone () { zone = $("#zone").val(); - console.log("Z: " +zone); + $.ajax({ type: "POST", url: "ajax.php", diff --git a/pandora_console/godmode/update_manager/update_manager.messages.php b/pandora_console/godmode/update_manager/update_manager.messages.php index 39103a49b6..f40edbc649 100644 --- a/pandora_console/godmode/update_manager/update_manager.messages.php +++ b/pandora_console/godmode/update_manager/update_manager.messages.php @@ -264,9 +264,7 @@ if ($total_messages){ $("#"+target).parent().children().each(function(){ var full_class = $(this).attr('class'); - console.log ("current_class: " + full_class); full_class = full_class.replace (/um_not_read_message/g, "um_read_message"); - console.log ("modified_class: " + full_class); $(this).attr('class', full_class); }); } @@ -280,7 +278,7 @@ if ($total_messages){ }); $(".check_selection").click(function (event) { - console.log(event.target.id); + if ($("#" + event.target.id).is(':checked')) { $("#" + event.target.id).parent().parent().css('background', "#FFFFEE"); } else { diff --git a/pandora_console/index.php b/pandora_console/index.php index ef03f6542b..25e673ae8f 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -860,7 +860,7 @@ require('include/php_to_js_values.php'); function run_identification_wizard (register, newsletter , return_button) { if (times_fired_register_wizard) { - console.log ("only open"); + $(".ui-dialog-titlebar-close").show(); //Reset some values From 2ea9b6f97beb0b42d087d26633e04bc40977c647 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 13 Jun 2016 18:18:12 +0200 Subject: [PATCH 19/20] Added some dafault values --- pandora_console/general/login_required.php | 3 +++ pandora_console/include/functions_config.php | 4 ++++ pandora_console/pandoradb.data.oracle.sql | 2 ++ pandora_console/pandoradb.data.postgreSQL.sql | 2 ++ pandora_console/pandoradb_data.sql | 2 ++ 5 files changed, 13 insertions(+) diff --git a/pandora_console/general/login_required.php b/pandora_console/general/login_required.php index 054b299982..6dc94e2eff 100644 --- a/pandora_console/general/login_required.php +++ b/pandora_console/general/login_required.php @@ -179,6 +179,9 @@ $(document).ready (function () { closeOnEscape: false, open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); } }); + + $(".ui-widget-overlay").css("background", "#000"); + $(".ui-widget-overlay").css("opacity", 0.6); }); /* ]]> */ diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index dd31ae027c..36174664e3 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1445,6 +1445,10 @@ function config_process_config () { config_update_value ('identification_reminder', 1); } + if (!isset ($config["identification_reminder_timestamp"])) { + config_update_value ('identification_reminder_timestamp', 0); + } + if (!isset ($config["instance_registered"])) { config_update_value ('instance_registered', 0); } diff --git a/pandora_console/pandoradb.data.oracle.sql b/pandora_console/pandoradb.data.oracle.sql index bb8bc79e07..0ddcc4cb19 100644 --- a/pandora_console/pandoradb.data.oracle.sql +++ b/pandora_console/pandoradb.data.oracle.sql @@ -132,6 +132,8 @@ INSERT INTO tconfig (token, value) VALUES ('custom_report_front_font', 'FreeSans INSERT INTO tconfig (token, value) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'); INSERT INTO tconfig (token, value) VALUES ('custom_report_front_header', ''); INSERT INTO tconfig (token, value) VALUES ('custom_report_front_footer', ''); +INSERT INTO tconfig (token, value) VALUES ('identification_reminder', 1); +INSERT INTO tconfig (token, value) VALUES ('identification_reminder_timestamp', 0); INSERT INTO tconfig (token, value) VALUES ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'); COMMIT; diff --git a/pandora_console/pandoradb.data.postgreSQL.sql b/pandora_console/pandoradb.data.postgreSQL.sql index 9ecac660f5..8b10b2c721 100644 --- a/pandora_console/pandoradb.data.postgreSQL.sql +++ b/pandora_console/pandoradb.data.postgreSQL.sql @@ -119,6 +119,8 @@ INSERT INTO "tconfig" ("token", "value") VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''); +('identification_reminder', 1); +('identification_reminder_timestamp', 0); COMMIT WORK; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index b0608161c1..dd997df798 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -106,6 +106,8 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), +('identification_reminder', 1), +('identification_reminder_timestamp', 0), ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'); UNLOCK TABLES; From a5bb1079843f480d10bdb7876809c35d860cdaf0 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 13 Jun 2016 18:18:36 +0200 Subject: [PATCH 20/20] Fixed display newsletter checkbox at first time --- pandora_console/general/login_identification_wizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/general/login_identification_wizard.php b/pandora_console/general/login_identification_wizard.php index 501bdd05df..f69b90f034 100644 --- a/pandora_console/general/login_identification_wizard.php +++ b/pandora_console/general/login_identification_wizard.php @@ -34,7 +34,7 @@ function display_newsletter ($data) { if ($data['newsletter_subscribed'] == 1) return false; if ($data['force_newsletter'] == 1) return true; if ($data['force_newsletter'] == 0) return false; - if ($data['newsletter_reminder'] == 0) return false; + if ($data['newsletter_reminder'] === 0) return false; if (!isset ($data['newsletter_reminder_timestamp'])) return true; if (!is_numeric ($data['newsletter_reminder_timestamp'])) return true; if ($data['newsletter_reminder_timestamp'] < time()) return true;