public function executeDelete(\Library\HttpRequest $rq) { // Init result $result = $this->InitResponseWS(); $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user()); $db_result = FALSE; $task_id = intval($this->dataPost["task_id"]); //Check if the task to be deleted if the Task manager's $task_selected = \Applications\PMTool\Helpers\TaskHelper::GetSessionTask($this->app()->user(), $task_id); //Load interface to query the database if ($task_selected !== NULL) { $manager = $this->managers->getManagerOf($this->module()); if ($manager->delete($task_selected[\Library\Enums\SessionKeys::TaskObj], "task_id")) { $sessionTasks = \Applications\PMTool\Helpers\TaskHelper::GetSessionTasks($this->app()->user()); unset($sessionTasks[\Library\Enums\SessionKeys::TaskKey . $task_id]); \Applications\PMTool\Helpers\TaskHelper::SetSessionTasks($this->app()->user(), $sessionTasks); $index = \Applications\PMTool\Helpers\CommonHelper::FindIndexInIdListById(\Library\Enums\SessionKeys::TaskKey . $task_id, $sessionProject[\Library\Enums\SessionKeys::ProjectTasks]); $db_result = $index === NULL ? FALSE : TRUE; unset($sessionProject[\Library\Enums\SessionKeys::ProjectTasks][$index]); \Applications\PMTool\Helpers\ProjectHelper::SetUserSessionProject($this->app()->user(), $sessionProject); $currentSessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->app()->user()); if ($currentSessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id() == $task_id) { \Applications\PMTool\Helpers\TaskHelper::UnsetCurrentSessionTask($this->app()->user()); } } } $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Task, "resx_key" => $this->action(), "step" => $db_result !== FALSE ? "success" : "error")); }