2013-02-27 Miguel de Dios <miguel.dedios@artica.es>

* godmode/agentes/module_manager_editor_common.php,
	godmode/agentes/modificar_agente.php,
	godmode/agentes/module_manager_editor.php,
	godmode/agentes/agent_manager.php: updated the code to module
	constants.
	
	* include/javascript/pandora_modules.js: fixed the set the
	module_data from to the json.
	
	* include/functions_api.php: cleaned source code style.
	
	* include/constants.php: addded lost constant for the module
	prediction.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7728 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-02-27 09:51:48 +00:00
parent eec4bbb4ae
commit 606e825895
8 changed files with 157 additions and 114 deletions

View File

@ -1,3 +1,19 @@
2013-02-27 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/module_manager_editor_common.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/agent_manager.php: updated the code to module
constants.
* include/javascript/pandora_modules.js: fixed the set the
module_data from to the json.
* include/functions_api.php: cleaned source code style.
* include/constants.php: addded lost constant for the module
prediction.
2013-02-26 Sancho Lerena <slerena@artica.es>
* include/functions_filemanager.php: Fixed tooltips to use new format.

View File

@ -118,8 +118,10 @@ echo '<div style="height: 5px">&nbsp;</div>';
if (!$new_agent) {
// Agent remote configuration editor
$agent_md5 = md5 ($nombre_agente, false);
$filename['md5'] = $config["remote_config"]."/md5/".$agent_md5.".md5";
$filename['conf'] = $config["remote_config"]."/conf/".$agent_md5.".conf";
$filename['md5'] = $config["remote_config"] . "/md5/" .
$agent_md5 . ".md5";
$filename['conf'] = $config["remote_config"] . "/conf/" .
$agent_md5 . ".conf";
}
$disk_conf = (bool) get_parameter ('disk_conf');
@ -170,7 +172,7 @@ if (!$new_agent) {
// Delete link from here
if (!$new_agent) {
$table->data[0][1] .= "&nbsp;&nbsp;<span align='right'><a onClick=\"if (!confirm('" . __('Are you sure?') . "')) return false;\" title='".__("Delete agent")."' href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=$id_agente&search=&offset=0&sort_field=&sort=none'><img src='images/cross.png'></a>";
$table->data[0][1] .= "&nbsp;&nbsp;<span align='right'><a onClick=\"if (!confirm('" . __('Are you sure?') . "')) return false;\" title='".__("Delete agent")."' href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=$id_agente&search=&offset=0&sort_field=&sort=none'><img src='images/cross.png'></a>";
}
$table->data[1][0] = __('IP Address');
@ -274,7 +276,7 @@ foreach ($listIcons as $index => $value) $arraySelectIcon[$index] = $index;
$path = 'images/gis_map/icons/'; //TODO set better method the path
$table->data[4][0] = __('Agent icon') . ui_print_help_tip(__('Agent icon for GIS Maps.'), true);
if($icon_path == '') {
if ($icon_path == '') {
$display_icons = 'none';
// Hack to show no icon. Use any given image to fix not found image errors
$path_without = "images/spinner.png";
@ -331,7 +333,7 @@ $table->data = array ();
$fields = db_get_all_fields_in_table('tagent_custom_fields');
if($fields === false) $fields = array();
if ($fields === false) $fields = array();
foreach ($fields as $field) {
@ -339,7 +341,7 @@ foreach ($fields as $field) {
$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 = '';
}
@ -348,7 +350,7 @@ foreach ($fields as $field) {
array_push ($table->data, $data);
}
if(!empty($fields)) {
if (!empty($fields)) {
ui_toggle(html_print_table ($table, true), __('Custom fields'));
}

View File

@ -89,7 +89,7 @@ if ($agent_to_delete) {
// Check if the remote config file still exist
if (isset ($config["remote_config"])) {
$agent_md5 = md5 (agents_get_name($id_agente, ""), FALSE);
if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5") ||
file_exists ($config["remote_config"]."/conf/".$agent_md5.".conf")) {
ui_print_error_message(__('Maybe the files conf or md5 could not be deleted'));
@ -97,7 +97,7 @@ if ($agent_to_delete) {
}
}
if($enable_agent) {
if ($enable_agent) {
$result = db_process_sql_update('tagente', array('disabled' => 0), array('id_agente' => $enable_agent));
if ($result) {
@ -111,7 +111,7 @@ if($enable_agent) {
__('Successfully enabled'), __('Could not be enabled'));
}
if($disable_agent) {
if ($disable_agent) {
$result = db_process_sql_update('tagente', array('disabled' => 1), array('id_agente' => $disable_agent));
if ($result) {
@ -186,11 +186,15 @@ switch ($sortField) {
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
$order = array('field' => 'nombre COLLATE utf8_general_ci',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'ASC');
break;
case 'down':
$selectNameDown = $selected;
$order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
$order = array('field' => 'nombre COLLATE utf8_general_ci',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'DESC');
break;
}
break;
@ -198,11 +202,15 @@ switch ($sortField) {
switch ($sort) {
case 'up':
$selectOsUp = $selected;
$order = array('field' => 'id_os', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
$order = array('field' => 'id_os',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'ASC');
break;
case 'down':
$selectOsDown = $selected;
$order = array('field' => 'id_os', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
$order = array('field' => 'id_os',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'DESC');
break;
}
break;
@ -210,11 +218,15 @@ switch ($sortField) {
switch ($sort) {
case 'up':
$selectGroupUp = $selected;
$order = array('field' => 'id_grupo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
$order = array('field' => 'id_grupo',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'ASC');
break;
case 'down':
$selectGroupDown = $selected;
$order = array('field' => 'id_grupo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
$order = array('field' => 'id_grupo',
'field2' => 'nombre COLLATE utf8_general_ci',
'order' => 'DESC');
break;
}
break;
@ -230,7 +242,7 @@ switch ($sortField) {
}
$search_sql = '';
if ($search != ""){
if ($search != "") {
$search_sql = " AND ( nombre COLLATE utf8_general_ci LIKE '%$search%' OR direccion LIKE '%$search%') ";
}
@ -239,7 +251,7 @@ if ($ag_group > 0) {
$sql = sprintf ('SELECT COUNT(*)
FROM tagente
WHERE id_grupo = %d
%s',
%s',
$ag_group, $search_sql);
$total_agents = db_get_sql ($sql);
@ -254,16 +266,18 @@ if ($ag_group > 0) {
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo IN (%s)
%s
ORDER BY %s, %s %s LIMIT %d, %d',
%s
ORDER BY %s, %s %s
LIMIT %d, %d',
implode (",", $ag_groups), $search_sql, $order['field'], $order['field2'], $order['order'], $offset, $config["block_size"]);
break;
case "postgresql":
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo IN (%s)
%s
ORDER BY %s, %s %s LIMIT %d OFFSET %d',
%s
ORDER BY %s, %s %s
LIMIT %d OFFSET %d',
implode (",", $ag_groups), $search_sql, $order['field'], $order['field2'], $order['order'], $config["block_size"], $offset);
break;
case "oracle":
@ -273,7 +287,7 @@ if ($ag_group > 0) {
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo IN (%s)
%s
%s
ORDER BY %s, %s %s',
implode (",", $ag_groups), $search_sql, $order['field'], $order['field2'], $order['order']);
$sql = oracle_recode_query ($sql, $set);
@ -288,13 +302,17 @@ else {
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ('SELECT *
FROM tagente WHERE 1=1 %s
FROM tagente
WHERE 1=1
%s
ORDER BY %s, %s %s LIMIT %d, %d', $search_sql, $order['field'], $order['field2'],
$order['order'], $offset, $config["block_size"]);
break;
case "postgresql":
$sql = sprintf ('SELECT *
FROM tagente WHERE 1=1 %s
FROM tagente
WHERE 1=1
%s
ORDER BY %s, %s %s LIMIT %d OFFSET %d', $search_sql, $order['field'], $order['field2'],
$order['order'], $config["block_size"], $offset);
break;
@ -303,7 +321,9 @@ else {
$set['limit'] = $config["block_size"];
$set['offset'] = $offset;
$sql = sprintf ('SELECT *
FROM tagente WHERE 1=1 %s
FROM tagente
WHERE 1=1
%s
ORDER BY %s, %s %s', $search_sql, $order['field'], $order['field2'], $order['order']);
$sql = oracle_recode_query ($sql, $set);
break;
@ -319,19 +339,20 @@ else {
$sql = sprintf ('SELECT COUNT(*)
FROM tagente
WHERE id_grupo IN (%s)
%s',
%s',
implode (',', array_keys ($user_groups)),
$search_sql);
$total_agents = db_get_sql ($sql);
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo IN (%s)
%s
ORDER BY %s, %s %s LIMIT %d, %d',
%s
ORDER BY %s, %s %s
LIMIT %d, %d',
implode (',', array_keys ($user_groups)),
$search_sql, $order['field'], $order['field2'], $order['order'], $offset, $config["block_size"]);
break;
@ -339,8 +360,9 @@ else {
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo IN (%s)
%s
ORDER BY %s, %s %s LIMIT %d OFFSET %d',
%s
ORDER BY %s, %s %s
LIMIT %d OFFSET %d',
implode (',', array_keys ($user_groups)),
$search_sql, $order['field'], $order['field2'], $order['order'], $config["block_size"], $offset);
break;
@ -351,7 +373,7 @@ else {
$sql = sprintf ('SELECT *
FROM tagente
WHERE id_grupo IN (%s)
%s
%s
ORDER BY %s, %s %s',
implode (',', array_keys ($user_groups)),
$search_sql, $order['field'], $order['field2'], $order['order']);
@ -366,7 +388,7 @@ $agents = db_get_all_rows_sql ($sql);
// Delete rnum row generated by oracle_recode_query() function
if (($config['dbtype'] == 'oracle') && ($agents !== false)) {
for ($i=0; $i < count($agents); $i++) {
unset($agents[$i]['rnum']);
unset($agents[$i]['rnum']);
}
}
@ -398,7 +420,7 @@ if ($agents !== false) {
$iterator = 0;
foreach ($agents as $agent) {
$id_grupo = $agent["id_grupo"];
if (! check_acl ($config["id_user"], $id_grupo, "AW", $agent['id_agente']) && ! check_acl ($config["id_user"], $id_grupo, "AD", $agent['id_agente']))
continue;
@ -429,8 +451,8 @@ if ($agents !== false) {
html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => ""));
echo "&nbsp;";
}
if(check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
$main_tab = 'main';
}
else {
@ -448,7 +470,7 @@ if ($agents !== false) {
echo "</em>";
}
echo '</span><div class="left actions" style="visibility: hidden; clear: left">';
if(check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
echo '<a href="index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=main&
id_agente='.$agent["id_agente"].'">'.__('Edit').'</a>';
@ -509,7 +531,7 @@ if ($agents !== false) {
html_print_image('images/lightbulb.png', true, array('alt' => __('Disable agent'), 'title' => __('Disable agent'))) ."</a>";
}
if(check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
echo "&nbsp;&nbsp;<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
borrar_agente=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort'";
echo ' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
@ -527,12 +549,13 @@ else {
echo "&nbsp;</td></tr><tr><td>";
}
if(check_acl ($config["id_user"], 0, "AW")) {
if (check_acl ($config["id_user"], 0, "AW")) {
// Create agent button
echo '<a name="bottom">';
echo '<form method="post" action="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente">';
html_print_input_hidden ('new_agent', 1);
html_print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"');
html_print_submit_button (__('Create agent'), 'crt', false,
'class="sub next"');
echo "</form>";
}
@ -546,22 +569,17 @@ $(document).ready (function () {
},
function () {
$(".actions", this).css ("visibility", "hidden");
});
});
$("#ag_group").click (
function () {
$(this).css ("width", "auto");
$(this).css ("min-width", "100px");
});
/* $("#ag_group").hover (
function () {
$(this).css ("width", "auto");
});*/
function () {
$(this).css ("width", "auto");
$(this).css ("min-width", "100px");
});
$("#ag_group").blur (function () {
$(this).css ("width", "100px");
});
$(this).css ("width", "100px");
});
});
</script>

View File

@ -40,7 +40,7 @@ if (is_ajax ()) {
$components = network_components_get_network_components ($id_module_component,
array ('id_group' => $id_module_group,
'order' => 'name ASC'),
'order' => 'name ASC'),
array ('id_nc', 'name'));
echo json_encode ($components);
@ -328,11 +328,12 @@ $remote_conf = false;
switch ($moduletype) {
case "dataserver":
case 1:
$moduletype = 1;
case MODULE_DATA:
$moduletype = MODULE_DATA;
// Has remote configuration ?
$agent_md5 = md5 (agents_get_name($id_agente), false);
$remote_conf = file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5");
$remote_conf = file_exists ($config["remote_config"] ."/md5/" .
$agent_md5 . ".md5");
/* Categories is an array containing the allowed module types
(generic_data, generic_string, etc) from ttipo_modulo (field categoria) */
@ -349,31 +350,31 @@ switch ($moduletype) {
}
break;
case "networkserver":
case 2:
$moduletype = 2;
case MODULE_NETWORK:
$moduletype = MODULE_NETWORK;
$categories = array (3, 4, 5);
require ('module_manager_editor_common.php');
require ('module_manager_editor_network.php');
break;
case "pluginserver":
case 4:
$moduletype = 4;
case MODULE_PLUGIN:
$moduletype = MODULE_PLUGIN;
$categories = array (0, 1, 2);
require ('module_manager_editor_common.php');
require ('module_manager_editor_plugin.php');
break;
case "predictionserver":
case 5:
$moduletype = 5;
case MODULE_PREDICTION:
$moduletype = MODULE_PREDICTION;
$categories = array (0, 1);
require ('module_manager_editor_common.php');
require ('module_manager_editor_prediction.php');
break;
case "wmiserver":
case 6:
$moduletype = 6;
case MODULE_WMI:
$moduletype = MODULE_WMI;
$categories = array (0, 1, 2);
require ('module_manager_editor_common.php');

View File

@ -157,8 +157,7 @@ if (isset($id_agent_module)) {
$edit = true;
}
}
else
{
else {
//Run into a policy
$edit = true;
}
@ -173,10 +172,10 @@ if (!$edit) {
$type_names = db_get_all_rows_sql($sql);
$type_names_hash = array();
foreach($type_names as $tn) {
foreach ($type_names as $tn) {
$type_names_hash[$tn['id_tipo']] = $tn['nombre'];
}
$table_simple->data[1][1] = '<em>'.modules_get_moduletype_description ($id_module_type).' ('.$type_names_hash[$id_module_type].')</em>';
$table_simple->data[1][1] .= html_print_input_hidden('type_names',base64_encode(json_encode($type_names_hash)),true);
}
@ -196,21 +195,21 @@ else {
$table_simple->data[1][1] = html_print_select_from_sql ($sql, 'id_module_type',
$idModuleType, '', '', '', true, false, false, $disabledBecauseInPolicy, false, false, 100);
// Store the relation between id and name of the types on a hidden field
$sql = sprintf ('SELECT id_tipo, nombre
FROM ttipo_modulo
WHERE categoria IN (%s)
ORDER BY descripcion',
implode (',', $categories));
$type_names = db_get_all_rows_sql($sql);
$type_names_hash = array();
foreach($type_names as $tn) {
foreach ($type_names as $tn) {
$type_names_hash[$tn['id_tipo']] = $tn['nombre'];
}
$table_simple->data[1][1] .= html_print_input_hidden('type_names',base64_encode(json_encode($type_names_hash)),true);
}
@ -372,7 +371,8 @@ $table_advanced->data[6][4] = html_print_select_from_sql (
$table_advanced->data[7][0] = __('Quiet');
$table_advanced->data[7][0] .= ui_print_help_tip(__('The module still stores data but the alerts and events will be stop'), true);
$table_advanced->colspan[7][1] = 4;
$table_advanced->data[7][1] = html_print_checkbox('quiet_module', 1, $quiet_module, true);
$table_advanced->data[7][1] = html_print_checkbox('quiet_module', 1,
$quiet_module, true);
$table_advanced->data[8][0] = __('Critical instructions'). ui_print_help_tip(__("Instructions when the status is critical"), true);
$table_advanced->data[8][1] = html_print_textarea ('critical_instructions', 2, 65, $critical_instructions, '', true);
@ -391,10 +391,12 @@ $table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour, $minu
$table_advanced->colspan[11][1] = 4;
$table_advanced->data[12][0] = __('Timeout');
$table_advanced->data[12][1] = html_print_input_text ('max_timeout', $max_timeout, '', 5, 10, true);
$table_advanced->data[12][1] = html_print_input_text ('max_timeout',
$max_timeout, '', 5, 10, true);
$table_advanced->data[12][2] = '';
$table_advanced->data[12][3] = __('Retries');
$table_advanced->data[12][4] = html_print_input_text ('max_retries', $max_retries, '', 5, 10, true);
$table_advanced->data[12][4] = html_print_input_text ('max_retries',
$max_retries, '', 5, 10, true);
if (check_acl ($config['id_user'], 0, "PM")) {
$table_advanced->data[13][0] = __('Category');

View File

@ -228,6 +228,7 @@ define ('MODULE_DATA', 1);
define ('MODULE_NETWORK', 2);
define ('MODULE_SNMP', 2);
define ('MODULE_PLUGIN', 4);
define ('MODULE_PREDICTION', 5);
define ('MODULE_WMI', 6);
define ('MODULE_WEB', 7);

View File

@ -3043,9 +3043,9 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) {
* @param $thrash3 Don't use
*/
function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) {
if ($id == ""){
if ($id == "") {
returnError('error_update_network_module_policy', __('Error updating network module in policy. Id_policy cannot be left blank.'));
return;
return;
}
if ($other['data'][0] == ""){

View File

@ -20,7 +20,7 @@ function configure_modules_form () {
});
$("#local_component_group").change (function () {
var $select = $("#local_component").hide ();
$("#component").hide ();
if (this.value == 0) {
@ -54,7 +54,7 @@ function configure_modules_form () {
},
"json"
);
}
);
@ -69,7 +69,7 @@ function configure_modules_form () {
$("#textarea_configuration_data").val('');
$('#simple-configuration_data').show();
$("#text-name").val('');
$("#textarea_description").val('');
$("#checkbox-history_data").check ();
@ -108,7 +108,7 @@ function configure_modules_form () {
configuration_data = js_html_entity_decode (data['data']);
$("#text-name").attr ("value", js_html_entity_decode (data["name"]));
$("#textarea_description").attr ("value", js_html_entity_decode (data["description"]));
$("#textarea_configuration_data").attr ("value", configuration_data);
$("#textarea_configuration_data").val(configuration_data);
$("#component_loading").hide ();
$("#id_module_type option[value="+data["type"]+"]").select (1);
$("#text-max").attr ("value", data["max"]);
@ -119,7 +119,10 @@ function configure_modules_form () {
}
else {
period_select_update('module_interval', data["module_interval"]);
} $("#id_module_group option[value="+data["id_module_group"]+"]").select (1);
}
$("#id_module_group option[value="+data["id_module_group"]+"]").select (1);
if (data["history_data"])
$("#checkbox-history_data").check ();
else
@ -137,13 +140,13 @@ function configure_modules_form () {
$("#text-warning_inverse").attr ("value", (data["warning_inverse"] == 0) ? 0 : data["warning_inverse"]);
$("#component_loading").hide ();
$("#id_module_type").change ();
if($("#id_category").is("select")) {
if ($("#id_category").is("select")) {
$("#id_category option[value="+data["id_category"]+"]").select (1);
}
else {
$("#hidden-id_category").val(data["id_category"]);
}
var tags = data["tags"];
// Reset the selection of tags (put all of them into available box)
@ -162,7 +165,7 @@ function configure_modules_form () {
if(tags != '') {
tags = tags.split(',');
// Fill the selected tags box with select ones
for(i=0; i<tags.length; i++){
$("#id_tag_available option").each(function(){
@ -183,7 +186,7 @@ function configure_modules_form () {
$('.macro_field').remove();
$('#hidden-macros').val('');
var legend = '';
// If exist macros, load the fields
if(data["macros"] != '' && data["macros"] != null) {
@ -195,7 +198,7 @@ function configure_modules_form () {
legend += macro['macro']+" = "+ macro['desc']+"<br>";
});
$('#configuration_data_legend').html(legend);
$('#simple-show_configuration_data').show();
$('#simple-hide_configuration_data').hide();
$('#configuration_data_legend').show();
@ -300,7 +303,7 @@ function configure_modules_form () {
$("#text-warning_inverse").attr ("value", (data["warning_inverse"] == 0) ? 0 : data["warning_inverse"]);
$("#component_loading").hide ();
$("#id_module_type").change ();
if($("#id_category").is("select")) {
if ($("#id_category").is("select")) {
$("#id_category option[value="+data["id_category"]+"]").select (1);
}
else {
@ -316,16 +319,16 @@ function configure_modules_form () {
$("select[name='id_tag_available[]']").append($("<option></option>").val($(this).attr('value')).html($(this).text()));
}
});
if($("#id_tag_available option").length > 1) {
if ($("#id_tag_available option").length > 1) {
$("#id_tag_available").find("option[value='']").remove();
}
if($("#id_tag_selected option").length == 0) {
if ($("#id_tag_selected option").length == 0) {
$("select[name='id_tag_selected[]']").append($("<option></option>").val('').html('<i>None</i>'));
}
if(tags != '') {
if (tags != '') {
tags = tags.split(',');
// Fill the selected tags box with select ones
for(i=0; i<tags.length; i++){
$("#id_tag_available option").each(function(){
@ -341,12 +344,12 @@ function configure_modules_form () {
}
}
}
// Delete macro fields
$('.macro_field').remove();
$('#hidden-macros').val('');
// If exist macros, load the fields
if(data["macros"] != '' && data["macros"] != null) {
$('#hidden-macros').val(Base64.encode(data["macros"]));
@ -397,7 +400,7 @@ function configure_modules_form () {
$("#message").showMessage (no_plugin_lang);
return false;
}
moduletype = $("#hidden-moduletype").val ();
if (moduletype == 5) {
if ($("#prediction_module").val () == null) {
@ -449,7 +452,7 @@ function configure_modules_form () {
});
}
if(typeof $("#prediction_id_agent").pandoraSelectAgentModule == 'function') {
if (typeof $("#prediction_id_agent").pandoraSelectAgentModule == 'function') {
$("#prediction_id_agent").pandoraSelectAgentModule ({
moduleSelect: "select#prediction_module"
});
@ -461,13 +464,13 @@ function configure_modules_form () {
function delete_macro(prefix) {
var next_number = parseInt($('#next_macro').html());
// Is not possible delete first macro
if(next_number == 3) {
if (next_number == 3) {
$('#delete_macro_button').hide();
}
var next_row = parseInt($('#next_row').html());
$('#next_macro').html(next_number-1);
$('#next_row').html(next_row-2);
var nrow1 = next_row - 2;
var nrow2 = next_row - 1;
@ -477,9 +480,9 @@ function delete_macro(prefix) {
function new_macro(prefix) {
$('#delete_macro_button').show();
var next_row = parseInt($('#next_row').html());
$('#next_row').html(next_row+2);
var nrow1 = next_row - 2;
var nrow2 = next_row - 1;
@ -493,7 +496,7 @@ function new_macro(prefix) {
// Clone two last rows
var $row1 = $('#'+prefix+nrow1).clone(true);
var $row2 = $('#'+prefix+nrow2).clone(true);
// Change the tr ID
$row1.attr('id',prefix+(nrow3));
$row2.attr('id',prefix+(nrow4));
@ -506,14 +509,14 @@ function new_macro(prefix) {
$row1.insertAfter('#'+prefix+nrow2);
// Change labels
for(i=0;i<=3;i++) {
for(i = 0; i <= 3; i++) {
var label1 = $("#"+prefix+nrow3+"-"+i).html();
var exp_reg = new RegExp('field'+current_number, 'g');
label1 = label1.replace(exp_reg,'field'+next_number);
$("#"+prefix+nrow3+"-"+i).html(label1);
}
for(i=0;i<=1;i++) {
for(i = 0; i <= 1; i++) {
var label2 = $("#"+prefix+nrow4+"-"+i).html();
var exp_reg = new RegExp('field'+current_number, 'g');
label2 = label2.replace(exp_reg,'field'+next_number);
@ -561,7 +564,7 @@ function add_macro_field(macro, row_model_id) {
var macro_help = macro['help'];
var macro_macro = macro['macro'];
var macro_value = macro['value'];
var row_id = row_model_id + macro_macro;
var $macro_field = $('#'+ row_model_id +'_field').clone(true);
@ -569,12 +572,12 @@ function add_macro_field(macro, row_model_id) {
// Change attributes to be unique and with identificable class
$macro_field.attr('id',row_id);
$macro_field.attr('class','macro_field');
// Get the number of fields already printed
var fields = $('.macro_field').size();
// If is the first, we insert it after model row
if(fields == 0) {
if (fields == 0) {
$macro_field.insertAfter('#'+ row_model_id +'_field');
}
// If there are more fields, we insert it after the last one
@ -583,7 +586,7 @@ function add_macro_field(macro, row_model_id) {
}
// Change the label
if(macro_help == '') {
if (macro_help == '') {
$('#'+row_id).children().eq(0).html(macro_desc);
}
else {
@ -597,8 +600,8 @@ function add_macro_field(macro, row_model_id) {
$('#'+row_id).children().eq(1).children().attr('id','text-'+macro_macro);
$('#'+row_id).children().eq(1).children().attr('name',macro_macro);
$('#'+row_id).children().eq(1).children().val(macro_value);
$('#'+row_id).show();
}
@ -620,8 +623,8 @@ function load_plugin_macros_fields(row_model_id) {
success: function (data) {
// Delete all the macro fields
$('.macro_field').remove();
if(data['array'] != null) {
if (data['array'] != null) {
$('#hidden-macros').val(data['base64']);
jQuery.each (data['array'], function (i, macro) {
if(macro['desc'] != '') {
@ -630,6 +633,6 @@ function load_plugin_macros_fields(row_model_id) {
});
}
}
});
});
}