columns = array('agent' => 1);
if ($system->checkACL($this->acl)) {
$this->correct_acl = true;
}
else {
$this->correct_acl = false;
}
}
public function setReadOnly() {
$this->readOnly = true;
}
public function ajax($parameter2 = false) {
$system = System::getInstance();
if (!$this->correct_acl) {
return;
}
else {
switch ($parameter2) {
case 'get_events':
$this->eventsGetFilters();
$page = $system->getRequest('page', 0);
$system = System::getInstance();
$listEvents = $this->getListEvents($page);
$events_db = $listEvents['events'];
$total_events = $listEvents['total'];
$events = array();
$end = 1;
foreach ($events_db as $event) {
$end = 0;
$row = array();
$row[] = '
' . __('Event Name') . '
' .
io_safe_output($event['evento']) . '';
/*
switch ($event['estado']) {
case 0:
$img_st = "images/star.png";
$title_st = __('New event');
break;
case 1:
$img_st = "images/tick.png";
$title_st = __('Event validated');
break;
case 2:
$img_st = "images/hourglass.png";
$title_st = __('Event in process');
break;
}
$row[] = html_print_image ($img_st, true,
array ("class" => "image_status",
"width" => 16,
"height" => 16,
"title" => $title_st,
"id" => 'status_img_' . $event["id_evento"]));
*/
$row[] = '' . __('Timestamp') . '' .
ui_print_timestamp ($event['timestamp_rep'], true);
if ($event["id_agente"] == 0) {
$agent_name = __('System');
}
else {
$agent_name = ui_print_agent_name ($event["id_agente"], true);
}
$row[] = '' . __('Agent') . '' .
$agent_name;
$status =
html_print_image ("mobile/images/" .
get_priority_class($event['criticity']) . ".png", true);
$status .= " ";
if ($event['estado'] == 1) {
$img_st = "images/tick.png";
$title_st = __('Event validated');
$status .= html_print_image ($img_st, true,
array ("class" => "image_status",
"width" => 16,
"height" => 16,
"title" => $title_st,
"id" => 'status_img_' . $event["id_evento"]));
}
else {
$status .= '';
}
$row[] = '' . __('Status') . '' .
$status;
$events[$event['id_evento']] = $row;
}
echo json_encode(array('end' => $end, 'events' => $events));
break;
case 'get_detail_event':
$system = System::getInstance();
$id_event = $system->getRequest('id_event', 0);
$event = events_get_event($id_event);
if ($event) {
//Check if it is a event from module.
if ($event['id_agentmodule'] > 0) {
$event['module_graph_link'] =
'' .
html_print_image('images/chart_curve.png', true, array ("style" => 'vertical-align: middle;')) .
'';
}
$event['evento'] = io_safe_output($event['evento']);
$event['clean_tags'] = events_clean_tags($event['tags']);
$event["timestamp"] = date($system->getConfig("date_format"), strtotime($event["timestamp"]));
if(empty($event["owner_user"])) {
$event["owner_user"] = ''.__('N/A').'';
}
else {
$user_owner = db_get_value('fullname', 'tusuario', 'id_user', $event["owner_user"]);
if (empty($user_owner)) {
$user_owner = $event['owner_user'];
}
$event["owner_user"] = $user_owner;
}
$event["event_type"] = events_print_type_img ($event["event_type"], true).' '.events_print_type_description($event["event_type"], true);
if (!isset($group_rep))
$group_rep = 0;
if ($group_rep != 0) {
if($event["event_rep"] <= 1) {
$event["event_repeated"] = ''.__('No').'';
}
else {
$event["event_repeated"] = sprintf("%d Times",$event["event_rep"]);
}
}
else {
$event["event_repeated"] = ''.__('No').'';
}
$event_criticity = get_priority_name ($event["criticity"]);
switch ($event["criticity"]) {
default:
case 0:
$img_sev = "images/status_sets/default/severity_maintenance.png";
break;
case 1:
$img_sev = "images/status_sets/default/severity_informational.png";
break;
case 2:
$img_sev = "images/status_sets/default/severity_normal.png";
break;
case 3:
$img_sev = "images/status_sets/default/severity_warning.png";
break;
case 4:
$img_sev = "images/status_sets/default/severity_critical.png";
break;
case 5:
$img_sev = "images/status_sets/default/severity_minor.png";
break;
case 6:
$img_sev = "images/status_sets/default/severity_major.png";
break;
}
$event["criticity"] = html_print_image ($img_sev, true,
array ("class" => "image_status",
"width" => 12,
"height" => 12,
"title" => $event_criticity));
$event["criticity"] .= ' ' . $event_criticity;
if ($event['estado'] == 1) {
$user_ack = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']);
if (empty($user_ack)) {
$user_ack = $event['id_usuario'];
}
$date_ack = date ($system->getConfig("date_format"), $event['ack_utimestamp']);
$event["acknowledged_by"] = $user_ack .
' (' . $date_ack . ')';
}
else {
$event["acknowledged_by"] = ''.__('N/A').'';
}
// Get Status
switch($event['estado']) {
case 0:
$img_st = "images/star.png";
$title_st = __('New event');
break;
case 1:
$img_st = "images/tick.png";
$title_st = __('Event validated');
break;
case 2:
$img_st = "images/hourglass.png";
$title_st = __('Event in process');
break;
}
$event["status"] = html_print_image($img_st,true).' '.$title_st;
$event["group"] = ui_print_group_icon ($event["id_grupo"], true);
$event["group"] .= groups_get_name ($event["id_grupo"]);
$event["tags"] = tags_get_tags_formatted($event["tags"]);
if (empty($event["tags"])) {
$event["tags"] = ''.__('N/A').'';
}
echo json_encode(array('correct' => 1, 'event' => $event));
}
else {
echo json_encode(array('correct' => 0, 'event' => array()));
}
break;
case 'validate_event':
$system = System::getInstance();
$id_event = $system->getRequest('id_event', 0);
if (events_validate_event($id_event)) {
echo json_encode(array('correct' => 1));
}
else {
echo json_encode(array('correct' => 0));
}
break;
}
}
}
public function disabledColumns($columns = null) {
if (!empty($columns)) {
foreach ($columns as $column) {
$this->columns[$column] = 1;
}
}
}
private function eventsGetFilters() {
$system = System::getInstance();
$user = User::getInstance();
$this->hours_old = $system->getRequest('hours_old', 8);
if ($this->hours_old != 8) {
$this->default = false;
}
$this->free_search = $system->getRequest('free_search', '');
if ($this->free_search != '') {
$this->default = false;
}
$this->status = $system->getRequest('status', __("Status"));
if (($this->status === __("Status")) || ($this->status == 3)) {
$this->status = 3;
}
else {
$this->status = (int)$this->status;
$this->default = false;
}
$this->type = $system->getRequest('type', __("Type"));
if ($this->type === __("Type")) {
$this->type = "";
}
else {
$this->default = false;
}
$this->group = $system->getRequest('group', __("Group"));
if (!$user->isInGroup($this->acl, $this->group)) {
$this->group = 0;
}
if (($this->group === __("Group")) || ($this->group == 0)) {
$this->group = 0;
}
else {
$this->default = false;
}
$this->severity = $system->getRequest('severity', __("Severity"));
if ($this->severity === __("Severity")) {
$this->severity = -1;
}
else {
$this->default = false;
}
$this->filter = $system->getRequest('filter', __('Preset Filters'));
if (($this->filter === __("Preset Filters")) || ($this->filter == 0)) {
$this->filter = 0;
}
else {
$this->default = false;
}
///The user set a preset filter
if ($this->filter > 0) {
$this->loadPresetFilter();
}
}
public function setFilters($filters) {
if (isset($filters['id_agent'])) {
$this->id_agent = $filters['id_agent'];
}
if (isset($filters['all_events'])) {
$this->all_events = $filters['all_events'];
}
}
private function loadPresetFilter() {
$filter = db_get_row('tevent_filter', 'id_filter', $this->filter);
$this->free_search = $filter['search'];
$this->hours_old = $filter['event_view_hr'];
$this->status = $filter['status'];
$this->type = $filter['type'];
$this->severity = $filter['severity'];
}
public function show() {
if (!$this->correct_acl) {
$this->show_fail_acl();
}
else {
$this->eventsGetFilters();
$this->show_events();
}
}
private function show_fail_acl() {
$error['title_text'] = __('You don\'t have access to this page');
$error['content_text'] = __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance.
Please know that all attempts to access this page are recorded in security logs of Pandora System Database');
$home = new Home();
$home->show($error);
}
private function show_events() {
$ui = Ui::getInstance();
$ui->createPage();
$options['type'] = 'hidden';
$options['dialog_id'] = 'detail_event_dialog';
$options['title_close_button'] = true;
$options['title_text'] = __('Event detail');
//Content
ob_start();
?>
' . __('No events') . '
'); } else { return '' . __('No events') . '
'; } } else { $table = new Table(); $table->id = 'list_events'; $table->setRowClass($row_class); $table->importFromHash($events); if (!$return) { $ui->contentAddHtml($table->getHTML()); if ($system->getPageSize() < $total_events) { $ui->contentAddHtml('