19 declare(strict_types=1);
53 $references_of = [ilObject::class,
'_getAllReferences'],
54 $type_of = [ilObject::class,
'_lookupType']
58 $this->incident = $incident ??
new Incident();
59 $this->references_of = Closure::fromCallable($references_of);
60 $this->type_of = Closure::fromCallable($type_of);
67 return new Error(
'Not a question image path of test questions.');
70 $object_id = $this->
objectId($question_id);
75 $permitted = $this->incident->any([$this,
'refIdPermitted'], ($this->references_of)($object_id));
77 return new Ok($permitted);
89 case 'qpl':
return $this->
access->checkAccess(
'read',
'', $ref_id);
90 case 'tst':
return $this->
access->checkAccess(
'write',
'', $ref_id);
91 default:
return false;
98 if (!preg_match(
':/assessment/qst_preview/\d+/(\d+)/fileuploads/([^/]+)$:', $path,
$results)) {
107 $object_id = $this->database->fetchAssoc($this->database->queryF(
108 'SELECT obj_fi FROM qpl_questions WHERE question_id = %s',
111 ))[
'obj_fi'] ?? null;
113 return $object_id ? (
int) $object_id : null;
isPermitted(string $path)
objectId(int $question_id)
A result encapsulates a value or an error and simplifies the handling of those.
A result encapsulates a value or an error and simplifies the handling of those.
__construct(ilDBInterface $database, ilAccess $access, ?Incident $incident=null, $references_of=[ilObject::class, '_getAllReferences'], $type_of=[ilObject::class, '_lookupType'])
refIdPermitted(int $ref_id)