1<?php 2 3// Pandora FMS - http://pandorafms.com 4// ================================================== 5// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas 6// Please see http://pandorafms.org for full contribution list 7 8// This program is free software; you can redistribute it and/or 9// modify it under the terms of the GNU Lesser General Public License 10// as published by the Free Software Foundation; version 2 11 12// This program is distributed in the hope that it will be useful, 13// but WITHOUT ANY WARRANTY; without even the implied warranty of 14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15// GNU General Public License for more details. 16 17/** 18 * @package Include 19 * @subpackage UI 20 */ 21 22require_once ($config['homedir'] . '/include/functions_groups.php'); 23 24/** 25 */ 26function renders_agent_field ($agent, $field, $field_value = false, $return = false) { 27 global $config; 28 29 if (empty ($agent)) 30 return ''; 31 32 $output = ''; 33 switch ($field) { 34 case 'group_name': 35 if (! isset ($agent['id_grupo'])) 36 return ''; 37 38 $output = groups_get_name ($agent['id_grupo'], true); 39 40 break; 41 case 'group_icon': 42 if (! isset ($agent['id_grupo'])) 43 return ''; 44 $output = ui_print_group_icon ($agent['id_grupo'], true); 45 46 break; 47 case 'group': 48 if (! isset ($agent['id_grupo'])) 49 return ''; 50 51 $output = ui_print_group_icon ($agent['id_grupo'], true); 52 $output .= ' '; 53 $output .= groups_get_name ($agent['id_grupo']); 54 55 break; 56 case 'view_link': 57 if (! isset ($agent['nombre'])) 58 return ''; 59 if (! isset ($agent['id_agente'])) 60 return ''; 61 62 $output = '<a class="agent_link" id="agent-'.$agent['id_agente'].'" href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'">'; 63 $output .= $agent['nombre']; 64 $output .= '</a>'; 65 66 break; 67 case 'name': 68 if (! isset ($agent['nombre'])) 69 return ''; 70 71 $output = $agent['nombre']; 72 73 break; 74 case 'status': 75 if (! isset ($agent['id_agente'])) 76 return ui_print_status_image (STATUS_AGENT_NO_DATA, '', $return); 77 78 require_once ('include/functions_reporting.php'); 79 $info = reporting_get_agent_module_info ($agent['id_agente']); 80 $output = $info['status_img']; 81 82 break; 83 case 'ajax_link': 84 if (! $field_value || ! is_array ($field_value)) 85 return ''; 86 87 if (! isset ($field_value['callback'])) 88 return ''; 89 90 if (! isset ($agent['id_agente'])) 91 return ''; 92 93 $parameters = $agent['id_agente']; 94 if (isset ($field_value['parameters'])) 95 $parameters = implode (',', $field_value['parameters']); 96 97 $text = __('Action'); 98 if (isset ($field_value['name'])) 99 $text = $field_value['name']; 100 101 if (isset ($field_value['image'])) 102 $text = html_print_image ($field_value['image'], true, array ('title' => $text)); 103 104 $output = '<a href="#" onclick="'.$field_value['callback'].'(this, '.$parameters.'); return false"">'; 105 $output .= $text; 106 $output .= '</a>'; 107 108 break; 109 default: 110 if (! isset ($agent[$field])) 111 return ''; 112 113 $ouput = $agent[$field]; 114 } 115 116 if ($return) 117 return $output; 118 echo $output; 119} 120?> 121