19 declare(strict_types=1);
29 private \ILIAS\ResourceStorage\Services
$irss;
30 private \ILIAS\FileUpload\FileUpload
$upload;
38 public function __construct(
private readonly
int $obj_id = 0,
private int $pos_id = 0)
41 $this->irss = $DIC->resourceStorage();
42 $this->
upload = $DIC->upload();
53 if ($use_cache && isset($this->posting_cache[$posting_id])) {
54 return $this->posting_cache[$posting_id];
57 return $this->posting_cache[$posting_id] =
new ilForumPost($posting_id);
62 if (isset($this->collection_cache[$this->pos_id])) {
63 return $this->collection_cache[$this->pos_id];
66 return $this->collection_cache[$this->pos_id] = $this->irss->collection()->get(
67 $this->irss->collection()->id(
76 $revision = $this->irss->manage()->getCurrentRevision($identification);
77 if ($revision->getTitle() === $hash) {
78 return $identification;
95 public function setPosId(
int $posting_id): void
97 $this->pos_id = $posting_id;
102 return self::FORUM_PATH_RCID;
112 $revision = $this->irss->manage()->getCurrentRevision($identification);
113 $info = $revision->getInformation();
114 $files[$info->getTitle()] = [
115 'path' => $this->irss->consume()->stream($identification)->getStream()->getMetadata(
'uri'),
116 'md5' => $revision->getTitle(),
117 'name' => $info->getTitle(),
118 'size' => $info->getSize(),
119 'ctime' => $info->getCreationDate()->format(
'Y-m-d H:i:s')
132 public function ilClone(
int $new_obj_id,
int $new_posting_id): bool
135 $new_collection_id = $this->irss->collection()->clone($current_collection_id);
137 $new_posting->setRCID($new_collection_id->serialize());
138 $new_posting->update();
143 public function delete(array $posting_ids_to_delete = null):
bool 145 if ($posting_ids_to_delete === null) {
149 foreach ($posting_ids_to_delete as $post_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 $posting->setRCID($collection->getIdentification()->serialize());
191 $revision = $this->irss->manage()->getCurrentRevision($identification);
192 if ($revision->getTitle() === md5($filename)) {
193 $this->irss->manage()->remove($identification, $this->stakeholder);
206 $revision = $this->irss->manage()->getCurrentRevision($identification);
207 if ($revision->getTitle() === $hashed_filename) {
208 $info = $revision->getInformation();
211 'filename' => $info->getTitle(),
212 'clean_filename' => $info->getTitle()
225 $hashes = is_array($hashed_filename_or_filenames)
226 ? $hashed_filename_or_filenames
227 : [$hashed_filename_or_filenames];
229 foreach ($hashes as $hash) {
231 if ($identification !== null) {
232 $this->irss->manage()->remove($identification, $this->stakeholder);
243 $this->irss->consume()->download($rid)->run();
255 $this->irss->consume()->downloadCollection($rcid, $zip_filename)
256 ->useRevisionTitlesForFileNames(
false)
265 $rcid = $this->irss->collection()->id();
266 $post->
setRCID($rcid->serialize());
269 $rcid = $this->irss->collection()->id($post->
getRCID());
272 $collection = $this->irss->collection()->get($rcid);
273 $rid = $this->irss->manage()->stream(
274 Streams::ofResource(fopen($path_to_file,
'rb')),
276 md5(basename($path_to_file))
278 $collection->add($rid);
279 $this->irss->collection()->store($collection);
static returnASCIIFileName(string $original_filename)
Converts a UTF-8 filename to ASCII.
getResourceIdByHash(string $hash)
deliverFile(string $file)
importFileToCollection(string $path_to_file, ilForumPost $post)
ILIAS ResourceStorage Services $irss
unlinkFile(string $filename)
ilClone(int $new_obj_id, int $new_posting_id)
ilForumPostingFileStakeholder $stakeholder
getCurrentPosting(bool $use_cache=true)
Class ResourceCollection.
unlinkFilesByMD5Filenames($hashed_filename_or_filenames)
__construct(private readonly int $obj_id=0, private int $pos_id=0)
setPosId(int $posting_id)
ILIAS FileUpload FileUpload $upload
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPostingById(int $posting_id, bool $use_cache=true)
Class ResourceIdentification.
getFileDataByMD5Filename(string $hashed_filename)
moveFilesOfPost(int $new_frm_id=0)