ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Mail\Attachments\MailAttachments Class Reference
+ Collaboration diagram for ILIAS\Mail\Attachments\MailAttachments:

Public Member Functions

 isEmpty ()
 
 isIrss ()
 
 isLegacy ()
 
 rcid ()
 
 legacyFilenames ()
 
 toDb ()
 
 toBackgroundTask ()
 
 stageRcidOrNull ()
 

Static Public Member Functions

static empty ()
 
static fromIrss (ResourceCollectionIdentification $rcid)
 
static fromLegacyFilenames (array $filenames)
 Legacy rows come from unserialize() and may contain non-strings. More...
 
static fromDb (?string $raw)
 
static fromBackgroundTask (string $serialized)
 

Data Fields

const string SERIALIZED_RCID_KEY = '__irss_rcid'
 

Private Attributes

const string RCID_PATTERN = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/'
 

Detailed Description

Definition at line 26 of file MailAttachments.php.

Member Function Documentation

◆ empty()

static ILIAS\Mail\Attachments\MailAttachments::empty ( )
static

◆ fromBackgroundTask()

static ILIAS\Mail\Attachments\MailAttachments::fromBackgroundTask ( string  $serialized)
static

Definition at line 99 of file MailAttachments.php.

99 : self
100 {
101 $parsed = @unserialize($serialized, ['allowed_classes' => false]);
102 if (!is_array($parsed)) {
103 return self::empty();
104 }
105
106 if (isset($parsed[self::SERIALIZED_RCID_KEY])) {
107 return self::fromIrss(
108 new ResourceCollectionIdentification((string) $parsed[self::SERIALIZED_RCID_KEY])
109 );
110 }
111
112 return self::fromLegacyFilenames($parsed);
113 }
static fromLegacyFilenames(array $filenames)
Legacy rows come from unserialize() and may contain non-strings.
static fromIrss(ResourceCollectionIdentification $rcid)

References ILIAS\Mail\Attachments\MailAttachments\empty(), ILIAS\Mail\Attachments\MailAttachments\fromIrss(), and ILIAS\Mail\Attachments\MailAttachments\fromLegacyFilenames().

+ Here is the call graph for this function:

◆ fromDb()

static ILIAS\Mail\Attachments\MailAttachments::fromDb ( ?string  $raw)
static

Definition at line 70 of file MailAttachments.php.

70 : ?self
71 {
72 if ($raw === null || $raw === '') {
73 return null;
74 }
75
76 if (str_starts_with($raw, 'a:')) {
77 $unserialized = @unserialize($raw, ['allowed_classes' => false]);
78 if (!is_array($unserialized)) {
79 return null;
80 }
81
82 if (isset($unserialized[self::SERIALIZED_RCID_KEY])) {
83 return self::fromIrss(
84 new ResourceCollectionIdentification((string) $unserialized[self::SERIALIZED_RCID_KEY])
85 );
86 }
87
88 return self::fromLegacyFilenames($unserialized);
89 }
90
91 // Very old rows may contain other serialized values (e.g. "N;"), which are no collection
92 if (preg_match(self::RCID_PATTERN, $raw) !== 1) {
93 return null;
94 }
95
96 return self::fromIrss(new ResourceCollectionIdentification($raw));
97 }

References ILIAS\Mail\Attachments\MailAttachments\fromIrss(), and ILIAS\Mail\Attachments\MailAttachments\fromLegacyFilenames().

Referenced by ILIAS\Mail\Message\MailRecordMapper\normalizeRow().

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

◆ fromIrss()

static ILIAS\Mail\Attachments\MailAttachments::fromIrss ( ResourceCollectionIdentification  $rcid)
static

Definition at line 43 of file MailAttachments.php.

43 : self
44 {
45 return new self($rcid, []);
46 }

Referenced by ILIAS\Mail\Attachments\MailAttachments\fromBackgroundTask(), ILIAS\Mail\Attachments\MailAttachments\fromDb(), and ILIAS\EmployeeTalk\Notification\Notification\send().

+ Here is the caller graph for this function:

◆ fromLegacyFilenames()

static ILIAS\Mail\Attachments\MailAttachments::fromLegacyFilenames ( array  $filenames)
static

Legacy rows come from unserialize() and may contain non-strings.

Those entries are dropped so one bad value does not abort the migration.

Parameters
array<array-key,mixed>$filenames

Definition at line 54 of file MailAttachments.php.

54 : self
55 {
56 $names = [];
57 foreach ($filenames as $filename) {
58 if (is_string($filename)) {
59 $names[] = $filename;
60 }
61 }
62
63 if ($names === []) {
64 return self::empty();
65 }
66
67 return new self(null, $names);
68 }
$filename
Definition: buildRTE.php:78

References $filename, and ILIAS\Mail\Attachments\MailAttachments\empty().

Referenced by ILIAS\Mail\Attachments\MailAttachments\fromBackgroundTask(), and ILIAS\Mail\Attachments\MailAttachments\fromDb().

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

◆ isEmpty()

ILIAS\Mail\Attachments\MailAttachments::isEmpty ( )

Definition at line 115 of file MailAttachments.php.

115 : bool
116 {
117 return $this->rcid === null && $this->legacy_filenames === [];
118 }

References ILIAS\Mail\Attachments\MailAttachments\rcid().

Referenced by ilMailFormGUI\buildFormElements(), ilMail\createQueueSnapshot(), ilMailFolderGUI\getAttachmentHashes(), ilMail\getDeliveryAttachments(), ilMail\irssAttachmentsWereLost(), and ilMail\releaseSourceAttachments().

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

◆ isIrss()

◆ isLegacy()

ILIAS\Mail\Attachments\MailAttachments::isLegacy ( )

Definition at line 125 of file MailAttachments.php.

125 : bool
126 {
127 return $this->rcid === null && $this->legacy_filenames !== [];
128 }

References ILIAS\Mail\Attachments\MailAttachments\rcid().

Referenced by ilFileDataMail\migrateLegacyPoolAttachments(), and ilMail\normalizeLegacyAttachments().

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

◆ legacyFilenames()

ILIAS\Mail\Attachments\MailAttachments::legacyFilenames ( )
Returns
list<string>

Definition at line 142 of file MailAttachments.php.

142 : array
143 {
144 if ($this->isIrss()) {
145 throw new InvalidArgumentException('Mail attachments are not legacy filenames.');
146 }
147
148 return $this->legacy_filenames;
149 }

References ILIAS\Mail\Attachments\MailAttachments\isIrss().

Referenced by ilFileDataMail\migrateLegacyPoolAttachments(), and ilMail\normalizeLegacyAttachments().

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

◆ rcid()

ILIAS\Mail\Attachments\MailAttachments::rcid ( )

◆ stageRcidOrNull()

ILIAS\Mail\Attachments\MailAttachments::stageRcidOrNull ( )

Definition at line 169 of file MailAttachments.php.

170 {
171 return $this->rcid;
172 }

◆ toBackgroundTask()

ILIAS\Mail\Attachments\MailAttachments::toBackgroundTask ( )

Definition at line 160 of file MailAttachments.php.

160 : string
161 {
162 if ($this->isIrss()) {
163 return serialize([self::SERIALIZED_RCID_KEY => $this->rcid->serialize()]);
164 }
165
166 return serialize($this->legacy_filenames);
167 }

References ILIAS\Mail\Attachments\MailAttachments\isIrss(), and ILIAS\Mail\Attachments\MailAttachments\rcid().

+ Here is the call graph for this function:

◆ toDb()

ILIAS\Mail\Attachments\MailAttachments::toDb ( )

Definition at line 151 of file MailAttachments.php.

151 : string
152 {
153 if ($this->isIrss()) {
154 return $this->rcid->serialize();
155 }
156
157 return serialize($this->legacy_filenames);
158 }

References ILIAS\Mail\Attachments\MailAttachments\isIrss(), and ILIAS\Mail\Attachments\MailAttachments\rcid().

Referenced by ilMail\persistMailAttachmentsColumn().

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

Field Documentation

◆ RCID_PATTERN

const string ILIAS\Mail\Attachments\MailAttachments::RCID_PATTERN = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/'
private

Definition at line 29 of file MailAttachments.php.

◆ SERIALIZED_RCID_KEY

const string ILIAS\Mail\Attachments\MailAttachments::SERIALIZED_RCID_KEY = '__irss_rcid'

Definition at line 28 of file MailAttachments.php.


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