ILIAS  release_8 Revision v8.24
ilFileDataMail Class Reference

This class handles all operations on files (attachments) in directory ilias_data/mail. More...

+ Inheritance diagram for ilFileDataMail:
+ Collaboration diagram for ilFileDataMail:

Public Member Functions

 __construct (int $a_user_id=0)
 
 initDirectory ()
 
 getUploadLimit ()
 
 getAttachmentsTotalSizeLimit ()
 
 getMailPath ()
 
 getAbsoluteAttachmentPoolPathPrefix ()
 
 getAttachmentPathAndFilenameByMd5Hash (string $md5FileHash, int $mailId)
 
 getAttachmentPath (string $a_filename, int $a_mail_id)
 
 adoptAttachments (array $a_attachments, int $a_mail_id)
 Adopt attachments (in case of forwarding a mail) More...
 
 checkReadWrite ()
 
 getUserFilesData ()
 
 storeAsAttachment (string $a_filename, string $a_content)
 
 storeUploadedFile (array $file)
 
 copyAttachmentFile (string $a_abs_path, string $a_new_name)
 Copy files in mail directory. More...
 
 unlinkFiles (array $a_filenames)
 
 unlinkFile (string $a_filename)
 
 getAbsoluteAttachmentPoolPathByFilename (string $fileName)
 Resolves a path for a passed filename in regards of a user's mail attachment pool, meaning attachments not being sent. More...
 
 saveFiles (int $a_mail_id, array $a_attachments)
 Saves all attachment files in a specific mail directory .../mail/<calculated_path>/mail_<mail_id>_<user_id>/... More...
 
 saveFile (int $a_mail_id, string $a_attachment)
 Save attachment file in a specific mail directory .../mail/<calculated_path>/mail_<mail_id>_<user_id>/... More...
 
 checkFilesExist (array $a_files)
 
 assignAttachmentsToDirectory (int $a_mail_id, int $a_sent_mail_id)
 
 deassignAttachmentFromDirectory (int $a_mail_id)
 
 deliverAttachmentsAsZip (string $basename, int $mailId, array $files=[], bool $isDraft=false)
 
- Public Member Functions inherited from ilFileData
 __construct ()
 
 checkPath (string $a_path)
 
 getPath ()
 
- Public Member Functions inherited from ilFile
 deleteTrailingSlash (string $a_path)
 delete trailing slash of path variables More...
 

Static Public Member Functions

static getStorage (int $a_mail_id, int $a_usr_id)
 

Data Fields

int $user_id
 
string $mail_path
 

Protected Member Functions

 initAttachmentMaxUploadSize ()
 

Protected Attributes

int $mail_max_upload_file_size
 
Filesystem $tmpDirectory
 
Filesystem $storageDirectory
 
ilDBInterface $db
 
ILIAS $ilias
 
- Protected Attributes inherited from ilFile
string $path
 

Private Member Functions

 getAttachmentPathByMailId (int $mailId)
 
 rotateFiles (string $a_path)
 
 deleteAttachmentDirectory (string $a_rel_path)
 

Detailed Description

This class handles all operations on files (attachments) in directory ilias_data/mail.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 30 of file class.ilFileDataMail.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileDataMail::__construct ( int  $a_user_id = 0)

Definition at line 40 of file class.ilFileDataMail.php.

41 {
42 global $DIC;
43
44 if (!defined('MAILPATH')) {
45 define('MAILPATH', 'mail');
46 }
48 $this->mail_path = $this->getPath() . "/" . MAILPATH;
49 $this->ilias = $DIC['ilias'];
50 $this->checkReadWrite();
51 $this->user_id = $a_user_id;
52
53 $this->db = $DIC->database();
54 $this->tmpDirectory = $DIC->filesystem()->temp();
55 $this->storageDirectory = $DIC->filesystem()->storage();
56
58 }
const MAILPATH
Definition: constants.php:50
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
header include for all ilias files.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), checkReadWrite(), ilFileData\getPath(), initAttachmentMaxUploadSize(), and MAILPATH.

+ Here is the call graph for this function:

Member Function Documentation

◆ adoptAttachments()

ilFileDataMail::adoptAttachments ( array  $a_attachments,
int  $a_mail_id 
)

Adopt attachments (in case of forwarding a mail)

Parameters
string[]$a_attachments
int$a_mail_id
Returns
string An error message

Definition at line 161 of file class.ilFileDataMail.php.

161 : string
162 {
163 foreach ($a_attachments as $file) {
164 $path = $this->getAttachmentPath($file, $a_mail_id);
165 if (!copy($path, $this->getMailPath() . '/' . $this->user_id . '_' . $file)) {
166 return 'ERROR: ' . $this->getMailPath() . '/' . $this->user_id . '_' . $file . ' cannot be created';
167 }
168 }
169
170 return '';
171 }
getAttachmentPath(string $a_filename, int $a_mail_id)
string $path

References ilFile\$path, getAttachmentPath(), and getMailPath().

+ Here is the call graph for this function:

◆ assignAttachmentsToDirectory()

ilFileDataMail::assignAttachmentsToDirectory ( int  $a_mail_id,
int  $a_sent_mail_id 
)

Definition at line 404 of file class.ilFileDataMail.php.

404 : void
405 {
406 global $ilDB;
407
408 $oStorage = self::getStorage($a_sent_mail_id, $this->user_id);
409 $res = $ilDB->manipulateF(
410 '
411 INSERT INTO mail_attachment
412 ( mail_id, path) VALUES (%s, %s)',
413 ['integer', 'text'],
414 [$a_mail_id, $oStorage->getRelativePathExMailDirectory()]
415 );
416 }
static getStorage(int $a_mail_id, int $a_usr_id)
$res
Definition: ltiservices.php:69

References $ilDB, $res, and getStorage().

+ Here is the call graph for this function:

◆ checkFilesExist()

ilFileDataMail::checkFilesExist ( array  $a_files)
Parameters
string[]$a_files
Returns
bool

Definition at line 391 of file class.ilFileDataMail.php.

391 : bool
392 {
393 if ($a_files) {
394 foreach ($a_files as $file) {
395 if (!is_file($this->mail_path . '/' . $this->user_id . '_' . $file)) {
396 return false;
397 }
398 }
399 return true;
400 }
401 return true;
402 }

◆ checkReadWrite()

ilFileDataMail::checkReadWrite ( )

Definition at line 173 of file class.ilFileDataMail.php.

173 : bool
174 {
175 if (is_writable($this->mail_path) && is_readable($this->mail_path)) {
176 return true;
177 }
178
179 $this->ilias->raiseError(
180 "Mail directory is not readable/writable by webserver: " .
181 $this->mail_path,
182 $this->ilias->error_obj->FATAL
183 );
184
185 return false;
186 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ copyAttachmentFile()

ilFileDataMail::copyAttachmentFile ( string  $a_abs_path,
string  $a_new_name 
)

Copy files in mail directory.

This is used for sending ILIAS generated mails with attachments

Parameters
string$a_abs_path
string$a_new_name
Returns
bool

Definition at line 288 of file class.ilFileDataMail.php.

288 : bool
289 {
290 @copy($a_abs_path, $this->getMailPath() . "/" . $this->user_id . "_" . $a_new_name);
291
292 return true;
293 }

References getMailPath().

+ Here is the call graph for this function:

◆ deassignAttachmentFromDirectory()

ilFileDataMail::deassignAttachmentFromDirectory ( int  $a_mail_id)

Definition at line 418 of file class.ilFileDataMail.php.

418 : bool
419 {
420 global $ilDB;
421 // IF IT'S THE LAST MAIL CONTAINING THESE ATTACHMENTS => DELETE ATTACHMENTS
422 $res = $ilDB->query(
423 'SELECT path FROM mail_attachment WHERE mail_id = ' .
424 $ilDB->quote($a_mail_id, 'integer')
425 );
426
427 $path = '';
428 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
429 $path = (string) $row->path;
430 }
431
432 if ($path !== '') {
433 $res = $ilDB->query(
434 'SELECT COUNT(mail_id) count_mail_id FROM mail_attachment WHERE path = ' .
435 $ilDB->quote($path, 'text')
436 ) ;
437
438 $cnt_mail_id = 0;
439 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
440 $cnt_mail_id = (int) $row->count_mail_id;
441 }
442
443 if ($cnt_mail_id === 1) {
445 }
446 }
447
448 $ilDB->manipulateF(
449 'DELETE FROM mail_attachment WHERE mail_id = %s',
450 ['integer'],
451 [$a_mail_id]
452 );
453
454 return true;
455 }
deleteAttachmentDirectory(string $a_rel_path)

References $ilDB, ilFile\$path, $res, deleteAttachmentDirectory(), ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ deleteAttachmentDirectory()

ilFileDataMail::deleteAttachmentDirectory ( string  $a_rel_path)
private

Definition at line 457 of file class.ilFileDataMail.php.

457 : void
458 {
459 ilFileUtils::delDir($this->mail_path . "/" . $a_rel_path);
460 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilFileUtils\delDir().

Referenced by deassignAttachmentFromDirectory().

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

◆ deliverAttachmentsAsZip()

ilFileDataMail::deliverAttachmentsAsZip ( string  $basename,
int  $mailId,
array  $files = [],
bool  $isDraft = false 
)
Exceptions
ILIAS

Filesystem\Exception\FileNotFoundException

Exceptions
ILIAS

Filesystem\Exception\IOException

Exceptions
ilException
ilFileUtilsException

Definition at line 589 of file class.ilFileDataMail.php.

594 : void {
595 $path = '';
596 if (!$isDraft) {
597 $path = $this->getAttachmentPathByMailId($mailId);
598 if ($path === '') {
599 throw new ilException('mail_download_zip_no_attachments');
600 }
601 }
602
603 $downloadFilename = ilFileUtils::getASCIIFilename($basename);
604 if ($downloadFilename === '') {
605 $downloadFilename = 'attachments';
606 }
607
608 $processingDirectory = ilFileUtils::ilTempnam();
609 $relativeProcessingDirectory = basename($processingDirectory);
610
611 $absoluteZipDirectory = $processingDirectory . '/' . $downloadFilename;
612 $relativeZipDirectory = $relativeProcessingDirectory . '/' . $downloadFilename;
613
614 $this->tmpDirectory->createDir($relativeZipDirectory);
615
616 foreach ($files as $fileName) {
617 if ($isDraft) {
618 $source = str_replace(
619 $this->mail_path,
620 MAILPATH,
622 );
623 } else {
624 $source = MAILPATH . '/' . $path . '/' . $fileName;
625 }
626
627 $source = str_replace('//', '/', $source);
628 if (!$this->storageDirectory->has($source)) {
629 continue;
630 }
631
632 $target = $relativeZipDirectory . '/' . $fileName;
633
634 $stream = $this->storageDirectory->readStream($source);
635 $this->tmpDirectory->writeStream($target, $stream);
636 }
637
638 $pathToZipFile = $processingDirectory . '/' . $downloadFilename . '.zip';
639 ilFileUtils::zip($absoluteZipDirectory, $pathToZipFile);
640
641 $this->tmpDirectory->deleteDir($relativeZipDirectory);
642
644 $processingDirectory . '/' . $downloadFilename . '.zip',
645 ilFileUtils::getValidFilename($downloadFilename . '.zip')
646 );
647 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAbsoluteAttachmentPoolPathByFilename(string $fileName)
Resolves a path for a passed filename in regards of a user's mail attachment pool,...
getAttachmentPathByMailId(int $mailId)
static deliverFileAttached(string $path_to_file, ?string $download_file_name=null, ?string $mime_type=null, bool $delete_file=false)
static getASCIIFilename(string $a_filename)
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
static getValidFilename(string $a_filename)
$source
Definition: metadata.php:93

References ilFile\$path, and getAttachmentPathByMailId().

+ Here is the call graph for this function:

◆ getAbsoluteAttachmentPoolPathByFilename()

ilFileDataMail::getAbsoluteAttachmentPoolPathByFilename ( string  $fileName)

Resolves a path for a passed filename in regards of a user's mail attachment pool, meaning attachments not being sent.

Parameters
string$fileName
Returns
string

Definition at line 335 of file class.ilFileDataMail.php.

335 : string
336 {
337 return $this->getAbsoluteAttachmentPoolPathPrefix() . $fileName;
338 }

References getAbsoluteAttachmentPoolPathPrefix().

+ Here is the call graph for this function:

◆ getAbsoluteAttachmentPoolPathPrefix()

ilFileDataMail::getAbsoluteAttachmentPoolPathPrefix ( )

Definition at line 91 of file class.ilFileDataMail.php.

91 : string
92 {
93 return $this->mail_path . '/' . $this->user_id . '_';
94 }

Referenced by getAbsoluteAttachmentPoolPathByFilename().

+ Here is the caller graph for this function:

◆ getAttachmentPath()

ilFileDataMail::getAttachmentPath ( string  $a_filename,
int  $a_mail_id 
)

Definition at line 144 of file class.ilFileDataMail.php.

144 : string
145 {
146 $path = $this->getMailPath() . '/' . $this->getAttachmentPathByMailId($a_mail_id) . '/' . $a_filename;
147
148 if (is_readable($path)) {
149 return $path;
150 }
151
152 return '';
153 }

References ilFile\$path, getAttachmentPathByMailId(), and getMailPath().

Referenced by adoptAttachments().

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

◆ getAttachmentPathAndFilenameByMd5Hash()

ilFileDataMail::getAttachmentPathAndFilenameByMd5Hash ( string  $md5FileHash,
int  $mailId 
)
Returns
array{path: string, filename: string} An array containing 'path' and 'filename' for the passed MD5 hash
Exceptions
OutOfBoundsException

Definition at line 100 of file class.ilFileDataMail.php.

100 : array
101 {
102 $res = $this->db->queryF(
103 "SELECT path FROM mail_attachment WHERE mail_id = %s",
104 ['integer'],
105 [$mailId]
106 );
107
108 if (1 !== $this->db->numRows($res)) {
109 throw new OutOfBoundsException();
110 }
111
112 $row = $this->db->fetchAssoc($res);
113
114 $relativePath = $row['path'];
115 $path = $this->getMailPath() . '/' . $row['path'];
116
117 $files = ilFileUtils::getDir($path);
118 foreach ($files as $file) {
119 if ($file['type'] === 'file' && md5($file['entry']) === $md5FileHash) {
120 return [
121 'path' => $this->getMailPath() . '/' . $relativePath . '/' . $file['entry'],
122 'filename' => $file['entry'],
123 ];
124 }
125 }
126
127 throw new OutOfBoundsException();
128 }
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory

References ilFile\$path, $res, ilFileUtils\getDir(), and getMailPath().

+ Here is the call graph for this function:

◆ getAttachmentPathByMailId()

ilFileDataMail::getAttachmentPathByMailId ( int  $mailId)
private

Definition at line 131 of file class.ilFileDataMail.php.

131 : string
132 {
133 $query = $this->db->query(
134 "SELECT path FROM mail_attachment WHERE mail_id = " . $this->db->quote($mailId, 'integer')
135 );
136
137 while ($row = $this->db->fetchObject($query)) {
138 return $row->path;
139 }
140
141 return '';
142 }
$query

References $query.

Referenced by deliverAttachmentsAsZip(), and getAttachmentPath().

+ Here is the caller graph for this function:

◆ getAttachmentsTotalSizeLimit()

ilFileDataMail::getAttachmentsTotalSizeLimit ( )

Definition at line 76 of file class.ilFileDataMail.php.

76 : ?float
77 {
78 $max_size = $this->ilias->getSetting('mail_maxsize_attach', '');
79 if ($max_size === '') {
80 return null;
81 }
82
83 return (float) $this->ilias->getSetting('mail_maxsize_attach', '0') * 1024;
84 }

◆ getMailPath()

ilFileDataMail::getMailPath ( )

Definition at line 86 of file class.ilFileDataMail.php.

86 : string
87 {
88 return $this->mail_path;
89 }

References $mail_path.

Referenced by adoptAttachments(), copyAttachmentFile(), getAttachmentPath(), getAttachmentPathAndFilenameByMd5Hash(), storeAsAttachment(), and storeUploadedFile().

+ Here is the caller graph for this function:

◆ getStorage()

static ilFileDataMail::getStorage ( int  $a_mail_id,
int  $a_usr_id 
)
static

Definition at line 356 of file class.ilFileDataMail.php.

357 {
358 static $fsstorage_cache = [];
359
360 $fsstorage_cache[$a_mail_id][$a_usr_id] = new ilFSStorageMail($a_mail_id, $a_usr_id);
361
362 return $fsstorage_cache[$a_mail_id][$a_usr_id];
363 }

Referenced by assignAttachmentsToDirectory(), and saveFile().

+ Here is the caller graph for this function:

◆ getUploadLimit()

ilFileDataMail::getUploadLimit ( )

Definition at line 71 of file class.ilFileDataMail.php.

71 : int
72 {
74 }

References $mail_max_upload_file_size.

Referenced by storeAsAttachment().

+ Here is the caller graph for this function:

◆ getUserFilesData()

ilFileDataMail::getUserFilesData ( )
Returns
list<array{name: string, size: int, ctime: int}>

Definition at line 191 of file class.ilFileDataMail.php.

191 : array
192 {
193 return $this->getUnsentFiles();
194 }

◆ initAttachmentMaxUploadSize()

ilFileDataMail::initAttachmentMaxUploadSize ( )
protected
Todo:
mjansen: Unfortunately we cannot reuse the implementation of ilFileInputGUI

Definition at line 462 of file class.ilFileDataMail.php.

462 : void
463 {
466 // Copy of ilFileInputGUI: begin
467 // get the value for the maximal uploadable filesize from the php.ini (if available)
468 $umf = ini_get("upload_max_filesize");
469 // get the value for the maximal post data from the php.ini (if available)
470 $pms = ini_get("post_max_size");
471
472 //convert from short-string representation to "real" bytes
473 $multiplier_a = ["K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024];
474
475 $umf_parts = preg_split(
476 "/(\d+)([K|G|M])/",
477 $umf,
478 -1,
479 PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
480 );
481 $pms_parts = preg_split(
482 "/(\d+)([K|G|M])/",
483 $pms,
484 -1,
485 PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
486 );
487
488 if (count($umf_parts) === 2) {
489 $umf = (float) $umf_parts[0] * $multiplier_a[$umf_parts[1]];
490 }
491 if (count($pms_parts) === 2) {
492 $pms = (float) $pms_parts[0] * $multiplier_a[$pms_parts[1]];
493 }
494
495 // use the smaller one as limit
496 $max_filesize = min($umf, $pms);
497
498 if (!$max_filesize) {
499 $max_filesize = max($umf, $pms);
500 }
501
502 $this->mail_max_upload_file_size = (int) $max_filesize;
503 }

References ILIAS\Repository\int().

Referenced by __construct().

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

◆ initDirectory()

ilFileDataMail::initDirectory ( )

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

60 : bool
61 {
62 if (is_writable($this->getPath())
63 && mkdir($this->getPath() . '/' . MAILPATH)
64 && chmod($this->getPath() . '/' . MAILPATH, 0755)) {
65 $this->mail_path = $this->getPath() . '/' . MAILPATH;
66 return true;
67 }
68 return false;
69 }

References ilFileData\getPath(), and MAILPATH.

+ Here is the call graph for this function:

◆ rotateFiles()

ilFileDataMail::rotateFiles ( string  $a_path)
private

Definition at line 295 of file class.ilFileDataMail.php.

295 : bool
296 {
297 if (is_file($a_path)) {
298 $this->rotateFiles($a_path . ".old");
299 return ilFileUtils::rename($a_path, $a_path . '.old');
300 }
301
302 return true;
303 }
rotateFiles(string $a_path)
static rename(string $a_source, string $a_target)

References ilFileUtils\rename(), and rotateFiles().

Referenced by rotateFiles(), storeAsAttachment(), and storeUploadedFile().

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

◆ saveFile()

ilFileDataMail::saveFile ( int  $a_mail_id,
string  $a_attachment 
)

Save attachment file in a specific mail directory .../mail/<calculated_path>/mail_<mail_id>_<user_id>/...

Parameters
int$a_mail_id
string$a_attachment
Returns
bool

Definition at line 371 of file class.ilFileDataMail.php.

371 : bool
372 {
373 $oStorage = self::getStorage($a_mail_id, $this->user_id);
374 $oStorage->create();
375 $storage_directory = $oStorage->getAbsolutePath();
376
377 if (!is_dir($storage_directory)) {
378 return false;
379 }
380
381 return copy(
382 $this->mail_path . '/' . $this->user_id . '_' . $a_attachment,
383 $storage_directory . '/' . $a_attachment
384 );
385 }

References getStorage().

Referenced by saveFiles().

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

◆ saveFiles()

ilFileDataMail::saveFiles ( int  $a_mail_id,
array  $a_attachments 
)

Saves all attachment files in a specific mail directory .../mail/<calculated_path>/mail_<mail_id>_<user_id>/...

Parameters
int$a_mail_idid of mail in sent box
string[]$a_attachmentsto save

Definition at line 345 of file class.ilFileDataMail.php.

345 : void
346 {
347 if (!is_numeric($a_mail_id) || $a_mail_id < 1) {
348 throw new InvalidArgumentException('The passed mail_id must be a valid integer!');
349 }
350
351 foreach ($a_attachments as $attachment) {
352 $this->saveFile($a_mail_id, $attachment);
353 }
354 }
saveFile(int $a_mail_id, string $a_attachment)
Save attachment file in a specific mail directory .../mail/<calculated_path>/mail_<mail_id>_<user_id>...

References saveFile().

+ Here is the call graph for this function:

◆ storeAsAttachment()

ilFileDataMail::storeAsAttachment ( string  $a_filename,
string  $a_content 
)

Definition at line 223 of file class.ilFileDataMail.php.

223 : string
224 {
225 if (strlen($a_content) >= $this->getUploadLimit()) {
226 throw new DomainException(
227 sprintf(
228 'Mail upload limit reached for user with id %s',
229 $this->user_id
230 )
231 );
232 }
233
235 $this->rotateFiles($this->getMailPath() . '/' . $this->user_id . '_' . $name);
236
237 $abs_path = $this->getMailPath() . '/' . $this->user_id . '_' . $name;
238
239 $fp = fopen($abs_path, 'wb+');
240 if (!is_resource($fp)) {
241 throw new RuntimeException(
242 sprintf(
243 'Could not read file: %s',
244 $abs_path
245 )
246 );
247 }
248
249 if (fwrite($fp, $a_content) === false) {
250 fclose($fp);
251 throw new RuntimeException(
252 sprintf(
253 'Could not write file: %s',
254 $abs_path
255 )
256 );
257 }
258
259 fclose($fp);
260
261 return $name;
262 }
static _sanitizeFilemame(string $a_filename)
if($format !==null) $name
Definition: metadata.php:247

References $name, ilFileUtils\_sanitizeFilemame(), getMailPath(), getUploadLimit(), and rotateFiles().

+ Here is the call graph for this function:

◆ storeUploadedFile()

ilFileDataMail::storeUploadedFile ( array  $file)
Parameters
array{name:string,tmp_name:string}$file

Definition at line 267 of file class.ilFileDataMail.php.

267 : string
268 {
269 $sanitized_filename = ilFileUtils::_sanitizeFilemame($file['name']);
270
271 $this->rotateFiles($this->getMailPath() . '/' . $this->user_id . '_' . $sanitized_filename);
272
274 $file['tmp_name'],
275 $sanitized_filename,
276 $this->getMailPath() . '/' . $this->user_id . '_' . $sanitized_filename
277 );
278
279 return $sanitized_filename;
280 }
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file

References ilFileUtils\_sanitizeFilemame(), getMailPath(), ilFileUtils\moveUploadedFile(), and rotateFiles().

+ Here is the call graph for this function:

◆ unlinkFile()

ilFileDataMail::unlinkFile ( string  $a_filename)

Definition at line 320 of file class.ilFileDataMail.php.

320 : bool
321 {
322 if (is_file($this->mail_path . '/' . basename($this->user_id . '_' . $a_filename))) {
323 return unlink($this->mail_path . '/' . basename($this->user_id . '_' . $a_filename));
324 }
325
326 return false;
327 }

Referenced by unlinkFiles().

+ Here is the caller graph for this function:

◆ unlinkFiles()

ilFileDataMail::unlinkFiles ( array  $a_filenames)
Parameters
string[]$a_filenamesFilenames to delete
Returns
string error message with filename that couldn't be deleted

Definition at line 309 of file class.ilFileDataMail.php.

309 : string
310 {
311 foreach ($a_filenames as $file) {
312 if (!$this->unlinkFile($file)) {
313 return $file;
314 }
315 }
316
317 return '';
318 }
unlinkFile(string $a_filename)

References unlinkFile().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilFileDataMail::$db
protected

Definition at line 37 of file class.ilFileDataMail.php.

◆ $ilias

ILIAS ilFileDataMail::$ilias
protected

Definition at line 38 of file class.ilFileDataMail.php.

◆ $mail_max_upload_file_size

int ilFileDataMail::$mail_max_upload_file_size
protected

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

Referenced by getUploadLimit().

◆ $mail_path

string ilFileDataMail::$mail_path

Definition at line 33 of file class.ilFileDataMail.php.

Referenced by getMailPath().

◆ $storageDirectory

Filesystem ilFileDataMail::$storageDirectory
protected

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

◆ $tmpDirectory

Filesystem ilFileDataMail::$tmpDirectory
protected

Definition at line 35 of file class.ilFileDataMail.php.

◆ $user_id

int ilFileDataMail::$user_id

Definition at line 32 of file class.ilFileDataMail.php.


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