19 declare(strict_types=1);
27 private \ILIAS\ResourceStorage\Services
$irss;
28 private \ILIAS\FileUpload\FileUpload
$upload;
36 private readonly
int $obj_id = 0,
37 private int $draft_id = 0
40 $this->irss = $DIC->resourceStorage();
41 $this->
upload = $DIC->upload();
52 if ($use_cache && isset($this->posting_cache[$draft_id])) {
53 return $this->posting_cache[$draft_id];
61 if (isset($this->collection_cache[$this->draft_id])) {
62 return $this->collection_cache[$this->draft_id];
65 return $this->collection_cache[$this->draft_id] = $this->irss->collection()->get(
66 $this->irss->collection()->id(
75 $revision = $this->irss->manage()->getCurrentRevision($identification);
76 if ($revision->getTitle() === $hash) {
77 return $identification;
91 return $this->draft_id;
94 public function setPosId(
int $posting_id): void
96 $this->draft_id = $posting_id;
101 return self::FORUM_PATH_RCID;
111 $revision = $this->irss->manage()->getCurrentRevision($identification);
112 $info = $revision->getInformation();
113 $files[$revision->getTitle()] = [
114 'path' => $this->irss->consume()->stream($identification)->getStream()->getMetadata(
'uri'),
115 'md5' => $revision->getTitle(),
116 'name' => $info->getTitle(),
117 'size' => $info->getSize(),
118 'ctime' => $info->getCreationDate()->format(
'Y-m-d H:i:s')
131 public function ilClone(
int $new_obj_id,
int $new_posting_id): bool
134 $new_collection_id = $this->irss->collection()->clone($current_collection_id);
136 $new_draft->setRCID($new_collection_id->serialize());
137 $new_draft->update();
142 public function delete(array $posting_ids_to_delete = null):
bool 145 if ($posting_ids_to_delete === null) {
149 foreach ($posting_ids_to_delete as $draft_id) {
150 $this->irss->collection()->remove(
151 $this->irss->collection()->id(
164 if (!$this->
upload->hasBeenProcessed()) {
169 foreach ($this->
upload->getResults() as $result) {
170 if (!$result->isOK()) {
173 $rid = $this->irss->manage()->upload(
176 md5($result->getName())
178 $collection->add($rid);
180 $this->irss->collection()->store($collection);
182 $draft->setRCID($collection->getIdentification()->serialize());
199 $revision = $this->irss->manage()->getCurrentRevision($identification);
200 if ($revision->getTitle() === $hashed_filename) {
201 $info = $revision->getInformation();
204 'filename' => $info->getTitle(),
205 'clean_filename' => $info->getTitle()
218 $hashes = is_array($hashed_filename_or_filenames)
219 ? $hashed_filename_or_filenames
220 : [$hashed_filename_or_filenames];
222 foreach ($hashes as $hash) {
224 if ($identification !== null) {
225 $this->irss->manage()->remove($identification, $this->stakeholder);
235 $this->irss->consume()->download($rid)->run();
247 $this->irss->consume()->downloadCollection($rcid, $zip_filename)
248 ->useRevisionTitlesForFileNames(
false)
static returnASCIIFileName(string $original_filename)
Converts a UTF-8 filename to ASCII.
getFileDataByMD5Filename(string $hashed_filename)
unlinkFile(string $filename)
Class ResourceCollection.
__construct(private readonly int $obj_id=0, private int $draft_id=0)
deliverFile(string $file)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDraftById(int $draft_id, bool $use_cache=true)
Class ResourceIdentification.
unlinkFilesByMD5Filenames($hashed_filename_or_filenames)
moveFilesOfPost(int $new_frm_id=0)
ILIAS ResourceStorage Services $irss
getResourceIdByHash(string $hash)
getCurrentDraft(bool $use_cache=true)
setPosId(int $posting_id)
ilClone(int $new_obj_id, int $new_posting_id)
static newInstanceByDraftId(int $draft_id)
ILIAS FileUpload FileUpload $upload
ilForumPostingFileStakeholder $stakeholder