diff --git a/pandora_console/godmode/setup/welcome_tips.php b/pandora_console/godmode/setup/welcome_tips.php index c558404925..144a1a88cb 100644 --- a/pandora_console/godmode/setup/welcome_tips.php +++ b/pandora_console/godmode/setup/welcome_tips.php @@ -44,6 +44,7 @@ if ($view === 'create' || $view === 'edit') { if ($action === 'create' || $action === 'edit') { $files = $_FILES; $id_lang = get_parameter('id_lang', ''); + $id_profile = get_parameter('id_profile', ''); $title = get_parameter('title', ''); $text = get_parameter('text', ''); $url = get_parameter('url', ''); @@ -76,7 +77,7 @@ if ($view === 'create' || $view === 'edit') { $uploadImages = $tipsWindow->uploadImages($files); } - $response = $tipsWindow->createTip($id_lang, $title, $text, $url, $enable, $uploadImages); + $response = $tipsWindow->createTip($id_lang, $id_profile, $title, $text, $url, $enable, $uploadImages); if ($response === 0) { $errors[] = __('Error in insert tip'); @@ -100,7 +101,7 @@ if ($view === 'create' || $view === 'edit') { $uploadImages = $tipsWindow->uploadImages($files); } - $response = $tipsWindow->updateTip($idTip, $id_lang, $title, $text, $url, $enable, $uploadImages); + $response = $tipsWindow->updateTip($idTip, $id_profile, $id_lang, $title, $text, $url, $enable, $uploadImages); if ($response === 0) { $errors[] = __('Error in update tip'); diff --git a/pandora_console/include/class/TipsWindow.class.php b/pandora_console/include/class/TipsWindow.class.php index b620745d62..95a45c0a60 100644 --- a/pandora_console/include/class/TipsWindow.class.php +++ b/pandora_console/include/class/TipsWindow.class.php @@ -128,7 +128,7 @@ class TipsWindow ui_require_javascript_file('tipsWindow'); ui_require_javascript_file('jquery.bxslider.min'); echo '
'; - $totalTips = $this->getTotalTipsEnabled(); + $totalTips = $this->getTotalTipsShowUser(); if ($totalTips > 0) { ?> @@ -192,6 +192,11 @@ class TipsWindow { global $config; $exclude = get_parameter('exclude', ''); + $profilesUser = users_get_user_profile($config['id_user']); + $idProfilesFilter = '0'; + foreach ($profilesUser as $key => $profile) { + $idProfilesFilter .= ','.$profile['id_perfil']; + } $sql = 'SELECT id, title, text, url FROM twelcome_tip @@ -204,6 +209,8 @@ class TipsWindow } } + $sql .= sprintf(' AND id_profile IN (%s)', $idProfilesFilter); + $sql .= ' ORDER BY CASE WHEN id_lang = "'.$config['language'].'" THEN id_lang END DESC, RAND()'; $tip = db_get_row_sql($sql); @@ -240,9 +247,24 @@ class TipsWindow } - public function getTotalTipsEnabled() + public function getTotalTipsShowUser() { - return db_get_sql('SELECT count(*) FROM twelcome_tip WHERE enable = "1"'); + global $config; + $profilesUser = users_get_user_profile($config['id_user']); + $idProfilesFilter = '0'; + foreach ($profilesUser as $key => $profile) { + $idProfilesFilter .= ','.$profile['id_perfil']; + } + + $sql = 'SELECT count(*) + FROM twelcome_tip + WHERE enable = "1" '; + + $sql .= sprintf(' AND id_profile IN (%s)', $idProfilesFilter); + + $sql .= ' ORDER BY CASE WHEN id_lang = "'.$config['language'].'" THEN id_lang END DESC, RAND()'; + + return db_get_sql($sql); } @@ -535,6 +557,8 @@ class TipsWindow } } + $profiles = profile_get_profiles(); + $table = new stdClass(); $table->width = '100%'; $table->class = 'databox filters'; @@ -555,14 +579,16 @@ class TipsWindow '0', 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); + $table->data[2][0] = __('Profile'); + $table->data[2][1] = html_print_select($profiles, 'id_profile', '0', '', __('All'), 0, true); + $table->data[3][0] = __('Title'); + $table->data[3][1] = html_print_input_text('title', '', '', 35, 100, true); + $table->data[4][0] = __('Text'); + $table->data[4][1] = html_print_textarea('text', 5, 1, '', '', true); + $table->data[5][0] = __('Url'); + $table->data[5][1] = html_print_input_text('url', '', '', 35, 100, true); + $table->data[6][0] = __('Enable'); + $table->data[6][1] = html_print_checkbox_switch('enable', true, true, true); echo '