mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°8796 - Add PHP code style validation in iTop and extensions - format whole code base
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Core\Authentication\Client\OAuth;
|
||||
|
||||
interface IOAuthClientProvider{
|
||||
}
|
||||
interface IOAuthClientProvider
|
||||
{
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use OAuthClient;
|
||||
abstract class OAuthClientProviderAbstract implements IOAuthClientProvider
|
||||
{
|
||||
/** @var string */
|
||||
static protected $sVendorName = '';
|
||||
protected static $sVendorName = '';
|
||||
|
||||
/** @var \League\OAuth2\Client\Provider\GenericProvider */
|
||||
protected $oVendorProvider;
|
||||
@@ -70,4 +70,4 @@ abstract class OAuthClientProviderAbstract implements IOAuthClientProvider
|
||||
return self::$sVendorName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use TheNetworg\OAuth2\Client\Provider\Azure;
|
||||
class OAuthClientProviderAzure extends OAuthClientProviderAbstract
|
||||
{
|
||||
/** @var string */
|
||||
static protected $sVendorName = 'Azure';
|
||||
protected static $sVendorName = 'Azure';
|
||||
|
||||
public function __construct($oOAuthClient, array $collaborators = [])
|
||||
{
|
||||
@@ -20,7 +20,7 @@ class OAuthClientProviderAzure extends OAuthClientProviderAbstract
|
||||
'clientId' => $oOAuthClient->Get('client_id'),
|
||||
'clientSecret' => $oOAuthClient->Get('client_secret'),
|
||||
'redirectUri' => $oOAuthClient->Get('redirect_url'),
|
||||
'tenant' => $oOAuthClient->Get('tenant'),
|
||||
'tenant' => $oOAuthClient->Get('tenant'),
|
||||
];
|
||||
|
||||
$this->oVendorProvider = new Azure($aOptions, $collaborators);
|
||||
|
||||
@@ -125,4 +125,4 @@ class OAuthClientProviderFactory
|
||||
return new $sProviderClass($oOAuthClient, $aCollaborators);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use League\OAuth2\Client\Provider\Google;
|
||||
class OAuthClientProviderGoogle extends OAuthClientProviderAbstract
|
||||
{
|
||||
/** @var string */
|
||||
static protected $sVendorName = 'Google';
|
||||
protected static $sVendorName = 'Google';
|
||||
|
||||
public function __construct($oOAuthClient, array $collaborators = [])
|
||||
{
|
||||
@@ -24,4 +24,4 @@ class OAuthClientProviderGoogle extends OAuthClientProviderAbstract
|
||||
$this->oVendorProvider = new Google($aOptions, $collaborators);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -6,7 +7,6 @@
|
||||
|
||||
namespace Combodo\iTop\Core\CMDBChange;
|
||||
|
||||
|
||||
/**
|
||||
* Class CMDBChangeOrigin
|
||||
*
|
||||
@@ -34,4 +34,4 @@ class CMDBChangeOrigin
|
||||
public const WEBSERVICE_SOAP = 'webservice-soap';
|
||||
/** @var string Made through an extension */
|
||||
public const CUSTOM_EXTENSION = 'custom-extension';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ class EmailFactory
|
||||
{
|
||||
return EMailSymfony::GetMailer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Send an email (abstraction for synchronous/asynchronous modes)
|
||||
*
|
||||
@@ -38,9 +39,9 @@ use Symfony\Component\Mime\Part\TextPart;
|
||||
class EMailSymfony extends Email
|
||||
{
|
||||
// Serialization formats
|
||||
const ORIGINAL_FORMAT = 1; // Original format, consisting in serializing the whole object, inculding the Swift Mailer's object.
|
||||
public const ORIGINAL_FORMAT = 1; // Original format, consisting in serializing the whole object, inculding the Swift Mailer's object.
|
||||
// Did not work with attachements since their binary representation cannot be stored as a valid UTF-8 string
|
||||
const FORMAT_V2 = 2; // New format, only the raw data are serialized (base64 encoded if needed)
|
||||
public const FORMAT_V2 = 2; // New format, only the raw data are serialized (base64 encoded if needed)
|
||||
|
||||
protected $m_aData; // For storing data to serialize
|
||||
|
||||
@@ -52,7 +53,7 @@ class EMailSymfony extends Email
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->m_aData = array();
|
||||
$this->m_aData = [];
|
||||
$this->m_oMessage = new SymfonyEmail();
|
||||
|
||||
$this->InitRecipientFrom();
|
||||
@@ -129,12 +130,11 @@ class EMailSymfony extends Email
|
||||
{
|
||||
try {
|
||||
AsyncSendEmail::AddToQueue($this, $oLog);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$aIssues = array($e->GetMessage());
|
||||
} catch (Exception $e) {
|
||||
$aIssues = [$e->GetMessage()];
|
||||
return EMAIL_SEND_ERROR;
|
||||
}
|
||||
$aIssues = array();
|
||||
$aIssues = [];
|
||||
return EMAIL_SEND_PENDING;
|
||||
}
|
||||
|
||||
@@ -165,11 +165,10 @@ class EMailSymfony extends Email
|
||||
$sPassword = self::$m_oConfig->Get('email_transport_smtp.password');
|
||||
$bVerifyPeer = static::$m_oConfig->Get('email_transport_smtp.verify_peer');
|
||||
|
||||
|
||||
// Build the DSN string
|
||||
$sDsnUser = $sUserName !== null ? rawurlencode($sUserName) : '';
|
||||
$sDsnPassword = ($sPassword !== null && $sPassword !== '') ? ':' . rawurlencode($sPassword) : '';
|
||||
$sDsnPort = $sHost . (strlen($sPort) ? ':' . $sPort : '');
|
||||
$sDsnPassword = ($sPassword !== null && $sPassword !== '') ? ':'.rawurlencode($sPassword) : '';
|
||||
$sDsnPort = $sHost.(strlen($sPort) ? ':'.$sPort : '');
|
||||
$sDsn = null;
|
||||
|
||||
if (strtolower($sEncryption) === 'ssl') {
|
||||
@@ -188,7 +187,7 @@ class EMailSymfony extends Email
|
||||
|
||||
// Handle peer verification
|
||||
$oStream = $oTransport->getStream();
|
||||
$aOptions= $oStream->getStreamOptions();
|
||||
$aOptions = $oStream->getStreamOptions();
|
||||
if (!$bVerifyPeer && array_key_exists('ssl', $aOptions)) {
|
||||
// Disable verification
|
||||
$aOptions['ssl']['verify_peer'] = false;
|
||||
@@ -226,7 +225,7 @@ class EMailSymfony extends Email
|
||||
case 'LogFile':
|
||||
// Use a custom transport that writes to a log file
|
||||
// Note: the log file is not rotated, so this should be used for debugging
|
||||
$oTransport = new SymfonyFileTransport(APPROOT . 'log/', 'mail.log');
|
||||
$oTransport = new SymfonyFileTransport(APPROOT.'log/', 'mail.log');
|
||||
$oMailer = new Mailer($oTransport);
|
||||
break;
|
||||
|
||||
@@ -245,19 +244,17 @@ class EMailSymfony extends Email
|
||||
}
|
||||
|
||||
$oMailer->send($this->m_oMessage);
|
||||
$aIssues = array();
|
||||
$aIssues = [];
|
||||
$oKPI->ComputeStats('Email Sent', 'Succeded');
|
||||
|
||||
return EMAIL_SEND_OK;
|
||||
}
|
||||
catch (TransportExceptionInterface $e) {
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
IssueLog::Warning('Email sending failed: '.$e->getMessage());
|
||||
$aIssues = array($e->getMessage());
|
||||
$aIssues = [$e->getMessage()];
|
||||
$oKPI->ComputeStats('Email Sent', 'Error received');
|
||||
|
||||
return EMAIL_SEND_ERROR;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$oKPI->ComputeStats('Email Sent', 'Error received');
|
||||
throw $e;
|
||||
}
|
||||
@@ -325,10 +322,10 @@ class EMailSymfony extends Email
|
||||
$this->SetRecipientFrom($this->m_aData['to']);
|
||||
}
|
||||
|
||||
if($iSyncAsync === true) {
|
||||
if ($iSyncAsync === true) {
|
||||
return $this->SendSynchronous($aIssues, $oLog);
|
||||
} else {
|
||||
switch($iSyncAsync) {
|
||||
switch ($iSyncAsync) {
|
||||
case Email::ENUM_SEND_FORCE_SYNCHRONOUS:
|
||||
return $this->SendSynchronous($aIssues, $oLog);
|
||||
case Email::ENUM_SEND_FORCE_ASYNCHRONOUS:
|
||||
@@ -337,7 +334,7 @@ class EMailSymfony extends Email
|
||||
default:
|
||||
$oConfig = $this->LoadConfig();
|
||||
$bConfigASYNC = $oConfig->Get('email_asynchronous');
|
||||
if($bConfigASYNC) {
|
||||
if ($bConfigASYNC) {
|
||||
return $this->SendAsynchronous($aIssues, $oLog);
|
||||
} else {
|
||||
return $this->SendSynchronous($aIssues, $oLog);
|
||||
@@ -352,7 +349,7 @@ class EMailSymfony extends Email
|
||||
public function AddToHeader($sKey, $sValue)
|
||||
{
|
||||
if (!array_key_exists('headers', $this->m_aData)) {
|
||||
$this->m_aData['headers'] = array();
|
||||
$this->m_aData['headers'] = [];
|
||||
}
|
||||
$this->m_aData['headers'][$sKey] = $sValue;
|
||||
|
||||
@@ -367,7 +364,7 @@ class EMailSymfony extends Email
|
||||
|
||||
// Note: The email library will add the angle brackets for you
|
||||
// so let's remove the angle brackets if present, for historical reasons
|
||||
$sId = str_replace(array('<', '>'), '', $sId);
|
||||
$sId = str_replace(['<', '>'], '', $sId);
|
||||
|
||||
$this->m_oMessage->getHeaders()->addIdHeader('Message-ID', $sId);
|
||||
}
|
||||
@@ -381,10 +378,10 @@ class EMailSymfony extends Email
|
||||
{
|
||||
// Note: Symfony will add the angle brackets
|
||||
// let's remove the angle brackets if present, for historical reasons
|
||||
$sId = str_replace(array('<', '>'), '', $sMessageId);
|
||||
$this->m_aData['in_reply_to'] = '<' . $sId . '>';
|
||||
$sId = str_replace(['<', '>'], '', $sMessageId);
|
||||
$this->m_aData['in_reply_to'] = '<'.$sId.'>';
|
||||
|
||||
$this->m_oMessage->getHeaders()->addTextHeader('In-Reply-To', '<' . $sId . '>');
|
||||
$this->m_oMessage->getHeaders()->addTextHeader('In-Reply-To', '<'.$sId.'>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,7 +394,7 @@ class EMailSymfony extends Email
|
||||
$sBody = static::InlineCssIntoBodyContent($sBody, $sCustomStyles);
|
||||
}
|
||||
|
||||
$this->m_aData['body'] = array('body' => $sBody, 'mimeType' => $sMimeType);
|
||||
$this->m_aData['body'] = ['body' => $sBody, 'mimeType' => $sMimeType];
|
||||
|
||||
$oTextPart = new TextPart(strip_tags($sBody), 'utf-8', 'plain', 'base64');
|
||||
|
||||
@@ -409,12 +406,11 @@ class EMailSymfony extends Email
|
||||
// Default root part is the HTML body
|
||||
$oRootPart = $oAlternativePart;
|
||||
|
||||
if(count($aAdditionalParts) > 0) {
|
||||
if (count($aAdditionalParts) > 0) {
|
||||
$aRelatedParts = array_merge([$oAlternativePart], $aAdditionalParts);
|
||||
$oRootPart = new RelatedPart(...$aRelatedParts);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Default root part is the text body
|
||||
$oRootPart = $oTextPart;
|
||||
}
|
||||
@@ -442,9 +438,9 @@ class EMailSymfony extends Email
|
||||
$sMimeSubtype = $this->GetMimeSubtype($sMimeType);
|
||||
|
||||
if (!array_key_exists('parts', $this->m_aData)) {
|
||||
$this->m_aData['parts'] = array();
|
||||
$this->m_aData['parts'] = [];
|
||||
}
|
||||
$this->m_aData['parts'][] = array('text' => $sText, 'mimeType' => $sMimeType);
|
||||
$this->m_aData['parts'][] = ['text' => $sText, 'mimeType' => $sMimeType];
|
||||
|
||||
$oNewPart = new TextPart($sText, $sMimeType, $sMimeSubtype, 'base64');
|
||||
$this->m_oMessage->addPart($oNewPart);
|
||||
@@ -453,20 +449,19 @@ class EMailSymfony extends Email
|
||||
public function AddAttachment($data, $sFileName, $sMimeType)
|
||||
{
|
||||
if (!array_key_exists('attachments', $this->m_aData)) {
|
||||
$this->m_aData['attachments'] = array();
|
||||
$this->m_aData['attachments'] = [];
|
||||
}
|
||||
$this->m_aData['attachments'][] = array('data' => base64_encode($data), 'filename' => $sFileName, 'mimeType' => $sMimeType);
|
||||
$this->m_aData['attachments'][] = ['data' => base64_encode($data), 'filename' => $sFileName, 'mimeType' => $sMimeType];
|
||||
|
||||
$oBody = $this->m_oMessage->getBody();
|
||||
|
||||
$oRootPart = $oBody;
|
||||
$aAttachmentPart = new DataPart($data, $sFileName, $sMimeType, 'base64');
|
||||
if( $oBody instanceof MixedPart) {
|
||||
if ($oBody instanceof MixedPart) {
|
||||
$aCurrentParts = $oBody->getParts();
|
||||
$aCurrentParts[] = $aAttachmentPart;
|
||||
$oRootPart = new MixedPart(...$aCurrentParts);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$oRootPart = new MixedPart($oBody, $aAttachmentPart);
|
||||
}
|
||||
|
||||
@@ -489,7 +484,7 @@ class EMailSymfony extends Email
|
||||
*/
|
||||
protected function AddressStringToArray($sAddressCSVList)
|
||||
{
|
||||
$aAddresses = array();
|
||||
$aAddresses = [];
|
||||
foreach (explode(',', $sAddressCSVList) as $sAddress) {
|
||||
$sAddress = trim($sAddress);
|
||||
if (strlen($sAddress) > 0) {
|
||||
@@ -513,14 +508,14 @@ class EMailSymfony extends Email
|
||||
$aRes = $this->m_oMessage->getTo();
|
||||
|
||||
if ($bAsString) {
|
||||
$aStrings = array();
|
||||
$aStrings = [];
|
||||
foreach ($aRes as $oEmail) {
|
||||
$sName = $oEmail->getName();
|
||||
$sEmail = $oEmail->getAddress();
|
||||
if (empty($sName)) {
|
||||
$aStrings[] = $sEmail;
|
||||
} else {
|
||||
$sName = str_replace(array('<', '>'), '', $sName);
|
||||
$sName = str_replace(['<', '>'], '', $sName);
|
||||
$aStrings[] = "$sName <$sEmail>";
|
||||
}
|
||||
}
|
||||
@@ -550,20 +545,20 @@ class EMailSymfony extends Email
|
||||
|
||||
public function SetRecipientFrom($sAddress, $sLabel = '')
|
||||
{
|
||||
$this->m_aData['from'] = array('address' => $sAddress, 'label' => $sLabel);
|
||||
$this->m_aData['from'] = ['address' => $sAddress, 'label' => $sLabel];
|
||||
if ($sLabel != '') {
|
||||
$this->m_oMessage->from(sprintf('%s <%s>', $sLabel, $sAddress));
|
||||
} else if (!empty($sAddress)) {
|
||||
} elseif (!empty($sAddress)) {
|
||||
$this->m_oMessage->from($sAddress);
|
||||
}
|
||||
}
|
||||
|
||||
public function SetRecipientReplyTo($sAddress, $sLabel = '')
|
||||
{
|
||||
$this->m_aData['reply_to'] = array('address' => $sAddress, 'label' => $sLabel);
|
||||
$this->m_aData['reply_to'] = ['address' => $sAddress, 'label' => $sLabel];
|
||||
if ($sLabel != '') {
|
||||
$this->m_oMessage->replyTo(sprintf('%s <%s>', $sLabel, $sAddress));
|
||||
} else if (!empty($sAddress)) {
|
||||
} elseif (!empty($sAddress)) {
|
||||
$this->m_oMessage->replyTo($sAddress);
|
||||
}
|
||||
}
|
||||
@@ -588,4 +583,4 @@ class EMailSymfony extends Email
|
||||
|
||||
return $sBody;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class SymfonyFileTransport extends AbstractTransport
|
||||
public function __construct(?string $sLogDir = null, string $sFilename = 'mail.log', ?EventDispatcherInterface $oDispatcher = null, ?LoggerInterface $oLogger = null)
|
||||
{
|
||||
parent::__construct($oDispatcher, $oLogger);
|
||||
$this->sDir = rtrim($sLogDir ?? APPROOT . 'log/', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
$this->sDir = rtrim($sLogDir ?? APPROOT.'log/', DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
||||
$this->sFilename = $sFilename;
|
||||
}
|
||||
|
||||
@@ -60,4 +60,3 @@ class SymfonyFileTransport extends AbstractTransport
|
||||
return 'logfile';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ class SymfonyOAuthTransport extends EsmtpTransport
|
||||
{
|
||||
/** @var OAuthClientProviderAbstract|null */
|
||||
protected static $oProvider = null;
|
||||
const LOG_CHANNEL = 'OAuth';
|
||||
|
||||
public const LOG_CHANNEL = 'OAuth';
|
||||
|
||||
public function __construct($aConfig = [], ?LoggerInterface $oLogger = null)
|
||||
{
|
||||
@@ -90,16 +89,14 @@ class SymfonyOAuthTransport extends EsmtpTransport
|
||||
|
||||
try {
|
||||
$oAccessToken = $oProvider->GetAccessToken();
|
||||
}
|
||||
catch (\Throwable $e) {
|
||||
} catch (\Throwable $e) {
|
||||
IssueLog::Error('Failed to get OAuth provider access token: '.$e->getMessage(), 'OAuth');
|
||||
throw new TransportException('Failed to obtain OAuth access token for SMTP', 0, $e);
|
||||
}
|
||||
|
||||
if ($oAccessToken === null) {
|
||||
throw new IdentityProviderException('Not prior authentication to OAuth', 255, []);
|
||||
}
|
||||
elseif ($oAccessToken->hasExpired()) {
|
||||
} elseif ($oAccessToken->hasExpired()) {
|
||||
self::$oProvider->SetAccessToken(self::$oProvider->GetVendorProvider()->getAccessToken('refresh_token', [
|
||||
'refresh_token' => $oAccessToken->getRefreshToken(),
|
||||
'scope' => self::$oProvider->GetScope(),
|
||||
@@ -124,8 +121,7 @@ class SymfonyOAuthTransport extends EsmtpTransport
|
||||
// Ensure a fresh token is available and set as SMTP password
|
||||
try {
|
||||
$this->ensureOAuthTokenIsReady();
|
||||
}
|
||||
catch (IdentityProviderException $e) {
|
||||
} catch (IdentityProviderException $e) {
|
||||
IssueLog::Error('Failed to get SMTP oAuth credentials for incoming mails for provider '.self::$oProvider::GetVendorName(), static::LOG_CHANNEL, [
|
||||
'exception.message' => $e->getMessage(),
|
||||
'exception.stack' => $e->getTraceAsString(),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Core\Email\Transport;
|
||||
|
||||
use Symfony\Component\Mailer\SentMessage;
|
||||
@@ -33,7 +34,6 @@ class SymfonyPHPMailTransport extends AbstractTransport
|
||||
return $oHeaders->get('Subject')->getBodyAsString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Email $oRawEmail
|
||||
*
|
||||
@@ -56,13 +56,13 @@ class SymfonyPHPMailTransport extends AbstractTransport
|
||||
$sHeaders = '';
|
||||
foreach ($oHeaders->all() as $header) {
|
||||
if (strtolower($header->getName()) !== 'to' && strtolower($header->getName()) !== 'subject') {
|
||||
$sHeaders .= $header->toString() . "\r\n";
|
||||
$sHeaders .= $header->toString()."\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
$oBodyHeader = $oRawEmail->getBody()->getPreparedHeaders();
|
||||
foreach ($oBodyHeader->all() as $header) {
|
||||
$sHeaders .= $header->toString() . "\r\n";
|
||||
$sHeaders .= $header->toString()."\r\n";
|
||||
}
|
||||
|
||||
// Remove trailing line break
|
||||
@@ -85,7 +85,6 @@ class SymfonyPHPMailTransport extends AbstractTransport
|
||||
|
||||
$success = mail($sTo, $sSubject, $sBody, $sHeaders);
|
||||
|
||||
|
||||
if (!$success) {
|
||||
throw new \RuntimeException('The mail() function failed to send the message. Check server mail configuration.');
|
||||
}
|
||||
@@ -95,4 +94,4 @@ class SymfonyPHPMailTransport extends AbstractTransport
|
||||
{
|
||||
return 'phpmail://default';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ interface iEMail
|
||||
* @throws \CoreException
|
||||
* @throws \Symfony\Component\CssSelector\Exception\SyntaxErrorException
|
||||
*/
|
||||
static public function UnSerializeV2($sSerializedMessage);
|
||||
public static function UnSerializeV2($sSerializedMessage);
|
||||
|
||||
public function Send(&$aIssues, $bForceSynchronous = false, $oLog = null);
|
||||
|
||||
@@ -48,4 +48,4 @@ interface iEMail
|
||||
|
||||
public function SetRecipientReplyTo($sAddress, $sLabel = '');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -60,7 +61,7 @@ class AttributeBlobEventListener implements iEventServiceSetup
|
||||
$oDocument = $oEventData->Get('document');
|
||||
|
||||
$sTriggerClass = TriggerOnAttributeBlobDownload::class;
|
||||
$aTriggerContextArgs = array(
|
||||
$aTriggerContextArgs = [
|
||||
'this->object()' => $oObject,
|
||||
'attribute_code' => $sAttCode,
|
||||
'file->mime_type' => $oDocument->GetMimeType(),
|
||||
@@ -68,9 +69,9 @@ class AttributeBlobEventListener implements iEventServiceSetup
|
||||
'file->downloads_count' => $oDocument->GetDownloadsCount(),
|
||||
'file->data' => $oDocument->GetData(),
|
||||
'file->data_as_base64' => base64_encode($oDocument->GetData()),
|
||||
);
|
||||
$aTriggerParams = array('class_list' => MetaModel::EnumParentClasses(get_class($oObject), ENUM_PARENT_CLASSES_ALL));
|
||||
$oTriggerSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT $sTriggerClass AS t WHERE t.target_class IN (:class_list)"), array(), $aTriggerParams);
|
||||
];
|
||||
$aTriggerParams = ['class_list' => MetaModel::EnumParentClasses(get_class($oObject), ENUM_PARENT_CLASSES_ALL)];
|
||||
$oTriggerSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT $sTriggerClass AS t WHERE t.target_class IN (:class_list)"), [], $aTriggerParams);
|
||||
|
||||
/** @var \Trigger $oTrigger */
|
||||
while ($oTrigger = $oTriggerSet->Fetch()) {
|
||||
@@ -86,4 +87,4 @@ class AttributeBlobEventListener implements iEventServiceSetup
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -8,118 +9,118 @@ namespace Combodo\iTop\Core\Kpi;
|
||||
|
||||
class KpiLogData
|
||||
{
|
||||
const TYPE_REPORT = 'report';
|
||||
const TYPE_STATS = 'stats';
|
||||
const TYPE_REQUEST = 'request';
|
||||
public const TYPE_REPORT = 'report';
|
||||
public const TYPE_STATS = 'stats';
|
||||
public const TYPE_REQUEST = 'request';
|
||||
|
||||
/** @var string */
|
||||
public $sType;
|
||||
/** @var string */
|
||||
public $sOperation;
|
||||
/** @var string */
|
||||
public $sArguments;
|
||||
/** @var float */
|
||||
public $fStartTime;
|
||||
/** @var float */
|
||||
public $fStopTime;
|
||||
/** @var string */
|
||||
public $sExtension;
|
||||
/** @var int */
|
||||
public $iInitialMemory;
|
||||
/** @var int */
|
||||
public $iCurrentMemory;
|
||||
/** @var int */
|
||||
public $iPeakMemory;
|
||||
/** @var array */
|
||||
public $aData;
|
||||
/** @var string */
|
||||
public $sType;
|
||||
/** @var string */
|
||||
public $sOperation;
|
||||
/** @var string */
|
||||
public $sArguments;
|
||||
/** @var float */
|
||||
public $fStartTime;
|
||||
/** @var float */
|
||||
public $fStopTime;
|
||||
/** @var string */
|
||||
public $sExtension;
|
||||
/** @var int */
|
||||
public $iInitialMemory;
|
||||
/** @var int */
|
||||
public $iCurrentMemory;
|
||||
/** @var int */
|
||||
public $iPeakMemory;
|
||||
/** @var array */
|
||||
public $aData;
|
||||
|
||||
/**
|
||||
* @param string $sType
|
||||
* @param string $sOperation
|
||||
* @param string $sArguments
|
||||
* @param float $fStartTime
|
||||
* @param float $fStopTime
|
||||
* @param string $sExtension
|
||||
* @param int $iInitialMemory
|
||||
* @param int $iCurrentMemory
|
||||
* @param array $aData
|
||||
*/
|
||||
public function __construct($sType, $sOperation, $sArguments, $fStartTime, $fStopTime, $sExtension, $iInitialMemory = 0, $iCurrentMemory = 0, $iPeakMemory = 0, $aData = [])
|
||||
{
|
||||
$this->sType = $sType;
|
||||
$this->sOperation = $sOperation;
|
||||
$this->sArguments = @iconv(mb_detect_encoding($sArguments, mb_detect_order(), true), 'UTF-8', $sArguments);
|
||||
$this->fStartTime = $fStartTime;
|
||||
$this->fStopTime = $fStopTime;
|
||||
$this->sExtension = $sExtension;
|
||||
$this->iInitialMemory = $iInitialMemory;
|
||||
$this->iCurrentMemory = $iCurrentMemory;
|
||||
$this->iPeakMemory = $iPeakMemory;
|
||||
$this->aData = $aData;
|
||||
}
|
||||
/**
|
||||
* @param string $sType
|
||||
* @param string $sOperation
|
||||
* @param string $sArguments
|
||||
* @param float $fStartTime
|
||||
* @param float $fStopTime
|
||||
* @param string $sExtension
|
||||
* @param int $iInitialMemory
|
||||
* @param int $iCurrentMemory
|
||||
* @param array $aData
|
||||
*/
|
||||
public function __construct($sType, $sOperation, $sArguments, $fStartTime, $fStopTime, $sExtension, $iInitialMemory = 0, $iCurrentMemory = 0, $iPeakMemory = 0, $aData = [])
|
||||
{
|
||||
$this->sType = $sType;
|
||||
$this->sOperation = $sOperation;
|
||||
$this->sArguments = @iconv(mb_detect_encoding($sArguments, mb_detect_order(), true), 'UTF-8', $sArguments);
|
||||
$this->fStartTime = $fStartTime;
|
||||
$this->fStopTime = $fStopTime;
|
||||
$this->sExtension = $sExtension;
|
||||
$this->iInitialMemory = $iInitialMemory;
|
||||
$this->iCurrentMemory = $iCurrentMemory;
|
||||
$this->iPeakMemory = $iPeakMemory;
|
||||
$this->aData = $aData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the CSV Header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function GetCSVHeader()
|
||||
{
|
||||
return "Type,Operation,Arguments,StartTime,StopTime,Duration,Extension,InitialMemory,CurrentMemory,PeakMemory";
|
||||
}
|
||||
/**
|
||||
* Return the CSV Header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function GetCSVHeader()
|
||||
{
|
||||
return "Type,Operation,Arguments,StartTime,StopTime,Duration,Extension,InitialMemory,CurrentMemory,PeakMemory";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the CSV line for the values
|
||||
* @return string
|
||||
*/
|
||||
public function GetCSV()
|
||||
{
|
||||
$fDuration = sprintf('%01.4f', $this->fStopTime - $this->fStartTime);
|
||||
$sType = $this->RemoveQuotes($this->sType);
|
||||
$sOperation = $this->RemoveQuotes($this->sOperation);
|
||||
$sArguments = $this->RemoveQuotes($this->sArguments);
|
||||
$sExtension = $this->RemoveQuotes($this->sExtension);
|
||||
return "\"$sType\",\"$sOperation\",\"$sArguments\",$this->fStartTime,$this->fStopTime,$fDuration,\"$sExtension\",$this->iInitialMemory,$this->iCurrentMemory,$this->iPeakMemory";
|
||||
}
|
||||
/**
|
||||
* Return the CSV line for the values
|
||||
* @return string
|
||||
*/
|
||||
public function GetCSV()
|
||||
{
|
||||
$fDuration = sprintf('%01.4f', $this->fStopTime - $this->fStartTime);
|
||||
$sType = $this->RemoveQuotes($this->sType);
|
||||
$sOperation = $this->RemoveQuotes($this->sOperation);
|
||||
$sArguments = $this->RemoveQuotes($this->sArguments);
|
||||
$sExtension = $this->RemoveQuotes($this->sExtension);
|
||||
return "\"$sType\",\"$sOperation\",\"$sArguments\",$this->fStartTime,$this->fStopTime,$fDuration,\"$sExtension\",$this->iInitialMemory,$this->iCurrentMemory,$this->iPeakMemory";
|
||||
}
|
||||
|
||||
private function RemoveQuotes(string $sEntry): string
|
||||
{
|
||||
return str_replace('"', "'", $sEntry);
|
||||
}
|
||||
private function RemoveQuotes(string $sEntry): string
|
||||
{
|
||||
return str_replace('"', "'", $sEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Combodo\iTop\Core\Kpi\KpiLogData $oOther
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function Compare(KpiLogData $oOther): float
|
||||
{
|
||||
if ($oOther->fStartTime > $this->fStartTime) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/**
|
||||
* @param \Combodo\iTop\Core\Kpi\KpiLogData $oOther
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function Compare(KpiLogData $oOther): float
|
||||
{
|
||||
if ($oOther->fStartTime > $this->fStartTime) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function Contains(KpiLogData $oOther): bool
|
||||
{
|
||||
if ($oOther->fStartTime < $this->fStartTime) {
|
||||
return false;
|
||||
}
|
||||
public function Contains(KpiLogData $oOther): bool
|
||||
{
|
||||
if ($oOther->fStartTime < $this->fStartTime) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($oOther->fStartTime > $this->fStopTime) {
|
||||
return false;
|
||||
}
|
||||
if ($oOther->fStartTime > $this->fStopTime) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return "$this->sType:$this->sOperation:$this->sArguments";
|
||||
}
|
||||
public function __toString()
|
||||
{
|
||||
return "$this->sType:$this->sOperation:$this->sArguments";
|
||||
}
|
||||
|
||||
public function GetUUID(): string
|
||||
{
|
||||
return sha1($this->__toString());
|
||||
}
|
||||
}
|
||||
public function GetUUID(): string
|
||||
{
|
||||
return sha1($this->__toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -6,7 +7,6 @@
|
||||
|
||||
namespace Combodo\iTop\Core\MetaModel;
|
||||
|
||||
|
||||
/**
|
||||
* Class FriendlyNameType
|
||||
*
|
||||
@@ -23,4 +23,4 @@ class FriendlyNameType
|
||||
public const COMPLEMENTARY = 'compl';
|
||||
/** @var string long friendly name made whith short + complementary data*/
|
||||
public const LONG = 'long';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -17,8 +18,8 @@ use MetaModel;
|
||||
* @package Combodo\iTop\Core\MetaModel
|
||||
* @since 3.0.0 N°2527
|
||||
*/
|
||||
class HierarchicalKey {
|
||||
|
||||
class HierarchicalKey
|
||||
{
|
||||
/**
|
||||
* Verify that an HK control information is correct
|
||||
* @param $sClass
|
||||
@@ -126,4 +127,4 @@ class HierarchicalKey {
|
||||
return [$aControlByParent, $aControlById];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace Combodo\iTop\Core\Trigger\Enum;
|
||||
* @package Combodo\iTop\Core\Trigger\Enum
|
||||
* @since 3.2.0
|
||||
*/
|
||||
enum SubscriptionPolicy: string {
|
||||
enum SubscriptionPolicy: string
|
||||
{
|
||||
case AllowNoChannel = "allow_no_channel";
|
||||
case ForceAtLeastOneChannel = "force_at_least_one_channel";
|
||||
case ForceAllChannels = "force_all_channels";
|
||||
|
||||
Reference in New Issue
Block a user