From 2c7e97a7d56cf3d5fc98a50585e96026a4a915f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Tue, 25 Jan 2022 13:00:31 +0100 Subject: [PATCH] [#431] Fix undefined index warnings in user tasks report. --- web/services/getTasksFiltered.php | 40 +++++++------------------------ web/userTasksReport.php | 2 -- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/web/services/getTasksFiltered.php b/web/services/getTasksFiltered.php index d0b2dfa9d..3abb93a06 100644 --- a/web/services/getTasksFiltered.php +++ b/web/services/getTasksFiltered.php @@ -123,9 +123,9 @@ function maybeEscapeString($string, $csvExport) { return $csvExport? $string : escape_string($string); } - $sid = $_GET['sid']; + $sid = $_GET['sid'] ?? NULL; - $csvExport = ($_GET["format"] && $_GET["format"] == "csv"); + $csvExport = (isset($_GET["format"]) && $_GET["format"] == "csv"); $csvFile = null; if ($csvExport) { @@ -162,24 +162,21 @@ function maybeEscapeString($string, $csvExport) { } /* Retrieve the data from the request */ - $dateFormat = "Y-m-d"; + $dateFormat = $_GET['dateFormat'] ?? "Y-m-d"; + $filterText = $_GET['filterText'] ?? NULL; + $type = $_GET['type'] ?? NULL; + $projectId = $_GET['projectId'] ?? NULL; + $customerId = $_GET['customerId'] ?? NULL; + $taskStoryId = $_GET['taskStoryId'] ?? NULL; + $filterStory = $_GET['filterStory'] ?? NULL; $filterStartDate = NULL; $filterEndDate = NULL; $telework = NULL; $onsite = NULL; - $filterText = NULL; - $type = NULL; $userId = NULL; - $projectId = NULL; - $customerId = NULL; - $taskStoryId = NULL; - $filterStory = NULL; $emptyText = NULL; $emptyStory = NULL; $showProjectNames = false; - if (isset($_GET['dateFormat'])) { - $dateFormat = $_GET['dateFormat']; - } if (isset($_GET['filterStartDate'])) { $filterStartDate = DateTime::createFromFormat( $dateFormat, $_GET['filterStartDate']); @@ -204,12 +201,6 @@ function maybeEscapeString($string, $csvExport) { $onsite = false; } } - if (isset($_GET['filterText'])) { - $filterText = $_GET['filterText']; - } - if (isset($_GET['type'])) { - $type = $_GET['type']; - } if (isset($_GET['userId'])) { //Request to check user tasks of other user if($_GET['userId'] != $_SESSION['user']->getId()){ @@ -220,19 +211,6 @@ function maybeEscapeString($string, $csvExport) { } $userId = $_GET['userId']; } - if (isset($_GET['projectId'])) { - $projectId = $_GET['projectId']; - } - if (isset($_GET['customerId'])) { - $customerId = $_GET['customerId']; - } - - if (isset($_GET['taskStoryId'])) { - $taskStoryId = $_GET['taskStoryId']; - } - if (isset($_GET['filterStory'])) { - $filterStory = $_GET['filterStory']; - } if (isset($_GET['emptyText'])) { $emptyText = filter_var($_GET['emptyText'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); diff --git a/web/userTasksReport.php b/web/userTasksReport.php index 590f0de09..c3e2df3b0 100644 --- a/web/userTasksReport.php +++ b/web/userTasksReport.php @@ -20,8 +20,6 @@ define('PHPREPORT_ROOT', __DIR__ . '/../'); -$sid = $_GET["sid"]; - /* We check authentication and authorization */ require_once(PHPREPORT_ROOT . '/web/auth.php');