Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed resolution of some language variables in permissions #4676

Merged
merged 2 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Services/AccessControl/classes/class.ilObjRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,16 @@ public static function _getTranslation($a_role_title)
global $DIC;

$lng = $DIC['lng'];
$objDefinition = $DIC['objDefinition'];

$role_title = self::_removeObjectId($a_role_title);

if (preg_match("/^il_./", $role_title)) {
if (preg_match("/^il_([a-z]{1,4})_./", $role_title, $type)) {
//BT ID 0032909: language variables for roles from plugins were not resolved properly
if ($objDefinition->isPlugin($type[1])) {
return ilObjectPlugin::lookupTxtById($type[1], $role_title);
}

return $lng->txt($role_title);
}

Expand Down
9 changes: 5 additions & 4 deletions Services/AccessControl/classes/class.ilObjRoleGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ protected function readRoleProperties(ilObjRole $role)

$rbacreview = $DIC['rbacreview'];

$data['title'] = $role->getTitle();
$data['title'] = ilObjRole::_getTranslation($role->getTitle());
$data['desc'] = $role->getDescription();
$data['ilias_id'] = 'il_' . IL_INST_ID . '_' . ilObject::_lookupType($role->getId()) . '_' . $role->getId();
$data['reg'] = $role->getAllowRegister();
Expand Down Expand Up @@ -661,7 +661,7 @@ protected function confirmDeleteRoleObject()
$confirm->addItem(
'role',
$this->object->getId(),
$this->object->getTitle(),
ilObjRole::_getTranslation($this->object->getTitle()),
ilUtil::getImagePath('icon_role.svg')
);

Expand Down Expand Up @@ -855,7 +855,8 @@ public function adoptPermSaveObject()

// send info
$obj_data = &$this->ilias->obj_factory->getInstanceByObjId($_POST["adopt"]);
ilUtil::sendSuccess($this->lng->txt("msg_perm_adopted_from1") . " '" . $obj_data->getTitle() . "'.<br/>" .
ilUtil::sendSuccess($this->lng->txt("msg_perm_adopted_from1") . " '" .
ilObjRole::_getTranslation($obj_data->getTitle()) . "'.<br/>" .
$this->lng->txt("msg_perm_adopted_from2"), true);
}

Expand Down Expand Up @@ -1190,7 +1191,7 @@ protected function addAdminLocatorItems($a_do_not_add_object = false)

if ($_GET["obj_id"] > 0) {
$ilLocator->addItem(
$this->object->getTitle(),
ilObjRole::_getTranslation($this->object->getTitle()),
$this->ctrl->getLinkTarget($this, 'perm')
);
}
Expand Down
8 changes: 8 additions & 0 deletions Services/AccessControl/classes/class.ilObjRoleTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public function __construct($a_id = 0, $a_call_by_reference = false)
}


/**
* return translated title for autogenerated templates
*/
public function getPresentationTitle() : string
{
return ilObjRole::_getTranslation($this->getTitle());
}

/**
* delete role template and all related data
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function initFormRoleTemplate($a_mode = self::FORM_MODE_CREATE)
if ($this->object->isInternalTemplate()) {
$title->setDisabled(true);
}
$title->setValue($this->object->getTitle());
$title->setValue(ilObjRole::_getTranslation($this->object->getTitle()));
}
$title->setSize(40);
$title->setMaxLength(70);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,14 @@ public function fillRow($row)
$this->getObjType() . "_" . $row['perm']['operation']
));
} elseif (substr($row['perm']['operation'], 0, 6) == 'create') {
$this->tpl->setVariable('PERM_LONG', $this->lng->txt('rbac_' . $row['perm']['operation']));
if ($objDefinition->isPlugin(substr($row['perm']['operation'], 7))) {
$this->tpl->setVariable('PERM_LONG', ilObjectPlugin::lookupTxtById(
substr($row['perm']['operation'], 7),
$this->getObjType() . "_" . $row['perm']['operation']
));
} else {
$this->tpl->setVariable('PERM_LONG', $this->lng->txt('rbac_' . $row['perm']['operation']));
}
} else {
$this->tpl->setVariable('PERM_LONG', $this->lng->txt($this->getObjType() . '_' . $row['perm']['operation']));
}
Expand Down
6 changes: 3 additions & 3 deletions Services/AccessControl/classes/class.ilRbacLogTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ protected function parseChangesFaPa(array $raw)
// added only
foreach ($raw["ops"] as $role_id => $ops) {
foreach ($ops as $op) {
$result[] = array("action" => sprintf($this->lng->txt("rbac_log_operation_add"), ilObject::_lookupTitle($role_id)),
$result[] = array("action" => sprintf($this->lng->txt("rbac_log_operation_add"), ilObjRole::_getTranslation(ilObject::_lookupTitle($role_id))),
"operation" => $this->getOPCaption($type, $op));
}
}
} elseif (isset($raw["ops"])) {
foreach ($raw["ops"] as $role_id => $actions) {
foreach ($actions as $action => $ops) {
foreach ((array) $ops as $op) {
$result[] = array("action" => sprintf($this->lng->txt("rbac_log_operation_" . $action), ilObject::_lookupTitle($role_id)),
$result[] = array("action" => sprintf($this->lng->txt("rbac_log_operation_" . $action), ilObjRole::_getTranslation(ilObject::_lookupTitle($role_id))),
"operation" => $this->getOPCaption($type, $op));
}
}
Expand All @@ -158,7 +158,7 @@ protected function parseChangesFaPa(array $raw)
if (isset($raw["inht"])) {
foreach ($raw["inht"] as $action => $role_ids) {
foreach ((array) $role_ids as $role_id) {
$result[] = array("action" => sprintf($this->lng->txt("rbac_log_inheritance_" . $action), ilObject::_lookupTitle($role_id)));
$result[] = array("action" => sprintf($this->lng->txt("rbac_log_inheritance_" . $action), ilObjRole::_getTranslation(ilObject::_lookupTitle($role_id))));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(
parent::__construct($a_parent_obj, $a_parent_cmd);

$this->setTitle($this->lng->txt('rep_recommended_content') .
', ' . $this->lng->txt("obj_role") . ': ' . ilObject::_lookupTitle($this->role_id));
', ' . $this->lng->txt("obj_role") . ': ' . ilObjRole::_getTranslation(ilObject::_lookupTitle($this->role_id)));

$this->addColumn('', '', 1);
$this->addColumn($this->lng->txt('title'), 'title');
Expand Down