mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 18:18:46 +02:00
Merge remote-tracking branch 'origin/support/3.1' into develop
This commit is contained in:
@@ -256,6 +256,38 @@ abstract class TriggerOnObject extends Trigger
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate trigger based on attribute list given instead of changed attributes
|
||||
*
|
||||
* @param array $aContextArgs
|
||||
* @param array|null $aAttributes if null default to changed attributes
|
||||
*
|
||||
* @throws \ArchivedObjectException
|
||||
* @throws \CoreException
|
||||
* @throws \MissingQueryArgument
|
||||
* @throws \MySQLException
|
||||
* @throws \MySQLHasGoneAwayException
|
||||
* @throws \OQLException
|
||||
* @since 3.1.1 3.2.0 N°6228
|
||||
*/
|
||||
public function DoActivateForSpecificAttributes(array $aContextArgs, ?array $aAttributes)
|
||||
{
|
||||
if (isset($aContextArgs['this->object()']))
|
||||
{
|
||||
/** @var \DBObject $oObject */
|
||||
$oObject = $aContextArgs['this->object()'];
|
||||
if (is_null($aAttributes)) {
|
||||
$aChanges = $oObject->ListPreviousValuesForUpdatedAttributes();
|
||||
} else {
|
||||
$aChanges = array_fill_keys($aAttributes, true);
|
||||
}
|
||||
if (false === $this->IsTargetObject($oObject->GetKey(), $aChanges)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
parent::DoActivate($aContextArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $iObjectId
|
||||
* @param array $aChanges
|
||||
@@ -546,38 +578,6 @@ class TriggerOnObjectUpdate extends TriggerOnObject
|
||||
MetaModel::Init_SetZListItems('standard_search', array('description', 'target_class')); // Criteria of the std search form
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate trigger based on attribute list given instead of changed attributes
|
||||
*
|
||||
* @param array $aContextArgs
|
||||
* @param array|null $aAttributes if null default to changed attributes
|
||||
*
|
||||
* @throws \ArchivedObjectException
|
||||
* @throws \CoreException
|
||||
* @throws \MissingQueryArgument
|
||||
* @throws \MySQLException
|
||||
* @throws \MySQLHasGoneAwayException
|
||||
* @throws \OQLException
|
||||
* @since 3.1.1 3.2.0 N°6228
|
||||
*/
|
||||
public function DoActivateForSpecificAttributes(array $aContextArgs, ?array $aAttributes)
|
||||
{
|
||||
if (isset($aContextArgs['this->object()']))
|
||||
{
|
||||
/** @var \DBObject $oObject */
|
||||
$oObject = $aContextArgs['this->object()'];
|
||||
if (is_null($aAttributes)) {
|
||||
$aChanges = $oObject->ListPreviousValuesForUpdatedAttributes();
|
||||
} else {
|
||||
$aChanges = array_fill_keys($aAttributes, true);
|
||||
}
|
||||
if (false === $this->IsTargetObject($oObject->GetKey(), $aChanges)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
parent::DoActivate($aContextArgs);
|
||||
}
|
||||
|
||||
public function IsTargetObject($iObjectId, $aChanges = array())
|
||||
{
|
||||
if (!parent::IsTargetObject($iObjectId, $aChanges))
|
||||
|
||||
@@ -205,7 +205,8 @@ class EMailLaminas extends Email
|
||||
case 'LogFile':
|
||||
$oTransport = new File();
|
||||
$aOptions = new FileOptions([
|
||||
'path' => APPROOT.'log/mail.log',
|
||||
'path' => APPROOT.'log/',
|
||||
'callback' => function() { return 'mail.log'; }
|
||||
]);
|
||||
$oTransport->setOptions($aOptions);
|
||||
break;
|
||||
@@ -389,6 +390,7 @@ class EMailLaminas extends Email
|
||||
$oNewPart = new Part($sBody);
|
||||
$oNewPart->encoding = Mime::ENCODING_8BIT;
|
||||
$oNewPart->type = $sMimeType;
|
||||
$oNewPart->charset = 'UTF-8';
|
||||
$oBody->addPart($oNewPart);
|
||||
|
||||
// Add additional images as new body parts
|
||||
|
||||
44
tests/php-unit-tests/unitary-tests/core/EMailTest.php
Normal file
44
tests/php-unit-tests/unitary-tests/core/EMailTest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Core;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
use EMail;
|
||||
use utils;
|
||||
|
||||
class EMailTest extends ItopTestCase {
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
* @covers Email::SetBody()
|
||||
* @covers Email::Send()
|
||||
*/
|
||||
public function testCheckHeadersOnSendEmail(): void
|
||||
{
|
||||
$oConfig = utils::GetConfig();
|
||||
$sCurrentEmailTransport = $oConfig->Get('email_transport');
|
||||
// Set our email transport to file so we can read it after
|
||||
$oConfig->Set('email_transport', 'LogFile');
|
||||
|
||||
$oEmail = new Email();
|
||||
$oEmail->SetRecipientTO('email@email.com');
|
||||
$oEmail->SetRecipientFrom('email2@email2.com');
|
||||
$oEmail->SetSubject('dummy subject');
|
||||
$oEmail->SetBody('dummy body');
|
||||
|
||||
// Send the mail and check if there's any issue
|
||||
$aIssues = [];
|
||||
$oEmail->Send($aIssues);
|
||||
$this->assertEmpty($aIssues);
|
||||
|
||||
// Check if our charset is correctly set
|
||||
// We know this file may be used by other future test, but as we can't configure output filename, it is what it is
|
||||
$sEmailContent = file_get_contents(APPROOT.'log/mail.log');
|
||||
$this->assertStringContainsString('charset="UTF-8"', $sEmailContent);
|
||||
|
||||
// Set our previous email transport value back, so it doesn't affect other tests
|
||||
$oConfig->Set('email_transport', $sCurrentEmailTransport);
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,11 @@ if (!file_exists($sConfigFile))
|
||||
|
||||
require_once(APPROOT.'/application/startup.inc.php');
|
||||
|
||||
//temporary fix until below bug is resolvedd properly:
|
||||
//N°7008 - Fix missing background tasks in CRON when NOT in "developer_mode"
|
||||
require_once(APPROOT.'/sources/SessionTracker/SessionGC.php');
|
||||
require_once(APPROOT.'/sources/Service/TemporaryObjects/TemporaryObjectGC.php');
|
||||
|
||||
$oCtx = new ContextTag(ContextTag::TAG_CRON);
|
||||
|
||||
function ReadMandatoryParam($oP, $sParam, $sSanitizationFilter = 'parameter')
|
||||
|
||||
Reference in New Issue
Block a user