From 9375219386a0d43b179236d54d85feda1993483c Mon Sep 17 00:00:00 2001 From: Tim Schmitz Date: Thu, 4 May 2023 15:33:48 +0200 Subject: [PATCH] Adds untranslated title to presentation title for autogenerated roles and role templates --- Services/AccessControl/classes/class.ilObjRole.php | 14 ++++++++++---- .../classes/class.ilObjRoleTemplate.php | 12 +++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Services/AccessControl/classes/class.ilObjRole.php b/Services/AccessControl/classes/class.ilObjRole.php index 10daeb7d9feb..b2eebed8681e 100755 --- a/Services/AccessControl/classes/class.ilObjRole.php +++ b/Services/AccessControl/classes/class.ilObjRole.php @@ -129,12 +129,18 @@ public function validate() } /** - * return translated title for autogenerated roles - * @return + * For autogenerated roles this returns 'Translated Title (untranslated title)'. + * If you only want the translated title, use getShortPresentationTitle. */ - public function getPresentationTitle() + public function getPresentationTitle() : string { - return ilObjRole::_getTranslation($this->getTitle()); + $r = ilObjRole::_getTranslation($this->getTitle()); + + if ($r === $this->getUntranslatedTitle()) { + return $r; + } + + return $r . ' (' . $this->getUntranslatedTitle() . ')'; } public function toggleAssignUsersStatus($a_assign_users) diff --git a/Services/AccessControl/classes/class.ilObjRoleTemplate.php b/Services/AccessControl/classes/class.ilObjRoleTemplate.php index 917980492476..6ca8f83b4f81 100755 --- a/Services/AccessControl/classes/class.ilObjRoleTemplate.php +++ b/Services/AccessControl/classes/class.ilObjRoleTemplate.php @@ -45,13 +45,19 @@ public function __construct($a_id = 0, $a_call_by_reference = false) parent::__construct($a_id, $a_call_by_reference); } - /** - * return translated title for autogenerated templates + * For autogenerated role templates this returns 'Translated Title (untranslated title)'. + * If you only want the translated title, use getShortPresentationTitle. */ public function getPresentationTitle() : string { - return ilObjRole::_getTranslation($this->getTitle()); + $r = ilObjRole::_getTranslation($this->getTitle()); + + if ($r === $this->getUntranslatedTitle()) { + return $r; + } + + return $r . ' (' . $this->getUntranslatedTitle() . ')'; } /**