Merge branch 'support/3.2' into develop

This commit is contained in:
odain
2025-11-07 20:33:14 +01:00
1837 changed files with 33034 additions and 34549 deletions

View File

@@ -1,6 +1,6 @@
<?php
namespace Combodo\iTop\Service\Notification\Event;
namespace Combodo\iTop\Service\Notification\Event;
use DBObjectSearch;
use DBObjectSet;
@@ -17,11 +17,10 @@ class EventNotificationNewsroomGC implements iBackgroundProcess
$iDeletionTime = (int) MetaModel::GetConfig()->Get('notifications.itop.read_notification_retention');
$oDBObjectSearch = DBObjectSearch::FromOQL("SELECT EventNotificationNewsroom WHERE read='yes' AND read_date < DATE_SUB(NOW(), INTERVAL :deletion_time DAY)", ['deletion_time' => $iDeletionTime]);
$oEventNotificationNewsroomSet = new DBObjectSet($oDBObjectSearch);
while($oEventNotificationNewsroom = $oEventNotificationNewsroomSet->Fetch()){
while ($oEventNotificationNewsroom = $oEventNotificationNewsroomSet->Fetch()) {
$oEventNotificationNewsroom->DBDelete();
}
}
catch (Exception $e) {
} catch (Exception $e) {
ExceptionLog::LogException($e);
return false;
}
@@ -30,6 +29,6 @@ class EventNotificationNewsroomGC implements iBackgroundProcess
public function GetPeriodicity()
{
return 24*3600; // Every day
return 24 * 3600; // Every day
}
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace Combodo\iTop\Service\Notification\Event;
namespace Combodo\iTop\Service\Notification\Event;
use Action;
use Combodo\iTop\Application\Branding;
@@ -17,7 +17,8 @@ use utils;
* @since 3.2.0
* @api
*/
class EventNotificationNewsroomService {
class EventNotificationNewsroomService
{
/**
* @param \Action $oAction
* @param int $iContactId
@@ -36,7 +37,7 @@ class EventNotificationNewsroomService {
*/
public static function MakeEventFromAction(Action $oAction, int $iContactId, int $iTriggerId, string $sMessage, string $sTitle, string $sUrl, int $iObjectId, ?string $sObjectClass, string|null $sDate = null): EventNotificationNewsroom
{
$oEvent = new EventNotificationNewsroom();
$oEvent->Set('title', $sTitle);
$oEvent->Set('message', $sMessage);
@@ -67,7 +68,7 @@ class EventNotificationNewsroomService {
} else {
$oEvent->SetCurrentDate('date');
}
return $oEvent;
}
}

View File

@@ -142,7 +142,7 @@ class NotificationsRepository
{
$oSearch = DBObjectSearch::FromOQL("SELECT lnkActionNotificationToContact AS lnk WHERE lnk.contact_id = :contact_id");
$oSearch->SetInternalParams([
"contact_id" => $iContactId
"contact_id" => $iContactId,
]);
return new DBObjectSet($oSearch);
@@ -232,7 +232,8 @@ class NotificationsRepository
public function SearchSubscriptionsByTriggerContactAndSubscription(int $iTriggerId, int $iContactId, string $sSubscription): DBObjectSet
{
$oSearch = DBObjectSearch::FromOQL("SELECT lnkActionNotificationToContact AS lnk WHERE lnk.contact_id = :contact_id AND lnk.trigger_id = :trigger_id AND lnk.subscribed = :subscription");
$oSearch->SetInternalParams([
$oSearch->SetInternalParams(
[
"trigger_id" => $iTriggerId,
"contact_id" => $iContactId,
"subscription" => $sSubscription]
@@ -241,7 +242,6 @@ class NotificationsRepository
return new DBObjectSet($oSearch);
}
/**
* Search for subscriptions based on trigger, contact, subscription type, and final class.
*
@@ -259,7 +259,7 @@ class NotificationsRepository
"trigger_id" => $iTriggerId,
"contact_id" => $iContactId,
"subscription" => $sSubscription,
"finalclass" => $sFinalclass
"finalclass" => $sFinalclass,
]);
return new DBObjectSet($oSearch);
@@ -270,4 +270,4 @@ class NotificationsRepository
$oSearch = DBObjectSearch::FromOQL("SELECT Contact AS c JOIN lnkActionNotificationToContact AS lnk ON lnk.contact_id = c.id WHERE lnk.trigger_id = :trigger_id AND lnk.action_id = :action_id AND lnk.subscribed = '0'");
return $oSearch;
}
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace Combodo\iTop\Service\Notification;
namespace Combodo\iTop\Service\Notification;
use ActionNotification;
use Combodo\iTop\Core\Trigger\Enum\SubscriptionPolicy;
@@ -15,7 +15,8 @@ use Trigger;
* @package Combodo\iTop\Service\Notification
* @since 3.2.0
*/
class NotificationsService {
class NotificationsService
{
protected static ?NotificationsService $oSingleton = null;
/**
@@ -40,7 +41,8 @@ class NotificationsService {
*
* @return void
*/
protected function __construct() {
protected function __construct()
{
// Don't do anything, we don't want to be initialized
}
@@ -74,8 +76,7 @@ class NotificationsService {
$oSubscribedActionsNotifications->Set('trigger_id', $oTrigger->GetKey());
$oSubscribedActionsNotifications->Set('subscribed', true);
$oSubscribedActionsNotifications->DBInsertNoReload();
}
else {
} else {
while ($oSubscribedActionsNotifications = $oSubscribedActionsNotificationsSet->Fetch()) {
// Update the subscription
$oSubscribedActionsNotifications->Set('subscribed', true);
@@ -114,4 +115,4 @@ class NotificationsService {
return $oSubscribedActionsNotifications->Get('subscribed');
}
}
}