$db = new Ossim_db(); $conn = $db->connect(); if ($asset_id && $asset_type) { if (!array_key_exists($asset_type, $asset_types)) { Av_exception::throw_error(Av_exception::USER_ERROR, _('Error! Invalid Asset Type')); } $class_name = $asset_types[$asset_type]; // Check Asset Permission if (method_exists($class_name, 'is_allowed') && !$class_name::is_allowed($conn, $asset_id)) { $error = sprintf(_('Error! %s is not allowed'), ucwords($asset_type)); Av_exception::throw_error(Av_exception::USER_ERROR, $error); } //Note filter $_type = $type_tr[$asset_type]; $filters = array(); $filters['order_by'] = 'date DESC'; $filters['where'] = "type='{$_type}' AND asset_id = UNHEX('{$asset_id}')"; list($notes, $total) = Notes::get_list($conn, $filters); } else { Av_exception::throw_error(Av_exception::USER_ERROR, _('Error retrieving information')); } } catch (Exception $e) { $db->close(); Util::response_bad_request($e->getMessage()); } $tooltip = sprintf(_("This %s has %s note(s)."), ucfirst($asset_type), $total); $data = array('value' => $total, 'level' => 0, 'tooltip' => $tooltip); $db->close(); echo json_encode($data); /* End of file get_status_notes.php */ /* Location: /av_asset/common/providers/get_status_notes.php */
} exit; } elseif (POST('action') == 'new_ajax') { $txt = POST('txt'); ossim_valid($txt, OSS_TEXT, OSS_PUNC_EXT, 'illegal:' . _('Note text')); if (ossim_error()) { die(ossim_error()); } if (Notes::insert($conn, $type, gmdate('Y-m-d H:i:s'), Session::get_session_user(), $id, $txt)) { echo json_encode(array('state' => 'OK')); } else { echo json_encode(array('state' => 'ERR')); } exit; } $notes = Notes::get_list($conn, " AND type='{$type}' AND asset_id = UNHEX('{$id}') ORDER BY date DESC"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title> <?php echo _("OSSIM Framework"); ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <meta http-equiv="Pragma" CONTENT="no-cache"/> <link rel="stylesheet" type="text/css" href="/ossim/style/av_common.css?t=<?php echo Util::get_css_id(); ?> "/>
if ($_GET['notes_ajax_mode'] != '') { require_once 'av_init.php'; $id = GET('id'); $_asset_type_aux = GET('type'); ossim_valid($id, OSS_HEX, 'illegal:' . _('Asset ID')); ossim_valid($_asset_type_aux, OSS_ALPHA, 'illegal:' . _('Asset Type')); if (ossim_error()) { die(ossim_error()); } // Patch for incoherences if ($_asset_type_aux == 'group') { $_asset_type_aux = 'host_group'; } $db = new ossim_db(); $conn = $db->connect(); $notes = Notes::get_list($conn, " AND type='" . $_asset_type_aux . "' AND asset_id = UNHEX('{$id}') ORDER BY date DESC"); $db->close(); if (count($notes) > 0) { foreach ($notes as $note) { ?> <div class="note_row" onmouseover="$('#delete_link_<?php echo $note->get_id(); ?> ').show();$(this).css('background-color', '#C7C7C7');" onmouseout="$('#delete_link_<?php echo $note->get_id(); ?> ').hide();$(this).css('background-color', 'transparent');"> <div> <div class='detail_header_left'> <?php