mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 15:34:12 +01:00
* N°2039 - Add iTop notifications to newsroom * Update sources/Controller/Newsroom/iTopNewsroomController.php Co-authored-by: Molkobain <lajarige.guillaume@free.fr> * Update sources/Controller/Newsroom/iTopNewsroomController.php Co-authored-by: Molkobain <lajarige.guillaume@free.fr> * Update sources/Service/Notification/Event/EventiTopNotificationGC.php Co-authored-by: Molkobain <lajarige.guillaume@free.fr> * Add a default value to Action url attribute, check if there's an object in the context before adding it to the event * Phpdoc * Fix default config values * Replace MetaModel::EnumPlugins calls for iNewsroomProvider * Replace hardcoded url with generated routes * Add dict entries * Correclty throw error when trying to display a non existing event * Fix unit test * Migrate old action email language values to its parent table * Migrate Action and Event class to XML, generate their dictionary entries, add meta data for ActionNotification and EventNotification * Fix issue in dictionary definition * Allows Action to create Events for users that the current user can't see * Dump autoloader * Remove classes from homemade "autoloader" as they are now loaded through XML * Apply suggestions from code review * Remove class from homemade "autoloader" as they are now loaded through GetClassesForInterfaces * Apply suggestions from code review Co-authored-by: Molkobain <lajarige.guillaume@free.fr> --------- Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
36 lines
947 B
PHP
36 lines
947 B
PHP
<?php
|
|
|
|
namespace Combodo\iTop\Service\Notification\Event;
|
|
|
|
use DBObjectSearch;
|
|
use DBObjectSet;
|
|
use Exception;
|
|
use ExceptionLog;
|
|
use iBackgroundProcess;
|
|
use MetaModel;
|
|
|
|
class EventiTopNotificationGC implements iBackgroundProcess
|
|
{
|
|
|
|
public function Process($iUnixTimeLimit)
|
|
{
|
|
try {
|
|
$iDeletionTime = (int) MetaModel::GetConfig()->Get('notifications.itop.read_notification_retention');
|
|
$oDBObjectSearch = DBObjectSearch::FromOQL("SELECT EventiTopNotification WHERE read='yes' AND read_date < DATE_SUB(NOW(), INTERVAL :deletion_time DAY)", ['deletion_time' => $iDeletionTime]);
|
|
$oEventiTopNotificationSet = new DBObjectSet($oDBObjectSearch);
|
|
while($oEventiTopNotification = $oEventiTopNotificationSet->Fetch()){
|
|
$oEventiTopNotification->DBDelete();
|
|
}
|
|
}
|
|
catch (Exception $e) {
|
|
ExceptionLog::LogException($e);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function GetPeriodicity()
|
|
{
|
|
return 24*3600; // Every day
|
|
}
|
|
} |