Skip to content

Commit

Permalink
Tweak question pool and question pool question comment permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuszych committed Jul 10, 2024
1 parent 8d4d94f commit df958f6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ public function infoScreenObject(): void
public function infoScreenForward(): void
{
if (!$this->access->checkAccess('visible', '', $this->ref_id)) {
$this->error->raiseError($this->lng->txt('msg_no_perm_read'));
$this->error->raiseError($this->lng->txt('msg_no_perm_read'), 403);
}
$info = new ilInfoScreenGUI($this);
$info->enablePrivateNotes();
Expand Down Expand Up @@ -1895,7 +1895,7 @@ protected function getTable(): string
$this->taxonomy->domain(),
$this->notes_service,
$this->object->getId(),
(int)$this->qplrequest->getRefId()
$this->qplrequest->getRefId()
);

/**
Expand Down
4 changes: 4 additions & 0 deletions Services/Notes/Comment/class.ilCommentGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public function getHTML(): string

public function getListHTML(bool $a_init_form = true): string
{
if (!$this->checkAccess()) {
return '';
}

$ilUser = $this->user;
$lng = $this->lng;
$ilCtrl = $this->ctrl;
Expand Down
19 changes: 18 additions & 1 deletion Services/Notes/Note/class.ilNoteGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ public function addNote(): void
)->getData("note") ?? "";

//if ($this->form->checkInput())
if ($text !== "" && !is_array($this->rep_obj_id)) {
if ($text !== "" && !is_array($this->rep_obj_id) && $this->checkAccess()) {
$context = $this->data->context(
$this->rep_obj_id,
$this->obj_id,
Expand Down Expand Up @@ -1555,4 +1555,21 @@ protected function updateNumber(): void
exit;
}

protected function checkAccess(): bool
{
$context = $this->data->context(
$this->rep_obj_id,
$this->obj_id,
$this->obj_type,
$this->news_id,
$this->repository_mode,
);
$refIds = ilObject::_getAllReferences($context->getObjId());
$refId = (int) array_shift($refIds);
return match ($this->obj_type) {
'qpl' => $this->access->checkAccess('visible', '', $refId),
'quest' => $this->access->checkAccess('read', '', $refId),
default => true,
};
}
}

0 comments on commit df958f6

Please sign in to comment.