19 declare(strict_types=1);
50 $references_of = [ilObject::class,
'_getAllReferences'],
51 $type_of = [ilObject::class,
'_lookupType']
55 $this->incident = $incident ??
new Incident();
56 $this->references_of = Closure::fromCallable($references_of);
57 $this->type_of = Closure::fromCallable($type_of);
64 return new Error(
'Not a question image path of test questions.');
67 $object_id = $this->
objectId($question_id);
72 $permitted = $this->incident->any([$this,
'refIdPermitted'], ($this->references_of)($object_id));
74 return new Ok($permitted);
83 case 'qpl':
return $this->
access->checkAccess(
'read',
'', $ref_id);
84 case 'tst':
return $this->
access->checkAccess(
'write',
'', $ref_id);
85 default:
return false;
92 if (!preg_match(
':/assessment/qst_preview/\d+/(\d+)/fileuploads/([^/]+)$:', $path,
$results)) {
101 $object_id = $this->database->fetchAssoc($this->database->queryF(
102 'SELECT obj_fi FROM qpl_questions WHERE question_id = %s',
105 ))[
'obj_fi'] ?? null;
107 return $object_id ? (
int) $object_id : null;
__construct(ilDBInterface $database, ilAccessHandler $access, ?Incident $incident=null, $references_of=[ilObject::class, '_getAllReferences'], $type_of=[ilObject::class, '_lookupType'])
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.
refIdPermitted(int $ref_id)