Removed the tinyMCE from the agent description and custom fields. Removed the url injection feature from the agent description. Added the url injection feature to the agent custom fields of some sections

(cherry picked from commit c4bbe38b69e9b076b45871bc35b8c861b8ed2cc9)
This commit is contained in:
Alejandro Gallardo Escobar 2016-06-08 19:15:43 +02:00
parent 4b13134366
commit a87de02e0b
10 changed files with 42 additions and 56 deletions

View File

@ -277,7 +277,7 @@ $table->data[6][1] = html_print_select (servers_get_names (),
// Description
$table->data[7][0] = __('Description');
$table->data[7][1] = html_print_input_text ('comentarios', $comentarios,
'', 45, 255, true);
'', 45, 200, true);
html_print_table ($table);
unset($table);
@ -417,6 +417,13 @@ if ($fields === false) $fields = array();
foreach ($fields as $field) {
$data[0] = '<b>'.$field['name'].'</b>';
$data[0] .= ui_print_help_tip(
__('This field allows url insertion using the BBCode\'s url tag')
. '.<br />'
. __('The format is: [url=\'url to navigate\']\'text to show\'[/url]')
. '.<br /><br />'
. __('e.g.: [url=pandorafms.org]Pandora FMS Community[/url]')
, true);
$custom_value = db_get_value_filter('description',
'tagent_custom_data',
@ -452,7 +459,6 @@ echo "</span>";
if ($id_agente) {
html_print_submit_button (__('Update'), 'updbutton', false,
'class="sub upd"');
html_print_input_hidden ('update_agent', 1);
@ -465,17 +471,16 @@ else {
}
echo '</div></form>';
ui_require_jquery_file ('pandora.controls');
ui_require_jquery_file ('ajaxqueue');
ui_require_jquery_file ('bgiframe');
ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
ui_require_jquery_file('pandora.controls');
ui_require_jquery_file('ajaxqueue');
ui_require_jquery_file('bgiframe');
?>
<script type="text/javascript">
/* <![CDATA[ */
//Use this function for change 3 icons when change the selectbox
function changeIcons() {
icon = $("#icon_path :selected").val();
var icon = $("#icon_path :selected").val();
$("#icon_without_status").attr("src", "images/spinner.png");
$("#icon_default").attr("src", "images/spinner.png");
@ -507,8 +512,6 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
$("#icon_bad").attr("style", "");
$("#icon_warning").attr("style", "");
}
//$("#icon_default").attr("src", "<?php echo $path; ?>" + icon +
}
function show_modules_not_learning_mode_context_help() {
@ -520,7 +523,7 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
}
}
$(document).ready (function () {
$(document).ready (function() {
$("select#id_os").pandoraSelectOS ();
paint_qrcode(
@ -529,32 +532,4 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
?>",
"#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: '95%',
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"
});
});
$(document).ready (function () {
$('#grupo').pandoraSelectGroupIcon ();
});
/* ]]> */
</script>

View File

@ -423,6 +423,13 @@ if ($fields === false) $fields = array();
foreach ($fields as $field) {
$data[0] = '<b>'.$field['name'].'</b>';
$data[0] .= ui_print_help_tip(
__('This field allows url insertion using the BBCode\'s url tag')
. '.<br />'
. __('The format is: [url=\'url to navigate\']\'text to show\'[/url]')
. '.<br /><br />'
. __('e.g.: [url=pandorafms.org]Pandora FMS Community[/url]')
, true);
$custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
@ -542,7 +549,7 @@ $(document).ready (function () {
});
function changeIcons() {
icon = $("#icon_path :selected").val();
var icon = $("#icon_path :selected").val();
$("#icon_without_status").attr("src", "images/spinner.png");
$("#icon_default").attr("src", "images/spinner.png");
@ -574,7 +581,5 @@ function changeIcons() {
$("#icon_bad").attr("style", "");
$("#icon_warning").attr("style", "");
}
//$("#icon_default").attr("src", "<?php echo $path; ?>" + icon +
}
</script>

View File

@ -1939,7 +1939,9 @@ function events_page_custom_fields ($event) {
$data = array();
$data[0] = $field['name'];
$data[1] = empty($fields_data[$field['id_field']]) ? '<i>'.__('N/A').'</i>' : $fields_data[$field['id_field']];
$data[1] = empty($fields_data[$field['id_field']])
? '<i>'.__('N/A').'</i>'
: ui_bbcode_to_html($fields_data[$field['id_field']]);
$field['id_field'];

View File

@ -3374,8 +3374,7 @@ function reporting_agent_configuration($report, $content) {
$agent_configuration['os'] = os_get_name($agent_data["id_os"]);
$agent_configuration['os_icon'] = ui_print_os_icon($agent_data["id_os"], true, true);
$agent_configuration['address'] = $agent_data['direccion'];
$agent_configuration['description'] =
strip_tags(ui_bbcode_to_html($agent_data['comentarios']));
$agent_configuration['description'] = $agent_data['comentarios'];
$agent_configuration['enabled'] = (int)!$agent_data['disabled'];
$agent_configuration['group'] = $report["group"];

View File

@ -530,7 +530,7 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
if (!empty($custom_value)) {
$row = array();
$row['title'] = $field['name'] . ui_print_help_tip (__('Custom field'), true);
$row['data'] = $custom_value;
$row['data'] = ui_bbcode_to_html($custom_value);
$table->data['custom_field_'.$field['id_field']] = $row;
}
}

View File

@ -30,13 +30,12 @@ if (isset($config['homedir'])) {
}
function ui_bbcode_to_html($text, $allowed_tags = array('[url]')) {
$return = "";
$return = $text;
if (array_search('[url]', $allowed_tags) !== false) {
$return = preg_replace("/\[url=([^\]]*)\]/",
"<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"$1\">", $return);
$return = str_replace('[/url]', '</a>', $return);
$return = preg_replace("/\[url=([^\]]*)\]/", "<a href=\"$1\">", $return);
}
return $return;
@ -3699,4 +3698,4 @@ function ui_print_module_string_value($value, $id_agente_module,
return $salida;
}
?>
?>

View File

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

View File

@ -47,6 +47,9 @@ foreach($fields as $field) {
if($custom_value === false || $custom_value == '') {
$custom_value = '<i>-'.__('empty').'-</i>';
}
else {
$custom_value = ui_bbcode_to_html($custom_value);
}
echo '<td class="datos f9" colspan="2">'.$custom_value.'</td></tr>';
}

View File

@ -531,7 +531,7 @@ foreach ($agents as $agent) {
}
$data[0] .= '</div></div>';
$data[1] = ui_print_truncate_text(strip_tags(ui_bbcode_to_html($agent["description"])), 'description', false, true, true, '[&hellip;]', 'font-size: 6.5pt');
$data[1] = ui_print_truncate_text($agent["description"], 'description', false, true, true, '[&hellip;]', 'font-size: 6.5pt');
$data[2] = ui_print_os_icon ($agent["id_os"], false, true);

View File

@ -173,9 +173,9 @@ $data[2] = html_print_image('images/default_list.png', true,
$table_agent->cellstyle[count($table_agent->data)][2] =
'width: 16px; text-align: right; padding: 0px;';
$data[3] = '<span style="vertical-align:top; display: inline-block;">';
$data[3] .= empty($agent["comentarios"]) ?
'<em>' . __('N/A') . '</em>' :
io_safe_output(ui_bbcode_to_html($agent["comentarios"]));
$data[3] .= empty($agent["comentarios"])
? '<em>' . __('N/A') . '</em>'
: $agent["comentarios"];
$data[3] .= '</span>';
$table_agent->colspan[count($table_agent->data)][3] = 2;
@ -359,6 +359,9 @@ foreach ($fields as $field) {
if ($custom_value === false || $custom_value == '') {
$custom_value = '<i>'.__('N/A').'</i>';
}
else {
$custom_value = ui_bbcode_to_html($custom_value);
}
$data[1] = $custom_value;
$table_data->data[] = $data;
}