19 declare(strict_types=1);
52 $references_of = [ilObject::class,
'_getAllReferences'],
53 $type_of = [ilObject::class,
'_lookupType']
57 $this->incident = $incident ??
new Incident();
58 $this->references_of = Closure::fromCallable($references_of);
59 $this->type_of = Closure::fromCallable($type_of);
66 return new Error(
'Not a question image path of test questions.');
69 $object_id = $this->
objectId($question_id);
74 $permitted = $this->incident->any([$this,
'refIdPermitted'], ($this->references_of)($object_id));
76 return new Ok($permitted);
85 case 'qpl':
return $this->
access->checkAccess(
'read',
'', $ref_id);
86 case 'tst':
return $this->
access->checkAccess(
'write',
'', $ref_id);
87 default:
return false;
94 if (!preg_match(
':/assessment/qst_preview/\d+/(\d+)/fileuploads/([^/]+)$:', $path,
$results)) {
103 $object_id = $this->database->fetchAssoc($this->database->queryF(
104 'SELECT obj_fi FROM qpl_questions WHERE question_id = %s',
107 ))[
'obj_fi'] ??
null;
109 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'])
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
refIdPermitted(int $ref_id)
A result encapsulates a value or an error and simplifies the handling of those.
isPermitted(string $path)
objectId(int $question_id)