Merge branch 'fixes/fix-move-calendar' into staging
This commit is contained in:
commit
0cbedac615
@ -5,9 +5,11 @@
|
|||||||
namespace OCA\Gestion\AppInfo;
|
namespace OCA\Gestion\AppInfo;
|
||||||
|
|
||||||
use OCA\DAV\Events\CalendarObjectCreatedEvent;
|
use OCA\DAV\Events\CalendarObjectCreatedEvent;
|
||||||
|
use OCA\DAV\Events\CalendarObjectMovedEvent;
|
||||||
use OCA\DAV\Events\CalendarObjectMovedToTrashEvent;
|
use OCA\DAV\Events\CalendarObjectMovedToTrashEvent;
|
||||||
use OCA\DAV\Events\CalendarObjectUpdatedEvent;
|
use OCA\DAV\Events\CalendarObjectUpdatedEvent;
|
||||||
use OCA\Gestion\Listener\CalendarObjectCreatedListener;
|
use OCA\Gestion\Listener\CalendarObjectCreatedListener;
|
||||||
|
use OCA\Gestion\Listener\CalendarObjectMovedListener;
|
||||||
use OCA\Gestion\Listener\CalendarObjectMovedToTrashListener;
|
use OCA\Gestion\Listener\CalendarObjectMovedToTrashListener;
|
||||||
use OCA\Gestion\Listener\CalendarObjectUpdatedListener;
|
use OCA\Gestion\Listener\CalendarObjectUpdatedListener;
|
||||||
use OCP\AppFramework\App;
|
use OCP\AppFramework\App;
|
||||||
@ -27,6 +29,7 @@ class Application extends App implements IBootstrap {
|
|||||||
$context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarObjectCreatedListener::class);
|
$context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarObjectCreatedListener::class);
|
||||||
$context->registerEventListener(CalendarObjectMovedToTrashEvent::class, CalendarObjectMovedToTrashListener::class);
|
$context->registerEventListener(CalendarObjectMovedToTrashEvent::class, CalendarObjectMovedToTrashListener::class);
|
||||||
$context->registerEventListener(CalendarObjectUpdatedEvent::class, CalendarObjectUpdatedListener::class);
|
$context->registerEventListener(CalendarObjectUpdatedEvent::class, CalendarObjectUpdatedListener::class);
|
||||||
|
$context->registerEventListener(CalendarObjectMovedEvent::class,CalendarObjectMovedListener::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function boot(IBootContext $context): void {
|
public function boot(IBootContext $context): void {
|
||||||
|
|||||||
@ -2487,16 +2487,21 @@ class Bdd {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCalendarPrincipalNameByCalendarId($calendarId){
|
||||||
|
$calendar = $this->getCalendarById($calendarId);
|
||||||
|
if($calendar != null){
|
||||||
|
$principalUri = $calendar["principaluri"];
|
||||||
|
$organizerName = str_replace('principals/users/','',$principalUri);
|
||||||
|
$organizerName = trim($organizerName);
|
||||||
|
return $organizerName;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCalendarOrganizerNameByCalendarObjectUuid(string $calendarObjectUuid){
|
public function getCalendarOrganizerNameByCalendarObjectUuid(string $calendarObjectUuid){
|
||||||
$calendarObject = $this->getCalendarObjectByUuid($calendarObjectUuid);
|
$calendarObject = $this->getCalendarObjectByUuid($calendarObjectUuid);
|
||||||
if($calendarObject != null){
|
if($calendarObject != null){
|
||||||
$calendar = $this->getCalendarById($calendarObject['calendarid']);
|
return $this->getCalendarPrincipalNameByCalendarId($calendarObject['calendarid']);
|
||||||
if($calendar != null){
|
|
||||||
$principalUri = $calendar["principaluri"];
|
|
||||||
$organizerName = str_replace('principals/users/','',$principalUri);
|
|
||||||
$organizerName = trim($organizerName);
|
|
||||||
return $organizerName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -3617,6 +3622,13 @@ class Bdd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateDevisThanato($devisId,$requestedThanatoId){
|
||||||
|
$sql= "UPDATE ".$this->tableprefix."devis as devis
|
||||||
|
SET devis.id_thanato = ?
|
||||||
|
WHERE devis.id = ?";
|
||||||
|
$this->execSQLNoData($sql,[$requestedThanatoId,$devisId]);
|
||||||
|
}
|
||||||
|
|
||||||
public function updateDevisClient($devisId,$requestedClientId,$currentClientId = null){
|
public function updateDevisClient($devisId,$requestedClientId,$currentClientId = null){
|
||||||
$clientIsUpdated = $currentClientId != $requestedClientId;
|
$clientIsUpdated = $currentClientId != $requestedClientId;
|
||||||
if($clientIsUpdated){
|
if($clientIsUpdated){
|
||||||
|
|||||||
58
gestion/lib/Listener/CalendarObjectMovedListener.php
Normal file
58
gestion/lib/Listener/CalendarObjectMovedListener.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||||
|
*
|
||||||
|
* @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OCA\Gestion\Listener;
|
||||||
|
|
||||||
|
use OCA\DAV\Events\CalendarObjectMovedEvent;
|
||||||
|
use OCA\Gestion\Service\GestionService;
|
||||||
|
use OCP\EventDispatcher\Event;
|
||||||
|
use OCP\EventDispatcher\IEventListener;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
class CalendarObjectMovedListener implements IEventListener {
|
||||||
|
|
||||||
|
/** @var LoggerInterface */
|
||||||
|
private $logger;
|
||||||
|
|
||||||
|
/** @var GestionService */
|
||||||
|
private $gestionService;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
LoggerInterface $logger,GestionService $gestionService) {
|
||||||
|
$this->logger = $logger;
|
||||||
|
$this->gestionService = $gestionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(Event $event): void {
|
||||||
|
if (!($event instanceof CalendarObjectMovedEvent)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$calendarData = $event->getObjectData();
|
||||||
|
$targetCalendarId = $event->getTargetCalendarId();
|
||||||
|
$vCalendarString = $calendarData["calendardata"];
|
||||||
|
$this->gestionService->HandleCalendarObjectMoved($vCalendarString,$targetCalendarId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -221,6 +221,27 @@ class GestionService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function HandleCalendarObjectMoved(string $vCalendarString,$targetCalendarId){
|
||||||
|
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
|
||||||
|
$isCalendarForLeave = $this->GetIsLeaveFromVCalendarString($vCalendarString);
|
||||||
|
$isCalendarDevis = $isCalendarForLeave == false;
|
||||||
|
if($isCalendarDevis){
|
||||||
|
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
|
||||||
|
if($devis != null){
|
||||||
|
$userPrincipalName = $this->gestionBdd->getCalendarPrincipalNameByCalendarId($targetCalendarId);
|
||||||
|
if($userPrincipalName != null){
|
||||||
|
$thanatoId = $this->gestionBdd->getThanatoIdByUserUuid($userPrincipalName);
|
||||||
|
if($thanatoId != null){
|
||||||
|
$thanatoHasBeenChanged = $thanatoId != $devis["id_thanato"];
|
||||||
|
if($thanatoHasBeenChanged){
|
||||||
|
$this->gestionBdd->updateDevisThanato($devis['id'],$thanatoId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function HandleCreatedCalendarObject(string $vCalendarString){
|
public function HandleCreatedCalendarObject(string $vCalendarString){
|
||||||
$isCalendarForLeave = $this->GetIsLeaveFromVCalendarString($vCalendarString);
|
$isCalendarForLeave = $this->GetIsLeaveFromVCalendarString($vCalendarString);
|
||||||
if($isCalendarForLeave){
|
if($isCalendarForLeave){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user