Added enable console task feature

This commit is contained in:
José González 2022-03-23 11:47:34 +01:00
parent 79162a787b
commit cc776ddbf7
2 changed files with 49 additions and 0 deletions

View File

@ -133,6 +133,11 @@ class DiscoveryTaskList extends HTML
return $this->deleteConsoleTask();
}
$toggle_console_task = (int) get_parameter('toggle_console_task', -1);
if ($toggle_console_task === 1 || $toggle_console_task === 0) {
return $this->toggleConsoleTask($toggle_console_task);
}
$delete = (bool) get_parameter('delete', false);
if ($delete === true) {
return $this->deleteTask();
@ -321,6 +326,49 @@ class DiscoveryTaskList extends HTML
}
/**
* Toggle enable/disable status of selected Console Task.
*
* @param integer $enable If 1 enable the console task.
*
* @return void
*/
public function toggleConsoleTask(int $enable)
{
global $config;
if ((bool) check_acl($config['id_user'], 0, 'RM') === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access recon task viewer'
);
include 'general/noaccess.php';
return;
}
$id_console_task = (int) get_parameter('id_console_task');
if ($id_console_task > 0) {
$result = db_process_sql_update(
'tuser_task_scheduled',
['enabled' => $enable],
['id' => $id_console_task]
);
if ((int) $result === 1) {
return [
'result' => 0,
'msg' => ((bool) $enable === true) ? __('Task successfully enabled') : __('Task succesfully disabled'),
'id' => false,
];
}
// Trick to avoid double execution.
header('Location: '.$this->url);
}
}
/**
* Delete a Console task.
*

View File

@ -3845,6 +3845,7 @@ CREATE TABLE IF NOT EXISTS `tuser_task_scheduled` (
`custom_data` INT NULL DEFAULT 0,
`flag_delete` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`id_grupo` INT UNSIGNED NOT NULL DEFAULT 0,
`enabled` TINYINT UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;