diff --git a/model/dao/ExtraHourDAO/PostgreSQLExtraHourDAO.php b/model/dao/ExtraHourDAO/PostgreSQLExtraHourDAO.php
index 99202b0e2..469359685 100644
--- a/model/dao/ExtraHourDAO/PostgreSQLExtraHourDAO.php
+++ b/model/dao/ExtraHourDAO/PostgreSQLExtraHourDAO.php
@@ -84,10 +84,13 @@ protected function setValues($row)
*/
public function getById($extraHourId) {
if (!is_numeric($extraHourId))
- throw new SQLIncorrectTypeException($extraHourId);
+ throw new SQLIncorrectTypeException($extraHourId);
$sql = "SELECT * FROM extra_hour WHERE id=".$extraHourId;
- $result = $this->execute($sql);
- return $result[0];
+ $result = $this->execute($sql);
+
+ if (empty($result))
+ return NULL;
+ return $result[0];
}
/** Extra Hours retriever by User id for PostgreSQL.
@@ -120,10 +123,13 @@ public function getByUserId($userId) {
*/
public function getLastByUserId($userId, DateTime $nowadays) {
if (!is_numeric($userId))
- throw new SQLIncorrectTypeException($userId);
+ throw new SQLIncorrectTypeException($userId);
$sql = "SELECT * FROM extra_hour WHERE usrid=" . $userId . " AND _date <=" . DBPostgres::formatDate($nowadays) . " ORDER BY _date DESC LIMIT 1";
- $result = $this->execute($sql);
- return $result[0];
+ $result = $this->execute($sql);
+
+ if (empty($result))
+ return NULL;
+ return $result[0];
}
/** Extra Hours retriever for PostgreSQL.
diff --git a/model/dao/TaskDAO/PostgreSQLTaskDAO.php b/model/dao/TaskDAO/PostgreSQLTaskDAO.php
index c000bb566..3778721c4 100644
--- a/model/dao/TaskDAO/PostgreSQLTaskDAO.php
+++ b/model/dao/TaskDAO/PostgreSQLTaskDAO.php
@@ -106,10 +106,13 @@ protected function setValues($row)
*/
public function getById($taskId) {
if (!is_numeric($taskId))
- throw new SQLIncorrectTypeException($taskId);
+ throw new SQLIncorrectTypeException($taskId);
$sql = "SELECT * FROM task WHERE id=".$taskId;
- $result = $this->execute($sql);
- return $result[0];
+ $result = $this->execute($sql);
+
+ if (empty($result))
+ return NULL;
+ return $result[0];
}
/** Tasks retriever by User id for PostgreSQL.
@@ -383,7 +386,7 @@ public function getFiltered($filterStartDate = NULL, $filterEndDate = NULL,
/** Tasks report generator for PostgreSQL.
*
* This function generates a report of the hours users have worked in Tasks related to an element $reportObject,
- * which may be a {@link UserVO}, {@link TaskVO} or {@link CustomerVO}. Two optional dates can also be passed, $initDate
+ * which may be a {@link UserVO}, {@link ProjectVO} or {@link CustomerVO}. Two optional dates can also be passed, $initDate
* and $endDate, to limit the dates of the tasks retrieved (if they are not passed, it returns the result for tasks of any date),
* and two group fields, $groupField1 and $groupField2, that only are used for making groups with the
* results if they are passed.
@@ -451,12 +454,14 @@ public function getTaskReport($reportObject, DateTime $initDate = NULL, DateTime
if ($res == NULL) throw new SQLQueryErrorException(pg_last_error());
- if(pg_num_rows($res) > 0) {
- for($i = 0; $i < pg_num_rows($res); $i++)
- {
- $rows[$i] = @pg_fetch_array($res);
- }
+ $rows = array();
+ if(pg_num_rows($res) > 0) {
+ for($i = 0; $i < pg_num_rows($res); $i++) {
+ $rows[$i] = @pg_fetch_array($res);
}
+ }
+ else
+ return NULL;
return $rows;
@@ -637,11 +642,13 @@ public function getVacations(UserVO $userVO, DateTime $initDate = NULL, DateTime
$res = pg_query($this->connect, $sql);
if ($res == NULL) throw new SQLQueryErrorException(pg_last_error());
- for($i = 0; $i < pg_num_rows($res); $i++)
- {
+ $result = array();
+ for($i = 0; $i < pg_num_rows($res); $i++) {
$result[$i] = @pg_fetch_array($res);
- }
+ }
+ if (empty($result))
+ return NULL;
return $result[0];
}
@@ -666,7 +673,7 @@ public function partialUpdate(DirtyTaskVO $taskVO) {
}
// If the query returned a row then update
- if(sizeof($currTaskVO) > 0) {
+ if(isset($currTaskVO)) {
$sql = "UPDATE task SET ";
diff --git a/model/dao/UserGoalDAO/PostgreSQLUserGoalDAO.php b/model/dao/UserGoalDAO/PostgreSQLUserGoalDAO.php
index b4aa717fd..5ecdcc9f9 100644
--- a/model/dao/UserGoalDAO/PostgreSQLUserGoalDAO.php
+++ b/model/dao/UserGoalDAO/PostgreSQLUserGoalDAO.php
@@ -221,6 +221,9 @@ public function getUserGoalsForCurrentDate($userId, DateTime $date) {
AND end_date >= " . DBPostgres::formatDate($date) . ";";
$result = $this->execute($sql);
+
+ if (empty($result))
+ return NULL;
return $result[0];
}
}
\ No newline at end of file
diff --git a/web/services/createTasksService.php b/web/services/createTasksService.php
index 5f2038e7d..a22b92e44 100644
--- a/web/services/createTasksService.php
+++ b/web/services/createTasksService.php
@@ -231,7 +231,7 @@
$string = "falseThere was some error while creating the tasks";
- if (!$string)
+ if (!isset($string))
{
$string = "trueOperation Success!";
diff --git a/web/services/getOpenTaskStoriesService.php b/web/services/getOpenTaskStoriesService.php
index 1ccd07f87..9c05d9954 100644
--- a/web/services/getOpenTaskStoriesService.php
+++ b/web/services/getOpenTaskStoriesService.php
@@ -30,7 +30,7 @@
include_once(PHPREPORT_ROOT . '/web/services/WebServicesFunctions.php');
include_once(PHPREPORT_ROOT . '/model/facade/CoordinationFacade.php');
- $sid = $_GET['sid'];
+ $sid = $_GET['sid'] ?? NULL;
$projectId = $_GET['pid'];
diff --git a/web/services/getPersonalSummaryByDateService.php b/web/services/getPersonalSummaryByDateService.php
index 6268cd0b7..477f169ed 100644
--- a/web/services/getPersonalSummaryByDateService.php
+++ b/web/services/getPersonalSummaryByDateService.php
@@ -78,25 +78,15 @@ function formatHours ($time, $journey, $limit) {
return $formatedHours;
}
- $date = $_GET['date'];
+ $dateString = $_GET['date'] ?? NULL;
- $dateFormat = $_GET['dateFormat'];
+ $dateFormat = $_GET['dateFormat'] ?? "Y-m-d";
- $sid = $_GET['sid'];
+ $sid = $_GET['sid'] ?? NULL;
- if ($dateFormat=="")
- $dateFormat = "Y-m-d";
-
- if ($date == "")
- $date = new DateTime();
- else
- {
- $dateParse = date_parse_from_format($dateFormat, $date);
-
- $date = "{$dateParse['year']}-{$dateParse['month']}-{$dateParse['day']}";
-
- $date = date_create($date);
- }
+ $date = new DateTime();
+ if ($dateString)
+ $date = DateTime::createFromFormat($dateFormat, $dateString);
do {
/* We check authentication and authorization */
diff --git a/web/services/getProjectsService.php b/web/services/getProjectsService.php
index a49c1e2ac..c9b3e61c5 100644
--- a/web/services/getProjectsService.php
+++ b/web/services/getProjectsService.php
@@ -31,56 +31,29 @@
include_once(PHPREPORT_ROOT . '/model/facade/ProjectsFacade.php');
include_once(PHPREPORT_ROOT . '/model/vo/ProjectVO.php');
-$sid = $_GET['sid'];
-$login = $_GET['login'];
-$order = 'id';
+$sid = $_GET['sid'] ?? NULL;
+$login = $_GET['login'] ?? NULL;
+$order = $_GET['order'] ?? 'id';
// In case some filtering args are set, retrieve them
-$description = NULL;
+$description = $_GET['description'] ?? NULL;
$filterStartDate = NULL;
$filterEndDate = NULL;
-$activation = NULL;
-$areaId = NULL;
-$type = NULL;
-$customerId = NULL;
-$cname = NULL;
-$active = false;
-$returnExtendedInfo = False;
-
-if (isset($_GET['description'])) {
- $description = $_GET['description'];
-}
+$activation = $_GET['activation'] ?? NULL;
+$areaId = $_GET['areaId'] ?? NULL;
+$type = $_GET['type'] ?? NULL;
+$customerId = $_GET['customerId'] ?? NULL;
+$cname = $_GET['cname'] ?? NULL;
+$active = $_GET['active'] ?? false;
+$returnExtendedInfo = $_GET['returnExtendedInfo'] ?? false;
+
if (isset($_GET['filterStartDate'])) {
$filterStartDate = DateTime::createFromFormat("Y-m-d", $_GET['filterStartDate']);
}
if (isset($_GET['filterEndDate'])) {
$filterEndDate = DateTime::createFromFormat("Y-m-d", $_GET['filterEndDate']);
}
-if (isset($_GET['activation'])) {
- $activation = $_GET['activation'];
-}
-if (isset($_GET['areaId'])) {
- $areaId = $_GET['areaId'];
-}
-if (isset($_GET['type'])) {
- $type = $_GET['type'];
-}
-if (isset($_GET['order'])) {
- $order = $_GET['order'];
-}
-if (isset($_GET['customerId'])) {
- $customerId = $_GET['customerId'];
-}
-if (isset($_GET['cname'])) {
- $cname = $_GET['cname'];
-}
-if (isset($_GET['returnExtendedInfo'])) {
- $returnExtendedInfo = $_GET['returnExtendedInfo'];
-}
-if (isset($_GET['active'])) {
- $active = $_GET['active'];
-}
do {
/* We check authentication and authorization */
diff --git a/web/services/getUserTasksService.php b/web/services/getUserTasksService.php
index 6f162be68..706d5b71f 100644
--- a/web/services/getUserTasksService.php
+++ b/web/services/getUserTasksService.php
@@ -31,32 +31,17 @@
include_once(PHPREPORT_ROOT . '/model/facade/TasksFacade.php');
include_once(PHPREPORT_ROOT . '/model/vo/UserVO.php');
- $userLogin = $_GET['uid'];
+ $userLogin = $_GET['uid'] ?? $_GET['login'] ?? NULL;
- $date = $_GET['date'];
+ $dateString = $_GET['date'] ?? NULL;
- $dateFormat = $_GET['dateFormat'];
+ $dateFormat = $_GET['dateFormat'] ?? "Y-m-d";
- $login = $_GET['login'];
+ $sid = $_GET['sid'] ?? NULL;
- if ($userLogin=="")
- $userLogin= $login;
-
- $sid = $_GET['sid'];
-
- if ($dateFormat=="")
- $dateFormat = "Y-m-d";
-
- if ($date == "")
- $date = new DateTime();
- else
- {
- $dateParse = date_parse_from_format($dateFormat, $date);
-
- $date = "{$dateParse['year']}-{$dateParse['month']}-{$dateParse['day']}";
-
- $date = date_create($date);
- }
+ $date = new DateTime();
+ if ($dateString)
+ $date = DateTime::createFromFormat($dateFormat, $dateString);
do {
/* We check authentication and authorization */
diff --git a/web/services/getUserTemplatesService.php b/web/services/getUserTemplatesService.php
index 2ee0dbfd7..e1c74613f 100644
--- a/web/services/getUserTemplatesService.php
+++ b/web/services/getUserTemplatesService.php
@@ -23,7 +23,7 @@
include_once(PHPREPORT_ROOT . '/model/facade/TemplatesFacade.php');
include_once(PHPREPORT_ROOT . '/model/vo/TemplateVO.php');
-$sid = $_GET['sid'];
+$sid = $_GET['sid'] ?? NULL;
do {
/* We check authentication and authorization */