Added feature to set bbcode links in agents description and custom fields. Ticket #1404

This commit is contained in:
mdtrooper 2014-12-02 16:38:07 +01:00
parent 673d0bd34f
commit 303b4f148f
10 changed files with 172 additions and 71 deletions

View File

@ -268,7 +268,8 @@ $table->data[6][1] = html_print_select (servers_get_names (),
// Description // Description
$table->data[7][0] = __('Description'); $table->data[7][0] = __('Description');
$table->data[7][1] = html_print_input_text ('comentarios', $comentarios, '', 45, 255, true); $table->data[7][1] = html_print_input_text ('comentarios', $comentarios,
'', 45, 255, true);
html_print_table ($table); html_print_table ($table);
unset($table); unset($table);
@ -376,10 +377,12 @@ if ($config['activate_gis']) {
} }
$table->data[6][0] = __('Url address'); $table->data[6][0] = __('Url address');
$table->data[6][1] = html_print_input_text ('url_description', $url_description, '', 45, 255, true); $table->data[6][1] = html_print_input_text ('url_description',
$url_description, '', 45, 255, true);
$table->data[7][0] = __('Quiet'); $table->data[7][0] = __('Quiet');
$table->data[7][0] .= ui_print_help_tip(__('The agent still runs but the alerts and events will be stop'), true); $table->data[7][0] .= ui_print_help_tip(
__('The agent still runs but the alerts and events will be stop'), true);
$table->data[7][1] = html_print_checkbox('quiet', 1, $quiet, true); $table->data[7][1] = html_print_checkbox('quiet', 1, $quiet, true);
ui_toggle(html_print_table ($table, true), __('Advanced options')); ui_toggle(html_print_table ($table, true), __('Advanced options'));
@ -401,13 +404,16 @@ foreach ($fields as $field) {
$data[0] = '<b>'.$field['name'].'</b>'; $data[0] = '<b>'.$field['name'].'</b>';
$custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente)); $custom_value = db_get_value_filter('description',
'tagent_custom_data',
array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
if ($custom_value === false) { if ($custom_value === false) {
$custom_value = ''; $custom_value = '';
} }
$data[1] = html_print_textarea ('customvalue_'.$field['id_field'], 2, 65, $custom_value, 'style="min-height: 30px;"', true); $data[1] = html_print_textarea ('customvalue_'.$field['id_field'],
2, 65, $custom_value, 'style="min-height: 30px;"', true);
array_push ($table->data, $data); array_push ($table->data, $data);
} }
@ -433,12 +439,14 @@ echo "</span>";
if ($id_agente) { if ($id_agente) {
html_print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); html_print_submit_button (__('Update'), 'updbutton', false,
'class="sub upd"');
html_print_input_hidden ('update_agent', 1); html_print_input_hidden ('update_agent', 1);
html_print_input_hidden ('id_agente', $id_agente); html_print_input_hidden ('id_agente', $id_agente);
} }
else { else {
html_print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"'); html_print_submit_button (__('Create'), 'crtbutton', false,
'class="sub wand"');
html_print_input_hidden ('create_agent', 1); html_print_input_hidden ('create_agent', 1);
} }
echo '</div></form>'; echo '</div></form>';
@ -446,6 +454,7 @@ echo '</div></form>';
ui_require_jquery_file ('pandora.controls'); ui_require_jquery_file ('pandora.controls');
ui_require_jquery_file ('ajaxqueue'); ui_require_jquery_file ('ajaxqueue');
ui_require_jquery_file ('bgiframe'); ui_require_jquery_file ('bgiframe');
ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
@ -468,11 +477,16 @@ function changeIcons() {
$("#icon_warning").attr("style", "display:none;"); $("#icon_warning").attr("style", "display:none;");
} }
else { else {
$("#icon_without_status").attr("src", "<?php echo $path; ?>" + icon + ".default.png"); $("#icon_without_status").attr("src",
$("#icon_default").attr("src", "<?php echo $path; ?>" + icon + ".default.png"); "<?php echo $path; ?>" + icon + ".default.png");
$("#icon_ok").attr("src", "<?php echo $path; ?>" + icon + ".ok.png"); $("#icon_default").attr("src",
$("#icon_bad").attr("src", "<?php echo $path; ?>" + icon + ".bad.png"); "<?php echo $path; ?>" + icon + ".default.png");
$("#icon_warning").attr("src", "<?php echo $path; ?>" + icon + ".warning.png"); $("#icon_ok").attr("src",
"<?php echo $path; ?>" + icon + ".ok.png");
$("#icon_bad").attr("src",
"<?php echo $path; ?>" + icon + ".bad.png");
$("#icon_warning").attr("src",
"<?php echo $path; ?>" + icon + ".warning.png");
$("#icon_without_status").attr("style", ""); $("#icon_without_status").attr("style", "");
$("#icon_default").attr("style", ""); $("#icon_default").attr("style", "");
$("#icon_ok").attr("style", ""); $("#icon_ok").attr("style", "");
@ -495,7 +509,35 @@ function show_modules_not_learning_mode_context_help() {
$(document).ready (function () { $(document).ready (function () {
$("select#id_os").pandoraSelectOS (); $("select#id_os").pandoraSelectOS ();
paint_qrcode("<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agente); ?>", "#qr_code_agent_view", 128, 128); paint_qrcode(
"<?php
echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agente);
?>",
"#qr_code_agent_view", 128, 128);
});
$(document).ready(function() {
tinyMCE.init({
mode : "exact",
elements: <?php
$elements = array('comentarios');
foreach ($fields as $field) {
$elements[] = 'customvalue_' . $field['id_field'];
}
echo '"' . implode(', ', $elements) . '"';
?>,
width: 300,
theme : "advanced",
theme_advanced_path : false,
statusbar : false,
plugins: "bbcode",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1 : "undo, redo, | , link, unlink"
});
}); });
/* ]]> */ /* ]]> */
</script> </script>

View File

@ -404,7 +404,8 @@ foreach ($fields as $field) {
$custom_value = ''; $custom_value = '';
} }
$data[1] = html_print_textarea ('customvalue_'.$field['id_field'], 2, 65, $custom_value, 'style="min-height: 30px;"', true); $data[1] = html_print_textarea ('customvalue_' . $field['id_field'],
2, 65, $custom_value, 'style="min-height: 30px;"', true);
array_push ($table->data, $data); array_push ($table->data, $data);
} }
@ -433,6 +434,8 @@ ui_require_jquery_file ('pandora.controls');
ui_require_jquery_file ('pandora.controls'); ui_require_jquery_file ('pandora.controls');
ui_require_jquery_file ('ajaxqueue'); ui_require_jquery_file ('ajaxqueue');
ui_require_jquery_file ('bgiframe'); ui_require_jquery_file ('bgiframe');
ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
@ -530,7 +533,29 @@ function changeIcons() {
$("#icon_bad").attr("style", ""); $("#icon_bad").attr("style", "");
$("#icon_warning").attr("style", ""); $("#icon_warning").attr("style", "");
} }
//$("#icon_default").attr("src", "<?php echo $path; ?>" + icon +
} }
$(document).ready(function() {
tinyMCE.init({
mode : "exact",
elements: <?php
$elements = array('description');
foreach ($fields as $field) {
$elements[] = 'customvalue_' . $field['id_field'];
}
echo '"' . implode(', ', $elements) . '"';
?>,
width: 300,
theme : "advanced",
theme_advanced_path : false,
statusbar : false,
plugins: "bbcode",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1 : "undo, redo, | , link, unlink"
});
});
</script> </script>

View File

@ -275,13 +275,16 @@ elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE'
$filter_description = $filter; $filter_description = $filter;
switch ($config['dbtype']) { switch ($config['dbtype']) {
case "mysql": case "mysql":
$filter_description[] = '(nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion NOT LIKE "%'.$string.'%" AND comentarios LIKE "%'.$string.'%")'; $filter_description[] =
'(nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion NOT LIKE "%'.$string.'%" AND comentarios LIKE "%'.$string.'%")';
break; break;
case "postgresql": case "postgresql":
$filter_description[] = '(nombre NOT LIKE \'%'.$string.'%\' AND direccion NOT LIKE \'%'.$string.'%\' AND comentarios LIKE \'%'.$string.'%\')'; $filter_description[] =
'(nombre NOT LIKE \'%'.$string.'%\' AND direccion NOT LIKE \'%'.$string.'%\' AND comentarios LIKE \'%'.$string.'%\')';
break; break;
case "oracle": case "oracle":
$filter_description[] = '(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))'; $filter_description[] =
'(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))';
break; break;
} }
$agents = agents_get_agents($filter_description, $agents = agents_get_agents($filter_description,

View File

@ -6842,7 +6842,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$data[1] = ui_print_group_icon ($agent_data['id_grupo'], true, '', '', false); $data[1] = ui_print_group_icon ($agent_data['id_grupo'], true, '', '', false);
$data[2] = ui_print_os_icon ($agent_data["id_os"], true, true); $data[2] = ui_print_os_icon ($agent_data["id_os"], true, true);
$data[3] = $agent_data['direccion']; $data[3] = $agent_data['direccion'];
$data[4] = $agent_data['comentarios']; $agent_data_comentarios = strip_tags(ui_bbcode_to_html($agent_data['comentarios']));
$data[4] = $agent_data_comentarios;
if ($agent_data['disabled'] == 0) if ($agent_data['disabled'] == 0)
$data[5] = __('Enabled'); $data[5] = __('Enabled');
@ -6985,7 +6986,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$data[1] = ui_print_group_icon ($agent_data['id_grupo'], true, '', '', false); $data[1] = ui_print_group_icon ($agent_data['id_grupo'], true, '', '', false);
$data[2] = ui_print_os_icon ($agent_data["id_os"], true, true); $data[2] = ui_print_os_icon ($agent_data["id_os"], true, true);
$data[3] = $agent_data['direccion']; $data[3] = $agent_data['direccion'];
$data[4] = $agent_data['comentarios']; $agent_data_comentarios = strip_tags(ui_bbcode_to_html($agent_data['comentarios']));
$data[4] = $agent_data_comentarios;
if ($agent_data['disabled'] == 0) if ($agent_data['disabled'] == 0)
$data[5] = __('Enabled'); $data[5] = __('Enabled');

View File

@ -29,6 +29,19 @@ if (isset($config['homedir'])) {
require_once($config['homedir'] . '/include/functions_html.php'); require_once($config['homedir'] . '/include/functions_html.php');
} }
function ui_bbcode_to_html($text, $allowed_tags = array('[url]')) {
$return = "";
$return = $text;
if (array_search('[url]', $allowed_tags) !== false) {
$return = str_replace('[/url]', '</a>', $return);
$return = preg_replace("/\[url=([^\]]*)\]/", "<a href=\"$1\">", $return);
}
return $return;
}
/** /**
* Truncate a text to num chars (pass as parameter) and if flag show tooltip is * Truncate a text to num chars (pass as parameter) and if flag show tooltip is
* true the html artifal to show the tooltip with rest of text. * true the html artifal to show the tooltip with rest of text.

View File

@ -143,7 +143,7 @@ class Agent {
$description .= '<i>' . __('N/A') . '</i>'; $description .= '<i>' . __('N/A') . '</i>';
} }
else { else {
$description .= $this->agent["comentarios"]; $description .= ui_bbcode_to_html($this->agent["comentarios"]);
} }

View File

@ -82,6 +82,9 @@ else {
if ($custom_value === false || $custom_value == '') { if ($custom_value === false || $custom_value == '') {
$custom_value = '<i>-'.__('empty').'-</i>'; $custom_value = '<i>-'.__('empty').'-</i>';
} }
else {
$custom_value = ui_bbcode_to_html($custom_value);
}
$data[2] = $custom_value; $data[2] = $custom_value;

View File

@ -113,7 +113,8 @@ $data[0] .= ui_print_help_tip(__('Agent statuses are re-calculated by the server
$data[0] .= '</div>'; $data[0] .= '</div>';
$table_agent->rowspan[count($table_agent->data)][0] = 6; $table_agent->rowspan[count($table_agent->data)][0] = 6;
$table_agent->colspan[count($table_agent->data)][0] = 2; $table_agent->colspan[count($table_agent->data)][0] = 2;
$table_agent->cellstyle[count($table_agent->data)][0] = 'width: 150px; text-align:center; padding: 0px; vertical-align: top;'; $table_agent->cellstyle[count($table_agent->data)][0] =
'width: 150px; text-align:center; padding: 0px; vertical-align: top;';
$data[2] = ui_print_os_icon ($agent["id_os"], false, true, true, false, false, false, array('title' => __('OS') . ': ' . get_os_name ($agent["id_os"]))); $data[2] = ui_print_os_icon ($agent["id_os"], false, true, true, false, false, false, array('title' => __('OS') . ': ' . get_os_name ($agent["id_os"])));
@ -159,11 +160,14 @@ $table_agent->data[] = $data;
$table_agent->rowclass[] = ''; $table_agent->rowclass[] = '';
$data = array(); $data = array();
$data[2] = html_print_image('images/default_list.png', true, array('title' => __('Description'))); $data[2] = html_print_image('images/default_list.png', true,
array('title' => __('Description')));
$table_agent->cellstyle[count($table_agent->data)][2] = $table_agent->cellstyle[count($table_agent->data)][2] =
'width: 16px; text-align: right; padding: 0px; vertical-align: top;'; 'width: 16px; text-align: right; padding: 0px; vertical-align: top;';
$data[3] = '<span style="vertical-align:top; display: inline-block;">'; $data[3] = '<span style="vertical-align:top; display: inline-block;">';
$data[3] .= empty($agent["comentarios"]) ? '<em>' . __('N/A') . '</em>' : $agent["comentarios"]; $data[3] .= empty($agent["comentarios"]) ?
'<em>' . __('N/A') . '</em>' :
ui_bbcode_to_html($agent["comentarios"]);
$data[3] .= '</span>'; $data[3] .= '</span>';
$table_agent->colspan[count($table_agent->data)][3] = 2; $table_agent->colspan[count($table_agent->data)][3] = 2;
@ -576,9 +580,15 @@ if ($config["agentaccess"] && $access_agent > 0) {
} }
$data[1] = html_print_table($table_contact, true); $data[1] = html_print_table($table_contact, true);
$data[1] .= empty($table_data->data) ? '' : '<br>' . html_print_table($table_data, true); $data[1] .= empty($table_data->data) ?
$data[1] .= !isset($table_incident) ? '' : '<br>' . html_print_table($table_incident, true); '' :
$data[1] .= !isset($table_interface) ? '' : '<br>' . html_print_table($table_interface, true); '<br>' . html_print_table($table_data, true);
$data[1] .= !isset($table_incident) ?
'' :
'<br>' . html_print_table($table_incident, true);
$data[1] .= !isset($table_interface) ?
'' :
'<br>' . html_print_table($table_interface, true);
$table->rowspan[0][1] = 2; $table->rowspan[0][1] = 2;

View File

@ -897,9 +897,12 @@ foreach ($config['extensions'] as $extension) {
if ($extension['extension_ope_tab']['id'] === "vmware_manager") { if ($extension['extension_ope_tab']['id'] === "vmware_manager") {
//Check if OS is vmware //Check if OS is vmware
$id_remote_field = db_get_value ("id_field", "tagent_custom_fields", "name", "vmware_type"); $id_remote_field = db_get_value ("id_field",
"tagent_custom_fields", "name", "vmware_type");
$vmware_type = db_get_value_filter("description", "tagent_custom_data", array("id_field" => $id_remote_field, "id_agent" => $agent["id_agente"])); $vmware_type = db_get_value_filter("description",
"tagent_custom_data",
array("id_field" => $id_remote_field, "id_agent" => $agent["id_agente"]));
if ($vmware_type != "vm") { if ($vmware_type != "vm") {
continue; continue;