diff --git a/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntryFactory.php b/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntryFactory.php index 1405dff5c..173e2bc6c 100644 --- a/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntryFactory.php +++ b/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/ActivityEntryFactory.php @@ -83,7 +83,8 @@ class ActivityEntryFactory DateTime::createFromFormat(AttributeDateTime::GetInternalFormat(), $aOrmEntry['date']), $sUserLogin, $sAttCode, - $aOrmEntry['message_html'] + $aOrmEntry['message_html'], + $aOrmEntry['user_login'] ); return $oEntry; diff --git a/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/CaseLogEntry.php b/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/CaseLogEntry.php index 29c7263b3..0301eef85 100644 --- a/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/CaseLogEntry.php +++ b/sources/application/UI/Base/Layout/ActivityPanel/ActivityEntry/CaseLogEntry.php @@ -21,6 +21,7 @@ namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry; use DateTime; +use utils; /** * Class CaseLogEntry @@ -45,27 +46,58 @@ class CaseLogEntry extends ActivityEntry /** @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; + protected $iCaseLogRank; + /** @var string $sAuthorName Fallback name used if $sAuthorLogin is empty */ + protected $sAuthorName; /** * CaseLogEntry constructor. * * @param \DateTime $oDateTime - * @param \User $sAuthorLogin + * @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 $sId = null) + 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); $this->SetOrigin('caselog:'.$this->sAttCode); } + + /* + * 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 the code of the corresponding case log attribute