ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilFileDataForumDraftsRCImplementation Class Reference
+ Inheritance diagram for ilFileDataForumDraftsRCImplementation:
+ Collaboration diagram for ilFileDataForumDraftsRCImplementation:

Public Member Functions

 __construct (private readonly int $obj_id=0, private int $draft_id=0)
 
 getObjId ()
 
 getPosId ()
 
 setPosId (int $posting_id)
 
 getForumPath ()
 
 getFilesOfPost ()
 
 moveFilesOfPost (int $new_frm_id=0)
 
 ilClone (int $new_obj_id, int $new_posting_id)
 
 delete (?array $posting_ids_to_delete=null)
 
 storeUploadedFiles ()
 
 unlinkFile (string $filename)
 
 getFileDataByMD5Filename (string $hashed_filename)
 
 unlinkFilesByMD5Filenames ($hashed_filename_or_filenames)
 
 deliverFile (string $file)
 
 deliverZipFile ()
 
 getObjId ()
 
 getPosId ()
 
 setPosId (int $posting_id)
 
 getForumPath ()
 
 getFilesOfPost ()
 
 moveFilesOfPost (int $new_frm_id=0)
 
 ilClone (int $new_obj_id, int $new_posting_id)
 
 delete (?array $posting_ids_to_delete=null)
 
 storeUploadedFiles ()
 
 unlinkFile (string $filename)
 
 getFileDataByMD5Filename (string $hashed_filename)
 
 unlinkFilesByMD5Filenames ($hashed_filename_or_filenames)
 
 deliverFile (string $file)
 
 deliverZipFile ()
 

Data Fields

const FORUM_PATH_RCID = 'RCID'
 

Private Member Functions

 getCurrentDraft (bool $use_cache=true)
 
 getDraftById (int $draft_id, bool $use_cache=true)
 
 getCurrentCollection ()
 
 getResourceIdByHash (string $hash)
 

Private Attributes

readonly ILIAS ResourceStorage Services $irss
 
readonly ILIAS FileUpload FileUpload $upload
 
array $collection_cache = []
 
array $posting_cache = []
 
readonly ilForumPostingFileStakeholder $stakeholder
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilFileDataForumDraftsRCImplementation::__construct ( private readonly int  $obj_id = 0,
private int  $draft_id = 0 
)

Definition at line 36 of file class.ilFileDataForumDraftsRCImplementation.php.

39 {
40 global $DIC;
41 $this->irss = $DIC->resourceStorage();
42 $this->upload = $DIC->upload();
43 $this->stakeholder = new ilForumPostingFileStakeholder();
44 }
global $DIC
Definition: shib_login.php:26

References $DIC, and ILIAS\Repository\upload().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilFileDataForumDraftsRCImplementation::delete ( ?array  $posting_ids_to_delete = null)
Parameters
list<int>|null$posting_ids_to_delete

Implements ilFileDataForumInterface.

Definition at line 140 of file class.ilFileDataForumDraftsRCImplementation.php.

140 : bool
141 {
142 // Each element of $posting_ids_to_delete represents a "Draft Id", NOT a "Posting Id"
143 if ($posting_ids_to_delete === null) {
144 return true;
145 }
146
147 foreach ($posting_ids_to_delete as $draft_id) {
148 $this->irss->collection()->remove(
149 $this->irss->collection()->id(
150 $this->getDraftById($draft_id)->getRCID()
151 ),
152 $this->stakeholder,
153 true
154 );
155 }
156
157 return true;
158 }

References $stakeholder, getDraftById(), and true.

+ Here is the call graph for this function:

◆ deliverFile()

ilFileDataForumDraftsRCImplementation::deliverFile ( string  $file)

Implements ilFileDataForumInterface.

Definition at line 230 of file class.ilFileDataForumDraftsRCImplementation.php.

230 : void
231 {
232 $rid = $this->getResourceIdByHash($file);
233 if ($rid !== null) {
234 $this->irss->consume()->download($rid)->run();
235 }
236 }

References getResourceIdByHash().

+ Here is the call graph for this function:

◆ deliverZipFile()

ilFileDataForumDraftsRCImplementation::deliverZipFile ( )

Implements ilFileDataForumInterface.

Definition at line 238 of file class.ilFileDataForumDraftsRCImplementation.php.

238 : bool
239 {
240 // https://mantis.ilias.de/view.php?id=39910
242 $this->getCurrentDraft()->getPostSubject() . '.zip'
243 );
244 $rcid = $this->getCurrentCollection()->getIdentification();
245
246 $this->irss
247 ->consume()
248 ->downloadCollection($rcid, $zip_filename)
249 ->useRevisionTitlesForFileNames(false)
250 ->run();
251
252 return true;
253 }
static returnASCIIFileName(string $original_filename)
Converts a UTF-8 filename to ASCII.
Definition: Delivery.php:513

References getCurrentCollection(), getCurrentDraft(), and ILIAS\FileDelivery\Delivery\returnASCIIFileName().

+ Here is the call graph for this function:

◆ getCurrentCollection()

ilFileDataForumDraftsRCImplementation::getCurrentCollection ( )
private

Definition at line 60 of file class.ilFileDataForumDraftsRCImplementation.php.

61 {
62 return $this->collection_cache[$this->draft_id] ?? ($this->collection_cache[$this->draft_id] = $this->irss->collection(
63 )->get(
64 $this->irss->collection()->id(
65 $this->getCurrentDraft()->getRCID()
66 )
67 ));
68 }

Referenced by deliverZipFile(), getFileDataByMD5Filename(), getFilesOfPost(), getResourceIdByHash(), ilClone(), and storeUploadedFiles().

+ Here is the caller graph for this function:

◆ getCurrentDraft()

ilFileDataForumDraftsRCImplementation::getCurrentDraft ( bool  $use_cache = true)
private

Definition at line 46 of file class.ilFileDataForumDraftsRCImplementation.php.

47 {
48 return $this->getDraftById($this->draft_id, $use_cache);
49 }
Class ilForumPostDraft.

References getDraftById().

Referenced by deliverZipFile(), and storeUploadedFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDraftById()

ilFileDataForumDraftsRCImplementation::getDraftById ( int  $draft_id,
bool  $use_cache = true 
)
private

Definition at line 51 of file class.ilFileDataForumDraftsRCImplementation.php.

52 {
53 if ($use_cache && isset($this->posting_cache[$draft_id])) {
54 return $this->posting_cache[$draft_id];
55 }
56
57 return $this->posting_cache[$draft_id] = ilForumPostDraft::newInstanceByDraftId($draft_id);
58 }
static newInstanceByDraftId(int $draft_id)

References ilForumPostDraft\newInstanceByDraftId().

Referenced by delete(), getCurrentDraft(), and ilClone().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileDataByMD5Filename()

ilFileDataForumDraftsRCImplementation::getFileDataByMD5Filename ( string  $hashed_filename)
Returns
array{path: string, filename: string, clean_filename: string}|null

Implements ilFileDataForumInterface.

Definition at line 194 of file class.ilFileDataForumDraftsRCImplementation.php.

194 : ?array
195 {
196 foreach ($this->getCurrentCollection()->getResourceIdentifications() as $identification) {
197 $revision = $this->irss->manage()->getCurrentRevision($identification);
198 if ($revision->getTitle() === $hashed_filename) {
199 $info = $revision->getInformation();
200 return [
201 'path' => '',
202 'filename' => $info->getTitle(),
203 'clean_filename' => $info->getTitle()
204 ];
205 }
206 }
207
208 return null;
209 }
$info
Definition: entry_point.php:21

References $info, and getCurrentCollection().

+ Here is the call graph for this function:

◆ getFilesOfPost()

ilFileDataForumDraftsRCImplementation::getFilesOfPost ( )
Returns
array<string, array{path: string, md5: string, name: string, size: int, ctime: string}>

Implements ilFileDataForumInterface.

Definition at line 105 of file class.ilFileDataForumDraftsRCImplementation.php.

105 : array
106 {
107 $files = [];
108 foreach ($this->getCurrentCollection()->getResourceIdentifications() as $identification) {
109 $revision = $this->irss->manage()->getCurrentRevision($identification);
110 $info = $revision->getInformation();
111 $files[$revision->getTitle()] = [
112 'path' => $this->irss->consume()->stream($identification)->getStream()->getMetadata('uri'),
113 'md5' => $revision->getTitle(),
114 'name' => $info->getTitle(),
115 'size' => $info->getSize(),
116 'ctime' => $info->getCreationDate()->format('Y-m-d H:i:s')
117 ];
118 }
119
120 return $files;
121 }

References $info, and getCurrentCollection().

+ Here is the call graph for this function:

◆ getForumPath()

ilFileDataForumDraftsRCImplementation::getForumPath ( )

◆ getObjId()

ilFileDataForumDraftsRCImplementation::getObjId ( )

Implements ilFileDataForumInterface.

Definition at line 82 of file class.ilFileDataForumDraftsRCImplementation.php.

82 : int
83 {
84 return $this->obj_id;
85 }

◆ getPosId()

ilFileDataForumDraftsRCImplementation::getPosId ( )

Implements ilFileDataForumInterface.

Definition at line 87 of file class.ilFileDataForumDraftsRCImplementation.php.

87 : int
88 {
89 return $this->draft_id;
90 }

◆ getResourceIdByHash()

ilFileDataForumDraftsRCImplementation::getResourceIdByHash ( string  $hash)
private

Definition at line 70 of file class.ilFileDataForumDraftsRCImplementation.php.

71 {
72 foreach ($this->getCurrentCollection()->getResourceIdentifications() as $identification) {
73 $revision = $this->irss->manage()->getCurrentRevision($identification);
74 if ($revision->getTitle() === $hash) {
75 return $identification;
76 }
77 }
78
79 return null;
80 }

References getCurrentCollection().

Referenced by deliverFile(), and unlinkFilesByMD5Filenames().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ilClone()

ilFileDataForumDraftsRCImplementation::ilClone ( int  $new_obj_id,
int  $new_posting_id 
)

Implements ilFileDataForumInterface.

Definition at line 129 of file class.ilFileDataForumDraftsRCImplementation.php.

129 : bool
130 {
131 $current_collection_id = $this->getCurrentCollection()->getIdentification();
132 $new_collection_id = $this->irss->collection()->clone($current_collection_id);
133 $new_draft = $this->getDraftById($new_posting_id);
134 $new_draft->setRCID($new_collection_id->serialize());
135 $new_draft->update();
136
137 return true;
138 }

References getCurrentCollection(), and getDraftById().

+ Here is the call graph for this function:

◆ moveFilesOfPost()

ilFileDataForumDraftsRCImplementation::moveFilesOfPost ( int  $new_frm_id = 0)

Implements ilFileDataForumInterface.

Definition at line 123 of file class.ilFileDataForumDraftsRCImplementation.php.

123 : bool
124 {
125 // nothing to do here since collections are related to the post
126 return true;
127 }

◆ setPosId()

ilFileDataForumDraftsRCImplementation::setPosId ( int  $posting_id)

Implements ilFileDataForumInterface.

Definition at line 92 of file class.ilFileDataForumDraftsRCImplementation.php.

92 : void
93 {
94 $this->draft_id = $posting_id;
95 }

◆ storeUploadedFiles()

ilFileDataForumDraftsRCImplementation::storeUploadedFiles ( )

Implements ilFileDataForumInterface.

Definition at line 160 of file class.ilFileDataForumDraftsRCImplementation.php.

160 : bool
161 {
162 if (!$this->upload->hasBeenProcessed()) {
163 $this->upload->process();
164 }
165 $collection = $this->getCurrentCollection();
166
167 foreach ($this->upload->getResults() as $result) {
168 if (!$result->isOK()) {
169 continue;
170 }
171 $rid = $this->irss->manage()->upload(
172 $result,
173 $this->stakeholder,
174 md5($result->getName())
175 );
176 $collection->add($rid);
177 }
178 $this->irss->collection()->store($collection);
179 $draft = $this->getCurrentDraft(false);
180 $draft->setRCID($collection->getIdentification()->serialize());
181 $draft->update();
182
183 return true;
184 }

References getCurrentCollection(), getCurrentDraft(), and ILIAS\Repository\upload().

+ Here is the call graph for this function:

◆ unlinkFile()

ilFileDataForumDraftsRCImplementation::unlinkFile ( string  $filename)

Implements ilFileDataForumInterface.

Definition at line 186 of file class.ilFileDataForumDraftsRCImplementation.php.

186 : bool
187 {
188 throw new DomainException('Not implemented');
189 }

◆ unlinkFilesByMD5Filenames()

ilFileDataForumDraftsRCImplementation::unlinkFilesByMD5Filenames (   $hashed_filename_or_filenames)
Parameters
string | string[]$hashed_filename_or_filenames

Implements ilFileDataForumInterface.

Definition at line 214 of file class.ilFileDataForumDraftsRCImplementation.php.

214 : bool
215 {
216 $hashes = is_array($hashed_filename_or_filenames)
217 ? $hashed_filename_or_filenames
218 : [$hashed_filename_or_filenames];
219
220 foreach ($hashes as $hash) {
221 $identification = $this->getResourceIdByHash($hash);
222 if ($identification !== null) {
223 $this->irss->manage()->remove($identification, $this->stakeholder);
224 }
225 }
226
227 return true;
228 }

References getResourceIdByHash().

+ Here is the call graph for this function:

Field Documentation

◆ $collection_cache

array ilFileDataForumDraftsRCImplementation::$collection_cache = []
private

◆ $irss

readonly ILIAS ResourceStorage Services ilFileDataForumDraftsRCImplementation::$irss
private

◆ $posting_cache

array ilFileDataForumDraftsRCImplementation::$posting_cache = []
private

◆ $stakeholder

readonly ilForumPostingFileStakeholder ilFileDataForumDraftsRCImplementation::$stakeholder
private

Definition at line 34 of file class.ilFileDataForumDraftsRCImplementation.php.

Referenced by delete().

◆ $upload

readonly ILIAS FileUpload FileUpload ilFileDataForumDraftsRCImplementation::$upload
private

◆ FORUM_PATH_RCID

const ilFileDataForumDraftsRCImplementation::FORUM_PATH_RCID = 'RCID'

Definition at line 26 of file class.ilFileDataForumDraftsRCImplementation.php.

Referenced by getForumPath().


The documentation for this class was generated from the following file: