Skip to content

Commit

Permalink
split up getPresentationTitle into two methods
Browse files Browse the repository at this point in the history
  • Loading branch information
schmitz-ilias committed Jul 25, 2022
1 parent 96c5fb3 commit 1046c76
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Modules/OrgUnit/classes/Staff/class.ilOrgUnitStaffGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private function addOtherRolesToolbar() : void
foreach ($arrLocalRoles as $role_id) {
$ilObjRole = new ilObjRole($role_id);
if (!preg_match("/il_orgu_/", $ilObjRole->getUntranslatedTitle())) {
$types[$role_id] = $ilObjRole->getPresentationTitle(false);
$types[$role_id] = $ilObjRole->getShortPresentationTitle();
}
}
$this->ctrl->setParameterByClass('ilRepositorySearchGUI', 'addusertype', 'other');
Expand Down
13 changes: 9 additions & 4 deletions Services/AccessControl/classes/class.ilObjRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,24 @@ public function validate() : bool
/**
* @inheritDoc
* For autogenerated roles this returns 'Translated Title (untranslated title).
* If you only want the translated title, set extended to false.
* If you only want the translated title, use getShortPresentationTitle.
*/
public function getPresentationTitle(bool $extended = true) : string
public function getPresentationTitle() : string
{
$r = ilObjRole::_getTranslation($this->getTitle());
$r = $this->getShortPresentationTitle();

if (!$extended || $r === $this->getUntranslatedTitle()) {
if ($r === $this->getUntranslatedTitle()) {
return $r;
}

return $r . ' (' . $this->getUntranslatedTitle() . ')';
}

public function getShortPresentationTitle() : string
{
return ilObjRole::_getTranslation($this->getTitle());
}

public function toggleAssignUsersStatus(bool $a_assign_users) : void
{
$this->assign_users = $a_assign_users;
Expand Down
17 changes: 11 additions & 6 deletions Services/AccessControl/classes/class.ilObjRoleTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,27 @@ public function __construct(int $a_id = 0, bool $a_call_by_reference = false)
parent::__construct($a_id, $a_call_by_reference);
}


/**
* For autogenerated templates this returns 'Translated Title (untranslated title).
* If you only want the translated title, set extended to false.
* @inheritDoc
* For autogenerated role templates this returns 'Translated Title (untranslated title).
* If you only want the translated title, use getShortPresentationTitle.
*/
public function getPresentationTitle(bool $extended = true) : string
public function getPresentationTitle() : string
{
$r = ilObjRole::_getTranslation($this->getTitle());
$r = $this->getShortPresentationTitle();

if (!$extended || $r === $this->getUntranslatedTitle()) {
if ($r === $this->getUntranslatedTitle()) {
return $r;
}

return $r . ' (' . $this->getUntranslatedTitle() . ')';
}

public function getShortPresentationTitle() : string
{
return ilObjRole::_getTranslation($this->getTitle());
}

/**
* delete role template and all related data
*
Expand Down

0 comments on commit 1046c76

Please sign in to comment.