"; } else { echo "
"; } echo ""; echo ""; echo "
".__('Group').""; html_print_select_groups(false, "AR", true, "ag_group", $ag_group, 'this.form.submit();', '', 0, false, false, true, '', false, 'width:100px;'); echo " "; echo __('Free text for search (*)'); echo ""; // Show group selector if (isset($_POST["ag_group"])) { $group_mod = "&ag_group_refresh=".get_parameter_post ("ag_group"); } else { $group_mod =""; } echo "
"; echo ""; echo "
"; echo ""; echo ""; echo ""; echo '
'; html_print_input_hidden ('new_agent', 1); html_print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"'); echo "
"; echo "
"; $selected = 'border: 1px solid black;'; $selectNameUp = ''; $selectNameDown = ''; $selectOsUp = ''; $selectOsDown = ''; $selectGroupUp = ''; $selectGroupDown = ''; switch ($sortField) { case 'name': switch ($sort) { case 'up': $selectNameUp = $selected; $order = array('field' => 'nombre', 'order' => 'ASC'); break; case 'down': $selectNameDown = $selected; $order = array('field' => 'nombre', 'order' => 'DESC'); break; } break; case 'os': switch ($sort) { case 'up': $selectOsUp = $selected; $order = array('field' => 'id_os', 'order' => 'ASC'); break; case 'down': $selectOsDown = $selected; $order = array('field' => 'id_os', 'order' => 'DESC'); break; } break; case 'group': switch ($sort) { case 'up': $selectGroupUp = $selected; $order = array('field' => 'id_grupo', 'order' => 'ASC'); break; case 'down': $selectGroupDown = $selected; $order = array('field' => 'id_grupo', 'order' => 'DESC'); break; } break; default: $selectNameUp = $selected; $selectNameDown = ''; $selectOsUp = ''; $selectOsDown = ''; $selectGroupUp = ''; $selectGroupDown = ''; $order = array('field' => 'nombre', 'order' => 'ASC'); break; } $search_sql = ''; if ($search != ""){ $search_sql = " AND ( nombre COLLATE utf8_general_ci LIKE '%$search%' OR direccion LIKE '%$search%') "; } // Show only selected groups if ($ag_group > 0) { $sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE id_grupo = %d %s', $ag_group, $search_sql); $total_agents = db_get_sql ($sql); switch ($config["dbtype"]) { case "mysql": $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo = %d %s ORDER BY %s %s LIMIT %d, %d', $ag_group, $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); break; case "postgresql": $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo = %d %s ORDER BY %s %s LIMIT %d OFFSET %d', $ag_group, $search_sql, $order['field'], $order['order'], $config["block_size"], $offset); break; case "oracle": $set = array (); $set['limit'] = $config["block_size"]; $set['offset'] = $offset; $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo = %d %s ORDER BY %s %s', $ag_group, $search_sql, $order['field'], $order['order']); $sql = oracle_recode_query ($sql, $set); break; } } else { // Admin user get ANY group, even if they doesnt exist if (check_acl ($config['id_user'], 0, "PM")) { $subquery_enterprise = ''; if (ENTERPRISE_NOT_HOOK !== enterprise_include_once('include/functions_policies.php')) { $subquery_enterprise = subquery_acl_enterprise(); } $sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE 1=1 %s %s', $search_sql, $subquery_enterprise); $total_agents = db_get_sql ($sql); switch ($config["dbtype"]) { case "mysql": $sql = sprintf ('SELECT * FROM tagente WHERE 1=1 %s %s ORDER BY %s %s LIMIT %d, %d', $search_sql, $subquery_enterprise, $order['field'], $order['order'], $offset, $config["block_size"]); break; case "postgresql": $sql = sprintf ('SELECT * FROM tagente WHERE 1=1 %s %s ORDER BY %s %s LIMIT %d OFFSET %d', $search_sql, $subquery_enterprise, $order['field'], $order['order'], $config["block_size"], $offset); break; case "oracle": $set = array (); $set['limit'] = $config["block_size"]; $set['offset'] = $offset; $sql = sprintf ('SELECT * FROM tagente WHERE 1=1 %s %s ORDER BY %s %s', $search_sql, $subquery_enterprise, $order['field'], $order['order']); $sql = oracle_recode_query ($sql, $set); break; } } else { if (!$enterprise_acl) { $sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE id_grupo IN (%s) %s', implode (',', array_keys (get_user_groups ())), $search_sql); $total_agents = db_get_sql ($sql); switch ($config["dbtype"]) { case "mysql": $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo IN (%s) %s ORDER BY %s %s LIMIT %d, %d', implode (',', array_keys (get_user_groups ())), $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); break; case "postgresql": $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo IN (%s) %s ORDER BY %s %s LIMIT %d OFFSET %d', implode (',', array_keys (get_user_groups ())), $search_sql, $order['field'], $order['order'], $config["block_size"], $offset); break; case "oracle": $set = array (); $set['limit'] = $config["block_size"]; $set['offset'] = $offset; $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo IN (%s) %s ORDER BY %s %s', implode (',', array_keys (get_user_groups ())), $search_sql, $order['field'], $order['order']); $sql = oracle_recode_query ($sql, $set); break; } } else { $total_agents = enterprise_count_agents_manage_agents($search_sql); $sql = enterprise_sql_manage_agents($search_sql, $order, $offset); } } } $agents = db_get_all_rows_sql ($sql); // Delete rnum row generated by oracle_recode_query() function if (($config['dbtype'] == 'oracle') && ($agents !== false)) { for ($i=0; $i < count($agents); $i++) { unset($agents[$i]['rnum']); } } // Prepare pagination ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset); echo "
"; if ($agents !== false) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $color=1; $rowPair = true; $iterator = 0; foreach ($agents as $agent) { $id_grupo = $agent["id_grupo"]; if (! check_acl ($config["id_user"], $id_grupo, "AW", $agent['id_agente'])) continue; if ($color == 1) { $tdcolor = "datos"; $color = 0; } else { $tdcolor = "datos2"; $color = 1; } if ($rowPair) $rowclass = 'rowPair'; else $rowclass = 'rowOdd'; $rowPair = !$rowPair; $iterator++; // Agent name echo ""; echo ""; // Operating System icon echo ""; // Group icon and name echo ""; // Description echo ""; // Action //When there is only one element in page it's necesary go back page. if ((count($agents) == 1) && ($offset >= $config["block_size"])) $offsetArg = $offset - $config["block_size"]; else $offsetArg = $offset; echo ""; } echo "
".__('Agent name') . ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . ''; echo "".__('R')."".__('OS'). ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown)) . ''; echo "".__('Group'). ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . ''; echo "".__('Description')."".__('Delete')."
"; if ($agent["disabled"]) { echo ""; } echo ''; echo "" . ui_print_truncate_text($agent["nombre"], 40, true).""; if ($agent["disabled"]) { ui_print_help_tip(__('Disabled')); echo ""; } echo ''; echo ""; // Has remote configuration ? $agent_md5 = md5 ($agent["nombre"], false); if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) { echo ""; echo html_print_image("images/application_edit.png", true, array("align" => 'middle', "title" => __('Edit remote config'))); echo ""; } echo ""; ui_print_os_icon ($agent["id_os"], false); echo "" . ui_print_group_icon ($id_grupo, true)."".$agent["comentarios"]."'; echo html_print_image('images/cross.png', true, array("border" => '0')) . "
"; ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset); echo "
"; } else { echo "
".__('There are no defined agents')."
"; echo " 
"; } // Create agent button echo ''; echo '
'; html_print_input_hidden ('new_agent', 1); html_print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"'); echo "
"; ?>