diff --git a/pandora_console/operation/search_graphs.getdata.php b/pandora_console/operation/search_graphs.getdata.php
index aefd6e2073..4dc6f3ba74 100644
--- a/pandora_console/operation/search_graphs.getdata.php
+++ b/pandora_console/operation/search_graphs.getdata.php
@@ -26,6 +26,7 @@ if ($searchGraphs) {
$usergraphs_id = array_keys($usergraphs);
if (empty($usergraphs_id)) {
+ $totalGraphs = 0;
return;
}
@@ -37,6 +38,7 @@ if ($searchGraphs) {
'id_graph',
'name',
'description',
+
];
$totalGraphs = (int) db_get_value_filter('COUNT(id_graph) AS count', 'tgraph', $filter);
@@ -45,5 +47,7 @@ if ($searchGraphs) {
$filter['limit'] = $config['block_size'];
$filter['offset'] = (int) get_parameter('offset');
$graphs = db_get_all_rows_filter('tgraph', $filter, $columns);
+ } else {
+ $totalGraphs = 0;
}
}
diff --git a/pandora_console/operation/search_main.php b/pandora_console/operation/search_main.php
index 3a0880e348..718fd45be5 100644
--- a/pandora_console/operation/search_main.php
+++ b/pandora_console/operation/search_main.php
@@ -20,6 +20,7 @@ $searchGraphs = check_acl($config['id_user'], 0, 'RR');
$searchMaps = check_acl($config['id_user'], 0, 'RR');
$searchReports = check_acl($config['id_user'], 0, 'RR');
$searchUsers = check_acl($config['id_user'], 0, 'UM');
+$searchPolicies = check_acl($config['id_user'], 0, 'AW');
$searchHelps = true;
echo '
';
@@ -44,8 +45,12 @@ $table->style[9] = 'font-weight: bold; text-align: center;';
$table->style[10] = 'font-weight: bold; text-align: center;';
$table->style[11] = 'font-weight: bold; text-align: center;';
$table->style[13] = 'font-weight: bold; text-align: center;';
+$table->style[14] = 'font-weight: bold; text-align: center;';
$table->style[15] = 'font-weight: bold; text-align: center;';
+
+
+
$table->data[0][0] = html_print_image('images/agent.png', true, ['title' => __('Agents found')]);
$table->data[0][1] = "
".sprintf(__('%s Found'), $totalAgents).'';
$table->data[0][2] = html_print_image('images/module.png', true, ['title' => __('Modules found')]);
@@ -64,8 +69,10 @@ $table->data[0][10] = html_print_image('images/reporting.png', true, ['title' =>
$table->data[0][11] = "
".sprintf(__('%s Found'), $totalReports).'';
$table->data[0][12] = html_print_image('images/visual_console_green.png', true, ['title' => __('Maps found')]);
$table->data[0][13] = "
".sprintf(__('%s Found'), $totalMaps).'';
-$table->data[0][14] = html_print_image('images/help.png', true, ['title' => __('Helps found')]);
-$table->data[0][15] = "
".sprintf(__('%s Found'), $totalHelps).'';
+if (enterprise_installed()) {
+ $table->data[0][14] = html_print_image('images/policies.png', true, ['title' => __('Policies')]);
+ $table->data[0][15] = "
".sprintf(__('%s Found'), $totalPolicies).'';
+}
html_print_table($table);
@@ -79,4 +86,5 @@ if ($searchAgents && $totalAgents > 0) {
).'';
}
+
echo '
';
diff --git a/pandora_console/operation/search_policies.getdata.php b/pandora_console/operation/search_policies.getdata.php
new file mode 100644
index 0000000000..a8c05ea071
--- /dev/null
+++ b/pandora_console/operation/search_policies.getdata.php
@@ -0,0 +1,200 @@
+ 'id',
+ 'order' => 'ASC',
+ ];
+ break;
+
+ case 'down':
+ $selectpolicieIDDown = $selected;
+ $order = [
+ 'field' => 'id',
+ 'order' => 'DESC',
+ ];
+ break;
+ }
+ break;
+
+ case 'name':
+ switch ($sort) {
+ case 'up':
+ $selectNameUp = $selected;
+ $order = [
+ 'field' => 'name',
+ 'order' => 'ASC',
+ ];
+ break;
+
+ case 'down':
+ $selectNameDown = $selected;
+ $order = [
+ 'field' => 'name',
+ 'order' => 'DESC',
+ ];
+ break;
+ }
+ break;
+
+ case 'description':
+ switch ($sort) {
+ case 'up':
+ $selectId_groupUp = $selected;
+ $order = [
+ 'field' => 'description',
+ 'order' => 'ASC',
+ ];
+ break;
+
+ case 'down':
+ $selectDescriptionDown = $selected;
+ $order = [
+ 'field' => 'description',
+ 'order' => 'DESC',
+ ];
+ break;
+ }
+ break;
+
+ case 'last_contact':
+ switch ($sort) {
+ case 'up':
+ $selectId_groupUp = $selected;
+ $order = [
+ 'field' => 'last_connect',
+ 'order' => 'ASC',
+ ];
+ break;
+
+ case 'down':
+ $selectId_groupDown = $selected;
+ $order = [
+ 'field' => 'last_connect',
+ 'order' => 'DESC',
+ ];
+ break;
+ }
+ break;
+
+ case 'id_group':
+ switch ($sort) {
+ case 'up':
+ $selectId_groupUp = $selected;
+ $order = [
+ 'field' => 'last_connect',
+ 'order' => 'ASC',
+ ];
+ break;
+
+ case 'down':
+ $selectId_groupDown = $selected;
+ $order = [
+ 'field' => 'last_connect',
+ 'order' => 'DESC',
+ ];
+ break;
+ }
+ break;
+
+ case 'status':
+ switch ($sort) {
+ case 'up':
+ $selectStatusUp = $selected;
+ $order = [
+ 'field' => 'is_admin',
+ 'order' => 'ASC',
+ ];
+ break;
+
+ case 'down':
+ $selectStatusDown = $selected;
+ $order = [
+ 'field' => 'is_admin',
+ 'order' => 'DESC',
+ ];
+ break;
+ }
+ break;
+
+ default:
+ $selectpolicieIDUp = $selected;
+ $selectpolicieIDDown = '';
+ $selectNameUp = '';
+ $selectNameDown = '';
+ $selectDescriptionUp = '';
+ $selectDescriptionDown = '';
+ $selectId_groupUp = '';
+ $selectId_groupDown = '';
+ $selectStatusUp = '';
+ $selectStatusDown = '';
+
+ $order = [
+ 'field' => 'id',
+ 'order' => 'ASC',
+ ];
+ break;
+}
+
+if ($searchpolicies == 0) {
+ /*
+ We take the user groups to get policies that meet the requirements of the search
+ and which the user have permission on this groups
+ */
+ $user_groups = users_get_groups($config['id_user'], 'AR', false);
+ $id_user_groups = array_keys($user_groups);
+ $id_user_groups_str = implode(',', $id_user_groups);
+
+ $sql = "SELECT id, name, description, id_group, status
+ FROM tpolicies
+ WHERE name LIKE '$stringSearchSQL'
+ AND id_group IN ($id_user_groups_str)";
+}
+
+
+ $sql .= ' LIMIT '.$config['block_size'].' OFFSET '.get_parameter('offset', 0);
+
+ $policies = db_process_sql($sql);
+
+if ($policies !== false) {
+ $totalPolicies = count($policies);
+
+ if ($only_count) {
+ unset($policies);
+ }
+} else {
+ $totalPolicies = 0;
+}
diff --git a/pandora_console/operation/search_policies.php b/pandora_console/operation/search_policies.php
new file mode 100644
index 0000000000..26b3f7737d
--- /dev/null
+++ b/pandora_console/operation/search_policies.php
@@ -0,0 +1,90 @@
+".__('Zero results found')."
\n";
+} else {
+ $table->cellpadding = 4;
+ $table->cellspacing = 4;
+ $table->width = '98%';
+ $table->class = 'databox';
+
+ $table->align = [];
+ $table->align[4] = 'center';
+
+ $table->head = [];
+ // $table->head[0] = __('ID').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectpolicieIDUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectpolicieIDDown]).'';
+ $table->head[0] = __('Name').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectNameUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectNameDown]).'';
+ $table->head[1] = __('Description').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectDescriptionUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectDescriptionDown]).'';
+ $table->head[2] = __('Id_group').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectId_groupUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectId_groupDown]).'';
+ $table->head[3] = __('Status').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectStatusUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectstatusDown]).'';
+
+ $table->data = [];
+
+ foreach ($policies as $policie) {
+ $policieIDCell = "".$policies['id'].'';
+
+ switch ($policie['status']) {
+ case POLICY_UPDATED:
+ $status = html_print_image(
+ 'images/policies_ok.png',
+ true,
+ ['title' => __('Policy updated')]
+ );
+ break;
+
+ case POLICY_PENDING_DATABASE:
+ $status = html_print_image(
+ 'images/policies_error_db.png',
+ true,
+ ['title' => __('Pending update policy only database')]
+ );
+ break;
+
+ case POLICY_PENDING_ALL:
+ $status = html_print_image(
+ 'images/policies_error.png',
+ true,
+ ['title' => __('Pending update policy')]
+ );
+ break;
+ }
+
+ $url = $config['homeurl'].'/index.php?'.'sec=gmodules&'.'sec2=enterprise/godmode/policies/policies&id='.$policie['id'].'';
+
+ array_push(
+ $table->data,
+ [
+ // $policie['id'],
+ ''.$policie['name'].'',
+ $policie['description'],
+ ui_print_group_icon($policie['id_group'], true),
+ $status,
+
+ ]
+ );
+ }
+
+ $totalPolicies = count($policies);
+ echo '
';
+ html_print_table($table);
+ unset($table);
+ ui_pagination($totalPolicies);
+}
diff --git a/pandora_console/operation/search_results.php b/pandora_console/operation/search_results.php
index d59e6908cb..803a92cdd1 100644
--- a/pandora_console/operation/search_results.php
+++ b/pandora_console/operation/search_results.php
@@ -18,7 +18,7 @@ require_once $config['homedir'].'/include/functions_reporting.php';
enterprise_include('operation/reporting/custom_reporting.php');
$searchAgents = $searchAlerts = $searchModules = check_acl($config['id_user'], 0, 'AR');
-$searchUsers = check_acl($config['id_user'], 0, 'UM');
+$searchUsers = $searchPolicies = check_acl($config['id_user'], 0, 'AW');
$searchMaps = $searchReports = $searchGraphs = check_acl($config['id_user'], 0, 'IR');
$searchMain = true;
$searchHelps = true;
@@ -43,6 +43,7 @@ if ($config['search_category'] == 'all') {
// INI SECURITY ACL
if ((!$searchAgents && !$searchUsers && !$searchMaps)
|| (!$searchUsers && $searchTab == 'users')
+ || (!$searchPolicies && $searchTab == 'policies')
|| (!$searchAgents && ($searchTab == 'agents' || $searchTab == 'alerts'))
|| (!$searchGraphs && ($searchTab == 'graphs' || $searchTab == 'maps' || $searchTab == 'reports'))
) {
@@ -161,29 +162,29 @@ if ($searchModules) {
$modules_tab = '';
}
-if ($searchHelps) {
- $helps_tab = [
- 'text' => "".html_print_image(
- 'images/help_w.png',
+if ($searchPolicies) {
+ $policies_tab = [
+ 'text' => "".html_print_image(
+ 'images/policies.png',
true,
- ['title' => __('Helps')]
+ ['title' => __('Policies')]
).'',
- 'active' => $searchTab == 'helps',
+ 'active' => $searchTab == 'policies',
];
} else {
- $helps_tab = '';
+ $policies_tab = '';
}
$onheader = [
- 'main' => $main_tab,
- 'agents' => $agents_tab,
- 'modules' => $modules_tab,
- 'alerts' => $alerts_tab,
- 'users' => $users_tab,
- 'graphs' => $graphs_tab,
- 'reports' => $reports_tab,
- 'maps' => $maps_tab,
- 'helps' => $helps_tab,
+ 'main' => $main_tab,
+ 'agents' => $agents_tab,
+ 'modules' => $modules_tab,
+ 'alerts' => $alerts_tab,
+ 'users' => $users_tab,
+ 'graphs' => $graphs_tab,
+ 'reports' => $reports_tab,
+ 'maps' => $maps_tab,
+ 'policies' => $policies_tab,
];
ui_print_page_header(
@@ -212,6 +213,7 @@ switch ($searchTab) {
include_once 'search_maps.getdata.php';
include_once 'search_modules.getdata.php';
include_once 'search_helps.getdata.php';
+ include_once 'search_policies.getdata.php';
include_once 'search_main.php';
break;
@@ -251,8 +253,9 @@ switch ($searchTab) {
include_once 'search_modules.php';
break;
- case 'helps':
- include_once 'search_helps.getdata.php';
- include_once 'search_helps.php';
+ case 'policies':
+ include_once 'search_policies.getdata.php';
+ include_once 'search_policies.php';
+
break;
}