From 85bbec133760e938def4fbdeae0299c26501c0d3 Mon Sep 17 00:00:00 2001 From: Tiavina Date: Tue, 31 Dec 2024 01:55:13 +0300 Subject: [PATCH] fix get user of the calendar --- gestion/lib/Service/GestionService.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/gestion/lib/Service/GestionService.php b/gestion/lib/Service/GestionService.php index 85c7bc5..0a1d98a 100644 --- a/gestion/lib/Service/GestionService.php +++ b/gestion/lib/Service/GestionService.php @@ -67,7 +67,7 @@ class GestionService { } else{ //get from calendar object - $organizerName = $this->getOrganizerNameFromVCalendarString($vCalendarString); + $organizerName = $this->getPrincipalUsernameFromVCalendarString($vCalendarString); if($organizerName != null){ $thanatoIdFromDb = $this->gestionBdd->getFirstThanatoIdByName($organizerName); if($thanatoIdFromDb != null){ @@ -78,10 +78,10 @@ class GestionService { return $thanatoId; } - private function getOrganizerNameFromVCalendarString(string $vCalendarString){ + private function getPrincipalUsernameFromVCalendarString(string $vCalendarString){ $calendarUuid = VCalendarHelpers::GetValueFromKeyInVCalendarString("UID", $vCalendarString); - $organizerName = $this->gestionBdd->getCalendarOrganizerNameByCalendarObjectUuid($calendarUuid); - return $organizerName; + $principalUsername = $this->gestionBdd->getCalendarOrganizerNameByCalendarObjectUuid($calendarUuid); + return $principalUsername; } private function GetAttendeesNameFromVCalendarString(string $vCalendarString): array { @@ -132,8 +132,21 @@ class GestionService { $articlesId = $this->gestionBdd->getArticlesIdFromArticlesNameArray($articlesValue); $this->gestionBdd->insertDevisArticleFromDevisIdAndArticlesIdArray($devisId, $articlesId); } - $organizerName = $this->getOrganizerNameFromVCalendarString($vCalendarString); - $this->gestionBdd->createDevisTrajetFromVCalendar($devisId,$organizerName); + $userName = $this->GetThanatoNameFromVCalendarString($vCalendarString); + $this->gestionBdd->createDevisTrajetFromVCalendar($devisId,$userName); + } + + private function GetThanatoNameFromVCalendarString($vCalendarString){ + $thanatoName = null; + $thanatoNames = $this->GetAttendeesNameFromVCalendarString($vCalendarString); + if(count($thanatoNames) > 0){ + $thanatoName = $thanatoNames[0]; + } + else{ + //get from calendar object + $thanatoName = $this->getPrincipalUsernameFromVCalendarString($vCalendarString); + } + return $thanatoName; } private function GetClientIdFromVCalendarString(string $vCalendarString){