ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 (public int $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 (UploadResult $result)
 
 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

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 31 of file class.ilFileDataMail.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileDataMail::__construct ( public int  $user_id = 0)

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

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

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 
52  $this->db = $DIC->database();
53  $this->tmpDirectory = $DIC->filesystem()->temp();
54  $this->storageDirectory = $DIC->filesystem()->storage();
55 
57  }
const MAILPATH
Definition: constants.php:50
global $DIC
Definition: shib_login.php:22
Class ilObjForumAdministration.
__construct(Container $dic, ilPlugin $plugin)
+ 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
Returns
string An error message

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

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

159  : string
160  {
161  foreach ($a_attachments as $file) {
162  $path = $this->getAttachmentPath($file, $a_mail_id);
163  if (!copy($path, $this->getMailPath() . '/' . $this->user_id . '_' . $file)) {
164  return 'ERROR: ' . $this->getMailPath() . '/' . $this->user_id . '_' . $file . ' cannot be created';
165  }
166  }
167 
168  return '';
169  }
getAttachmentPath(string $a_filename, int $a_mail_id)
string $path
+ Here is the call graph for this function:

◆ assignAttachmentsToDirectory()

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

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

References $ilDB.

392  : void
393  {
394  global $ilDB;
395 
396  $oStorage = self::getStorage($a_sent_mail_id, $this->user_id);
397  $ilDB->manipulateF(
398  '
399  INSERT INTO mail_attachment
400  ( mail_id, path) VALUES (%s, %s)',
401  ['integer', 'text'],
402  [$a_mail_id, $oStorage->getRelativePathExMailDirectory()]
403  );
404  }

◆ checkFilesExist()

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

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

379  : bool
380  {
381  if ($a_files !== []) {
382  foreach ($a_files as $file) {
383  if (!is_file($this->mail_path . '/' . $this->user_id . '_' . $file)) {
384  return false;
385  }
386  }
387  return true;
388  }
389  return true;
390  }

◆ checkReadWrite()

ilFileDataMail::checkReadWrite ( )

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

Referenced by __construct().

171  : bool
172  {
173  if (is_writable($this->mail_path) && is_readable($this->mail_path)) {
174  return true;
175  }
176 
177  $this->ilias->raiseError(
178  "Mail directory is not readable/writable by webserver: " .
179  $this->mail_path,
180  $this->ilias->error_obj->FATAL
181  );
182 
183  return false;
184  }
Class ilObjForumAdministration.
+ 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

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

References getMailPath().

282  : bool
283  {
284  @copy($a_abs_path, $this->getMailPath() . "/" . $this->user_id . "_" . $a_new_name);
285 
286  return true;
287  }
+ Here is the call graph for this function:

◆ deassignAttachmentFromDirectory()

ilFileDataMail::deassignAttachmentFromDirectory ( int  $a_mail_id)

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

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

406  : bool
407  {
408  global $ilDB;
409  // IF IT'S THE LAST MAIL CONTAINING THESE ATTACHMENTS => DELETE ATTACHMENTS
410  $res = $ilDB->query(
411  'SELECT path FROM mail_attachment WHERE mail_id = ' .
412  $ilDB->quote($a_mail_id, 'integer')
413  );
414 
415  $path = '';
416  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
417  $path = (string) $row->path;
418  }
419 
420  if ($path !== '') {
421  $res = $ilDB->query(
422  'SELECT COUNT(mail_id) count_mail_id FROM mail_attachment WHERE path = ' .
423  $ilDB->quote($path, 'text')
424  ) ;
425 
426  $cnt_mail_id = 0;
427  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
428  $cnt_mail_id = (int) $row->count_mail_id;
429  }
430 
431  if ($cnt_mail_id === 1) {
433  }
434  }
435 
436  $ilDB->manipulateF(
437  'DELETE FROM mail_attachment WHERE mail_id = %s',
438  ['integer'],
439  [$a_mail_id]
440  );
441 
442  return true;
443  }
$res
Definition: ltiservices.php:66
string $path
deleteAttachmentDirectory(string $a_rel_path)
+ Here is the call graph for this function:

◆ deleteAttachmentDirectory()

ilFileDataMail::deleteAttachmentDirectory ( string  $a_rel_path)
private

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

References ilFileUtils\delDir().

Referenced by deassignAttachmentFromDirectory().

445  : void
446  {
447  ilFileUtils::delDir($this->mail_path . "/" . $a_rel_path);
448  }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ 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

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

References ilFile\$path, ilFileDelivery\deliverFileAttached(), getAbsoluteAttachmentPoolPathByFilename(), ilFileUtils\getASCIIFilename(), getAttachmentPathByMailId(), ilFileUtils\getValidFilename(), ilFileUtils\ilTempnam(), MAILPATH, and ilFileUtils\zip().

582  : void {
583  $path = '';
584  if (!$isDraft) {
585  $path = $this->getAttachmentPathByMailId($mailId);
586  if ($path === '') {
587  throw new ilMailException('mail_download_zip_no_attachments');
588  }
589  }
590 
591  $downloadFilename = ilFileUtils::getASCIIFilename($basename);
592  if ($downloadFilename === '') {
593  $downloadFilename = 'attachments';
594  }
595 
596  $processingDirectory = ilFileUtils::ilTempnam();
597  $relativeProcessingDirectory = basename($processingDirectory);
598 
599  $absoluteZipDirectory = $processingDirectory . '/' . $downloadFilename;
600  $relativeZipDirectory = $relativeProcessingDirectory . '/' . $downloadFilename;
601 
602  $this->tmpDirectory->createDir($relativeZipDirectory);
603 
604  foreach ($files as $fileName) {
605  if ($isDraft) {
606  $source = str_replace(
607  $this->mail_path,
608  MAILPATH,
610  );
611  } else {
612  $source = MAILPATH . '/' . $path . '/' . $fileName;
613  }
614 
615  $source = str_replace('//', '/', $source);
616  if (!$this->storageDirectory->has($source)) {
617  continue;
618  }
619 
620  $target = $relativeZipDirectory . '/' . $fileName;
621 
622  $stream = $this->storageDirectory->readStream($source);
623  $this->tmpDirectory->writeStream($target, $stream);
624  }
625 
626  $pathToZipFile = $processingDirectory . '/' . $downloadFilename . '.zip';
627  ilFileUtils::zip($absoluteZipDirectory, $pathToZipFile);
628 
629  $this->tmpDirectory->deleteDir($relativeZipDirectory);
630 
632  $processingDirectory . '/' . $downloadFilename . '.zip',
633  ilFileUtils::getValidFilename($downloadFilename . '.zip')
634  );
635  }
static getValidFilename(string $a_filename)
const MAILPATH
Definition: constants.php:50
static getASCIIFilename(string $a_filename)
getAttachmentPathByMailId(int $mailId)
static deliverFileAttached(string $path_to_file, ?string $download_file_name=null, ?string $mime_type=null, bool $delete_file=false)
getAbsoluteAttachmentPoolPathByFilename(string $fileName)
Resolves a path for a passed filename in regards of a user&#39;s mail attachment pool, meaning attachments not being sent.
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
static zip(string $a_dir, string $a_file, bool $compress_content=false)
string $path
+ 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.

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

References getAbsoluteAttachmentPoolPathPrefix().

Referenced by deliverAttachmentsAsZip().

327  : string
328  {
329  return $this->getAbsoluteAttachmentPoolPathPrefix() . $fileName;
330  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAbsoluteAttachmentPoolPathPrefix()

ilFileDataMail::getAbsoluteAttachmentPoolPathPrefix ( )

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

Referenced by getAbsoluteAttachmentPoolPathByFilename().

90  : string
91  {
92  return $this->mail_path . '/' . $this->user_id . '_';
93  }
+ Here is the caller graph for this function:

◆ getAttachmentPath()

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

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

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

Referenced by adoptAttachments().

143  : string
144  {
145  $path = $this->getMailPath() . '/' . $this->getAttachmentPathByMailId($a_mail_id) . '/' . $a_filename;
146 
147  if (is_readable($path)) {
148  return $path;
149  }
150 
151  return '';
152  }
getAttachmentPathByMailId(int $mailId)
string $path
+ 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 99 of file class.ilFileDataMail.php.

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

Referenced by ilMailFolderGUI\deliverFile().

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

◆ getAttachmentPathByMailId()

ilFileDataMail::getAttachmentPathByMailId ( int  $mailId)
private

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

Referenced by deliverAttachmentsAsZip(), and getAttachmentPath().

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

◆ getAttachmentsTotalSizeLimit()

ilFileDataMail::getAttachmentsTotalSizeLimit ( )

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

References null.

75  : ?float
76  {
77  $max_size = $this->ilias->getSetting('mail_maxsize_attach', '');
78  if ($max_size === '') {
79  return null;
80  }
81 
82  return (float) $this->ilias->getSetting('mail_maxsize_attach', '0') * 1024;
83  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class ilObjForumAdministration.

◆ getMailPath()

ilFileDataMail::getMailPath ( )

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

References $mail_path.

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

85  : string
86  {
87  return $this->mail_path;
88  }
+ Here is the caller graph for this function:

◆ getStorage()

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

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

349  {
350  static $fsstorage_cache = [];
351 
352  $fsstorage_cache[$a_mail_id][$a_usr_id] = new ilFSStorageMail($a_mail_id, $a_usr_id);
353 
354  return $fsstorage_cache[$a_mail_id][$a_usr_id];
355  }

◆ getUploadLimit()

ilFileDataMail::getUploadLimit ( )

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

References $mail_max_upload_file_size.

Referenced by storeAsAttachment().

70  : int
71  {
73  }
+ Here is the caller graph for this function:

◆ getUserFilesData()

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

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

References $user_id.

189  : array
190  {
191  return $this->getUnsentFiles();
192  }

◆ initAttachmentMaxUploadSize()

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

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

References $ilDB, ilFile\$path, $res, getMailPath(), and ILIAS\Repository\int().

Referenced by __construct().

450  : void
451  {
454  // Copy of ilFileInputGUI: begin
455  // get the value for the maximal uploadable filesize from the php.ini (if available)
456  $umf = ini_get("upload_max_filesize");
457  // get the value for the maximal post data from the php.ini (if available)
458  $pms = ini_get("post_max_size");
459 
460  //convert from short-string representation to "real" bytes
461  $multiplier_a = ["K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024];
462 
463  $umf_parts = preg_split(
464  "/(\d+)([K|G|M])/",
465  (string) $umf,
466  -1,
467  PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
468  );
469  $pms_parts = preg_split(
470  "/(\d+)([K|G|M])/",
471  (string) $pms,
472  -1,
473  PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
474  );
475 
476  if ((is_countable($umf_parts) ? count($umf_parts) : 0) === 2) {
477  $umf = (float) $umf_parts[0] * $multiplier_a[$umf_parts[1]];
478  }
479  if ((is_countable($pms_parts) ? count($pms_parts) : 0) === 2) {
480  $pms = (float) $pms_parts[0] * $multiplier_a[$pms_parts[1]];
481  }
482 
483  // use the smaller one as limit
484  $max_filesize = min($umf, $pms);
485 
486  if (!$max_filesize) {
487  $max_filesize = max($umf, $pms);
488  }
489 
490  $this->mail_max_upload_file_size = (int) $max_filesize;
491  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initDirectory()

ilFileDataMail::initDirectory ( )

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

References ilFileData\getPath(), and MAILPATH.

59  : bool
60  {
61  if (is_writable($this->getPath())
62  && mkdir($this->getPath() . '/' . MAILPATH)
63  && chmod($this->getPath() . '/' . MAILPATH, 0755)) {
64  $this->mail_path = $this->getPath() . '/' . MAILPATH;
65  return true;
66  }
67  return false;
68  }
const MAILPATH
Definition: constants.php:50
+ Here is the call graph for this function:

◆ rotateFiles()

ilFileDataMail::rotateFiles ( string  $a_path)
private

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

References ilFileUtils\rename().

Referenced by storeAsAttachment(), and storeUploadedFile().

289  : bool
290  {
291  if (is_file($a_path)) {
292  $this->rotateFiles($a_path . ".old");
293  return ilFileUtils::rename($a_path, $a_path . '.old');
294  }
295 
296  return true;
297  }
rotateFiles(string $a_path)
static rename(string $a_source, string $a_target)
+ 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>/...

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

Referenced by saveFiles().

360  : bool
361  {
362  $oStorage = self::getStorage($a_mail_id, $this->user_id);
363  $oStorage->create();
364  $storage_directory = $oStorage->getAbsolutePath();
365 
366  if (!is_dir($storage_directory)) {
367  return false;
368  }
369 
370  return copy(
371  $this->mail_path . '/' . $this->user_id . '_' . $a_attachment,
372  $storage_directory . '/' . $a_attachment
373  );
374  }
+ 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_attachments to save

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

References saveFile().

337  : void
338  {
339  if (!is_numeric($a_mail_id) || $a_mail_id < 1) {
340  throw new InvalidArgumentException('The passed mail_id must be a valid integer!');
341  }
342 
343  foreach ($a_attachments as $attachment) {
344  $this->saveFile($a_mail_id, $attachment);
345  }
346  }
saveFile(int $a_mail_id, string $a_attachment)
Save attachment file in a specific mail directory .../mail/<calculated_path>/mail_<mail_id>_<user_id>...
+ Here is the call graph for this function:

◆ storeAsAttachment()

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

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

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

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

◆ storeUploadedFile()

ilFileDataMail::storeUploadedFile ( UploadResult  $result)

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

References $filename, ilFileUtils\_sanitizeFilemame(), getMailPath(), ILIAS\FileUpload\DTO\UploadResult\getName(), ILIAS\FileUpload\DTO\UploadResult\getPath(), ilFileUtils\moveUploadedFile(), and rotateFiles().

262  : string
263  {
265  $result->getName()
266  );
267 
268  $this->rotateFiles($this->getMailPath() . '/' . $this->user_id . '_' . $filename);
269 
271  $result->getPath(),
272  $filename,
273  $this->getMailPath() . '/' . $this->user_id . '_' . $filename
274  );
275 
276  return $filename;
277  }
rotateFiles(string $a_path)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static _sanitizeFilemame(string $a_filename)
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:

◆ unlinkFile()

ilFileDataMail::unlinkFile ( string  $a_filename)

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

Referenced by unlinkFiles().

314  : bool
315  {
316  if (is_file($this->mail_path . '/' . basename($this->user_id . '_' . $a_filename))) {
317  return unlink($this->mail_path . '/' . basename($this->user_id . '_' . $a_filename));
318  }
319 
320  return false;
321  }
+ Here is the caller graph for this function:

◆ unlinkFiles()

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

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

References unlinkFile().

303  : string
304  {
305  foreach ($a_filenames as $file) {
306  if (!$this->unlinkFile($file)) {
307  return $file;
308  }
309  }
310 
311  return '';
312  }
unlinkFile(string $a_filename)
+ 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.


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