diff --git a/pandora_console/godmode/setup/welcome_tips.php b/pandora_console/godmode/setup/welcome_tips.php index cb5f730299..514beea60e 100644 --- a/pandora_console/godmode/setup/welcome_tips.php +++ b/pandora_console/godmode/setup/welcome_tips.php @@ -41,6 +41,7 @@ try { if ($view === 'create') { if ($action === 'create') { + $files = $_FILES; $secure_input = get_parameter('secure_input', ''); $id_lang = get_parameter('id_lang', ''); $title = get_parameter('title', ''); @@ -49,6 +50,13 @@ if ($view === 'create') { $enable = get_parameter_switch('enable', ''); $errors = []; + if (count($files) > 0) { + $e = $tipsWindow->validateImages($files); + if ($e !== false) { + $errors = $e; + } + } + if (empty($id_lang) === true) { $errors[] = __('Language is empty'); } @@ -62,7 +70,12 @@ if ($view === 'create') { } if (count($errors) === 0) { - $response = $tipsWindow->createTip($id_lang, $title, $text, $url, $enable); + if (count($files) > 0) { + $uploadImages = $tipsWindow->uploadImages($files); + } + + $response = $tipsWindow->createTip($id_lang, $title, $text, $url, $enable, $uploadImages); + if ($response === false) { $errors[] = __('Error in insert data'); } diff --git a/pandora_console/include/class/TipsWindow.class.php b/pandora_console/include/class/TipsWindow.class.php index fa8e9ea46d..4303ac02db 100644 --- a/pandora_console/include/class/TipsWindow.class.php +++ b/pandora_console/include/class/TipsWindow.class.php @@ -27,6 +27,7 @@ */ // Begin. +use LDAP\Result; use PandoraFMS\View; global $config; @@ -129,9 +130,9 @@ class TipsWindow public function run() { global $config; - $user_info = users_get_user_by_id($config['id_user']); + $userInfo = users_get_user_by_id($config['id_user']); - if ((bool) $user_info['show_tips_startup'] === false) { + if ((bool) $userInfo['show_tips_startup'] === false) { return; } @@ -243,11 +244,11 @@ class TipsWindow public function setShowTipsAtStartup() { global $config; - $show_tips_startup = get_parameter('show_tips_startup', ''); - if ($show_tips_startup !== '' && $show_tips_startup !== null) { + $showTipsStartup = get_parameter('show_tips_startup', ''); + if ($showTipsStartup !== '' && $showTipsStartup !== null) { $result = db_process_sql_update( 'tusuario', - ['show_tips_startup' => $show_tips_startup], + ['show_tips_startup' => $showTipsStartup], ['id_user' => $config['id_user']] ); @@ -274,7 +275,7 @@ class TipsWindow 'text', ]; - $column_names = [ + $columnNames = [ __('Title'), __('Text'), ]; @@ -286,7 +287,7 @@ class TipsWindow 'class' => 'info_table', 'style' => 'width: 100%', 'columns' => $columns, - 'column_names' => $column_names, + 'column_names' => $columnNames, 'ajax_url' => $this->ajaxController, 'ajax_data' => ['method' => 'getTips'], 'no_sortable_columns' => [-1], @@ -334,7 +335,7 @@ class TipsWindow // Catch post parameters. $start = get_parameter('start', 0); $length = get_parameter('length', $config['block_size']); - $order_datatable = get_datatable_order(true); + $orderDatatable = get_datatable_order(true); $filters = get_parameter('filter', []); $pagination = ''; $filter = ''; @@ -349,11 +350,11 @@ class TipsWindow } } - if (isset($order_datatable)) { + if (isset($orderDatatable)) { $order = sprintf( ' ORDER BY %s %s', - $order_datatable['field'], - $order_datatable['direction'] + $orderDatatable['field'], + $orderDatatable['direction'] ); } @@ -416,6 +417,9 @@ class TipsWindow public function viewCreate($errors=null) { + ui_require_javascript_file('tipsWindow'); + ui_require_css_file('tips_window'); + if ($errors !== null) { if (count($errors) > 0) { foreach ($errors as $key => $value) { @@ -433,8 +437,12 @@ class TipsWindow $table->style[0] = 'font-weight: bold'; $table->data = []; - $table->data[0][0] = __('Language'); - $table->data[0][1] = html_print_select_from_sql( + $table->data[0][0] = __('Images'); + $table->data[0][1] = html_print_input_hidden('number_images', 0, true); + $table->data[0][1] .= html_print_div(['id' => 'inputs_images'], true); + $table->data[0][1] .= html_print_button(__('Add image'), 'button_add_image', false, '', '', true); + $table->data[1][0] = __('Language'); + $table->data[1][1] = html_print_select_from_sql( 'SELECT id_language, name FROM tlanguage', 'id_lang', '', @@ -443,16 +451,16 @@ class TipsWindow '0', true ); - $table->data[1][0] = __('Title'); - $table->data[1][1] = html_print_input_text('title', '', '', 35, 100, true); - $table->data[2][0] = __('Text'); - $table->data[2][1] = html_print_textarea('text', 5, 1, '', '', true); - $table->data[3][0] = __('Url'); - $table->data[3][1] = html_print_input_text('url', '', '', 35, 100, true); - $table->data[4][0] = __('Enable'); - $table->data[4][1] = html_print_checkbox_switch('enable', true, true, true); + $table->data[2][0] = __('Title'); + $table->data[2][1] = html_print_input_text('title', '', '', 35, 100, true); + $table->data[3][0] = __('Text'); + $table->data[3][1] = html_print_textarea('text', 5, 1, '', '', true); + $table->data[4][0] = __('Url'); + $table->data[4][1] = html_print_input_text('url', '', '', 35, 100, true); + $table->data[5][0] = __('Enable'); + $table->data[5][1] = html_print_checkbox_switch('enable', true, true, true); - echo '