mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Merge branch 'buscar-un-grupo-en-el-tree-view-carrefour' into 'develop'
Resolve: Buscar un grupo en el tree view carrefour See merge request artica/pandorafms!1003
This commit is contained in:
commit
55dd05c406
@ -23,6 +23,7 @@ class Tree {
|
|||||||
protected $filter = array();
|
protected $filter = array();
|
||||||
protected $childrenMethod = "on_demand";
|
protected $childrenMethod = "on_demand";
|
||||||
|
|
||||||
|
protected $userGroupsACL;
|
||||||
protected $userGroups;
|
protected $userGroups;
|
||||||
|
|
||||||
protected $strictACL = false;
|
protected $strictACL = false;
|
||||||
@ -36,45 +37,54 @@ class Tree {
|
|||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->rootID = !empty($rootID) ? $rootID : $id;
|
$this->rootID = !empty($rootID) ? $rootID : $id;
|
||||||
$this->serverID = $serverID;
|
$this->serverID = $serverID;
|
||||||
$this->childrenMethod = $childrenMethod;
|
$this->childrenMethod = $childrenMethod;
|
||||||
$this->access = $access;
|
$this->access = $access;
|
||||||
|
|
||||||
$userGroups = users_get_groups(false, $this->access);
|
|
||||||
|
|
||||||
if (empty($userGroups))
|
$userGroupsACL = users_get_groups(false, $this->access);
|
||||||
$this->userGroups = false;
|
$this->userGroupsACL = empty($userGroupsACL) ? false : $userGroupsACL;
|
||||||
else
|
$this->userGroups = $this->userGroupsACL;
|
||||||
$this->userGroups = $userGroups;
|
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
include_once($config['homedir']."/include/functions_servers.php");
|
include_once($config['homedir']."/include/functions_servers.php");
|
||||||
include_once($config['homedir']."/include/functions_modules.php");
|
include_once($config['homedir']."/include/functions_modules.php");
|
||||||
require_once($config['homedir']."/include/functions_tags.php");
|
require_once($config['homedir']."/include/functions_tags.php");
|
||||||
|
|
||||||
if (is_metaconsole())
|
if (is_metaconsole()) enterprise_include_once("meta/include/functions_ui_meta.php");
|
||||||
enterprise_include_once("meta/include/functions_ui_meta.php");
|
|
||||||
|
|
||||||
$this->strictACL = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
|
$this->strictACL = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
|
||||||
|
|
||||||
$this->acltags = tags_get_user_module_and_tags($config['id_user'], $this->access);
|
$this->acltags = tags_get_user_module_and_tags($config['id_user'], $this->access);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setType($type) {
|
|
||||||
$this->type = $type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFilter($filter) {
|
public function setFilter($filter) {
|
||||||
|
// Filter the user groups
|
||||||
|
if (!empty($filter['groupID'])) {
|
||||||
|
$group_id = $filter['groupID'];
|
||||||
|
$this->userGroups = isset($this->userGroupsACL[$group_id])
|
||||||
|
? array($group_id => $this->userGroupsACL[$group_id])
|
||||||
|
: array();
|
||||||
|
}
|
||||||
|
else if (!empty($filter['searchGroup'])) {
|
||||||
|
$groups = db_get_all_rows_filter('tgrupo', array('nombre' => '%' . $filter['searchGroup'] . '%'));
|
||||||
|
|
||||||
|
// Save the groups which intersect
|
||||||
|
$userGroupsACL = $this->userGroupsACL;
|
||||||
|
$this->userGroups = array_reduce($groups, function ($userGroups, $group) use ($userGroupsACL) {
|
||||||
|
$group_id = $group['id_grupo'];
|
||||||
|
if (isset($userGroupsACL[$group_id])) {
|
||||||
|
$userGroups[$group_id] = $userGroupsACL[$group_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $userGroups;
|
||||||
|
}, array());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->userGroups = $this->userGroupsACL;
|
||||||
|
}
|
||||||
|
|
||||||
$this->filter = $filter;
|
$this->filter = $filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isStrict () {
|
|
||||||
return $this->strictACL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setStrict ($value) {
|
|
||||||
$this->strictACL = (bool) $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getAgentStatusFilter ($status = -1) {
|
protected function getAgentStatusFilter ($status = -1) {
|
||||||
if ($status == -1)
|
if ($status == -1)
|
||||||
$status = $this->filter['statusAgent'];
|
$status = $this->filter['statusAgent'];
|
||||||
@ -323,7 +333,7 @@ class Tree {
|
|||||||
case 'group':
|
case 'group':
|
||||||
// ACL Group
|
// ACL Group
|
||||||
$user_groups_str = "-1";
|
$user_groups_str = "-1";
|
||||||
$group_acl = "";
|
$group_filter = "";
|
||||||
if (!$this->strictACL) {
|
if (!$this->strictACL) {
|
||||||
if (empty($this->userGroups)) {
|
if (empty($this->userGroups)) {
|
||||||
return;
|
return;
|
||||||
@ -338,7 +348,7 @@ class Tree {
|
|||||||
// Asking for all groups.
|
// Asking for all groups.
|
||||||
else {
|
else {
|
||||||
$user_groups_str = implode(",", array_keys($this->userGroups));
|
$user_groups_str = implode(",", array_keys($this->userGroups));
|
||||||
$group_acl = "AND ta.id_grupo IN ($user_groups_str)";
|
$group_filter = "AND ta.id_grupo IN ($user_groups_str)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -356,7 +366,7 @@ class Tree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$group_acl = "AND ta.id_grupo IN ($user_groups_str)";
|
$group_filter = "AND ta.id_grupo IN ($user_groups_str)";
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
@ -390,7 +400,7 @@ class Tree {
|
|||||||
$module_status_join
|
$module_status_join
|
||||||
WHERE ta.disabled = 0
|
WHERE ta.disabled = 0
|
||||||
AND ta.id_grupo = $item_for_count
|
AND ta.id_grupo = $item_for_count
|
||||||
$group_acl
|
$group_filter
|
||||||
$agent_search_filter
|
$agent_search_filter
|
||||||
$agent_status_filter";
|
$agent_status_filter";
|
||||||
$sql = $this->getAgentCountersSql($agent_table);
|
$sql = $this->getAgentCountersSql($agent_table);
|
||||||
@ -411,7 +421,7 @@ class Tree {
|
|||||||
FROM tmetaconsole_agent ta
|
FROM tmetaconsole_agent ta
|
||||||
WHERE ta.disabled = 0
|
WHERE ta.disabled = 0
|
||||||
AND ta.id_grupo = $item_for_count
|
AND ta.id_grupo = $item_for_count
|
||||||
$group_acl
|
$group_filter
|
||||||
$agent_search_filter
|
$agent_search_filter
|
||||||
$agent_status_filter";
|
$agent_status_filter";
|
||||||
$sql = $this->getAgentCountersSql($agent_table);
|
$sql = $this->getAgentCountersSql($agent_table);
|
||||||
@ -439,7 +449,7 @@ class Tree {
|
|||||||
$module_status_join
|
$module_status_join
|
||||||
WHERE ta.disabled = 0
|
WHERE ta.disabled = 0
|
||||||
AND ta.id_grupo = $rootID
|
AND ta.id_grupo = $rootID
|
||||||
$group_acl
|
$group_filter
|
||||||
$agent_search_filter
|
$agent_search_filter
|
||||||
$agent_status_filter
|
$agent_status_filter
|
||||||
GROUP BY $group_by_fields
|
GROUP BY $group_by_fields
|
||||||
@ -456,7 +466,7 @@ class Tree {
|
|||||||
FROM tmetaconsole_agent ta
|
FROM tmetaconsole_agent ta
|
||||||
WHERE ta.disabled = 0
|
WHERE ta.disabled = 0
|
||||||
AND ta.id_grupo = $rootID
|
AND ta.id_grupo = $rootID
|
||||||
$group_acl
|
$group_filter
|
||||||
$agent_search_filter
|
$agent_search_filter
|
||||||
$agent_status_filter
|
$agent_status_filter
|
||||||
ORDER BY $order_fields";
|
ORDER BY $order_fields";
|
||||||
@ -498,7 +508,7 @@ class Tree {
|
|||||||
ON ta.disabled = 0
|
ON ta.disabled = 0
|
||||||
AND tam.id_agente = ta.id_agente
|
AND tam.id_agente = ta.id_agente
|
||||||
AND ta.id_grupo = $rootID
|
AND ta.id_grupo = $rootID
|
||||||
$group_acl
|
$group_filter
|
||||||
$agent_search_filter
|
$agent_search_filter
|
||||||
$agent_status_filter
|
$agent_status_filter
|
||||||
WHERE tam.disabled = 0
|
WHERE tam.disabled = 0
|
||||||
|
@ -18,6 +18,7 @@ global $config;
|
|||||||
|
|
||||||
$pure = get_parameter('pure', 0);
|
$pure = get_parameter('pure', 0);
|
||||||
$tab = get_parameter('tab', 'group');
|
$tab = get_parameter('tab', 'group');
|
||||||
|
$search_group = get_parameter('searchGroup', '');
|
||||||
$search_agent = get_parameter('searchAgent', '');
|
$search_agent = get_parameter('searchAgent', '');
|
||||||
$status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL);
|
$status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL);
|
||||||
$search_module = get_parameter('searchModule', '');
|
$search_module = get_parameter('searchModule', '');
|
||||||
@ -135,13 +136,16 @@ $agent_status_arr[AGENT_STATUS_UNKNOWN] = __('Unknown');
|
|||||||
$agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init');
|
$agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init');
|
||||||
|
|
||||||
$row = array();
|
$row = array();
|
||||||
|
$row[] = __('Search group');
|
||||||
|
$row[] = html_print_input_text("search_group", $search_group, '', is_metaconsole() ? 70 : 40, 30, true);
|
||||||
|
|
||||||
|
$table->data[] = $row;
|
||||||
|
|
||||||
|
$row = array();
|
||||||
|
$row[] = __('Search agent');
|
||||||
|
$row[] = html_print_input_text("search_agent", $search_agent, '', is_metaconsole() ? 70 : 40, 30, true);
|
||||||
$row[] = __('Agent status');
|
$row[] = __('Agent status');
|
||||||
$row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true);
|
$row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true);
|
||||||
$row[] = __('Search agent');
|
|
||||||
if (is_metaconsole())
|
|
||||||
$row[] = html_print_input_text("search_agent", $search_agent, '', 70, 30, true);
|
|
||||||
else
|
|
||||||
$row[] = html_print_input_text("search_agent", $search_agent, '', 40, 30, true);
|
|
||||||
|
|
||||||
// Button
|
// Button
|
||||||
$row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true);
|
$row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true);
|
||||||
@ -160,10 +164,10 @@ if (!is_metaconsole()) {
|
|||||||
$module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init');
|
$module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init');
|
||||||
|
|
||||||
$row = array();
|
$row = array();
|
||||||
$row[] = __('Module status');
|
|
||||||
$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true);
|
|
||||||
$row[] = __('Search module');
|
$row[] = __('Search module');
|
||||||
$row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true);
|
$row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true);
|
||||||
|
$row[] = __('Module status');
|
||||||
|
$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true);
|
||||||
|
|
||||||
$table->data[] = $row;
|
$table->data[] = $row;
|
||||||
}
|
}
|
||||||
@ -240,8 +244,9 @@ enterprise_hook('close_meta_frame');
|
|||||||
var parameters = {};
|
var parameters = {};
|
||||||
parameters['page'] = "include/ajax/tree.ajax";
|
parameters['page'] = "include/ajax/tree.ajax";
|
||||||
parameters['getChildren'] = 1;
|
parameters['getChildren'] = 1;
|
||||||
parameters['filter'] = {};
|
|
||||||
parameters['type'] = "<?php echo $tab; ?>";
|
parameters['type'] = "<?php echo $tab; ?>";
|
||||||
|
parameters['filter'] = {};
|
||||||
|
parameters['filter']['searchGroup'] = $("input#text-search_group").val();
|
||||||
parameters['filter']['searchAgent'] = $("input#text-search_agent").val();
|
parameters['filter']['searchAgent'] = $("input#text-search_agent").val();
|
||||||
parameters['filter']['statusAgent'] = $("select#status_agent").val();
|
parameters['filter']['statusAgent'] = $("select#status_agent").val();
|
||||||
parameters['filter']['searchModule'] = $("input#text-search_module").val();
|
parameters['filter']['searchModule'] = $("input#text-search_module").val();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user