N°4621 Fix naming inconsistencies in sources/*

This commit is contained in:
Pierre Goiffon
2021-12-31 15:21:08 +01:00
parent 16142bd979
commit 5f575d524a
192 changed files with 384 additions and 380 deletions

View File

@@ -0,0 +1,347 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use AttributeDateTime;
use Combodo\iTop\Application\UI\Base\UIBlock;
use Combodo\iTop\Core\CMDBChange\CMDBChangeOrigin;
use DateTime;
use UserRights;
use utils;
/**
* Class ActivityEntry
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry
* @internal
* @since 3.0.0
*/
class ActivityEntry extends UIBlock
{
// Overloaded constants
public const BLOCK_CODE = 'ibo-activity-entry';
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/activity-panel/activity-entry/layout';
/** @var string DEFAULT_ORIGIN */
public const DEFAULT_ORIGIN = CMDBChangeOrigin::INTERACTIVE;
/** @var string DEFAULT_TYPE */
public const DEFAULT_TYPE = 'generic';
/** @var string DEFAULT_DECORATION_CLASSES */
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-mortar-pestle';
/** @var string Relative URL (from the app. root) to the default author picture URL */
public const DEFAULT_AUTHOR_PICTURE_REL_URL = 'images/icons/icons8-music-robot.svg';
/** @var string $sType Type of entry, used for filtering (eg. case log, edits, transition, ...) */
protected $sType;
/** @var string $sDecorationClasses CSS classes to use to decorate the entry */
protected $sDecorationClasses;
/** @var string|null $sContent Raw content of the entry itself (should not have been processed / escaped) */
protected $sContent;
/** @var \DateTime $oDateTime Date / time the entry occurred */
protected $oDateTime;
/** @var string $sAuthorLogin Login of the author (user, cron, extension, ...) who made the activity of the entry */
protected $sAuthorLogin;
/** @var string $sAuthorFriendlyname */
protected $sAuthorFriendlyname;
/** @var string $sAuthorInitials */
protected $sAuthorInitials;
/** @var string $sAuthorPictureAbsUrl */
protected $sAuthorPictureAbsUrl;
/** @var bool $bIsFromCurrentUser Flag to know if the user who made the activity was the current user */
protected $bIsFromCurrentUser;
/**
* @var string $sOrigin Origin of the entry (interactive, CSV import, ...)
* @see \Combodo\iTop\Core\CMDBChange\CMDBChangeOrigin
*/
protected $sOrigin;
/**
* ActivityEntry constructor.
*
* @param \DateTime $oDateTime
* @param string $sAuthorLogin
* @param string|null $sContent
* @param string|null $sId
*
* @throws \OQLException
*/
public function __construct(DateTime $oDateTime, string $sAuthorLogin, ?string $sContent = null, ?string $sId = null)
{
parent::__construct($sId);
$this->SetType(static::DEFAULT_TYPE);
$this->SetDecorationClasses(static::DEFAULT_DECORATION_CLASSES);
$this->SetContent($sContent);
$this->SetDateTime($oDateTime);
$this->SetAuthor($sAuthorLogin);
$this->SetOrigin(static::DEFAULT_ORIGIN);
}
/**
* Set the type of the entry (eg. case log, edits, transition, ...)
*
* @param string $sType
*
* @return $this
*/
public function SetType(string $sType)
{
$this->sType = $sType;
return $this;
}
/**
* Return the type of the entry (eg. case log, edits, transition, ...)
*
* @return string
*/
public function GetType(): string
{
return $this->sType;
}
/**
* Set the CSS decoration classes
*
* @param string $sDecorationClasses Must be a space-separated list of CSS classes
*
* @return $this
*/
public function SetDecorationClasses(string $sDecorationClasses)
{
$this->sDecorationClasses = $sDecorationClasses;
return $this;
}
/**
* Return a string of the space separated CSS decoration classes
*
* @return string
*/
public function GetDecorationClasses(): string
{
return $this->sDecorationClasses;
}
/**
* Set the content without any filtering / escaping
*
* @param string|null $sContent
*
* @return $this
*/
public function SetContent(?string $sContent)
{
$this->sContent = $sContent;
return $this;
}
/**
* Return the raw content without any filtering / escaping
*
* @return string
*/
public function GetContent(): string
{
return $this->sContent;
}
/**
* @param \DateTime $oDateTime
*
* @return $this
*/
public function SetDateTime(DateTime $oDateTime)
{
$this->oDateTime = $oDateTime;
return $this;
}
/**
* Return the date time without formatting, as per the mysql format
* @return string
*/
public function GetRawDateTime(): string
{
return $this->oDateTime->format(AttributeDateTime::GetInternalFormat());
}
/**
* Return the date time formatted as per the iTop config.
*
* @return string
* @throws \Exception
*/
public function GetFormattedDateTime(): string
{
$oDateTimeFormat = AttributeDateTime::GetFormat();
return $oDateTimeFormat->Format($this->oDateTime);
}
/**
* Set the author and its information based on the $sAuthorLogin
*
* @param string $sAuthorLogin
*
* @return $this
* @throws \OQLException
* @throws \Exception
*/
public function SetAuthor(string $sAuthorLogin)
{
$this->sAuthorLogin = $sAuthorLogin;
// Set friendlyname to whatever we have in case $sAuthorLogin is not a valid login (deleted user, cron, ...)
$iAuthorId = UserRights::GetUserId($this->sAuthorLogin);
// - Friendlyname
if (true === empty($iAuthorId)) {
$this->sAuthorFriendlyname = $this->sAuthorLogin;
} else {
$this->sAuthorFriendlyname = UserRights::GetUserFriendlyName($this->sAuthorLogin);
}
// - Initials
$this->sAuthorInitials = UserRights::GetUserInitials($this->sAuthorLogin);
// - Picture
// ... first compute the user picture...
if (in_array('backoffice', utils::GetConfig()->Get('activity_panel.hide_avatars'))) {
$this->sAuthorPictureAbsUrl = null;
} else {
$this->sAuthorPictureAbsUrl = UserRights::GetUserPictureAbsUrl($this->sAuthorLogin, false);
}
// ... then fallback on system picture if necessary
if ((null === $this->sAuthorPictureAbsUrl) && (ITOP_APPLICATION_SHORT === $this->sAuthorLogin)) {
$this->sAuthorPictureAbsUrl = utils::GetAbsoluteUrlAppRoot().static::DEFAULT_AUTHOR_PICTURE_REL_URL;
}
$this->bIsFromCurrentUser = UserRights::GetUserId($this->sAuthorLogin) === UserRights::GetUserId();
return $this;
}
/**
* @return string
*/
public function GetAuthorLogin()
{
return $this->sAuthorLogin;
}
/**
* @return string
*/
public function GetAuthorFriendlyname()
{
return $this->sAuthorFriendlyname;
}
/**
* @return string
*/
public function GetAuthorInitials()
{
return $this->sAuthorInitials;
}
/**
* @return string
*/
public function GetAuthorPictureAbsUrl()
{
return $this->sAuthorPictureAbsUrl;
}
/**
* Return true if the current user is the author of the activity entry
*
* @return bool|null Can be null depending on the source of creation of the entry
*/
public function IsFromCurrentUser(): ?bool
{
return $this->bIsFromCurrentUser;
}
/**
* Set the origin of the activity entry
*
* @param string $sOrigin
*
* @return $this
*/
public function SetOrigin(string $sOrigin)
{
$this->sOrigin = $sOrigin;
return $this;
}
/**
* Return the origin of the activity entry
*
* @return string
*/
public function GetOrigin(): string
{
return $this->sOrigin;
}
/**
* @return string|null The CSS decoration classes for the origin of the entry
* @see \CMDBChangeOrigin
*/
public function GetOriginDecorationClasses(): ?string
{
$sDecorationClasses = null;
// Note: We put fa-fw on all cases instead of just in the template as one of the cases could (in the future) not use FA icons. This will ensure that any use of the FA icons are always the same width.
switch($this->GetOrigin()) {
case CMDBChangeOrigin::CSV_INTERACTIVE:
case CMDBChangeOrigin::CSV_IMPORT:
$sDecorationClasses = 'fas fa-fw fa-file-import';
break;
case CMDBChangeOrigin::EMAIL_PROCESSING:
$sDecorationClasses = 'fas fa-fw fa-envelope-open';
break;
case CMDBChangeOrigin::SYNCHRO_DATA_SOURCE:
$sDecorationClasses = 'fas fa-fw fa-lock';
break;
case CMDBChangeOrigin::WEBSERVICE_REST:
case CMDBChangeOrigin::WEBSERVICE_SOAP:
$sDecorationClasses = 'fas fa-fw fa-cloud';
break;
case CMDBChangeOrigin::CUSTOM_EXTENSION:
$sDecorationClasses = 'fas fa-fw fa-parachute-box';
break;
default:
break;
}
return $sDecorationClasses;
}
}

View File

@@ -0,0 +1,157 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use AttributeDateTime;
use CMDBChange;
use CMDBChangeOp;
use DateTime;
use DBObject;
use EventNotification;
use Exception;
use MetaModel;
use ReflectionClass;
/**
* Class ActivityEntryFactory
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry
* @since 3.0.0
* @internal
*/
class ActivityEntryFactory
{
/**
* Make an ActivityEntry entry (for ActivityPanel) based on the $oChangeOp.
*
* @param \CMDBChangeOp $oChangeOp
* @param \CMDBChange $oChange
*
* @return \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntry
* @throws \ReflectionException
* @throws \Exception
*/
public static function MakeFromCmdbChangeOp(CMDBChangeOp $oChangeOp, CMDBChange $oChange)
{
$sFactoryFqcn = static::GetFactoryClass($oChangeOp, 'CMDBChangeOp');
// If no factory found, throw an exception as the developer most likely forgot to create it
if (empty($sFactoryFqcn)) {
throw new Exception('No factory found for '.get_class($oChangeOp).', did you forgot to create one?');
}
/** @var \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntry $oEntry */
/** @noinspection PhpUndefinedMethodInspection Call static method from the $sFactoryFqcn class */
$oEntry = $sFactoryFqcn::MakeFromCmdbChangeOp($oChangeOp);
$oEntry->SetOrigin($oChange->Get('origin'));
return $oEntry;
}
/**
* Make a CaseLogEntry entry (for ActivityPanel) from an ormCaseLog array entry.
*
* @param string $sAttCode Code of the case log attribute
* @param array $aOrmEntry
*
* @return \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CaseLogEntry
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \OQLException
*/
public static function MakeFromCaseLogEntryArray(string $sAttCode, array $aOrmEntry)
{
$oUser = MetaModel::GetObject('User', $aOrmEntry['user_id'], false, true);
$sUserLogin = ($oUser === null) ? '' : $oUser->Get('login');
// We sanitize OrmEntry even if it's already sanitized: if the entry is somehow truncated or metadata are wrong we may break whole page DOM
$oEntry = new CaseLogEntry(
DateTime::createFromFormat(AttributeDateTime::GetInternalFormat(), $aOrmEntry['date']),
$sUserLogin,
$sAttCode,
\HTMLSanitizer::Sanitize($aOrmEntry['message_html']),
$aOrmEntry['user_login']
);
return $oEntry;
}
/**
* Make an ActivityEntry entry (for ActivityPanel) based on the $oEvent
*
* @param \EventNotification $oEvent
*
* @return \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntry
* @throws \ReflectionException
*/
public static function MakeFromEventNotification(EventNotification $oEvent)
{
$sFactoryFqcn = static::GetFactoryClass($oEvent, 'EventNotification');
// If no factory found, throw an exception as the developer most likely forgot to create it
if (empty($sFactoryFqcn)) {
throw new Exception('No factory found for '.get_class($oEvent).', did you forgot to create one?');
}
/** @var \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\NotificationEntry $oEntry */
/** @noinspection PhpUndefinedMethodInspection Call static method from the $sFactoryFqcn class */
$oEntry = $sFactoryFqcn::MakeFromEventNotification($oEvent);
return $oEntry;
}
/**
* Return the FQCN of the best fitted factory for the $oObject / $sObjectType tuple. If none found, null will be returned.
*
* @param \DBObject $oObject
*
* @return string|null
* @throws \ReflectionException
*/
protected static function GetFactoryClass(DBObject $oObject, string $sObjectType)
{
// Classes to search a factory for
$aClassesTree = [get_class($oObject)];
// Add parent classes to tree if not a root class
$aParentClasses = class_parents($oObject);
if (is_array($aParentClasses)) {
$aClassesTree = array_merge($aClassesTree, array_values($aParentClasses));
}
$sFactoryFqcn = null;
foreach ($aClassesTree as $sClass) {
// Warning: This will replace all occurrences of $sObjectType (eg. 'CMDBChangeOp', 'EventNotification', ...) which can be an issue on classes using this
// We used the case sensitive search to limit this issue.
$sSimplifiedClass = (new ReflectionClass($sClass))->getShortName();
$sFactoryFqcnToTry = __NAMESPACE__.'\\'.$sObjectType.'\\'.$sSimplifiedClass.'Factory';
// Stop at the first factory found
if (class_exists($sFactoryFqcnToTry)) {
$sFactoryFqcn = $sFactoryFqcnToTry;
break;
}
}
return $sFactoryFqcn;
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
/**
* Class CMDBChangeOpAttachmentAddedFactory
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp
* @since 3.0.0
* @internal
*/
class CMDBChangeOpAttachmentAddedFactory extends CMDBChangeOpFactory
{
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-paperclip';
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
/**
* Class CMDBChangeOpAttachmentRemovedFactory
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp
* @since 3.0.0
* @internal
*/
class CMDBChangeOpAttachmentRemovedFactory extends CMDBChangeOpFactory
{
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-unlink';
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
/**
* Class CMDBChangeOpCreateFactory
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp
* @since 3.0.0
* @internal
*/
class CMDBChangeOpCreateFactory extends CMDBChangeOpFactory {
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-seedling';
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
/**
* Class CMDBChangeOpDeleteFactory
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp
* @since 3.0.0
* @internal
*/
class CMDBChangeOpDeleteFactory extends CMDBChangeOpFactory {
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-trash';
}

View File

@@ -0,0 +1,96 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
use AttributeDateTime;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntry;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EditsEntry;
use DateTime;
use iCMDBChangeOp;
use MetaModel;
/**
* Class CMDBChangeOpFactory
*
* Default factory for CMDBChangeOp change ops
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp
* @since 3.0.0
* @internal
*/
class CMDBChangeOpFactory
{
/** @var string DEFAULT_TYPE Used to overload the type from the ActivityEntry */
public const DEFAULT_TYPE = EditsEntry::DEFAULT_TYPE;
/** @var string DEFAULT_DECORATION_CLASSES Used to overload the decoration classes from the ActivityEntry */
public const DEFAULT_DECORATION_CLASSES = ActivityEntry::DEFAULT_DECORATION_CLASSES;
/**
* Make an ActivityEntry from the iCMDBChangeOp $oChangeOp
*
* @param \iCMDBChangeOp $oChangeOp
*
* @return \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntry
* @throws \OQLException
*/
public static function MakeFromCmdbChangeOp(iCMDBChangeOp $oChangeOp)
{
$oDateTime = DateTime::createFromFormat(AttributeDateTime::GetInternalFormat(), $oChangeOp->Get('date'));
$sContent = $oChangeOp->GetDescription();
// Retrieve author login
$sAuthorLogin = static::GetUserLoginFromChangeOp($oChangeOp);
$oEntry = new ActivityEntry($oDateTime, $sAuthorLogin, $sContent);
$oEntry->SetType(static::DEFAULT_TYPE)
->SetDecorationClasses(static::DEFAULT_DECORATION_CLASSES);
return $oEntry;
}
/**
* Return the login of the $oChangeOp author or its friendlyname if the user cannot be retrieved.
*
* @param \iCMDBChangeOp $oChangeOp
*
* @return string|null
* @throws \ArchivedObjectException
* @throws \CoreException
*/
public static function GetUserLoginFromChangeOp(iCMDBChangeOp $oChangeOp)
{
$iAuthorId = $oChangeOp->Get('user_id');
// - Set login in the friendlyname as a fallback
$sAuthorLogin = $oChangeOp->Get('userinfo');
// - Try to find user login from its ID if present (since iTop 3.0.0)
if(empty($iAuthorId) === false)
{
$oAuthor = MetaModel::GetObject('User', $iAuthorId, false, true);
if(empty($oAuthor) === false)
{
$sAuthorLogin = $oAuthor->Get('login');
}
}
return $sAuthorLogin;
}
}

View File

@@ -0,0 +1,63 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
use AttributeDateTime;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EditsEntry;
use DateTime;
use iCMDBChangeOp;
/**
* Class CMDBChangeOpSetAttributeFactory
*
* Default factory for CMDBChangeOpSetAttribute change ops
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp
* @since 3.0.0
* @internal
*/
class CMDBChangeOpSetAttributeFactory extends CMDBChangeOpFactory
{
/**
* Make an EditsEntry from the iCMDBChangeOpSetAttribute $oChangeOp
*
* @param \iCMDBChangeOp $oChangeOp
*
* @return \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EditsEntry
* @throws \OQLException
* @throws \Exception
*/
public static function MakeFromCmdbChangeOp(iCMDBChangeOp $oChangeOp)
{
$sHostObjectClass = $oChangeOp->Get('objclass');
$sAttCode = $oChangeOp->Get('attcode');
$oDateTime = DateTime::createFromFormat(AttributeDateTime::GetInternalFormat(), $oChangeOp->Get('date'));
// Retrieve author login
$sAuthorLogin = static::GetUserLoginFromChangeOp($oChangeOp);
$oEntry = new EditsEntry($oDateTime, $sAuthorLogin, $sHostObjectClass);
$oEntry->AddAttribute($sAttCode, $oChangeOp->GetDescription());
return $oEntry;
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
use AttributeDateTime;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\TransitionEntry;
use DateTime;
use iCMDBChangeOp;
use MetaModel;
/**
* Class CMDBChangeOpSetAttributeScalarFactory
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp\Factory
* @since 3.0.0
* @internal
*/
class CMDBChangeOpSetAttributeScalarFactory extends CMDBChangeOpSetAttributeFactory
{
/**
* @inheritDoc
* @throws \CoreException
*/
public static function MakeFromCmdbChangeOp(iCMDBChangeOp $oChangeOp)
{
$sHostObjectClass = $oChangeOp->Get('objclass');
$sAttCode = $oChangeOp->Get('attcode');
// Specific ActivityEntry for state changes, otherwise just a regular EditsEntry
if (MetaModel::HasStateAttributeCode($sHostObjectClass) && ($sAttCode === MetaModel::GetStateAttributeCode($sHostObjectClass))) {
$oDateTime = DateTime::createFromFormat(AttributeDateTime::GetInternalFormat(), $oChangeOp->Get('date'));
// Retrieve author login
$sAuthorLogin = static::GetUserLoginFromChangeOp($oChangeOp);
$sOriginStateLabel = MetaModel::GetStateLabel($sHostObjectClass, $oChangeOp->Get('oldvalue'));
$sTargetStateLabel = MetaModel::GetStateLabel($sHostObjectClass, $oChangeOp->Get('newvalue'));
$oEntry = new TransitionEntry($oDateTime, $sAuthorLogin, $sHostObjectClass, $sOriginStateLabel, $sTargetStateLabel);
}
else
{
$oEntry = parent::MakeFromCmdbChangeOp($oChangeOp);
}
return $oEntry;
}
}

View File

@@ -0,0 +1,135 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use DateTime;
use utils;
/**
* Class CaseLogEntry
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry
* @internal
* @since 3.0.0
*/
class CaseLogEntry extends ActivityEntry
{
// Overloaded constants
public const BLOCK_CODE = 'ibo-caselog-entry';
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/activity-panel/activity-entry/caselog-entry';
public const DEFAULT_TYPE = 'caselog';
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-quote-left';
// Specific constants
public const DEFAULT_CASELOG_RANK = 0;
/** @var string $sAttCode Code of the corresponding case log attribute */
protected $sAttCode;
/** @var int $iCaseLogRank Rank of its case log in the host panel, can be used for highlight purposes for example */
protected $iCaseLogRank;
/** @var string $sAuthorName Fallback name used if $sAuthorLogin is empty */
protected $sAuthorName;
/**
* CaseLogEntry constructor.
*
* @param \DateTime $oDateTime
* @param string $sAuthorLogin
* @param string $sAttCode
* @param string $sContent
* @param string $sAuthorName
* @param string|null $sId
*
* @throws \OQLException
*/
public function __construct(DateTime $oDateTime, string $sAuthorLogin, string $sAttCode, string $sContent, string $sAuthorName, ?string $sId = null)
{
$this->sAuthorName = $sAuthorName;
parent::__construct($oDateTime, $sAuthorLogin, $sContent, $sId);
$this->sAttCode = $sAttCode;
$this->SetCaseLogRank(static::DEFAULT_CASELOG_RANK);
}
/*
* Set the author and its information based on the $sAuthorLogin using parent call
* If no parent call found no matching User, fallback on caselog author name and display it as foreign message
*
* @param string $sAuthorLogin
*
* @return $this
* @throws \OQLException
* @throws \Exception
*/
public function SetAuthor(string $sAuthorLogin)
{
parent::SetAuthor($sAuthorLogin);
// If no User was found in parent call
if($this->sAuthorLogin === '') {
// Use caselog user_login info as friendlyname and compute its initials
$this->sAuthorFriendlyname = $this->sAuthorName;
$this->sAuthorInitials = utils::ToAcronym($this->sAuthorFriendlyname);
// Reset Picture as we probably have default image
$this->sAuthorPictureAbsUrl = null;
// Reset bIsFromCurrentUser as UserRights often consider '' login as current user login
$this->bIsFromCurrentUser = null;
}
return $this;
}
/**
* Return the code of the corresponding case log attribute
*
* @return string
*/
public function GetAttCode(): string
{
return $this->sAttCode;
}
/**
* Set the rank of the case log in the host panel
*
* @param int $iCaseLogRank
*
* @return $this
*/
public function SetCaseLogRank(int $iCaseLogRank)
{
$this->iCaseLogRank = $iCaseLogRank;
return $this;
}
/**
* Return the rank of the case log in the host panel
*
* @return int
*/
public function GetCaseLogRank(): int
{
return $this->iCaseLogRank;
}
}

View File

@@ -0,0 +1,225 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use DateTime;
use Dict;
use Exception;
use MetaModel;
/**
* Class EditsEntry
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry
* @internal
* @since 3.0.0
*/
class EditsEntry extends ActivityEntry
{
// Overloaded constants
public const BLOCK_CODE = 'ibo-edits-entry';
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/activity-panel/activity-entry/edits-entry';
public const DEFAULT_TYPE = 'edits';
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-pen';
/** @var string $sObjectClass */
protected $sObjectClass;
/** @var array $aAttributes Array of edited attributes with their code, label and descriptions (an attribute can have several descriptions at once, eg. linkedset items added/removed) */
protected $aAttributes;
/**
* EditsEntry constructor.
*
* @param \DateTime $oDateTime
* @param string $sAuthorLogin
* @param string $sObjectClass Class of the object concerned by the edits
* @param string|null $sId
*
* @throws \OQLException
*/
public function __construct(DateTime $oDateTime, string $sAuthorLogin, string $sObjectClass, ?string $sId = null)
{
parent::__construct($oDateTime, $sAuthorLogin, null, $sId);
$this->sObjectClass = $sObjectClass;
$this->SetAttributes([]);
}
/**
* Return the class of the object concerned by the edits
*
* @return string
*/
public function GetObjectClass(): string
{
return $this->sObjectClass;
}
/**
* Set all attributes at once, replacing all existing.
*
* @param array $aAttributes
*
* @return $this
*/
public function SetAttributes(array $aAttributes)
{
$this->aAttributes = $aAttributes;
return $this;
}
/**
* Return an array of edited attributes with their code, label and description
*
* @return array
*/
public function GetAttributes(): array
{
return $this->aAttributes;
}
/**
* Add the attribute identified by $sAttCode to the edited attribute.
* Note that if an attribute with the same $sAttCode already exists, it's description will be append to the existing one.
*
* @param string $sAttCode
* @param string $sEditDescriptionAsHtml The description of the edit already in HTML, it MUSt have been sanitized first (Already in
* HTML because most of the time it comes from CMDBChangeOp::GetDescription())
*
* @return $this
* @throws \Exception
*/
public function AddAttribute(string $sAttCode, string $sEditDescriptionAsHtml)
{
// Create it if not already existing
if (!array_key_exists($sAttCode, $this->aAttributes)) {
$this->aAttributes[$sAttCode] = [
'code' => $sAttCode,
'label' => MetaModel::GetLabel($this->sObjectClass, $sAttCode),
'descriptions' => [],
];
}
// Append description
$this->aAttributes[$sAttCode]['descriptions'][] = $sEditDescriptionAsHtml;
return $this;
}
/**
* Remove the attribute of code $sAttCode from the edited attributes.
* Note that if there is no attribute with this code, it will proceed silently.
*
* @param string $sAttCode
*
* @return array
*/
public function RemoveAttribute(string $sAttCode)
{
if (array_key_exists($sAttCode, $this->aAttributes))
{
unset($this->aAttributes[$sAttCode]);
}
return $this->aAttributes;
}
/**
* Merge $oEntry into the current one ($this).
* Note that edits on any existing attribute codes will be replaced.
*
* @param \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EditsEntry $oEntry
*
* @return $this
* @throws \Exception
*/
public function Merge(EditsEntry $oEntry)
{
if ($oEntry->GetObjectClass() !== $this->GetObjectClass()) {
throw new Exception("Cannot merge an entry from {$oEntry->GetObjectClass()} into {$this->GetObjectClass()}, they must be for the same class");
}
// Merging attributes
foreach ($oEntry->GetAttributes() as $sAttCode => $aAttData) {
foreach ($aAttData['descriptions'] as $sDescription) {
$this->AddAttribute($sAttCode, $sDescription);
}
}
return $this;
}
/**
* Return the short description of the edits entry in HTML
*
* @return string
*/
public function GetShortDescriptionAsHtml(): string
{
// We need the array to be indexed by numbers instead of being associative
$aAttributesData = array_values($this->GetAttributes());
$iAttributesCount = count($aAttributesData);
switch($iAttributesCount)
{
case 0:
$sDescriptionAsHtml = '';
break;
case 1:
$iDescriptionsCount = count($aAttributesData[0]['descriptions']);
switch ($iDescriptionsCount) {
case 1:
$sDescriptionAsHtml = $aAttributesData[0]['descriptions'][0];
break;
default:
$sDescriptionAsHtml = '<span class="ibo-edits-entry--attribute-label" data-attribute-code="'.$aAttributesData[0]['code'].'">'.$aAttributesData[0]['label'].'</span>';
break;
}
break;
default:
$sFirstAttLabelAsHtml = '<span class="ibo-edits-entry--attribute-label" data-attribute-code="'.$aAttributesData[0]['code'].'">'.$aAttributesData[0]['label'].'</span>';
$sSecondAttLabelAsHtml = '<span class="ibo-edits-entry--attribute-label" data-attribute-code="'.$aAttributesData[1]['code'].'">'.$aAttributesData[1]['label'].'</span>';
switch($iAttributesCount)
{
case 2:
$sDescriptionAsHtml = Dict::Format('Change:TwoAttributesChanged', $sFirstAttLabelAsHtml, $sSecondAttLabelAsHtml);
break;
case 3:
$sDescriptionAsHtml = Dict::Format('Change:ThreeAttributesChanged', $sFirstAttLabelAsHtml, $sSecondAttLabelAsHtml);
break;
default:
$sDescriptionAsHtml = Dict::Format('Change:FourOrMoreAttributesChanged', $sFirstAttLabelAsHtml, $sSecondAttLabelAsHtml, count($aAttributesData) - 2);
break;
}
}
return $sDescriptionAsHtml;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EventNotification;
/**
* Class EventNotificationEmailFactory
*
* Factory for EventNotificationEmail events
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EventNotification
* @since 3.0.0
* @internal
*/
class EventNotificationEmailFactory extends EventNotificationFactory
{
/** @inheritDoc */
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-envelope';
}

View File

@@ -0,0 +1,68 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EventNotification;
use AttributeDateTime;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\NotificationEntry;
use DateTime;
use EventNotification;
/**
* Class EventNotificationFactory
*
* Default factory for EventNotification events
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EventNotification
* @since 3.0.0
* @internal
*/
class EventNotificationFactory
{
/** @var string Used to overload the type from the NotificationEntry */
public const DEFAULT_TYPE = NotificationEntry::DEFAULT_TYPE;
/** @var string Used to overload the decoration classes from the NotificationEntry */
public const DEFAULT_DECORATION_CLASSES = NotificationEntry::DEFAULT_DECORATION_CLASSES;
/**
* Make an ActivityEntry from the iEventNotification $oEvent
*
* @param \EventNotification $oEvent
*
* @return \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\NotificationEntry
* @throws \OQLException
*/
public static function MakeFromEventNotification(EventNotification $oEvent)
{
$oDateTime = DateTime::createFromFormat(AttributeDateTime::GetInternalFormat(), $oEvent->Get('date'));
// Author login is hardcoded:
// - Adding a user_id column to the event tables like for the CMDBChangeOp could be erro prone during migration as those tables are huge.
// - Marking events as created by the app. is good enough as the user triggering it as no power over it, it cannot avoid it.
$sAuthorLogin = ITOP_APPLICATION_SHORT;
$oEntry = new NotificationEntry($oDateTime, $sAuthorLogin, $oEvent->Get('action_id_friendlyname'), $oEvent->Get('message'));
$oEntry->SetType(static::DEFAULT_TYPE)
->SetDecorationClasses(static::DEFAULT_DECORATION_CLASSES);
return $oEntry;
}
}

View File

@@ -0,0 +1,111 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use DateTime;
/**
* Class NotificationEntry
*
* @internal
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry
* @since 3.0.0
*/
class NotificationEntry extends ActivityEntry
{
// Overloaded constants
public const BLOCK_CODE = 'ibo-notification-entry';
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/activity-panel/activity-entry/notification-entry';
public const DEFAULT_TYPE = 'edits';
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-bell';
/** @var string Title of the entry, usually the linked action title */
protected $sTitle;
/** @var string Message of the entry, usually it's status */
protected $sMessage;
/**
* NotificationEntry constructor.
*
* @param \DateTime $oDateTime
* @param string $sAuthorLogin
* @param string $sTitle
* @param string $sMessage
* @param string|null $sId
*
* @throws \OQLException
*/
public function __construct(DateTime $oDateTime, string $sAuthorLogin, string $sTitle, string $sMessage, ?string $sId = null)
{
parent::__construct($oDateTime, $sAuthorLogin, null, $sId);
$this->SetTitle($sTitle);
$this->SetMessage($sMessage);
}
/**
* @see static::$sTitle
*
* @param string $sTitle
*
* @return $this
*/
public function SetTitle(string $sTitle)
{
$this->sTitle = $sTitle;
return $this;
}
/**
* @see static::$sTitle
* @return string
*/
public function GetTitle(): string
{
return $this->sTitle;
}
/**
* @see static::$sMessage
*
* @param string $sMessage
*
* @return $this
*/
public function SetMessage(string $sMessage)
{
$this->sMessage = $sMessage;
return $this;
}
/**
* @see static::$sMessage
* @return string
*/
public function GetMessage(): string
{
return $this->sMessage;
}
}

View File

@@ -0,0 +1,148 @@
<?php
/**
* Copyright (C) 2013-2021 Combodo SARL
*
* This file is part of iTop.
*
* iTop 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.
*
* iTop 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
*/
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use DateTime;
use MetaModel;
/**
* Class TransitionEntry
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry
* @internal
* @since 3.0.0
*/
class TransitionEntry extends ActivityEntry
{
// Overloaded constants
public const BLOCK_CODE = 'ibo-transition-entry';
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/activity-panel/activity-entry/transition-entry';
public const DEFAULT_TYPE = 'transition';
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-map-signs';
/** @var string $sOriginStateCode Code of the state before the transition */
protected $sOriginStateCode;
/** @var string $sOriginStateLabel Label of the $sOriginStateCode state */
protected $sOriginStateLabel;
/** @var string $sTargetStateCode Code of the state after the transition */
protected $sTargetStateCode;
/** @var string $sTargetStateLabel Label of the $sTargetStateCode state */
protected $sTargetStateLabel;
/**
* TransitionEntry constructor.
*
* @param \DateTime $oDateTime
* @param \User $sAuthorLogin
* @param string $sObjectClass Class of the object which made the transition
* @param string $sOriginStateCode
* @param string $sTargetStateCode
* @param string|null $sId
*
* @throws \CoreException
* @throws \OQLException
*/
public function __construct(
DateTime $oDateTime, string $sAuthorLogin, string $sObjectClass, string $sOriginStateCode, string $sTargetStateCode,
?string $sId = null
) {
parent::__construct($oDateTime, $sAuthorLogin, null, $sId);
$this->SetOriginalState($sObjectClass, $sOriginStateCode);
$this->SetTargetState($sObjectClass, $sTargetStateCode);
}
/**
* Set the code / label of the state before the transition
*
* @param string $sObjectClass Class of the object the state is from
* @param string $sStateCode
*
* @return $this
* @throws \CoreException
*/
public function SetOriginalState(string $sObjectClass, string $sStateCode)
{
$this->sOriginStateCode = $sStateCode;
$this->sOriginStateLabel = MetaModel::GetStateLabel($sObjectClass, $sStateCode);
return $this;
}
/**
* Return the code of the state before the transition
*
* @return string
*/
public function GetOriginalStateCode(): string
{
return $this->sOriginStateCode;
}
/**
* Return the label of the state before the transition
*
* @return string
*/
public function GetOriginalStateLabel(): string
{
return $this->sOriginStateLabel;
}
/**
* Set the code / label of the state after the transition
*
* @param string $sObjectClass
* @param string $sStateCode
*
* @return $this
* @throws \CoreException
*/
public function SetTargetState(string $sObjectClass, string $sStateCode)
{
$this->sTargetStateCode = $sStateCode;
$this->sTargetStateLabel = MetaModel::GetStateLabel($sObjectClass, $sStateCode);
return $this;
}
/**
* Return the code of the state after the transition
*
* @return string
*/
public function GetTargetStateCode(): string
{
return $this->sTargetStateCode;
}
/**
* Return the label of the state after the transition
*
* @return string
*/
public function GetTargetStateLabel(): string
{
return $this->sTargetStateLabel;
}
}