Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ abstract class ilUnitConfigurationGUI
protected ilGlobalTemplateInterface $tpl;
protected ilLanguage $lng;
protected ilCtrlInterface $ctrl;
protected ilRbacSystem $rbac_system;

public function __construct(
protected ilUnitConfigurationRepository $repository
Expand All @@ -40,6 +41,7 @@ public function __construct(
$this->lng = $DIC->language();
$this->ctrl = $DIC->ctrl();
$this->tpl = $DIC->ui()->mainTemplate();
$this->rbac_system = $DIC->rbac()->system();

$local_dic = QuestionPoolDIC::dic();
$this->request = $local_dic['request_data_collector'];
Expand Down Expand Up @@ -74,6 +76,22 @@ protected function handleSubtabs(): void

protected function checkPermissions(string $cmd): void
{
if (!$this->rbac_system->checkAccess('read', $this->request->getRefId())) {
$this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
$this->ctrl->redirectToURL(ilUserUtil::getStartingPointAsUrl());
return;
}

if (in_array($cmd, ['showUnitCategories', 'showUnitsOfCategory', 'showGlobalUnitCategories'], true)) {
return;
}

if ($this->rbac_system->checkAccess('write', $this->request->getRefId())) {
return;
}

$this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
$this->ctrl->redirect($this, $this->getDefaultCommand());
}

public function executeCommand(): void
Expand Down Expand Up @@ -462,7 +480,7 @@ protected function showUnitsOfCategory(): void
$this->lng->txt('back'),
$this->ctrl->getLinkTarget($this, $this->getUnitCategoryOverviewCommand())
);
if ($this->isCRUDContext()) {
if ($this->isCRUDContext() && $this->rbac_system->checkAccess('write', $this->request->getRefId())) {
$this->ctrl->setParameterByClass(get_class($this), 'category_id', $category->getId());
$ilToolbar->addButton(
$this->lng->txt('un_add_unit'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*
*********************************************************************/

use ILIAS\TestQuestionPool\QuestionPoolDIC;
use ILIAS\TestQuestionPool\RequestDataCollector;

/**
* Class ilUnitTableGUI
*/
Expand All @@ -27,6 +30,8 @@ class ilUnitTableGUI extends ilTable2GUI
private $position = 1;
private \ILIAS\UI\Factory $ui_factory;
private \ILIAS\UI\Renderer $ui_renderer;
private ilRbacSystem $rbac_system;
private RequestDataCollector $request;

/**
* @param ilUnitConfigurationGUI $controller
Expand All @@ -44,14 +49,19 @@ public function __construct(ilUnitConfigurationGUI $controller, $default_cmd, as
$lng = $DIC['lng'];
$this->ui_factory = $DIC->ui()->factory();
$this->ui_renderer = $DIC->ui()->renderer();
$this->rbac_system = $DIC->rbac()->system();
$this->request = QuestionPoolDIC::dic()['request_data_collector'];

$this->setId('units_' . $controller->getUniqueId());

parent::__construct($controller, $default_cmd);

$ilCtrl->setParameter($this->getParentObject(), 'category_id', $category->getId());

if ($this->getParentObject()->isCRUDContext()) {
if (
$this->getParentObject()?->isCRUDContext()
&& $this->rbac_system->checkAccess('write', $this->request->getRefId())
) {
$this->addColumn('', '', '1%', true);
$this->setSelectAllCheckbox('unit_ids[]');
$this->addMultiCommand('confirmDeleteUnits', $this->lng->txt('delete'));
Expand Down Expand Up @@ -88,7 +98,10 @@ public function fillRow(array $a_set): void
global $DIC;
$ilCtrl = $DIC['ilCtrl'];

if ($this->getParentObject()->isCRUDContext()) {
if (
$this->getParentObject()?->isCRUDContext()
&& $this->rbac_system->checkAccess('write', $this->request->getRefId())
) {
$a_set['chb'] = ilLegacyFormElementsUtil::formCheckbox(false, 'unit_ids[]', $a_set['unit_id']);

$sequence = new ilNumberInputGUI('', 'sequence[' . $a_set['unit_id'] . ']');
Expand Down
Loading