mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
Merge branch 'ent-3621-Discover-vista-de-tasks-bloqueada-y-duplicada' into 'develop'
fix discover task view See merge request artica/pandorafms!2223 Former-commit-id: f8c236623756ef6e76d54cf4ab905f706df1ea84
This commit is contained in:
commit
a5c3136321
@ -306,7 +306,7 @@ class DiscoveryTaskList extends Wizard
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all recon servers.
|
// Get all discovery servers.
|
||||||
$servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3');
|
$servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3');
|
||||||
if ($servers === false) {
|
if ($servers === false) {
|
||||||
$servers = [];
|
$servers = [];
|
||||||
@ -337,28 +337,8 @@ class DiscoveryTaskList extends Wizard
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($servers as $serverItem) {
|
|
||||||
$id_server = $serverItem['id_server'];
|
|
||||||
$server_name = servers_get_name($id_server);
|
|
||||||
$recon_tasks = db_get_all_rows_sql('SELECT * FROM trecon_task');
|
$recon_tasks = db_get_all_rows_sql('SELECT * FROM trecon_task');
|
||||||
$user_groups = implode(',', array_keys(users_get_groups()));
|
$user_groups = implode(',', array_keys(users_get_groups()));
|
||||||
$defined_tasks = db_get_all_rows_filter(
|
|
||||||
'tuser_task_scheduled',
|
|
||||||
'id_grupo IN ('.$user_groups.')'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isset($tasks_console) === true
|
|
||||||
&& is_array($tasks_console) === true
|
|
||||||
) {
|
|
||||||
foreach ($tasks_console as $key => $value) {
|
|
||||||
$value['parameters'] = unserialize(
|
|
||||||
$value['parameters']
|
|
||||||
);
|
|
||||||
|
|
||||||
$value['type'] = 'Cron';
|
|
||||||
array_push($recon_tasks, $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show network tasks for Recon Server.
|
// Show network tasks for Recon Server.
|
||||||
if ($recon_tasks === false) {
|
if ($recon_tasks === false) {
|
||||||
@ -384,31 +364,52 @@ class DiscoveryTaskList extends Wizard
|
|||||||
$table->head[1] = __('Task name');
|
$table->head[1] = __('Task name');
|
||||||
$table->align[1] = 'left';
|
$table->align[1] = 'left';
|
||||||
|
|
||||||
$table->head[2] = __('Interval');
|
$table->head[2] = __('Server name');
|
||||||
$table->align[2] = 'left';
|
$table->align[2] = 'left';
|
||||||
|
|
||||||
$table->head[3] = __('Network');
|
$table->head[3] = __('Interval');
|
||||||
$table->align[3] = 'left';
|
$table->align[3] = 'left';
|
||||||
|
|
||||||
$table->head[4] = __('Status');
|
$table->head[4] = __('Network');
|
||||||
$table->align[4] = 'left';
|
$table->align[4] = 'left';
|
||||||
|
|
||||||
$table->head[5] = __('Task type');
|
$table->head[5] = __('Status');
|
||||||
$table->align[5] = 'left';
|
$table->align[5] = 'left';
|
||||||
|
|
||||||
$table->head[6] = __('Progress');
|
$table->head[6] = __('Task type');
|
||||||
$table->align[6] = 'left';
|
$table->align[6] = 'left';
|
||||||
|
|
||||||
$table->head[7] = __('Updated at');
|
$table->head[7] = __('Progress');
|
||||||
$table->align[7] = 'left';
|
$table->align[7] = 'left';
|
||||||
|
|
||||||
$table->head[8] = __('Operations');
|
$table->head[8] = __('Updated at');
|
||||||
$table->align[8] = 'left';
|
$table->align[8] = 'left';
|
||||||
|
|
||||||
|
$table->head[9] = __('Operations');
|
||||||
|
$table->align[9] = 'left';
|
||||||
|
|
||||||
foreach ($recon_tasks as $task) {
|
foreach ($recon_tasks as $task) {
|
||||||
$data = [];
|
$data = [];
|
||||||
|
$server_name = servers_get_name($task['id_recon_server']);
|
||||||
|
|
||||||
if ($task['disabled'] == 0) {
|
// By default.
|
||||||
|
$subnet = $task['subnet'];
|
||||||
|
|
||||||
|
// Exceptions: IPAM.
|
||||||
|
$ipam = false;
|
||||||
|
if ($task['id_recon_script'] != null) {
|
||||||
|
$recon_script_name = db_get_value('name', 'trecon_script', 'id_recon_script', $task['id_recon_script']);
|
||||||
|
if (io_safe_output($recon_script_name) == 'IPAM Recon'
|
||||||
|
&& enterprise_installed()
|
||||||
|
) {
|
||||||
|
$subnet_obj = json_decode($task['macros'], true);
|
||||||
|
$subnet = $subnet_obj['1']['value'];
|
||||||
|
$tipam_task_id = db_get_value('id', 'tipam_network', 'id_recon_task', $task['id_rt']);
|
||||||
|
$ipam = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($task['disabled'] == 0 && $server_name !== '') {
|
||||||
$data[0] = '<a href="'.ui_get_full_url(
|
$data[0] = '<a href="'.ui_get_full_url(
|
||||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&server_id='.$id_server.'&force='.$task['id_rt']
|
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&server_id='.$id_server.'&force='.$task['id_rt']
|
||||||
).'">';
|
).'">';
|
||||||
@ -425,54 +426,51 @@ class DiscoveryTaskList extends Wizard
|
|||||||
|
|
||||||
$data[1] = '<b>'.$task['name'].'</b>';
|
$data[1] = '<b>'.$task['name'].'</b>';
|
||||||
|
|
||||||
|
$data[2] = $server_name;
|
||||||
|
|
||||||
if ($task['interval_sweep'] > 0) {
|
if ($task['interval_sweep'] > 0) {
|
||||||
$data[2] = human_time_description_raw(
|
$data[3] = human_time_description_raw(
|
||||||
$task['interval_sweep']
|
$task['interval_sweep']
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$data[2] = __('Manual');
|
$data[3] = __('Manual');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($task['id_recon_script'] == 0) {
|
if ($task['id_recon_script'] == 0 || $ipam === true) {
|
||||||
$data[3] = $task['subnet'];
|
$data[4] = $subnet;
|
||||||
} else {
|
} else {
|
||||||
$data[3] = '-';
|
$data[4] = '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($task['status'] <= 0) {
|
if ($task['status'] <= 0) {
|
||||||
$data[4] = __('Done');
|
$data[5] = __('Done');
|
||||||
} else {
|
} else {
|
||||||
$data[4] = __('Pending');
|
$data[5] = __('Pending');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($task['id_recon_script'] == 0) {
|
if ($task['id_recon_script'] == 0) {
|
||||||
// Discovery NetScan.
|
// Discovery NetScan.
|
||||||
$data[5] = html_print_image(
|
$data[6] = html_print_image(
|
||||||
'images/network.png',
|
'images/network.png',
|
||||||
true,
|
true,
|
||||||
['title' => __('Discovery NetScan')]
|
['title' => __('Discovery NetScan')]
|
||||||
).' ';
|
).' ';
|
||||||
$data[5] .= network_profiles_get_name(
|
$data[6] .= network_profiles_get_name(
|
||||||
$task['id_network_profile']
|
$task['id_network_profile']
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// APP recon task.
|
// APP recon task.
|
||||||
$data[5] = html_print_image(
|
$data[6] = html_print_image(
|
||||||
'images/plugin.png',
|
'images/plugin.png',
|
||||||
true
|
true
|
||||||
).' ';
|
).' ';
|
||||||
$data[5] .= db_get_sql(
|
$data[6] .= $recon_script_name;
|
||||||
sprintf(
|
|
||||||
'SELECT name FROM trecon_script WHERE id_recon_script = %d',
|
|
||||||
$task['id_recon_script']
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($task['status'] <= 0 || $task['status'] > 100) {
|
if ($task['status'] <= 0 || $task['status'] > 100) {
|
||||||
$data[6] = '-';
|
$data[7] = '-';
|
||||||
} else {
|
} else {
|
||||||
$data[6] = progress_bar(
|
$data[7] = progress_bar(
|
||||||
$task['status'],
|
$task['status'],
|
||||||
100,
|
100,
|
||||||
20,
|
20,
|
||||||
@ -482,12 +480,12 @@ class DiscoveryTaskList extends Wizard
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($task['utimestamp'] > 0) {
|
if ($task['utimestamp'] > 0) {
|
||||||
$data[7] = ui_print_timestamp(
|
$data[8] = ui_print_timestamp(
|
||||||
$task['utimestamp'],
|
$task['utimestamp'],
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$data[7] = __('Not executed yet');
|
$data[8] = __('Not executed yet');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_acl(
|
if (check_acl(
|
||||||
@ -496,8 +494,25 @@ class DiscoveryTaskList extends Wizard
|
|||||||
'PM'
|
'PM'
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
// Check if is a H&D, Cloud or Application.
|
if ($ipam === true) {
|
||||||
$data[8] = '<a href="'.ui_get_full_url(
|
$data[9] = '<a href="'.ui_get_full_url(
|
||||||
|
sprintf(
|
||||||
|
'index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=edit&id=%d',
|
||||||
|
$tipam_task_id
|
||||||
|
)
|
||||||
|
).'">'.html_print_image(
|
||||||
|
'images/config.png',
|
||||||
|
true
|
||||||
|
).'</a>';
|
||||||
|
$data[9] .= '<a href="'.ui_get_full_url(
|
||||||
|
'index.php?sec=godmode/extensions&sec2=enterprise/extensions/ipam&action=delete&id='.$tipam_task_id
|
||||||
|
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
|
||||||
|
'images/cross.png',
|
||||||
|
true
|
||||||
|
).'</a>';
|
||||||
|
} else {
|
||||||
|
// Check if is a H&D, Cloud or Application or IPAM.
|
||||||
|
$data[9] = '<a href="'.ui_get_full_url(
|
||||||
sprintf(
|
sprintf(
|
||||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&task=%d',
|
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&task=%d',
|
||||||
$this->getTargetWiz($task),
|
$this->getTargetWiz($task),
|
||||||
@ -507,14 +522,15 @@ class DiscoveryTaskList extends Wizard
|
|||||||
'images/config.png',
|
'images/config.png',
|
||||||
true
|
true
|
||||||
).'</a>';
|
).'</a>';
|
||||||
$data[8] .= '<a href="'.ui_get_full_url(
|
$data[9] .= '<a href="'.ui_get_full_url(
|
||||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&delete=1&task='.$task['id_rt']
|
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&delete=1&task='.$task['id_rt']
|
||||||
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
|
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
|
||||||
'images/cross.png',
|
'images/cross.png',
|
||||||
true
|
true
|
||||||
).'</a>';
|
).'</a>';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$data[8] = '';
|
$data[9] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
array_push($table->data, $data);
|
array_push($table->data, $data);
|
||||||
@ -530,7 +546,6 @@ class DiscoveryTaskList extends Wizard
|
|||||||
|
|
||||||
unset($table);
|
unset($table);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user