mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Merge branch 'ent-4681-8764-Fallo-en-Vodat-a-la-hora-de-editar-módulos-de-politica' into 'develop'
Fixed modules_get_relations See merge request artica/pandorafms!2751
This commit is contained in:
commit
375fac7f3d
@ -1191,49 +1191,54 @@ $table_relations->data[-1][3] .= html_print_image('images/lock.png', true).'</a>
|
|||||||
$table_relations->data[-1][4] = '<a id="delete_relation_button" href="">';
|
$table_relations->data[-1][4] = '<a id="delete_relation_button" href="">';
|
||||||
$table_relations->data[-1][4] .= html_print_image('images/cross.png', true).'</a>';
|
$table_relations->data[-1][4] .= html_print_image('images/cross.png', true).'</a>';
|
||||||
|
|
||||||
$module_relations = modules_get_relations(['id_module' => $id_agent_module]);
|
|
||||||
if (!$module_relations) {
|
|
||||||
$module_relations = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$relations_count = 0;
|
$relations_count = 0;
|
||||||
foreach ($module_relations as $key => $module_relation) {
|
if ($id_agent_module) {
|
||||||
if ($module_relation['module_a'] == $id_agent_module) {
|
$module_relations = modules_get_relations(['id_module' => $id_agent_module]);
|
||||||
$module_id = $module_relation['module_b'];
|
|
||||||
$agent_id = modules_give_agent_id_from_module_id(
|
if (!$module_relations) {
|
||||||
$module_relation['module_b']
|
$module_relations = [];
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$module_id = $module_relation['module_a'];
|
|
||||||
$agent_id = modules_give_agent_id_from_module_id(
|
|
||||||
$module_relation['module_a']
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$agent_name = ui_print_agent_name($agent_id, true);
|
$relations_count = 0;
|
||||||
|
foreach ($module_relations as $key => $module_relation) {
|
||||||
|
if ($module_relation['module_a'] == $id_agent_module) {
|
||||||
|
$module_id = $module_relation['module_b'];
|
||||||
|
$agent_id = modules_give_agent_id_from_module_id(
|
||||||
|
$module_relation['module_b']
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$module_id = $module_relation['module_a'];
|
||||||
|
$agent_id = modules_give_agent_id_from_module_id(
|
||||||
|
$module_relation['module_a']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$module_name = modules_get_agentmodule_name($module_id);
|
$agent_name = ui_print_agent_name($agent_id, true);
|
||||||
if (empty($module_name) || $module_name == 'false') {
|
|
||||||
$module_name = $module_id;
|
$module_name = modules_get_agentmodule_name($module_id);
|
||||||
|
if (empty($module_name) || $module_name == 'false') {
|
||||||
|
$module_name = $module_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($module_relation['disable_update']) {
|
||||||
|
$disabled_update_class = '';
|
||||||
|
} else {
|
||||||
|
$disabled_update_class = 'alpha50';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Agent name.
|
||||||
|
$table_relations->data[$relations_count][0] = $agent_name;
|
||||||
|
// Module name.
|
||||||
|
$table_relations->data[$relations_count][1] = "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=".$agent_id.'&tab=module&edit_module=1&id_agent_module='.$module_id."'>".ui_print_truncate_text($module_name, 'module_medium', true, true, true, '[…]').'</a>';
|
||||||
|
// Type.
|
||||||
|
$table_relations->data[$relations_count][2] = ($module_relation['type'] === 'direct') ? __('Direct') : __('Failover');
|
||||||
|
// Lock relationship updates.
|
||||||
|
$table_relations->data[$relations_count][3] = '<a id="disable_updates_button" class="'.$disabled_update_class.'"href="javascript: change_lock_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/lock.png', true).'</a>';
|
||||||
|
// Delete relationship.
|
||||||
|
$table_relations->data[$relations_count][4] = '<a id="delete_relation_button" href="javascript: delete_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/cross.png', true).'</a>';
|
||||||
|
$relations_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($module_relation['disable_update']) {
|
|
||||||
$disabled_update_class = '';
|
|
||||||
} else {
|
|
||||||
$disabled_update_class = 'alpha50';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Agent name.
|
|
||||||
$table_relations->data[$relations_count][0] = $agent_name;
|
|
||||||
// Module name.
|
|
||||||
$table_relations->data[$relations_count][1] = "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=".$agent_id.'&tab=module&edit_module=1&id_agent_module='.$module_id."'>".ui_print_truncate_text($module_name, 'module_medium', true, true, true, '[…]').'</a>';
|
|
||||||
// Type.
|
|
||||||
$table_relations->data[$relations_count][2] = ($module_relation['type'] === 'direct') ? __('Direct') : __('Failover');
|
|
||||||
// Lock relationship updates.
|
|
||||||
$table_relations->data[$relations_count][3] = '<a id="disable_updates_button" class="'.$disabled_update_class.'"href="javascript: change_lock_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/lock.png', true).'</a>';
|
|
||||||
// Delete relationship.
|
|
||||||
$table_relations->data[$relations_count][4] = '<a id="delete_relation_button" href="javascript: delete_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/cross.png', true).'</a>';
|
|
||||||
$relations_count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
html_print_input_hidden('module_relations_count', $relations_count);
|
html_print_input_hidden('module_relations_count', $relations_count);
|
||||||
|
@ -2654,21 +2654,18 @@ function modules_get_relations($params=[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
$modules_type = '';
|
$modules_type = '';
|
||||||
|
$modules_type_filter = '';
|
||||||
if (isset($params['modules_type'])) {
|
if (isset($params['modules_type'])) {
|
||||||
$modules_type = $params['modules_type'];
|
$module_type = 'INNER JOIN ttipo_modulo ttm ON tam.id_tipo_modulo = ttm.id_tipo';
|
||||||
|
$modules_type_filter = sprintf(
|
||||||
|
"AND ttm.nombre = '%s'",
|
||||||
|
$params['modules_type']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT DISTINCT tmr.id, tmr.module_a, tmr.module_b,
|
$distinct = '';
|
||||||
tmr.disable_update, tmr.type
|
if (empty($params)) {
|
||||||
FROM tmodule_relationship tmr,
|
$distinct = 'DISTINCT';
|
||||||
tagente_modulo tam,
|
|
||||||
tagente ta,
|
|
||||||
ttipo_modulo ttm
|
|
||||||
WHERE ';
|
|
||||||
|
|
||||||
$agent_filter = '';
|
|
||||||
if ($id_agent > 0) {
|
|
||||||
$agent_filter = sprintf('AND ta.id_agente = %d', $id_agent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$module_a_filter = '';
|
$module_a_filter = '';
|
||||||
@ -2678,6 +2675,11 @@ function modules_get_relations($params=[])
|
|||||||
$module_b_filter = sprintf('AND tmr.module_b = %d', $id_module);
|
$module_b_filter = sprintf('AND tmr.module_b = %d', $id_module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$agent_filter = '';
|
||||||
|
if ($id_agent > 0) {
|
||||||
|
$agent_filter = sprintf('AND ta.id_agente = %d', $id_agent);
|
||||||
|
}
|
||||||
|
|
||||||
$disabled_update_filter = '';
|
$disabled_update_filter = '';
|
||||||
if ($disabled_update >= 0) {
|
if ($disabled_update >= 0) {
|
||||||
$disabled_update_filter = sprintf(
|
$disabled_update_filter = sprintf(
|
||||||
@ -2686,22 +2688,25 @@ function modules_get_relations($params=[])
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$modules_type_filter = '';
|
$sql = sprintf(
|
||||||
if ($modules_type != '') {
|
'SELECT %s tmr.id, tmr.module_a, tmr.module_b,
|
||||||
$modules_type_filter = sprintf(
|
tmr.disable_update, tmr.type
|
||||||
"AND (tam.id_tipo_modulo = ttm.id_tipo AND ttm.nombre = '%s')",
|
FROM tmodule_relationship tmr
|
||||||
$modules_type
|
INNER JOIN tagente_modulo tam
|
||||||
);
|
ON (tmr.module_a = tam.id_agente_modulo %s)
|
||||||
}
|
OR (tmr.module_b = tam.id_agente_modulo %s)
|
||||||
|
INNER JOIN tagente ta
|
||||||
$sql .= "( (tmr.module_a = tam.id_agente_modulo
|
ON tam.id_agente = ta.id_agente
|
||||||
$module_a_filter)
|
%s
|
||||||
OR (tmr.module_b = tam.id_agente_modulo
|
WHERE 1=1 %s %s %s',
|
||||||
$module_b_filter) )
|
$distinct,
|
||||||
AND tam.id_agente = ta.id_agente
|
$module_a_filter,
|
||||||
$agent_filter
|
$module_b_filter,
|
||||||
$disabled_update_filter
|
$module_type,
|
||||||
$modules_type_filter";
|
$agent_filter,
|
||||||
|
$disabled_update_filter,
|
||||||
|
$modules_type_filter
|
||||||
|
);
|
||||||
|
|
||||||
return db_get_all_rows_sql($sql);
|
return db_get_all_rows_sql($sql);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user